Skip to content

Commit

Permalink
add to post pages
Browse files Browse the repository at this point in the history
  • Loading branch information
qinwf committed Apr 26, 2020
1 parent d053842 commit d65e574
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 31 deletions.
3 changes: 2 additions & 1 deletion _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="manifest" href="/manifest.json">
<!-- <link rel="stylesheet" href="{{ site.baseurl }}/styles.css"> -->
{% include jquery.html %}
<style type="text/css">

{% include pure.min.css %}
Expand All @@ -29,7 +30,7 @@
background-color:rgb(38,38,38);
color: white;
}
.link-desc, #preview-content {
.link-desc, #preview-content, .ui-dialog-content {
word-wrap: break-word;
white-space: break-spaces;
}
Expand Down
7 changes: 7 additions & 0 deletions _includes/jquery.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _layouts/draft.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ <h3>Related posts</h3>
}
}
});
}, 3000);
}, 1000);
});
</script>
54 changes: 51 additions & 3 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,68 @@
layout: default
---

<article id='posts-content' class="post">
<article id='posts-content' class="post post-detail-{{ page.id | replace: '/', '' }}">
<h1 class="post-title">{{ page.title }}</h1>
<p class="added-hostname"><time style="display: inline;margin-right: 15px;" datetime="{{ page.date | date_to_xmlschema }}" class="post-date">{{ page.date | date_to_string }}</time>
{% include social-button.html %}
</p>

<form class="filter-box">
<input name="query" placeholder="type to filter" class="input-box title-filter">
</form>
{{ content }}

<div id="dialog-{{ page.id | replace: '/', '' }}" style="display:none;"></div>

<script class="inf-detail">
function onHostClick{{ page.id | replace: '/', '' | replace: '-', '_' }}(evt) {
console.log(evt.dataset.desc);
$("#dialog-{{ page.id | replace: '/', '' }}").text(evt.dataset.desc);
$("#dialog-{{ page.id | replace: '/', '' }}").dialog({
width: "80%",
maxWidth: 600,
maxHeight: 600,
});
}

setTimeout(function () {
$.ajax({
dataType: "json",
url: "https://live.rweekly.org/post-{{page.id | replace: '/', ''}}.json",
success: function (data) {
console.log(data);
if (typeof data === 'object') {
$(".post-detail-{{page.id | replace: '/', ''}} .added-hostname").each(function (index, elt) {
const href = $('a', elt).attr('href');
if (data[href]) {
$('.tooltiptext', elt).attr('data-desc', data[href]);
$('a', elt).attr('data-desc', data[href]);
$('.tooltiptext', elt).attr('onclick', "onHostClick{{ page.id | replace: '/', '' | replace: '-', '_' }}(this)");

$('a', elt).tooltip(
{
items: '[data-desc]',
content: function () {
var element = $(this);
return '<div class="link-desc">' + element.attr("data-desc") + '</div>';
},
position: {
collision: "none",
}
}
);
}
});
}
}
});
}, 1000);
</script>

<!--<p><small id="page_view">&nbsp;</small></p>-->
<div class="pagination">
{% if page.previous.url %}

<a id="next-page" class="pagination-item older" href="{{ page.previous.url }}">Older</a>
{% else %}
<span class="pagination-item older">Older</span>
Expand Down
52 changes: 50 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@

<div id="posts-content" class="posts">
{% for post in paginator.posts %}
<article class="post">
<article class="post post-detail-{{ post.id | replace: '/', '' }}">
<h1 class="post-title">
<a href="{{ site.baseurl }}{{ post.url }}">
{{ post.title }}
</a>
</h1>

<p class="added-hostname"><time style="display: inline;margin-right: 15px;" datetime="{{ post.date | date_to_xmlschema }}" class="post-date">{{ post.date | date_to_string }}</time>
<p class="added-hostname"><time style="display: inline;margin-right: 15px;" datetime="{{ post.date | date_to_xmlschema }}" class="post-date">{{ post.date | date_to_string }}</time>
{% include social-button.html %}
</p>

Expand All @@ -94,6 +94,54 @@ <h1 class="post-title">
</form>
{{ post.content }}
<!--<p><small id="page_view">&nbsp;</small></p>-->
<div id="dialog-{{ post.id | replace: '/', '' }}" style="display:none;"></div>

<script class="inf-detail">
console.log("loading page {{ post.id | replace: '/', '' | replace: '-', '_' }}");

function onHostClick{{ post.id | replace: '/', '' | replace: '-', '_' }}(evt) {
console.log(evt.dataset.desc);
$("#dialog-{{ post.id | replace: '/', '' }}").text(evt.dataset.desc);
$("#dialog-{{ post.id | replace: '/', '' }}").dialog({
width: "80%",
maxWidth: 600,
maxHeight: 600,
});
}

setTimeout(function () {
$.ajax({
dataType: "json",
url: "https://live.rweekly.org/post-{{post.id | replace: '/', ''}}.json",
success: function (data) {
console.log(data);
if (typeof data === 'object') {
$(".post-detail-{{post.id | replace: '/', ''}} .added-hostname").each(function (index, elt) {
const href = $('a', elt).attr('href');
if (data[href]) {
$('.tooltiptext', elt).attr('data-desc', data[href]);
$('a', elt).attr('data-desc', data[href]);
$('.tooltiptext', elt).attr('onclick', "onHostClick{{ post.id | replace: '/', '' | replace: '-', '_' }}(this)");

$('a', elt).tooltip(
{
items: '[data-desc]',
content: function () {
var element = $(this);
return '<div class="link-desc">' + element.attr("data-desc") + '</div>';
},
position: {
collision: "none",
}
}
);
}
});
}
}
});
}, 1000);
</script>
</article>
{% endfor %}

Expand Down
42 changes: 18 additions & 24 deletions public/jscroll.min.js

Large diffs are not rendered by default.

0 comments on commit d65e574

Please sign in to comment.