summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViktor Kleen <viktor@kleen.org>2015-01-02 14:50:48 +0000
committerViktor Kleen <viktor@kleen.org>2015-01-02 14:50:48 +0000
commitf3f1f5e7a7cb23230d623b02773b75ea997ea241 (patch)
tree0404076b32274ead989f3e2abe731476299dedae
parent0495a66c4b7953e27cb8c7ab20f8b061fed6b379 (diff)
downloaddirty-haskell.org-f3f1f5e7a7cb23230d623b02773b75ea997ea241.tar
dirty-haskell.org-f3f1f5e7a7cb23230d623b02773b75ea997ea241.tar.gz
dirty-haskell.org-f3f1f5e7a7cb23230d623b02773b75ea997ea241.tar.bz2
dirty-haskell.org-f3f1f5e7a7cb23230d623b02773b75ea997ea241.tar.xz
dirty-haskell.org-f3f1f5e7a7cb23230d623b02773b75ea997ea241.zip
Implement previews of lists in the index
-rw-r--r--.gitignore1
-rw-r--r--index.md.do7
-rw-r--r--lists/default.md.do20
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
9*.html 9*.html
10index.md 10index.md
11lists/*.md 11lists/*.md
12lists/*/preview
12tex/ \ No newline at end of file 13tex/ \ 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
23ideas and results. As such, it is woefully unpolished, unreliably and generally 23ideas and results. As such, it is woefully unpolished, unreliably and generally
24to be used at your own risk. 24to be used at your own risk.
25 25
26Still, have fun! And please send me [email](mailto:vkleen+math@17220103.de) with 26Still, have fun! And please send email with suggestions, corrections,
27suggestions, corrections, criticism or general rants if you like. 27criticism or general rants to <vkleen+math@17220103.de> if you like.
28 28
29I have the following categories of posts: 29I have the following categories of posts:
30 30
@@ -32,4 +32,7 @@ EOF
32 32
33for x in "${LISTS[@]}"; do 33for x in "${LISTS[@]}"; do
34 printf "* [%s](%s)\n" "$(<$x/title)" "$x.html" 34 printf "* [%s](%s)\n" "$(<$x/title)" "$x.html"
35 while read -r -d $'\n'; do
36 printf " %s" "$REPLY"
37 done < "$x/preview"
35done 38done
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=()
5while read -r -d $'\0'; do 5while read -r -d $'\0'; do
6 post=$(realpath --relative-to=. "$REPLY") 6 post=$(realpath --relative-to=. "$REPLY")
7 POSTS+=("$post") 7 POSTS+=("$post")
8done < <(find "$2" -maxdepth 1 -mindepth 1 -not -name 'title' -print0 | sort -z) 8done < <(find "$2" -maxdepth 1 -mindepth 1 -not -name 'title' -not -name 'preview' -print0 | sort -z)
9 9
10for x in "${POSTS[@]}"; do 10for x in "${POSTS[@]}"; do
11 printf "%s\0%s\0" "$x" "${x%.md}.html" 11 printf "%s\0%s\0" "$x" "${x%.md}.html"
@@ -18,7 +18,23 @@ cat <<EOF
18 18
19EOF 19EOF
20 20
21POST_TITLES=()
21for x in "${POSTS[@]}"; do 22for x in "${POSTS[@]}"; do
22 title=$(pandoc -t json "$x" | ../build/extract-title.hs 2>&1 >/dev/null) 23 title=$(pandoc -t json "$x" | ../build/extract-title.hs 2>&1 >/dev/null)
23 printf "* [%s](%s)\n" "$title" "${x%.md}.html" 24 POST_TITLES+=("$title")
25done
26
27for n in $(seq 0 $((${#POSTS[@]}-1))); do
28 printf "* [%s](%s)\n" "${POST_TITLES[$n]}" "${POSTS[$n]%.md}.html"
29done
30
31prev_no=3
32if [[ ${#POSTS[@]} -gt $prev_no ]]; then
33 printf "* …\n" > "$2/preview"
34else
35 prev_no=${#POSTS[@]}
36fi
37
38for n in $(seq $prev_no -1 1); do
39 printf "* [%s](%s)\n" "${POST_TITLES[-$n]}" "${POSTS[-$n]%.md}.html" >"$2/preview"
24done 40done