diff options
author | Viktor Kleen <viktor@kleen.org> | 2015-01-02 14:50:48 +0000 |
---|---|---|
committer | Viktor Kleen <viktor@kleen.org> | 2015-01-02 14:50:48 +0000 |
commit | f3f1f5e7a7cb23230d623b02773b75ea997ea241 (patch) | |
tree | 0404076b32274ead989f3e2abe731476299dedae /lists | |
parent | 0495a66c4b7953e27cb8c7ab20f8b061fed6b379 (diff) | |
download | dirty-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.do | 20 |
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=() | |||
5 | while read -r -d $'\0'; do | 5 | while read -r -d $'\0'; do |
6 | post=$(realpath --relative-to=. "$REPLY") | 6 | post=$(realpath --relative-to=. "$REPLY") |
7 | POSTS+=("$post") | 7 | POSTS+=("$post") |
8 | done < <(find "$2" -maxdepth 1 -mindepth 1 -not -name 'title' -print0 | sort -z) | 8 | done < <(find "$2" -maxdepth 1 -mindepth 1 -not -name 'title' -not -name 'preview' -print0 | sort -z) |
9 | 9 | ||
10 | for x in "${POSTS[@]}"; do | 10 | for 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 | ||
19 | EOF | 19 | EOF |
20 | 20 | ||
21 | POST_TITLES=() | ||
21 | for x in "${POSTS[@]}"; do | 22 | for 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") |
25 | done | ||
26 | |||
27 | for n in $(seq 0 $((${#POSTS[@]}-1))); do | ||
28 | printf "* [%s](%s)\n" "${POST_TITLES[$n]}" "${POSTS[$n]%.md}.html" | ||
29 | done | ||
30 | |||
31 | prev_no=3 | ||
32 | if [[ ${#POSTS[@]} -gt $prev_no ]]; then | ||
33 | printf "* …\n" > "$2/preview" | ||
34 | else | ||
35 | prev_no=${#POSTS[@]} | ||
36 | fi | ||
37 | |||
38 | for n in $(seq $prev_no -1 1); do | ||
39 | printf "* [%s](%s)\n" "${POST_TITLES[-$n]}" "${POSTS[-$n]%.md}.html" >"$2/preview" | ||
24 | done | 40 | done |