Skip to content
Snippets Groups Projects
Commit 8d6914b3 authored by Jake's avatar Jake
Browse files

render hidden pages too

parent 9943cdeb
No related branches found
No related tags found
No related merge requests found
......@@ -12,21 +12,34 @@ class Generator:
pages = self.factories['page'].all()
published_pages = []
hidden_pages = []
for lang in self.config['lang']['supported']:
for slug, page in pages[lang].items():
if page.status == "published":
published_pages.append(page)
elif page.status == "hidden":
hidden_pages.append(page)
# pages
all_pages = {}
# set context.pages from published_pages as a dict of languages containing dicts of slugs
all_published_pages = {}
for lang in self.config['lang']['supported']:
all_published_pages[lang] = {}
for page in published_pages:
if page.lang not in all_pages:
all_pages[page.lang] = {}
if page.slug in all_pages[page.lang]:
if page.slug in all_published_pages[page.lang]:
raise Exception("duplicate language (",lang,") for slug '", slug ,"'")
all_published_pages[page.lang][page.slug] = page
self.context['pages'] = all_published_pages
# set context.hidden_pages from hidden_pages as a dict of languages containing dicts of slugs
all_hidden_pages = {}
for lang in self.config['lang']['supported']:
all_hidden_pages[lang] = {}
for page in hidden_pages:
if page.slug in all_hidden_pages[page.lang]:
raise Exception("duplicate language (",lang,") for slug '", slug ,"'")
all_pages[page.lang][page.slug] = page
self.context['pages'] = all_pages
all_hidden_pages[page.lang][page.slug] = page
self.context['hidden_pages'] = all_hidden_pages
# pages_modified
pages_modified = {}
......@@ -40,7 +53,6 @@ class Generator:
pages_modified[lang] = lang_pages
self.context['pages_modified'] = pages_modified
# TODO hidden pages
# TODO draft pages
# TODO authors
......@@ -88,10 +100,15 @@ class Generator:
writer.write_file(f.link.path, f.rawcontents, mode="wb")
for lang in self.config['lang']['supported']:
# all pages
# all published pages
for page in self.context['pages'][lang].values():
writer.write_template(page.template, page.link.path, lang, {'page': page}, page.config)
# all hidden pages
for page in self.context['hidden_pages'][lang].values():
#print(page.slug)
writer.write_template(page.template, page.link.path, lang, {'page': page}, page.config)
# all tags
for tag in self.context['tags'][lang].values():
writer.write_template('tag.html', tag.link.path, lang, {'tag': tag}, tag.config)
......
{%- macro page_by_slug(slug, lang) -%}
{{- caller(pages[lang][slug]) -}}
{%- if slug in pages[lang]-%}
{{- caller(pages[lang][slug]) -}}
{%- elif slug in hidden_pages[lang]-%}
{{- caller(hidden_pages[lang][slug]) -}}
{%- endif -%}
{%- endmacro -%}
{%- macro tag_by_name(name, lang) -%}
......
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