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 | |
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
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | index.md.do | 7 | ||||
-rw-r--r-- | lists/default.md.do | 20 |
3 files changed, 24 insertions, 4 deletions
@@ -9,4 +9,5 @@ nginx | |||
9 | *.html | 9 | *.html |
10 | index.md | 10 | index.md |
11 | lists/*.md | 11 | lists/*.md |
12 | lists/*/preview | ||
12 | tex/ \ No newline at end of file | 13 | 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 | |||
23 | ideas and results. As such, it is woefully unpolished, unreliably and generally | 23 | ideas and results. As such, it is woefully unpolished, unreliably and generally |
24 | to be used at your own risk. | 24 | to be used at your own risk. |
25 | 25 | ||
26 | Still, have fun! And please send me [email](mailto:vkleen+math@17220103.de) with | 26 | Still, have fun! And please send email with suggestions, corrections, |
27 | suggestions, corrections, criticism or general rants if you like. | 27 | criticism or general rants to <vkleen+math@17220103.de> if you like. |
28 | 28 | ||
29 | I have the following categories of posts: | 29 | I have the following categories of posts: |
30 | 30 | ||
@@ -32,4 +32,7 @@ EOF | |||
32 | 32 | ||
33 | for x in "${LISTS[@]}"; do | 33 | for 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" | ||
35 | done | 38 | 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=() | |||
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 |