diff --git a/README.md b/README.md index 09f6bce..137bfdf 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Sources of the kmalloc.org website: plain static HTML, no JavaScript, valid HTML - `content/site.toml` holds the values shared by every page: contact address, Bitcoin address, manifesto version. - `content//lang.toml` holds the chrome strings of one language (`en`, `it`). - `content//*.html` are the pages: a front matter block, then an HTML fragment. -- `content//news/` holds the news posts. +- `content/en/news/` holds the news posts. News are written in English only. - `MANIFESTO.en.md` and `MANIFESTO.it.md` are the manifesto texts, version 1.0. - `fonts/terminess.woff2` is Terminess (Terminus), SIL Open Font License, subset to Latin. - `badges/` holds the official W3C badges, served from our own site. @@ -33,7 +33,7 @@ A page starts with a front matter block, then the HTML fragment: ## News -A post is a Markdown file named `YYYY-MM-DD-slug.md` in `content//news/`: +A post is a Markdown file named `YYYY-MM-DD-slug.md` in `content/en/news/`: --- title: Hello @@ -43,7 +43,7 @@ A post is a Markdown file named `YYYY-MM-DD-slug.md` in `content//news/`: ## A heading -The post is published at `/news/slug.html` (`/it/news/slug.html` for Italian). A post with the same file name in both languages is linked as a translation. The news index, the latest three posts on the home page and an RSS 2.0 feed (`/news/feed.xml`, `/it/news/feed.xml`, the latest 20 posts with full text) are built from the files. Every page links its feed in the head. No em dashes: the build refuses them. +The post is published at `/news/slug.html`. News are English only: the Italian pages list the same posts and link to them. The news index, the latest three posts on the home pages and an RSS 2.0 feed (`/news/feed.xml`, the latest 20 posts with full text) are built from the files. Every page links the feed in the head and shows the RSS icon in the footer. No em dashes: the build refuses them. ## Publishing diff --git a/build.py b/build.py index 20f0e7e..c1f33e6 100644 --- a/build.py +++ b/build.py @@ -9,7 +9,7 @@ Layout: content/site.toml values shared by every page (contact, bitcoin address, manifesto version) content//lang.toml the chrome strings of one language content//*.html pages: front matter, then an HTML fragment - content//news/*.md news posts: YYYY-MM-DD-slug.md, front matter, then Markdown + content/en/news/*.md news posts, English only: YYYY-MM-DD-slug.md, front matter, then Markdown A page starts with a front matter block: --- @@ -220,10 +220,10 @@ def load_pages(lang): return pages -def rss(lang, st, site, lang_pages): - """RSS 2.0 feed of the news of one language: the latest posts, full text, absolute links.""" +def rss(lang, st, site, all_posts): + """RSS 2.0 feed of the news (English only): the latest posts, full text, absolute links.""" base = site["base_url"] - posts = sorted((p for p in lang_pages if p["kind"] == "post"), key=lambda p: p["date"], reverse=True)[:NEWS_IN_FEED] + posts = all_posts[:NEWS_IN_FEED] def stamp(d): return format_datetime(datetime.strptime(d, "%Y-%m-%d").replace(tzinfo=timezone.utc)) @@ -271,17 +271,21 @@ def build(): manifesto_toc="\n".join(f'
  • {inline(h)}
  • ' for sl, h in toc), manifesto_body=body) + # News are written in English only; every language lists the same posts. + posts_en = sorted((p for p in pages["en"] if p["kind"] == "post"), key=lambda p: p["date"], reverse=True) + def news_lists(lang): - posts = sorted((p for p in pages[lang] if p["kind"] == "post"), key=lambda p: p["date"], reverse=True) + posts = posts_en + mark = "" if lang == "en" else ' hreflang="en" lang="en"' def li(p): - line = f'
  • {html.escape(p["title"], quote=False)}' + line = f'
  • {html.escape(p["title"], quote=False)}' if p.get("summary"): line += ": " + html.escape(p["summary"], quote=False) return line + "
  • " items = "\n".join(li(p) for p in posts) full = f"
      \n{items}\n
    " if posts else f"

    \n{strings[lang]['news_empty']}\n

    " - return full, items, posts[:NEWS_ON_HOME] + return full, items, posts[:NEWS_ON_HOME], mark news = {lang: news_lists(lang) for lang in LANGS} @@ -299,14 +303,14 @@ def build(): for k in NAV: ctx["cur_" + k] = ' aria-current="page"' if p["nav"] == k else "" ctx["alt_url"] = alt["path"] if alt else "" - ctx["alt_switch"] = p.get("switch") or (alt["path"] if alt else strings[other]["url_news"]) + ctx["alt_switch"] = p.get("switch") or (alt or by_id[("home", other)])["path"] ctx["alt_links"] = (f'\n' f'') if alt else "" - full, items, latest = news[lang] + full, items, latest, mark = news[lang] ctx["news_list"] = full ctx["latest_news"] = render(tpl["latest-news"], dict(ctx, news_items="\n".join( - f'
  • {html.escape(x["title"], quote=False)}
  • ' + f'
  • {html.escape(x["title"], quote=False)}
  • ' for x in latest)), "templates/latest-news.html") if latest else "" if p["kind"] == "post": @@ -320,13 +324,13 @@ def build(): ctx["lead"] = render(tpl["lead-" + lead], ctx, f"templates/lead-{lead}.html") ctx["badges"] = render(tpl["badges"], dict(ctx, doc_q=ctx["doc_url"].replace(":", "%3A").replace("/", "%2F")), "templates/badges.html") + ctx["feed"] = render(tpl["feed"], ctx, "templates/feed.html") ctx["header"] = render(tpl["header"], ctx, "templates/header.html") ctx["footer"] = render(tpl["footer"], ctx, "templates/footer.html") rel = p["path"].lstrip("/") write(rel + "index.html" if rel == "" or rel.endswith("/") else rel, render(tpl["base"], ctx, "templates/base.html")) - for lang in LANGS: - write(strings[lang]["url_news"].lstrip("/") + "feed.xml", rss(lang, strings[lang], site, pages[lang])) + write("news/feed.xml", rss("en", strings["en"], site, posts_en)) for dest, src in ASSETS.items(): target = os.path.join(OUT, dest) diff --git a/content/it/lang.toml b/content/it/lang.toml index 874831e..520bc42 100644 --- a/content/it/lang.toml +++ b/content/it/lang.toml @@ -6,7 +6,7 @@ home_link = "/it/" url_manifesto = "/it/manifesto.html" url_people = "/it/persone.html" url_services = "/it/servizi.html" -url_news = "/it/news/" +url_news = "/news/" nav_manifesto = "Manifesto" nav_people = "Persone" nav_services = "Servizi" @@ -16,6 +16,6 @@ nojs = "Questa pagina non usa JavaScript, cookie né tracker." back = "home" version = "Versione" toc = "Indice" -news_p = "Novità da kmalloc.org." +news_p = "Novità da kmalloc.org, scritte in inglese." news_all = "tutte le news" news_empty = "Ancora nessuna news." diff --git a/content/it/news.html b/content/it/news.html deleted file mode 100644 index 7b9be50..0000000 --- a/content/it/news.html +++ /dev/null @@ -1,18 +0,0 @@ ---- -id: news -path: /it/news/ -nav: news -title: kmalloc.org: News -description: Novità da kmalloc.org. ---- -

    News

    - -

    -Novità da kmalloc.org. -

    - -{{news_list}} - -

    -feed RSS -

    diff --git a/content/it/news/.gitkeep b/content/it/news/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/static/style.css b/static/style.css index e2a7363..a2b8320 100644 --- a/static/style.css +++ b/static/style.css @@ -106,6 +106,10 @@ code { height: auto; } +svg { + vertical-align: middle; +} + @media print { :root { --bg: #fff; @@ -115,7 +119,7 @@ code { --link: #000; } - header, .badges { + header, .badges, .feed { display: none; } diff --git a/templates/feed.html b/templates/feed.html new file mode 100644 index 0000000..12f04b3 --- /dev/null +++ b/templates/feed.html @@ -0,0 +1,3 @@ +

    + +

    diff --git a/templates/footer.html b/templates/footer.html index d859060..c772da0 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -3,5 +3,6 @@

    {{nojs}}

    +{{feed}} {{badges}}