Преглед изворни кода

Better handling of drafts

master
David Larlet пре 4 година
родитељ
комит
f859128237
No known key found for this signature in database
2 измењених фајлова са 9 додато и 2 уклоњено
  1. 1
    1
      david/templates/article_2020.html
  2. 8
    1
      site.py

+ 1
- 1
david/templates/article_2020.html Прегледај датотеку

@@ -5,7 +5,7 @@
<article>
<h1>{{ page.title }}</h1>
<nav>
<a rel="prev" href="{{ prev.url }}" title="Publication précédente : {{ prev.title }}">←</a> •
{% if prev and not prev.is_draft %}<a rel="prev" href="{{ prev.url }}" title="Publication précédente : {{ prev.title }}">←</a> •{% endif %}
<a href="/david/2020/" title="Liste des publications récentes">↑</a>
{% if next and not next.is_draft %} • <a rel="next" href="{{ next.url }}" title="Publication suivante : {{ next.title }}">→</a>{% endif %}
</nav>

+ 8
- 1
site.py Прегледај датотеку

@@ -22,6 +22,7 @@ locale.setlocale(locale.LC_ALL, "fr_FR.UTF-8")
HERE = Path(".")
DAVID = HERE / "david"
DOMAIN = "https://larlet.fr"
LOCAL_DOMAIN = "http://larlet.test:3579"
# Hardcoding publication at 12 in Paris timezone.
NORMALIZED_STRFTIME = "%Y-%m-%dT12:00:00+01:00"

@@ -132,13 +133,19 @@ def pages():
root_path = DAVID / "2020"
for previous, page, next_ in neighborhood(
reversed(Page.all(source=root_path, only_published=False)),
first={"url": "/david/stream/", "title": "Streams 2009-2019"},
first={
"url": "/david/stream/",
"title": "Streams 2009-2019",
"is_draft": False,
},
):
template = environment.get_template("article_2020.html")
content = template.render(page=page, prev=previous, next=next_,)
target_path = Path(page.url[1:])
target_path.mkdir(parents=True, exist_ok=True)
open(target_path / "index.html", "w").write(content)
if page.is_draft:
print(f"Draft: {LOCAL_DOMAIN}{page.url} ({page.title})")
template = environment.get_template("archives_2020.html")
content = template.render(page_list=Page.all(source=root_path))
open(root_path / "index.html", "w").write(content)

Loading…
Откажи
Сачувај