瀏覽代碼

Better handling of drafts

master
David Larlet 4 年之前
父節點
當前提交
f859128237
沒有發現已知的金鑰在資料庫的簽署中
共有 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…
取消
儲存