Add fuzzy dates with lw-timeago
Fixes #14
diff --git a/templates/article.html b/templates/article.html
index 553eb15..8814aab 100644
--- a/templates/article.html
+++ b/templates/article.html
@@ -24,7 +24,7 @@
{{ article.content }}
</div>
<div class="article_meta">
- <p>Posted on <time datetime="{{ article.date.isoformat() }}">{{ article.locale_date }}</time>
+ <p>Posted <time datetime="{{ article.date.isoformat() }}">{{ article.locale_date }}</time>
{% if article.author %}
by {% if AUTHORS_URL %} <a href="{{ SITEURL }}/{{ article.author.url }}">{{ article.author }}</a>{% else %}{{ article.author}}{% endif %}
{% endif %}
@@ -59,7 +59,15 @@
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
- {% endif %}
+ {% endif %}
+
+ {% if FUZZY_DATES %}
+ {% block scripts %}
+ {{ super() }}
+ <script type="text/javascript">lw_timeago.doReplace()</script>
+ {% endblock %}
+ {% endif %}
+
</article>
{% endblock %}
diff --git a/templates/base.html b/templates/base.html
index b0d97de..1200546 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -9,6 +9,11 @@
<script src="//cdnjs.cloudflare.com/ajax/libs/less.js/1.6.1/less.min.js" type="text/javascript"></script>
{% endif %}
+
+ {% if FUZZY_DATES %}
+ <script src="{{ SITEURL }}/theme/js/lw-timeago/lw-timeago.js" type="text/javascript"></script>
+ {% endif %}
+
<link rel="stylesheet" type="text/css" href="{{ SITEURL }}/theme/css/pygments.css">
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet">
@@ -138,6 +143,7 @@
</div>
</main>
+ {% block scripts %}
{% if SCROLL_TO_CONTENT %}
<script type="text/javascript">
if (window.location.pathname != '/' && window.location.pathname != '/index.html'){
@@ -169,5 +175,7 @@
}
</script>
{% endif %}
+
+ {% endblock scripts %}
</body>
</html>