Skip to content

Commit

Permalink
Add (optional) fancydate support and support for update time to base …
Browse files Browse the repository at this point in the history
…templates.
  • Loading branch information
George Leslie-Waksman committed Aug 9, 2018
1 parent 1220595 commit 4391663
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 7 deletions.
8 changes: 8 additions & 0 deletions nikola/data/themes/base-jinja/templates/base.tmpl
Expand Up @@ -20,6 +20,14 @@
{{ footer.html_footer() }}
</div>
{{ base.late_load_js() }}
{% if date_fanciness != 0 %}
<!-- fancy dates -->
<script>
moment.locale("{{ momentjs_locales[lang] }}");
fancydates({{ date_fanciness }}, {{ js_date_format }});
</script>
<!-- end fancy dates -->
{% endif %}
{% block extra_js %}{% endblock %}
<script>
baguetteBox.run('div#content', {
Expand Down
13 changes: 13 additions & 0 deletions nikola/data/themes/base-jinja/templates/base_helper.tmpl
Expand Up @@ -66,14 +66,27 @@ lang="{{ lang }}">
{% if use_bundles %}
{% if use_cdn %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.9.1/baguetteBox.min.js" integrity="sha256-SoEATAB7PgNWyyK100I7yQXYm5V08k5SFupDP0h72MY=" crossorigin="anonymous"></script>
{% if date_fanciness != 0 %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment-with-locales.min.js"></script>
{% endif %}
<script src="/assets/js/all.js"></script>
{% else %}
<script src="/assets/js/all-nocdn.js"></script>
{% endif %}
{% else %}
{% if use_cdn %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.9.1/baguetteBox.min.js" integrity="sha256-SoEATAB7PgNWyyK100I7yQXYm5V08k5SFupDP0h72MY=" crossorigin="anonymous"></script>
{% if date_fanciness != 0 %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment-with-locales.min.js"></script>
{% endif %}
{% else %}
<script src="/assets/js/baguetteBox.min.js"></script>
{% if date_fanciness != 0 %}
<script src="/assets/js/moment-with-locales.min.js"></script>
{% endif %}
{% endif %}
{% if date_fanciness != 0 %}
<script src="/assets/js/fancydates.js"></script>
{% endif %}
{% endif %}
{{ social_buttons_code }}
Expand Down
10 changes: 9 additions & 1 deletion nikola/data/themes/base-jinja/templates/index.tmpl
Expand Up @@ -37,7 +37,15 @@
{{ post.author()|e }}
{% endif %}
</span></p>
<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>
<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>
{% if post.updated and post.updated != post.date %}
<span class="updated"> updated </span>
<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>
{% endif %}
</a>
</p>
{% if not post.meta('nocomments') and site_has_comments %}
<p class="commentline">{{ comments.comment_link(post.permalink(), post._base_path) }}
{% endif %}
Expand Down
10 changes: 9 additions & 1 deletion nikola/data/themes/base-jinja/templates/post_header.tmpl
Expand Up @@ -38,7 +38,15 @@
{{ post.author()|e }}
{% endif %}
</span></p>
<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>
<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>
{% if post.updated and post.updated != post.date %}
<span class="updated"> updated </span>
<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>
{% endif %}
</a>
</p>
{% if not post.meta('nocomments') and site_has_comments %}
<p class="commentline">{{ comments.comment_link(post.permalink(), post._base_path) }}
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/themes/base/assets/js/fancydates.js
Expand Up @@ -3,7 +3,7 @@ function fancydates(fanciness, date_format) {
return;
}

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

var l = dates.length;

Expand Down
2 changes: 1 addition & 1 deletion nikola/data/themes/base/assets/js/fancydates.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion nikola/data/themes/base/bundles
@@ -1,3 +1,4 @@
assets/css/all.css=rst_base.css,nikola_rst.css,code.css,theme.css
assets/css/all-nocdn.css=rst_base.css,nikola_rst.css,code.css,theme.css,baguetteBox.min.css
assets/css/all-nocdn.js=baguetteBox.min.js
assets/js/all.js=fancydates.js
assets/js/all-nocdn.js=baguetteBox.min.js,moment-with-locales.min.js,fancydates.js
8 changes: 8 additions & 0 deletions nikola/data/themes/base/templates/base.tmpl
Expand Up @@ -20,6 +20,14 @@ ${template_hooks['extra_head']()}
${footer.html_footer()}
</div>
${base.late_load_js()}
% if date_fanciness != 0:
<!-- fancy dates -->
<script>
moment.locale("${momentjs_locales[lang]}");
fancydates(${date_fanciness}, ${js_date_format});
</script>
<!-- end fancy dates -->
% endif
<%block name="extra_js"></%block>
<script>
baguetteBox.run('div#content', {
Expand Down
13 changes: 13 additions & 0 deletions nikola/data/themes/base/templates/base_helper.tmpl
Expand Up @@ -66,14 +66,27 @@ lang="${lang}">
% if use_bundles:
% if use_cdn:
<script src="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.9.1/baguetteBox.min.js" integrity="sha256-SoEATAB7PgNWyyK100I7yQXYm5V08k5SFupDP0h72MY=" crossorigin="anonymous"></script>
% if date_fanciness != 0:
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment-with-locales.min.js"></script>
% endif
<script src="/assets/js/all.js"></script>
% else:
<script src="/assets/js/all-nocdn.js"></script>
% endif
% else:
% if use_cdn:
<script src="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.9.1/baguetteBox.min.js" integrity="sha256-SoEATAB7PgNWyyK100I7yQXYm5V08k5SFupDP0h72MY=" crossorigin="anonymous"></script>
% if date_fanciness != 0:
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment-with-locales.min.js"></script>
% endif
% else:
<script src="/assets/js/baguetteBox.min.js"></script>
% if date_fanciness != 0:
<script src="/assets/js/moment-with-locales.min.js"></script>
% endif
% endif
% if date_fanciness != 0:
<script src="/assets/js/fancydates.js"></script>
% endif
% endif
${social_buttons_code}
Expand Down
10 changes: 9 additions & 1 deletion nikola/data/themes/base/templates/index.tmpl
Expand Up @@ -37,7 +37,15 @@
${post.author()|h}
% endif
</span></p>
<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>
<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>
% if post.updated and post.updated != post.date:
<span class="updated"> updated </span>
<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>
% endif
</a>
</p>
% if not post.meta('nocomments') and site_has_comments:
<p class="commentline">${comments.comment_link(post.permalink(), post._base_path)}
% endif
Expand Down
10 changes: 9 additions & 1 deletion nikola/data/themes/base/templates/post_header.tmpl
Expand Up @@ -38,7 +38,15 @@
${post.author()|h}
% endif
</span></p>
<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>
<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>
% if post.updated and post.updated != post.date:
<span class="updated"> updated </span>
<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>
% endif
</a>
</p>
% if not post.meta('nocomments') and site_has_comments:
<p class="commentline">${comments.comment_link(post.permalink(), post._base_path)}
% endif
Expand Down

0 comments on commit 4391663

Please sign in to comment.