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 06a41f14a6e382235203a841a980c0da8ba69071
parent 9f64f8bff37fca4737f6c3cd2f2708a7adfe041f
Author: hbkk <tschugg@posteo.de>
Date:   Mon,  1 Apr 2019 00:27:53 +0200

site for all tags

Diffstat:
Mlinks.sh | 86++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 59 insertions(+), 27 deletions(-)

diff --git a/links.sh b/links.sh @@ -4,6 +4,7 @@ tmp=$(mktemp) offline=false dateformat="+%a, %d %b %Y %H:%M:%S %z" builddate=$(date "$dateformat") +alltags="" print_html_head() { @@ -21,6 +22,7 @@ print_html_head() { margin-bottom: 4em; font-family: Tahoma, Verdana, Arial, sans-serif; font-size: 7pt; + text-align: justify; } h2 { @@ -47,9 +49,9 @@ print_html_head() { .footer { position: fixed; - left: 0; + margin: 0 auto; bottom: 0; - width: 100%; + width: 50em; background-color: white; padding: 0.4em; text-align: center; @@ -93,6 +95,10 @@ print_html_head() { text-decoration: none; } + .tags { + text-align: center; + } + .tag:hover { color: purple; } @@ -100,7 +106,7 @@ print_html_head() { </head> <body> <div class="header"> - <a href="file:///home/hbkk/tmp/site/index.html"> + <a href="./index.html"> <h1>planner</h1> </a> <p>#${1:-tutti}<p> @@ -111,15 +117,38 @@ EOF print_html_tail() { cat << EOF <div class="footer"> - <a class="read new" href="file:///home/hbkk/tmp/site/rss">rss</a> + <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> </html> EOF } +print_html_tag() { + cat << EOF + <a class="tag" href="./$1.html">#$1</a> +EOF +} + +print_html_link_head() { + cat << EOF + <div class="entry"> + <h2><a class="$class" href="$2">$1</a></h2> + <a class="link" href="$2">$2</a> +EOF +} + +print_html_link_tail() { + printf " </div>\n" +} + +print_html_link_tag() { + printf " <a class=\"tag\" href=\"%s\">%s</a>\n" "./$1.html" "$1" +} + print_rss_head() { cat << EOF <?xml version="1.0" encoding="UTF-8" ?> @@ -161,22 +190,6 @@ print_rss_link() { EOF } -print_link_head() { - cat << EOF - <div class="entry"> - <h2><a class="$class" href="$2">$1</a></h2> - <a class="link" href="$2">$2</a> -EOF -} - -print_link_tail() { - printf " </div>\n" -} - -print_link_tag() { - printf " <a class=\"tag\" href=\"%s\">%s</a>\n" "./$1.html" "$1" -} - # main mkdir -p ./site @@ -234,31 +247,50 @@ while read -r line; do class="new $class" } - print_link_head "$title" "$link" >> ./site/index.html + true > ./site/link.html + + print_html_link_head "$title" "$link" >> ./site/link.html for tag in $tags; do [[ $tag == read ]] && continue - print_link_tag "$tag" >> ./site/index.html + print_html_link_tag "$tag" >> ./site/link.html + print_html_tag "$tag" >> ./site/tags_build.html + done + + print_html_link_tail >> ./site/link.html - print_link_head "$title" "$link" >> ./site/"${tag}_build.html" - print_link_tag "$tag" >> ./site/"${tag}_build.html" - print_link_tail >> ./site/"${tag}_build.html" + for tag in $tags; do + cat ./site/link.html >> ./site/"${tag}_build.html" done - print_link_tail >> ./site/index.html + cat ./site/link.html >> ./site/index.html print_rss_link "$title" "$link" "$date" >> ./site/rss done < "${1:-./links.txt}" +rm ./site/link.html + print_html_tail >> ./site/index.html print_rss_tail >> ./site/rss +print_html_head "tags" > ./site/tags.html + +{ + printf " <div class=\"tags\">" + sort -u -r ./site/tags_build.html + printf " \</div\>" +} >> ./site/tags.html + +print_html_tail >> ./site/tags.html + +rm ./site/tags_build.html + mv "$tmp" ./db.csv for file in ./site/*; do [[ $file != *_build.html ]] && continue - tag="$(sed -e 's_\./site/__' -e 's/_build.html//' <<< "$file")" + 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"