Browse Source

Better handling of drafts

master
David Larlet 4 years ago
parent
commit
f859128237
No known key found for this signature in database
2 changed files with 9 additions and 2 deletions
  1. 1
    1
      david/templates/article_2020.html
  2. 8
    1
      site.py

+ 1
- 1
david/templates/article_2020.html View File

<article> <article>
<h1>{{ page.title }}</h1> <h1>{{ page.title }}</h1>
<nav> <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> <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 %} {% if next and not next.is_draft %} • <a rel="next" href="{{ next.url }}" title="Publication suivante : {{ next.title }}">→</a>{% endif %}
</nav> </nav>

+ 8
- 1
site.py View File

HERE = Path(".") HERE = Path(".")
DAVID = HERE / "david" DAVID = HERE / "david"
DOMAIN = "https://larlet.fr" DOMAIN = "https://larlet.fr"
LOCAL_DOMAIN = "http://larlet.test:3579"
# Hardcoding publication at 12 in Paris timezone. # Hardcoding publication at 12 in Paris timezone.
NORMALIZED_STRFTIME = "%Y-%m-%dT12:00:00+01:00" NORMALIZED_STRFTIME = "%Y-%m-%dT12:00:00+01:00"


root_path = DAVID / "2020" root_path = DAVID / "2020"
for previous, page, next_ in neighborhood( for previous, page, next_ in neighborhood(
reversed(Page.all(source=root_path, only_published=False)), 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") template = environment.get_template("article_2020.html")
content = template.render(page=page, prev=previous, next=next_,) content = template.render(page=page, prev=previous, next=next_,)
target_path = Path(page.url[1:]) target_path = Path(page.url[1:])
target_path.mkdir(parents=True, exist_ok=True) target_path.mkdir(parents=True, exist_ok=True)
open(target_path / "index.html", "w").write(content) 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") template = environment.get_template("archives_2020.html")
content = template.render(page_list=Page.all(source=root_path)) content = template.render(page_list=Page.all(source=root_path))
open(root_path / "index.html", "w").write(content) open(root_path / "index.html", "w").write(content)

Loading…
Cancel
Save