From 15a96b5846fae7338b0fc6a670059b0800e165ef Mon Sep 17 00:00:00 2001 From: Anish Lakhwara Date: Mon, 7 Feb 2022 23:41:16 +1000 Subject: [PATCH] fixed up lists and tag_index a lil --- src/kitaab-public/build/build.py | 14 ++++++-------- src/kitaab-public/partial/index_table.html | 2 +- src/kitaab-public/partial/list.html | 6 ++---- src/kitaab-public/partial/main.html | 2 +- src/kitaab-public/shared/TagHelper.py | 2 +- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/kitaab-public/build/build.py b/src/kitaab-public/build/build.py index ddbee5b..9313ea4 100644 --- a/src/kitaab-public/build/build.py +++ b/src/kitaab-public/build/build.py @@ -6,18 +6,16 @@ import platform import re import shutil from datetime import datetime -import importlib -# TODO import from shared -TagHelper = importlib.load_module('shared.TagHelper') +# TODO flith +import sys +sys.path.append("./") +from shared import TagHelper, config # Default encoding encoding = 'utf-8' # Import local files mistune = __import__('mistune') -# TODO import from shared -config = __import__('shared.config') - # Activating the renderer renderer = mistune.Renderer() @@ -107,7 +105,7 @@ def generate_html_pages(site_folder, entries, template, sub_pages_list, template template = env.get_template(template) if len(entry['tags']) > 1: entry['tags'] = entry['tags'].split(' ') - page_template = template.render(page_body=entry['pageContent'], page_date="%s"%entry['date'], page_tags=entry['tags'], naem_of_site="Kitaab", page_navigation=nav_html, page_title=entry['title'], build_url=entry['parent_text'], config=config) + page_template = template.render(page_body=entry['pageContent'], page_date="%s"%entry['date'], page_tags=entry['tags'], name_of_site="Kitaab", page_navigation=nav_html, page_title=entry['title'], build_url=entry['parent_text'], config=config) # Checking if content folder exists folderExists = os.path.exists(site_folder+entry['folder']) @@ -270,7 +268,7 @@ def get_date(page): def parse_headings(page): try: - page = re.sub(r'= [\[\]a-zA-Z0-9:|+ ]* =', + page = re.sub(r'= [\[\]a-zA-Z0-9:|+& ]* =', lambda x: x.group().replace('=','###', 1).strip('='), page) return page diff --git a/src/kitaab-public/partial/index_table.html b/src/kitaab-public/partial/index_table.html index e1e81b1..f7b2900 100644 --- a/src/kitaab-public/partial/index_table.html +++ b/src/kitaab-public/partial/index_table.html @@ -50,7 +50,7 @@ media="screen" title="no title" charset="utf-8">
{{page_navigation}}

{{page_title}}

-
+
{% set count = namespace(value=0) %} diff --git a/src/kitaab-public/partial/list.html b/src/kitaab-public/partial/list.html index 1057253..a0b5154 100644 --- a/src/kitaab-public/partial/list.html +++ b/src/kitaab-public/partial/list.html @@ -3,8 +3,7 @@ {% endif %}
    {% for entry in entries %} -
  • -
    +

    {% if title %} {{entry["title"]}} @@ -20,13 +19,12 @@ {% endif %} {% endif %}

    -

    {{entry['date']}}

    +

    {{entry['date']}}

    {% for page in entry['tags'].split(' ') %} {{page}} {% endfor %} -
  • {% endfor %}
diff --git a/src/kitaab-public/partial/main.html b/src/kitaab-public/partial/main.html index 3446914..bc9be92 100644 --- a/src/kitaab-public/partial/main.html +++ b/src/kitaab-public/partial/main.html @@ -50,7 +50,7 @@ media="screen" title="no title" charset="utf-8">
{{ page_navigation }}

{{page_title}}

-
+
{% if page_tags %} {% for page in page_tags %} diff --git a/src/kitaab-public/shared/TagHelper.py b/src/kitaab-public/shared/TagHelper.py index 528e5e1..0722377 100644 --- a/src/kitaab-public/shared/TagHelper.py +++ b/src/kitaab-public/shared/TagHelper.py @@ -78,5 +78,5 @@ def getAllTags(): all_tags = makeDictFromTags(loadTagFile()) all_tags['untagged'] = getUntaggedFiles() for tag in privateList: - all_tags.pop(tag) + all_tags.pop(tag, None) return all_tags