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 0e92f1aacef7f866900076f75dd624b1b8ac527b
parent 162ed54b63ca1fecb51052625fd434fdf0ea6ad8
Author: hbkk <tschugg@posteo.de>
Date:   Sun, 31 Mar 2019 00:40:36 +0100

add a date field, highlight new links

Diffstat:
Mlinks.sh | 34+++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/links.sh b/links.sh @@ -12,6 +12,8 @@ offline=false mkdir -p ./site +touch ./db.csv + cat <<EOF > ./site/index.html <!DOCTYPE html> <html lang="en"> @@ -23,7 +25,7 @@ cat <<EOF > ./site/index.html width: 60em; margin: 0 auto; font-size: 7pt; - color: purple; + color: black; } h2 { @@ -44,7 +46,7 @@ cat <<EOF > ./site/index.html } a.read { - color: purple; + color: black; } a.read:hover { @@ -55,6 +57,10 @@ cat <<EOF > ./site/index.html color: blue; } + a.new { + background: yellow; + } + a.unread:hover { text-decoration: underline; } @@ -82,13 +88,14 @@ cat <<EOF > ./site/index.html EOF while read -r line; do - link=$(cut -d, -f1 <<< "$line") - tags=$(cut -s -d, -f2 <<< "$line") - title=$(cut -s -d, -f3- <<< "$line") + date=$(cut -d, -f1 <<< "$line") + link=$(cut -d, -f2 <<< "$line") + tags=$(cut -s -d, -f3 <<< "$line") + title=$(cut -s -d, -f4- <<< "$line") class="read" if [[ -z $title ]]; then - title=$(grep "^${link}," ./db.txt | cut -d, -f3-) + title=$(grep "${link}," ./db.csv | cut -d, -f4-) [[ -z $title && $offline == false ]] && { printf "getting title for %s...\n" "$link" >&2 @@ -107,16 +114,21 @@ while read -r line; do printf "\t%s\n" "$title" >&2 } - printf "%s,%s,%s\n" "$link" "$tags" "$title" >> "$tmp" + printf "%s,%s,%s,%s\n" "$date" "$link" "$tags" "$title" >> "$tmp" else printf "%s\n" "$line" >> "$tmp" fi - grep "^${link}," ./db.txt | cut -d, -f2 | grep -q "read" && { + grep -q "read" <<< "$tags" && { title="⛟ $title" class="unread" } + grep -q "$link" ./db.csv || { + echo "$title" + class="new $class" + } + cat << EOF >> ./site/index.html <div class="entry"> <h2><a class="$class" href="$link">$title</a></h2> @@ -130,7 +142,11 @@ EOF "./$tag.html" "$tag" >> ./site/index.html done + printf " <a class=\"tag\" href=\"%s\">%s</a>\n" \ + "./$date.html" "$date" >> ./site/index.html + printf " </div>\n" >> ./site/index.html + done < "${1:-./links.txt}" cat << EOF >> ./site/index.html @@ -138,4 +154,4 @@ cat << EOF >> ./site/index.html </html> EOF -mv "$tmp" ./db.txt +mv "$tmp" ./db.csv