summaryrefslogtreecommitdiff
path: root/lists
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 /lists
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
Diffstat (limited to 'lists')
-rw-r--r--lists/default.md.do20
1 files changed, 18 insertions, 2 deletions
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