From 82f4b0418bd6ecbd56253274cd4bbbfcb577a1fe Mon Sep 17 00:00:00 2001 From: Michael Reed Date: Wed, 12 Jul 2017 19:38:28 -0400 Subject: www/index.sh: Make meta() and title() take arguments It makes the code easier to understand than the global variables that were used before. --- www/index.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'www') diff --git a/www/index.sh b/www/index.sh index 45b9f575..5cd15818 100755 --- a/www/index.sh +++ b/www/index.sh @@ -19,17 +19,20 @@ BLOGTITLE="Libreboot News" BLOGBASE="https://libreboot.org/" BLOGDESCRIPTION="News on Libreboot development" +# usage: title file title() { - sed -n 1p $f | sed -e s-^..-- + sed -n 1p "$1" | sed -e s-^..-- } +# usage: meta file meta() { - URL=$(printf '%s\n' ${f%.md}.html | sed -e s-news/--) + file=$1 + URL=$(printf '%s\n' "${file%.md}.html" | sed -e s-news/--) - printf '%s\n' "[$(title)]($URL){.title}" - printf '%s\n' "[$(sed -n 3p $f | sed -e s-^..--)]{.date}" + printf '%s\n' "[$(title "$file")]($URL){.title}" + printf '%s\n' "[$(sed -n 3p "$file" | sed -e s-^..--)]{.date}" printf '\n' - tail -n +5 $f | perl -p0e 's/(\.|\?|\!)( |\n)(.|\n)*/.../g' + tail -n +5 "$file" | perl -p0e 's/(\.|\?|\!)( |\n)(.|\n)*/.../g' printf '\n' printf '\n' @@ -44,7 +47,7 @@ cat news-list.md > news/index.md for f in $FILES do - meta >> news/index.md + meta "$f" >> news/index.md done # generate an RSS index @@ -64,7 +67,7 @@ rss() { url="${f%.md}.html" printf '%s\n' '' - printf '%s\n' "$(title)" + printf '%s\n' "$(title "$f")" printf '%s\n' "$BLOGBASE$url" printf '%s\n' "$desc" printf '%s\n' '' -- cgit v1.2.3-70-g09d2