diff --git a/basant/build/kitaab.py b/basant/build/kitaab.py
index 3bb2753..3b9c9e8 100644
--- a/basant/build/kitaab.py
+++ b/basant/build/kitaab.py
@@ -62,7 +62,6 @@ def generate_index_pages(template=config.template_main, template_nav=config.temp
pages = all_tags[index]
pages = add_file_path(pages, config.files_folder)
entries = create_entries(pages)
- # TODO this broke as well, not sure what happened to entries, but the whole page is blank?
subPages = generate_sub_pages(entries, len(
entries), config.files_folder, False)
# Build the files by filling out the template
@@ -125,6 +124,7 @@ def generate_html_pages(site_folder, entries, template, sub_pages_list, template
head=generate_head(page_title=entry['title']),
page_body=entry['pageContent'],
page_date="%s" % entry['date'],
+ page_update="%s" % entry['update'],
page_tags=entry['tags'],
name_of_site="Kitaab",
page_navigation=nav_html,
@@ -288,6 +288,24 @@ def remove_date(page):
print(f'Unexpected error in removing date in {page}')
return page
+def remove_update(page):
+ try:
+ regex = r"%update [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}"
+ page = re.sub(regex, '', page)
+ return page
+ except Exception as e:
+ print(f'Unexpected error in removing date in {page}')
+ return page
+
+def remove_links(page):
+ try:
+ regex = r"%link *"
+ page = re.sub(regex, '', page)
+ return page
+ except Exception as e:
+ print(f'Unexpected error in removing date in {page}')
+ return page
+
def replacement_function(replace):
replace = replace.group()
@@ -329,6 +347,28 @@ def get_date(page):
# print(f"Could not parse date")
return None
+def get_update(page):
+ try:
+ regex = r"%update [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}"
+ match = re.findall(regex, page)[0].strip('%update')
+ return match
+ except:
+ # print(f"Could not parse date")
+ return None
+
+def get_links(page):
+ try:
+ regex = r"%link *"
+ match = re.findall(regex, page)[0].strip('%link')
+ ret = []
+ for m in match:
+ m = m.group()
+ m = m.strip("%link")
+ ret.append(m)
+ return ret
+ except:
+ # print(f"Could not parse date")
+ return None
def parse_headings(page):
try:
@@ -360,6 +400,7 @@ def create_entries(pages):
markdown_text = open(page, 'r').read()
except UnicodeDecodeError:
print(f"Couldn't parse {title}, {page}")
+ continue
markdown_text = parse_headings(markdown_text)
markdown_text = replace_generated(markdown_text)
markdown_text = style_iframes(markdown_text)
@@ -367,9 +408,13 @@ def create_entries(pages):
markdown_text = fix_wiki_links(markdown_text, path["folder"])
tags = get_tags(markdown_text)
date = get_date(markdown_text)
+ update = get_update(markdown_text)
+ links = get_links(markdown_text)
markdown_text = remove_tags(markdown_text)
markdown_text = remove_title(markdown_text)
markdown_text = remove_date(markdown_text)
+ markdown_text = remove_update(markdown_text)
+ markdown_text = remove_links(markdown_text)
pageContent = markdown(markdown_text)
# Create the page object with all the informations we need
@@ -383,9 +428,14 @@ def create_entries(pages):
tempPage['date'] = date
else:
tempPage['date'] = path['iso_date'][:-3]
+ if update:
+ tempPage['update'] = update
+ else:
+ tempPage['update'] = tempPage['date']
tempPage['title'] = fix_amp(title)
tempPage['pageContent'] = pageContent
tempPage['tags'] = tags
+ tempPage['links'] = links
fullContent.append(tempPage)
diff --git a/basant/partial/list.html b/basant/partial/list.html
index 6987cd2..74fbce8 100644
--- a/basant/partial/list.html
+++ b/basant/partial/list.html
@@ -12,7 +12,7 @@
TODO
Sometimes the entry doesn't output a title and I'm not entirely sure why
--!>
- {% if entry['title'] %}
+ {% if entry['title']|length > 0 %}
{{entry["title"]}}
{% else %}
{{entry['file']}}
diff --git a/basant/partial/main.html b/basant/partial/main.html
index b1817fa..4557a42 100644
--- a/basant/partial/main.html
+++ b/basant/partial/main.html
@@ -20,7 +20,10 @@
{% endfor %}
{% endif %}
{% if page_date %}
- {{page_date}}
+
published {{page_date}}
+ {% endif %}
+ {% if page_update %}
+ updated {{page_update}}
{% endif %}
{{page_body}}