-
{{ category_label}}{{ date }}
+
{{ category_label}}{{ friendly_date }}
{{ summary }}
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/layout/post.html b/layout/post.html
index 2d88b64..923332c 100644
--- a/layout/post.html
+++ b/layout/post.html
@@ -1,5 +1,5 @@
-
+
{{ title }}
+
{{ category_label}}{{ friendly_date }}
+ {{ content }}
+
\ No newline at end of file
diff --git a/makesite.py b/makesite.py
index 91a7207..c7d95b7 100755
--- a/makesite.py
+++ b/makesite.py
@@ -36,6 +36,10 @@ import json
import datetime
from pathlib import Path
import unicodedata
+import locale
+
+# set user locale
+locale.setlocale(locale.LC_ALL, '')
def fread(filename):
"""Read file and close the file."""
@@ -87,6 +91,7 @@ def slugify(value):
value = re.sub('[^\w\s-]', '', value).strip().lower()
return re.sub('[-\s]+', '-', value)
+
def read_content(filename):
"""Read content and metadata from file into a dictionary."""
# Read file content.
@@ -127,6 +132,17 @@ def read_content(filename):
return content
+def clean_html_tag(text):
+ """Remove HTML tags."""
+ while True:
+ original_text = text
+ text = re.sub('<\w+.*?>', '', text)
+ text = re.sub('<\/\w+>', '', text)
+ if original_text == text:
+ break
+ return text
+
+
def render(template, **params):
"""Replace placeholders in template with values from params."""
return re.sub(r'{{\s*([^}\s]+)\s*}}',
@@ -171,6 +187,11 @@ def make_pages(src, dst, layout, **params):
return sorted(items, key=lambda x: x['date'], reverse=True)
+def get_friendly_date(date_str):
+ dt = datetime.datetime.strptime(date_str, '%Y-%m-%d')
+ return dt.strftime('%d %b %Y')
+
+
def make_posts(src, src_pattern, dst, layout, category_layout, **params):
"""Generate posts from posts directory."""
items = []
@@ -182,6 +203,7 @@ def make_posts(src, src_pattern, dst, layout, category_layout, **params):
page_params = dict(params, **content)
page_params['banner'] =' '
page_params['date_path'] = page_params['date'].replace('-', '/')
+ page_params['friendly_date'] = get_friendly_date(page_params['date'])
page_params['year'] = page_params['date'].split('-')[0]
# categories
@@ -201,11 +223,11 @@ def make_posts(src, src_pattern, dst, layout, category_layout, **params):
summary_index = page_params['content'].find('