pub / zeitung

News-Aggregator in newspaper style as HTML/PDF/EPUB
git clone src.jayvii.de/pub/zeitung.git
Home | Log | Files | Exports | Refs | README | RSS

commit fe7d70b6f7c269a2fd801a2f34dc99e738f810b9
parent 49b9de2ef19a0c61491f631d50daf97fc82857a9
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date:   Sat, 25 Apr 2026 13:17:50 +0200

feat: enumeration for articles; remove unnecessary lines in source file

Diffstat:
Mgenerate.sh | 39+++++++++++++++++++++++++++++----------
Mtemplates/index.tt | 17+++++++----------
2 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/generate.sh b/generate.sh @@ -1,13 +1,13 @@ #!/usr/bin/env bash # run perlanet on the config file to fetch all feeds and populate the markdown - -echo "[1/8] Gather RSS sources..." +echo "[1/10] Gather RSS sources..." mkdir -p ./output/ perlanet "./perlanetrc.yaml" # remove all articles before yesterday ----------------------------------------- -echo "[2/8] Remove old articles..." +echo "[2/10] Remove old articles..." ## remove start/stop markers from all recent articles sed -E \ @@ -20,7 +20,7 @@ perl -pe 'BEGIN{undef $/;} s/<\!--START.*?<\!--STOP.*?-->//smg' \ -i ./output/zeitung.md # ensure the file only includes characters the compile can understand ---------- -echo "[3/8] Simplify character encoding..." +echo "[3/10] Simplify character encoding..." sed -E \ -e 's/รก/\[`a\]/g' \ @@ -86,7 +86,7 @@ sed -E \ -i ./output/zeitung.md # clean up HTML ---------------------------------------------------------------- -echo "[4/8] Clean up full text articles..." +echo "[4/10] Clean up full text articles..." ## remove linebreaks at the start of headline tags perl -pe 's/(<h[1-6][^>]*>)(.*)\n+/$1$2/g' -i ./output/zeitung.md @@ -135,19 +135,19 @@ sed -E -e 's/^([A-Z])\s([a-z])/\1\2/g' -i ./output/zeitung.md sed -E -e 's/\*/\\*/g' -e 's/\+/\\+/g' -i ./output/zeitung.md # generate internal linking by creating SHA1 hashes ---------------------------- -echo "[5/8] Generate article IDs..." +echo "[5/10] Generate article IDs..." perl -MDigest::SHA=sha1_hex \ -pe 's/HASH:(.+?):HASH/sha1_hex$1/ge' \ -i ./output/zeitung.md # generate domains from URLs --------------------------------------------------- -echo "[6/8] Generate custom fields..." +echo "[6/10] Generate custom fields..." sed -E -e 's/DOMAIN:http(s)*:\/\/([^\/]+).*?:DOMAIN/\2/g' -i ./output/zeitung.md # remove double entries -------------------------------------------------------- -echo "[7/8] Remove double entries..." +echo "[7/10] Remove double entries..." grep "{#" ./output/zeitung.md | \ sed -E -e 's/(\-|\;|\\|\/|\ |\!|\"|\#|\$|\&|\(|\)|\||\*|\,|\<|\>|\[|\]|\^|\`|\{|\.)/\\\1/g' | \ @@ -155,13 +155,31 @@ while read -r line; do perl -pe "BEGIN{undef $/;} s/$line.*?$line/$line/smg" -i ./output/zeitung.md done +# count entries ---------------------------------------------------------------- +echo "[8/9] Insert counters..." + +# Insert absolute counts +count=$(grep -c "\[NUMBER\]" ./output/zeitung.md) +sed -e "s/\[COUNT\]/${count}/g" -i ./output/zeitung.md + +# add running numbers into template +for number in $(seq 1 1 $count); do + sed -e "0,/\[NUMBER\]/{s//${number}/}" -i ./output/zeitung.md +done + +# final cleanup ---------------------------------------------------------------- +echo "[9/10] Cleaning up source file..." + +# remove double empty lines +cat -s ./output/zeitung.md | tee ./output/zeitung.md > /dev/null + # generate output (html, pdf, epub) -------------------------------------------- -echo "[8/8] Generate Output..." +echo "[10/10] Generate Output..." echo " -> HTML" pandoc ./output/zeitung.md -t html -f markdown -o ./output/zeitung.html \ --css=./templates/style.css --include-in-header=./templates/scale_fonts.html \ - --self-contained --toc --toc-depth=1 + --embed-resources --standalone --toc --toc-depth=1 echo " -> PDF (DIN A4)" pandoc ./output/zeitung.md -t pdf -f markdown -o ./output/zeitung.pdf \ @@ -172,7 +190,8 @@ pandoc ./output/zeitung.md -t pdf -f markdown -o ./output/zeitung_mobile.pdf \ --pdf-engine=xelatex --template eisvogel -V papersize=a5 echo " -> EPUB" -pandoc ./output/zeitung.md -t epub -f markdown -o ./output/zeitung.epub +pandoc ./output/zeitung.md -t epub -f markdown -o ./output/zeitung.epub \ + --css=./templates/style_epub.css --embed-resources --standalone # done echo "Done. Have fun reading." diff --git a/templates/index.tt b/templates/index.tt @@ -1,5 +1,6 @@ --- title: "Zeitung" +subtitle: "There are [COUNT] articles today." date: "[% feed.modified %]" titlepage: true titlepage-text-color: "FFFFFF" @@ -23,17 +24,13 @@ header-includes: [% FOREACH entry IN feed.entries %] <!--START:[% entry.issued | html %]--> -#### [% entry.title | html %] {#overview-HASH:[% entry.link | url | html %]:HASH} +#### ([NUMBER]/[COUNT]) [% entry.title | html %] {#overview-HASH:[% entry.link | url | html %]:HASH} - [% entry.issued | html %][% IF entry.author %] by [% entry.author | html %][% END %] via DOMAIN:[% entry.link | url | html %]:DOMAIN -[% IF entry.summary.body %] -[% entry.summary.body %] -[% ELSE %] -[% entry.content.body %] -[% END %] +[% IF entry.summary.body %] [% entry.summary.body %] [% ELSE %] [% entry.content.body %] [% END %] -_[Read article](#HASH:[% entry.link | url | html %]:HASH)_ +_[[Read article](#HASH:[% entry.link | url | html %]:HASH)]_ <!--STOP:[% entry.issued | html %]--> [% END %] @@ -50,8 +47,8 @@ _[Read article](#HASH:[% entry.link | url | html %]:HASH)_ ## [% entry.title | html %] {#HASH:[% entry.link | url | html %]:HASH} - [% entry.issued | html %][% IF entry.author %] by [% entry.author | html %][% END %] -- _[Read article on DOMAIN:[% entry.link | url | html %]:DOMAIN]([% entry.link | url | html %])_ -- _[Back to the overview](#overview-HASH:[% entry.link | url | html %]:HASH)_ +- _[[Read article on DOMAIN:[% entry.link | url | html %]:DOMAIN]([% entry.link | url | html %])]_ +- _[[Back to the overview](#overview-HASH:[% entry.link | url | html %]:HASH)]_ [% IF entry.content.body %] [% entry.content.body %] @@ -59,7 +56,7 @@ _[Read article](#HASH:[% entry.link | url | html %]:HASH)_ The content of the article could not be found. [% END %] -_[Back to the overview](#overview-HASH:[% entry.link | url | html %]:HASH)_ +_[[Back to the overview](#overview-HASH:[% entry.link | url | html %]:HASH)]_ --- <!--STOP:[% entry.issued | html %]-->