Skip to content

Commit 4391663

Browse files
author
George Leslie-Waksman
committedAug 9, 2018
Add (optional) fancydate support and support for update time to base templates.
1 parent 1220595 commit 4391663

File tree

11 files changed

+82
-7
lines changed

11 files changed

+82
-7
lines changed
 

‎nikola/data/themes/base-jinja/templates/base.tmpl

+8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
{{ footer.html_footer() }}
2121
</div>
2222
{{ base.late_load_js() }}
23+
{% if date_fanciness != 0 %}
24+
<!-- fancy dates -->
25+
<script>
26+
moment.locale("{{ momentjs_locales[lang] }}");
27+
fancydates({{ date_fanciness }}, {{ js_date_format }});
28+
</script>
29+
<!-- end fancy dates -->
30+
{% endif %}
2331
{% block extra_js %}{% endblock %}
2432
<script>
2533
baguetteBox.run('div#content', {

‎nikola/data/themes/base-jinja/templates/base_helper.tmpl

+13
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,27 @@ lang="{{ lang }}">
6666
{% if use_bundles %}
6767
{% if use_cdn %}
6868
<script src="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.9.1/baguetteBox.min.js" integrity="sha256-SoEATAB7PgNWyyK100I7yQXYm5V08k5SFupDP0h72MY=" crossorigin="anonymous"></script>
69+
{% if date_fanciness != 0 %}
70+
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment-with-locales.min.js"></script>
71+
{% endif %}
72+
<script src="/assets/js/all.js"></script>
6973
{% else %}
7074
<script src="/assets/js/all-nocdn.js"></script>
7175
{% endif %}
7276
{% else %}
7377
{% if use_cdn %}
7478
<script src="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.9.1/baguetteBox.min.js" integrity="sha256-SoEATAB7PgNWyyK100I7yQXYm5V08k5SFupDP0h72MY=" crossorigin="anonymous"></script>
79+
{% if date_fanciness != 0 %}
80+
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment-with-locales.min.js"></script>
81+
{% endif %}
7582
{% else %}
7683
<script src="/assets/js/baguetteBox.min.js"></script>
84+
{% if date_fanciness != 0 %}
85+
<script src="/assets/js/moment-with-locales.min.js"></script>
86+
{% endif %}
87+
{% endif %}
88+
{% if date_fanciness != 0 %}
89+
<script src="/assets/js/fancydates.js"></script>
7790
{% endif %}
7891
{% endif %}
7992
{{ social_buttons_code }}

‎nikola/data/themes/base-jinja/templates/index.tmpl

+9-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@
3737
{{ post.author()|e }}
3838
{% endif %}
3939
</span></p>
40-
<p class="dateline"><a href="{{ post.permalink() }}" rel="bookmark"><time class="published dt-published" datetime="{{ post.formatted_date('webiso') }}" title="{{ post.formatted_date(date_format)|e }}">{{ post.formatted_date(date_format)|e }}</time></a></p>
40+
<p class="dateline">
41+
<a href="{{ post.permalink() }}" rel="bookmark">
42+
<time class="published dt-published" datetime="{{ post.formatted_date('webiso') }}" itemprop="datePublished" title="{{ post.formatted_date(date_format)|e }}">{{ post.formatted_date(date_format)|e }}</time>
43+
{% if post.updated and post.updated != post.date %}
44+
<span class="updated"> updated </span>
45+
<time class="updated dt-updated" datetime="{{ post.formatted_updated('webiso') }}" itemprop="dateUpdated" title="{{ post.formatted_updated(date_format)|e }}">{{ post.formatted_updated(date_format)|e }}</time>
46+
{% endif %}
47+
</a>
48+
</p>
4149
{% if not post.meta('nocomments') and site_has_comments %}
4250
<p class="commentline">{{ comments.comment_link(post.permalink(), post._base_path) }}
4351
{% endif %}

‎nikola/data/themes/base-jinja/templates/post_header.tmpl

+9-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@
3838
{{ post.author()|e }}
3939
{% endif %}
4040
</span></p>
41-
<p class="dateline"><a href="{{ post.permalink() }}" rel="bookmark"><time class="published dt-published" datetime="{{ post.formatted_date('webiso') }}" itemprop="datePublished" title="{{ post.formatted_date(date_format)|e }}">{{ post.formatted_date(date_format)|e }}</time></a></p>
41+
<p class="dateline">
42+
<a href="{{ post.permalink() }}" rel="bookmark">
43+
<time class="published dt-published" datetime="{{ post.formatted_date('webiso') }}" itemprop="datePublished" title="{{ post.formatted_date(date_format)|e }}">{{ post.formatted_date(date_format)|e }}</time>
44+
{% if post.updated and post.updated != post.date %}
45+
<span class="updated"> updated </span>
46+
<time class="updated dt-updated" datetime="{{ post.formatted_updated('webiso') }}" itemprop="dateUpdated" title="{{ post.formatted_updated(date_format)|e }}">{{ post.formatted_updated(date_format)|e }}</time>
47+
{% endif %}
48+
</a>
49+
</p>
4250
{% if not post.meta('nocomments') and site_has_comments %}
4351
<p class="commentline">{{ comments.comment_link(post.permalink(), post._base_path) }}
4452
{% endif %}

‎nikola/data/themes/base/assets/js/fancydates.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function fancydates(fanciness, date_format) {
33
return;
44
}
55

6-
var dates = document.getElementsByClassName('dt-published');
6+
var dates = document.querySelectorAll('.dt-published, .dt-updated');
77

88
var l = dates.length;
99

‎nikola/data/themes/base/assets/js/fancydates.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎nikola/data/themes/base/bundles

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
assets/css/all.css=rst_base.css,nikola_rst.css,code.css,theme.css
22
assets/css/all-nocdn.css=rst_base.css,nikola_rst.css,code.css,theme.css,baguetteBox.min.css
3-
assets/css/all-nocdn.js=baguetteBox.min.js
3+
assets/js/all.js=fancydates.js
4+
assets/js/all-nocdn.js=baguetteBox.min.js,moment-with-locales.min.js,fancydates.js

‎nikola/data/themes/base/templates/base.tmpl

+8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ ${template_hooks['extra_head']()}
2020
${footer.html_footer()}
2121
</div>
2222
${base.late_load_js()}
23+
% if date_fanciness != 0:
24+
<!-- fancy dates -->
25+
<script>
26+
moment.locale("${momentjs_locales[lang]}");
27+
fancydates(${date_fanciness}, ${js_date_format});
28+
</script>
29+
<!-- end fancy dates -->
30+
% endif
2331
<%block name="extra_js"></%block>
2432
<script>
2533
baguetteBox.run('div#content', {

‎nikola/data/themes/base/templates/base_helper.tmpl

+13
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,27 @@ lang="${lang}">
6666
% if use_bundles:
6767
% if use_cdn:
6868
<script src="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.9.1/baguetteBox.min.js" integrity="sha256-SoEATAB7PgNWyyK100I7yQXYm5V08k5SFupDP0h72MY=" crossorigin="anonymous"></script>
69+
% if date_fanciness != 0:
70+
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment-with-locales.min.js"></script>
71+
% endif
72+
<script src="/assets/js/all.js"></script>
6973
% else:
7074
<script src="/assets/js/all-nocdn.js"></script>
7175
% endif
7276
% else:
7377
% if use_cdn:
7478
<script src="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.9.1/baguetteBox.min.js" integrity="sha256-SoEATAB7PgNWyyK100I7yQXYm5V08k5SFupDP0h72MY=" crossorigin="anonymous"></script>
79+
% if date_fanciness != 0:
80+
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment-with-locales.min.js"></script>
81+
% endif
7582
% else:
7683
<script src="/assets/js/baguetteBox.min.js"></script>
84+
% if date_fanciness != 0:
85+
<script src="/assets/js/moment-with-locales.min.js"></script>
86+
% endif
87+
% endif
88+
% if date_fanciness != 0:
89+
<script src="/assets/js/fancydates.js"></script>
7790
% endif
7891
% endif
7992
${social_buttons_code}

‎nikola/data/themes/base/templates/index.tmpl

+9-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@
3737
${post.author()|h}
3838
% endif
3939
</span></p>
40-
<p class="dateline"><a href="${post.permalink()}" rel="bookmark"><time class="published dt-published" datetime="${post.formatted_date('webiso')}" title="${post.formatted_date(date_format)|h}">${post.formatted_date(date_format)|h}</time></a></p>
40+
<p class="dateline">
41+
<a href="${post.permalink()}" rel="bookmark">
42+
<time class="published dt-published" datetime="${post.formatted_date('webiso')}" itemprop="datePublished" title="${post.formatted_date(date_format)|h}">${post.formatted_date(date_format)|h}</time>
43+
% if post.updated and post.updated != post.date:
44+
<span class="updated"> updated </span>
45+
<time class="updated dt-updated" datetime="${post.formatted_updated('webiso')}" itemprop="dateUpdated" title="${post.formatted_updated(date_format)|h}">${post.formatted_updated(date_format)|h}</time>
46+
% endif
47+
</a>
48+
</p>
4149
% if not post.meta('nocomments') and site_has_comments:
4250
<p class="commentline">${comments.comment_link(post.permalink(), post._base_path)}
4351
% endif

‎nikola/data/themes/base/templates/post_header.tmpl

+9-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@
3838
${post.author()|h}
3939
% endif
4040
</span></p>
41-
<p class="dateline"><a href="${post.permalink()}" rel="bookmark"><time class="published dt-published" datetime="${post.formatted_date('webiso')}" itemprop="datePublished" title="${post.formatted_date(date_format)|h}">${post.formatted_date(date_format)|h}</time></a></p>
41+
<p class="dateline">
42+
<a href="${post.permalink()}" rel="bookmark">
43+
<time class="published dt-published" datetime="${post.formatted_date('webiso')}" itemprop="datePublished" title="${post.formatted_date(date_format)|h}">${post.formatted_date(date_format)|h}</time>
44+
% if post.updated and post.updated != post.date:
45+
<span class="updated"> updated </span>
46+
<time class="updated dt-updated" datetime="${post.formatted_updated('webiso')}" itemprop="dateUpdated" title="${post.formatted_updated(date_format)|h}">${post.formatted_updated(date_format)|h}</time>
47+
% endif
48+
</a>
49+
</p>
4250
% if not post.meta('nocomments') and site_has_comments:
4351
<p class="commentline">${comments.comment_link(post.permalink(), post._base_path)}
4452
% endif

0 commit comments

Comments
 (0)
Please sign in to comment.