diff --git a/fgs/generator.py b/fgs/generator.py index 540f32b33273064c5b90f455a26506a3e467eb6e..e620c4aa0da86495de7be445d12e81d09b6ad8bb 100644 --- a/fgs/generator.py +++ b/fgs/generator.py @@ -42,22 +42,22 @@ class Generator: # categories categories = {} for page in published_pages: - if page.category not in categories: - categories[page.category] = {} - if page.lang not in categories[page.category]: - categories[page.category][page.lang] = [] - categories[page.category][page.lang].append(page) + if page.lang not in categories: + categories[page.lang] = {} + if page.category not in categories[page.lang]: + categories[page.lang][page.category] = [] + categories[page.lang][page.category].append(page) self.context['categories'] = categories # tags tags = {} for page in published_pages: for tag in page.tags: - if tag not in tags: - tags[tag] = {} - if page.lang not in tags[tag]: - tags[tag][page.lang] = [] - tags[tag][page.lang].append(page) + if page.lang not in tags: + tags[page.lang] = {} + if tag not in tags[page.lang]: + tags[page.lang][tag] = [] + tags[page.lang][tag].append(page) self.context['tags'] = tags @@ -77,6 +77,10 @@ class Generator: for page in self.context['pages'][lang].values(): writer.write_template(page.template, page.url, lang, {'page': page}) + # all tags + for tag, tagpages in self.context['tags'][lang].items(): + writer.write_template('tag.html', lang + '/tag/' + tag + '.html', lang, {'tag': tag, 'tagpages': tagpages}) + # homepages for languages self.generate_homepage(writer, lang, lang + "/index.html") diff --git a/fgs/reader.py b/fgs/reader.py index 96ddee441fd3d48a9a396b6118265d21dee14c62..9cc14065d9781c638546842e82415482dac9354a 100644 --- a/fgs/reader.py +++ b/fgs/reader.py @@ -150,7 +150,7 @@ class MarkdownReader: if not isinstance(slug, str): raise Exception("slug is not a string: '", slug, "'") slug = slug.lower() - whitelist = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + whitelist = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-" res = "" for c in slug: if c in whitelist: diff --git a/theme/templates/macros/getters.html b/theme/templates/macros/getters.html index ad8b7e5c16f9eb011400534847d3454e4e499077..1684d18c4e3a3e1bb601d94e0d230368a19db20c 100644 --- a/theme/templates/macros/getters.html +++ b/theme/templates/macros/getters.html @@ -10,7 +10,7 @@ {%- endcall -%} {%- endif -%} - {{- caller(ns.tagtitle, ns.tagcolor, [lang, 'tag', tagname + '.html']|join('/') , ns.tagpage, tags[tagname][lang]) -}} + {{- caller(ns.tagtitle, ns.tagcolor, [lang, 'tag', tagname + '.html']|join('/') , ns.tagpage, tags[lang][tagname]) -}} {%- endmacro -%} {%- macro metadata_entry(slug, lang, key) -%} diff --git a/theme/templates/tag.html b/theme/templates/tag.html new file mode 100644 index 0000000000000000000000000000000000000000..3c0cca1b0d16799bf01dacf967c4f2c742ed4ecd --- /dev/null +++ b/theme/templates/tag.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} +{% block title -%} + {%- call(tagtitle, tagcolor, tagurl, tagpage, tagpages) get.tag_by_name(tag, l) -%} + {{ t[l].title_prefix }}{{ t[l].sitename }}{{ t[l].title_suffix }} - {{ tagtitle|e }} + {%- endcall -%} +{%- endblock -%} + +{% block content %} + <section> + {{ render.section({"type": "tag", "tag": tag, "num": None}, l) }} + </section> +{% endblock content %}