From f3f1f5e7a7cb23230d623b02773b75ea997ea241 Mon Sep 17 00:00:00 2001 From: Viktor Kleen Date: Fri, 2 Jan 2015 14:50:48 +0000 Subject: Implement previews of lists in the index --- .gitignore | 1 + index.md.do | 7 +++++-- lists/default.md.do | 20 ++++++++++++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 210a8d7..22ca4e4 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ nginx *.html index.md lists/*.md +lists/*/preview tex/ \ No newline at end of file diff --git a/index.md.do b/index.md.do index 3b6eddd..d7c76d2 100644 --- a/index.md.do +++ b/index.md.do @@ -23,8 +23,8 @@ This site is supposed to serve as a research notebook to get me to write up ideas and results. As such, it is woefully unpolished, unreliably and generally to be used at your own risk. -Still, have fun! And please send me [email](mailto:vkleen+math@17220103.de) with -suggestions, corrections, criticism or general rants if you like. +Still, have fun! And please send email with suggestions, corrections, +criticism or general rants to if you like. I have the following categories of posts: @@ -32,4 +32,7 @@ EOF for x in "${LISTS[@]}"; do printf "* [%s](%s)\n" "$(<$x/title)" "$x.html" + while read -r -d $'\n'; do + printf " %s" "$REPLY" + done < "$x/preview" done diff --git a/lists/default.md.do b/lists/default.md.do index 94636df..daf7453 100644 --- a/lists/default.md.do +++ b/lists/default.md.do @@ -5,7 +5,7 @@ POSTS=() while read -r -d $'\0'; do post=$(realpath --relative-to=. "$REPLY") POSTS+=("$post") -done < <(find "$2" -maxdepth 1 -mindepth 1 -not -name 'title' -print0 | sort -z) +done < <(find "$2" -maxdepth 1 -mindepth 1 -not -name 'title' -not -name 'preview' -print0 | sort -z) for x in "${POSTS[@]}"; do printf "%s\0%s\0" "$x" "${x%.md}.html" @@ -18,7 +18,23 @@ cat <&1 >/dev/null) - printf "* [%s](%s)\n" "$title" "${x%.md}.html" + POST_TITLES+=("$title") +done + +for n in $(seq 0 $((${#POSTS[@]}-1))); do + printf "* [%s](%s)\n" "${POST_TITLES[$n]}" "${POSTS[$n]%.md}.html" +done + +prev_no=3 +if [[ ${#POSTS[@]} -gt $prev_no ]]; then + printf "* …\n" > "$2/preview" +else + prev_no=${#POSTS[@]} +fi + +for n in $(seq $prev_no -1 1); do + printf "* [%s](%s)\n" "${POST_TITLES[-$n]}" "${POSTS[-$n]%.md}.html" >"$2/preview" done -- cgit v1.2.3