Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #198 from schettino72/101-datetime-configurable

FIX #101. added date_format to GLOBAL_CONTEXT
  • Loading branch information...
commit 56c725a1a748d77847134b4951359ccb1feb6956 2 parents 1d5ae38 + 4539a0b
@ralsina authored
View
4 nikola/conf.py.in
@@ -187,6 +187,9 @@ INDEXES_PAGES = "" # If this is empty, the default is 'old posts page %d' trans
# Name of the theme to use. Themes are located in themes/theme_name
THEME = 'site'
+# date format used to display post dates. (str used by datetime.datetime.strftime)
+DATE_FORMAT = '%Y-%m-%d %H:%M'
+
# Show only teasers in the index pages? Defaults to False.
# INDEX_TEASERS = False
@@ -258,6 +261,7 @@ GLOBAL_CONTEXT = {
'blog_title': BLOG_TITLE,
'blog_url': BLOG_URL,
'blog_desc': BLOG_DESCRIPTION,
+ 'date_format': DATE_FORMAT,
'translations': TRANSLATIONS,
'license': LICENSE,
'search_form': SEARCH_FORM,
View
2  nikola/data/themes/default/templates/index.tmpl
@@ -5,7 +5,7 @@
<div class="postbox">
<h1><a href="${post.permalink(lang)}">${post.title(lang)}</a>
<small>&nbsp;&nbsp;
- ${messages[lang]["Posted"]}: ${post.date}
+ ${messages[lang]["Posted"]}: ${post.date.strftime(date_format)}
</small></h1>
<hr>
${post.text(lang, index_teasers)}
View
2  nikola/data/themes/default/templates/list_post.tmpl
@@ -6,7 +6,7 @@
<h1>${title}</h1>
<ul class="unstyled">
% for post in posts:
- <li><a href="${post.permalink(lang)}">[${post.date}] ${post.title(lang)}</a>
+ <li><a href="${post.permalink(lang)}">[${post.date.strftime(date_format)}] ${post.title(lang)}</a>
% endfor
</ul>
</div>
View
2  nikola/data/themes/default/templates/post.tmpl
@@ -9,7 +9,7 @@
% endif
<hr>
<small>
- ${messages[lang]["Posted"]}: ${post.date}&nbsp;&nbsp;|&nbsp;&nbsp;
+ ${messages[lang]["Posted"]}: ${post.date.strftime(date_format)}&nbsp;&nbsp;|&nbsp;&nbsp;
%if len(translations) > 1:
%for langname in translations.keys():
View
2  nikola/data/themes/jinja-default/templates/index.tmpl
@@ -4,7 +4,7 @@
<div class="postbox">
<h1><a href="{{post.permalink(lang)}}">{{post.title(lang)}}</a>
<small>&nbsp;&nbsp;
- {{messages[lang]["Posted"]}}: {{post.date}}
+ {{messages[lang]["Posted"]}}: {{post.date.strftime(date_format)}}
</small></h1>
<hr>
{{post.text(lang, index_teasers)}}
View
2  nikola/data/themes/jinja-default/templates/list_post.tmpl
@@ -5,7 +5,7 @@
<h1>{{title}}</h1>
<ul class="unstyled">
{% for post in posts %}
- <li><a href="{{post.permalink(lang)}}">[{{post.date}}] {{post.title(lang)}}</a>
+ <li><a href="{{post.permalink(lang)}}">[{{post.date.strftime(date_format)}}] {{post.title(lang)}}</a>
{% endfor %}
</ul>
</div>
View
2  nikola/data/themes/jinja-default/templates/post.tmpl
@@ -7,7 +7,7 @@
{% endif %}
<hr>
<small>
- {{messages[lang]["Posted"]}}: {{post.date}}&nbsp;&nbsp;|&nbsp;&nbsp;
+ {{messages[lang]["Posted"]}}: {{post.date.strftime(date_format)}}&nbsp;&nbsp;|&nbsp;&nbsp;
{% if translations|length > 1 %}
{% for langname in translations.keys() %}
View
2  nikola/data/themes/site/templates/post.tmpl
@@ -9,7 +9,7 @@
% endif
<hr>
<small>
- ${messages[lang]["Posted"]}: ${post.date}
+ ${messages[lang]["Posted"]}: ${post.date.strftime(date_format)}
%if len(translations) > 1:
%for langname in translations.keys():
View
2  nikola/nikola.py
@@ -156,6 +156,8 @@ def __init__(self, **config):
self.GLOBAL_CONTEXT['index_display_post_count'] = self.config[
'INDEX_DISPLAY_POST_COUNT']
self.GLOBAL_CONTEXT['use_bundles'] = self.config['USE_BUNDLES']
+ if 'date_format' not in self.GLOBAL_CONTEXT:
+ self.GLOBAL_CONTEXT['date_format'] = '%Y-%m-%d %H:%M'
# check if custom css exist and is not empty
for files_path in list(self.config['FILES_FOLDERS'].keys()):
View
2  nikola/plugins/compile_markdown/__init__.py
@@ -34,7 +34,7 @@
class CompileMarkdown(PageCompiler):
- """Compile reSt into HTML."""
+ """Compile markdown into HTML."""
name = "markdown"
Please sign in to comment.
Something went wrong with that request. Please try again.