fusch.online

git / lists / casts

git.fusch.online/planner

Generate static pages from a list of links
git clone git://git.fusch.online/planner
Log / Files / Readme / Issues

commit 1743efe822defb0dfc133ee44bef7ebda18a8c3a
parent 174c9f4240a01e280d483308bfcb8f80e7f0bbcf
Author: hbkk <tschugg@posteo.de>
Date:   Mon,  1 Apr 2019 23:35:59 +0200

set proper pubdate, change output dir to planner_html

Diffstat:
Mplanner | 117+++++++++++++++++++++++++++++++++++++++-----------------------------------------
1 file changed, 57 insertions(+), 60 deletions(-)

diff --git a/planner b/planner @@ -2,10 +2,10 @@ # SPDX-License-Identifier: MIT tmp=$(mktemp) +site=planner_html offline=false dateformat="+%a, %d %b %Y %H:%M:%S %z" builddate=$(date "$dateformat") -alltags="" print_html_head() { @@ -14,29 +14,30 @@ print_html_head() { <html lang="en"> <head> <meta charset="utf-8"> - <title>planner#$1</title> + <title>planner#${1:-tutti}</title> <style> body { width: 50em; margin: 0 auto; - margin-top: 6em; + line-height: 1em; + margin-top: 8em; margin-bottom: 4em; font-family: Tahoma, Verdana, Arial, sans-serif; - font-size: 7pt; text-align: justify; } + h1 { + font-size: larger; + color: black; + } + h2 { font-size: small; } .entry { - line-height: 1em; padding: 0.4em; margin-bottom: 1em; - border-bottom-style: dotted; - border-width: 1px; - border-color: black; } .header { @@ -52,6 +53,7 @@ print_html_head() { position: fixed; margin: 0 auto; bottom: 0; + line-height: 1.6em; width: 50em; background-color: white; padding: 0.4em; @@ -107,7 +109,12 @@ print_html_head() { </head> <body> <div class="header"> - <a href="./index.html"> + <a class="read new" href="https://git.fusch.online">git</a> + <a class="read new" href="https://planner.fusch.online">planner</a> + <a href="https://fusch.online"> + <h1>fusch.online</h1> + </a> + <a href="./"> <h1>planner</h1> </a> <p>#${1:-tutti}<p> @@ -119,8 +126,6 @@ print_html_tail() { cat << EOF <div class="footer"> <a class="read new" href="./rss">rss</a> - <a class="read new" href="https://tutti.town">tutti.town</a> - <a class="read new" href="https://kuku.tutti.town">kuku</a> <a class="read new" href="./tags.html">tags</a> </div> </body> @@ -128,12 +133,6 @@ print_html_tail() { EOF } -print_html_tag() { - cat << EOF - <a class="tag" href="./$1.html">#$1</a> -EOF -} - print_html_link_head() { cat << EOF <div class="entry"> @@ -177,8 +176,6 @@ EOF print_rss_link() { - pubdate=$(date --date="$3" "$dateformat") - cat << EOF <item> <title>$1</title> @@ -186,36 +183,38 @@ print_rss_link() { <link>$2</link> <guid>$2</guid> <dc:creator>tutti</dc:creator> - <pubDate>$pubdate</pubDate> + <pubDate>$3</pubDate> </item> EOF } # main -mkdir -p ./site -touch ./db.csv -rm ./site/*.html ./site/rss +mkdir -p $site +touch ./db.tsv +rm $site/*.html $site/rss [[ $1 == -n ]] && { offline=true shift } -print_html_head "" > ./site/index.html -print_rss_head > ./site/rss +print_html_head "" > $site/index.html +print_rss_head > $site/rss while read -r line; do - date=$(cut -d, -f1 <<< "$line") - link=$(cut -d, -f2 <<< "$line") - tags=$(cut -s -d, -f3 <<< "$line") - title=$(cut -s -d, -f4- <<< "$line") + link=$(cut -f2 <<< "$line") + tags=$(cut -s -f3 <<< "$line") + title=$(cut -s -f4- <<< "$line") class="read" - if [[ -z $title || $title == "~" ]]; then - [[ -z $title ]] && title=$(grep "${link}," ./db.csv | cut -d, -f4-) + date=$(grep "$link" ./db.tsv | cut -f1) + [[ -z $date ]] && date=$builddate - [[ -z $title && $offline == false || $title == "~" ]] && { + if [[ -z $title ]]; then + title=$(grep "$link" ./db.tsv | cut -f4-) + + [[ -z $title && $offline == false ]] && { printf "getting title for %s...\n" "$link" >&2 title=$(curl -L -s "$link" \ @@ -231,69 +230,67 @@ while read -r line; do title="⛷ $title" printf "\t%s\n" "$title" >&2 } - - printf "%s,%s,%s,%s\n" "$date" "$link" "$tags" "$title" >> "$tmp" - else - printf "%s\n" "$line" >> "$tmp" fi + printf "%s\t%s\t%s\t%s\n" "$date" "$link" "$tags" "$title" >> "$tmp" + grep -q "read" <<< "$tags" && { title="⛟ $title" class="unread" } - grep -q "$link" ./db.csv || { + grep -q "$link" ./db.tsv || { echo "$title" class="new $class" } - true > ./site/link.html + true > $site/link.html - print_html_link_head "$title" "$link" >> ./site/link.html + print_html_link_head "$title" "$link" >> $site/link.html for tag in $tags; do [[ $tag == read ]] && continue - print_html_link_tag "$tag" >> ./site/link.html - print_html_tag "$tag" >> ./site/tags_build.html + print_html_link_tag "$tag" >> $site/link.html + print_html_link_tag "$tag" >> $site/tags_build.html done - print_html_link_tail >> ./site/link.html + print_html_link_tail >> $site/link.html for tag in $tags; do - cat ./site/link.html >> ./site/"${tag}_build.html" + cat $site/link.html >> $site/"${tag}_build.html" done - cat ./site/link.html >> ./site/index.html + cat $site/link.html >> $site/index.html - print_rss_link "$title" "$link" "$date" >> ./site/rss + print_rss_link "$title" "$link" "$date" >> $site/rss done < "${1:-/dev/stdin}" -rm ./site/link.html +rm $site/link.html -print_html_tail >> ./site/index.html -print_rss_tail >> ./site/rss +print_html_tail >> $site/index.html +print_rss_tail >> $site/rss -print_html_head "tags" > ./site/tags.html +print_html_head "tags" > $site/tags.html { printf " <div class=\"tags\">" - sort -u -r ./site/tags_build.html + sort -u -r $site/tags_build.html printf " </div>" -} >> ./site/tags.html +} >> $site/tags.html -print_html_tail >> ./site/tags.html +print_html_tail >> $site/tags.html -rm ./site/tags_build.html +rm $site/tags_build.html -mv "$tmp" ./db.csv +mv "$tmp" ./db.tsv -for file in ./site/*; do +for file in $site/*; do [[ $file != *_build.html ]] && continue - tag=$(sed -e 's_\./site/__' -e 's/_build.html//' <<< "$file") - print_html_head "$tag" > ./site/"$tag.html" - cat "$file" >> ./site/"$tag.html" - print_html_tail >> ./site/"$tag.html" + tag=$(sed -e "s/$site\///" -e 's/_build.html//' <<< "$file") + print_html_head "$tag" > $site/"$tag.html" + cat "$file" >> $site/"$tag.html" + print_html_tail >> $site/"$tag.html" done -rm ./site/*_build.html +rm $site/*_build.html