Skip to content
Snippets Groups Projects
Verified Commit 39ff7724 authored by Jake's avatar Jake
Browse files

tags working

parent 05ee2f39
No related branches found
No related tags found
No related merge requests found
...@@ -42,22 +42,22 @@ class Generator: ...@@ -42,22 +42,22 @@ class Generator:
# categories # categories
categories = {} categories = {}
for page in published_pages: for page in published_pages:
if page.category not in categories: if page.lang not in categories:
categories[page.category] = {} categories[page.lang] = {}
if page.lang not in categories[page.category]: if page.category not in categories[page.lang]:
categories[page.category][page.lang] = [] categories[page.lang][page.category] = []
categories[page.category][page.lang].append(page) categories[page.lang][page.category].append(page)
self.context['categories'] = categories self.context['categories'] = categories
# tags # tags
tags = {} tags = {}
for page in published_pages: for page in published_pages:
for tag in page.tags: for tag in page.tags:
if tag not in tags: if page.lang not in tags:
tags[tag] = {} tags[page.lang] = {}
if page.lang not in tags[tag]: if tag not in tags[page.lang]:
tags[tag][page.lang] = [] tags[page.lang][tag] = []
tags[tag][page.lang].append(page) tags[page.lang][tag].append(page)
self.context['tags'] = tags self.context['tags'] = tags
...@@ -77,6 +77,10 @@ class Generator: ...@@ -77,6 +77,10 @@ class Generator:
for page in self.context['pages'][lang].values(): for page in self.context['pages'][lang].values():
writer.write_template(page.template, page.url, lang, {'page': page}) 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 # homepages for languages
self.generate_homepage(writer, lang, lang + "/index.html") self.generate_homepage(writer, lang, lang + "/index.html")
......
...@@ -150,7 +150,7 @@ class MarkdownReader: ...@@ -150,7 +150,7 @@ class MarkdownReader:
if not isinstance(slug, str): if not isinstance(slug, str):
raise Exception("slug is not a string: '", slug, "'") raise Exception("slug is not a string: '", slug, "'")
slug = slug.lower() slug = slug.lower()
whitelist = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" whitelist = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-"
res = "" res = ""
for c in slug: for c in slug:
if c in whitelist: if c in whitelist:
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
{%- endcall -%} {%- endcall -%}
{%- endif -%} {%- 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 -%} {%- endmacro -%}
{%- macro metadata_entry(slug, lang, key) -%} {%- macro metadata_entry(slug, lang, key) -%}
......
{% 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 %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment