pub / newsplanet

Planet-Style Newsfeed generated with perlanet
git clone https://src.jayvii.de/pub/newsplanet.git
Home | Log | Files | Exports | Refs | README | RSS

commit a0377272d86a517d2de68cd11b0358967afb5cc9
parent 1300101789f2e9f99bde2e63b769721e6c6e130c
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date:   Fri,  4 Oct 2024 11:21:42 +0200

feat: clean up HTML properly

Diffstat:
Mrun.sh | 18+++++++++++-------
Mtemplate.html | 18+++++++++++++++---
2 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/run.sh b/run.sh @@ -4,10 +4,13 @@ printf "Fetching feeds and generating html...\n" perlanet config.yaml -# Insert Update time -printf "Inserting update time...\n" -DATE=`date +%c` -sed -E -e "s/<!--UPDATED-->/$DATE/" -i index.html +# remove images and iframes from article previews +printf "Removing images and iframes...\n" +sed -E -e 's/<img[^>]*>//g' -e 's/<iframe[^>]*>//g' -i index.html + +# remove linebreaks and empty paragraphs +printf "Clean up HTML...\n" +sed -E -e 's/<br[^a-z]*[^>]*>//g' -e 's/<p[^a-z]*[^>]*><\/p>//g' -i index.html # Insert feeds list printf "Inserting feeds list...\n" @@ -18,6 +21,7 @@ FEEDS=` ` sed -E -e "s/<!--FEEDS-->/$FEEDS/" -i index.html -# remove images and iframes from article previews -printf "Removing images and iframes...\n" -sed -E -e 's/<img[^>]*>//g' -e 's/<iframe[^>]*>//g' -i index.html +# Insert Update time +printf "Inserting update time...\n" +DATE=`date +%c` +sed -E -e "s/<!--UPDATED-->/$DATE/" -i index.html diff --git a/template.html b/template.html @@ -9,6 +9,9 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>[% feed.title %] - [% feed.description %]</title> <meta name="description" content="[% feed.description %]"> + [% IF feed.author %] + <meta name="author" content="[% feed.author %]"> + [% END %] <link rel="icon" type="image/png" href="assets/favicon.png"> <link rel="icon" type="image/png" sizes="16x16" href="assets/favicon_16.png"> <link rel="icon" type="image/png" sizes="32x32" href="assets/favicon_32.png"> @@ -21,15 +24,23 @@ <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> /* Always scroll smoothly */ - * { scroll-behavior: smooth; } + * { + scroll-behavior: smooth; + } /* Hide linebreaks inside articles */ - section > br, section > p > br { display: none; } + section > br, + section > p > br + { + display: none; + } /* Mark headline anchors as external links */ h2 > a[href^="https"]::after { content: " \2197"; } /* Hide images and iframes in case they are not filtered out */ - img, iframe { + img, + iframe + { display: none; } </style> @@ -59,6 +70,7 @@ <main> <!-- This is updated by find-and-replace --> + <!-- WORKAROUND: [% feed.modified %] is hardcoded to UTC --> <p><!--UPDATED--></p> <!-- This is updated by find-and-replace-->