diff options
Diffstat (limited to '')
-rwxr-xr-x | v2/src/bin/html | 16 | ||||
-rwxr-xr-x | v2/src/bin/makemake | 14 | ||||
-rwxr-xr-x | v2/src/bin/series | 102 |
3 files changed, 130 insertions, 2 deletions
diff --git a/v2/src/bin/html b/v2/src/bin/html index 578c539..a54ab68 100755 --- a/v2/src/bin/html +++ b/v2/src/bin/html @@ -213,6 +213,22 @@ emit_body() { warn_duplicate_ids } +if [ -r "$FILENAME".prev ]; then + collection_head_prev_html="$( + printf ' <link rel="prev" type="text/html" href="%s" />' \ + "$(url-for < "$FILENAME".prev)" + )" + export collection_head_prev_html +fi + +if [ -r "$FILENAME".next ]; then + collection_head_next_html="$( + printf ' <link rel="next" type="text/html" href="%s" />' \ + "$(url-for < "$FILENAME".next)" + )" + export collection_head_next_html +fi + envsubst < src/lib/preamble.html emit_body | tee "${FILENAME%.*}.htmlbody" envsubst < src/lib/postamble.html diff --git a/v2/src/bin/makemake b/v2/src/bin/makemake index 3f4679d..22e92c9 100755 --- a/v2/src/bin/makemake +++ b/v2/src/bin/makemake @@ -136,6 +136,10 @@ for lang in $(langs); do echo "$CONTENT_PREFIX/$lang/${coll_path}index.extrahtml: $CONTENT_PREFIX/$lang/${coll_path}index.html" echo "$CONTENT_PREFIX/$lang/${coll_path}index.extrafeeds: $CONTENT_PREFIX/$lang/${coll_path}feed.xml" + + echo "$CONTENT_PREFIX/$lang/${coll_path}index.series: \$($c.$lang.conf)" + echo "\$($c.$lang.html): $CONTENT_PREFIX/$lang/${coll_path}index.series" + printf '\n\n' done @@ -152,6 +156,11 @@ for lang in $(langs); do collections | xargs -I% coll2path "$lang" % | + sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1index.series|" | + varlist "all-generated.$lang.series" + + collections | + xargs -I% coll2path "$lang" % | sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1index.categories|" | varlist "all-generated.$lang.categories" @@ -175,10 +184,11 @@ for lang in $(langs); do sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1feed.xml|" | varlist "all-generated.$lang.xml" - extensions '.categories' '.extrahtml' '.extrafeeds' '.index' '.xml' | + extensions '.series' '.categories' '.extrahtml' '.extrafeeds' '.index' '.xml' | sed "s|^\(.*\)\$|\$(all-generated.$lang\1)|" | varlist "all-generated.$lang" + printf '\n' done @@ -201,7 +211,7 @@ printf 'svgs = $(svgs.uncolored:.uncolored=)\n\n' } > "$CONTENT_PREFIX"/.gitignore -for e in $(extensions '.categories' '.extrahtml' '.extrafeeds' '.index' '.xml'); do +for e in $(extensions '.series' '.categories' '.extrahtml' '.extrafeeds' '.index' '.xml'); do langs | sed "s|^\(.*\)\$|\$(all-generated.\1$e)|" | varlist "all-generated$e" diff --git a/v2/src/bin/series b/v2/src/bin/series new file mode 100755 index 0000000..6712368 --- /dev/null +++ b/v2/src/bin/series @@ -0,0 +1,102 @@ +#!/bin/sh +set -eu + +usage() { + cat <<-'EOF' + Usage: + series FILENAME + series -h + EOF +} + +help() { + cat <<-'EOF' + Options: + -h, --help show this message + + FILENAME the sentinel file to be touched + + + Enumerate and sort all items of a collection type, and notify + them about their '<link rel="next" ... />' and '<link rel="prev" .../>. + The collection type and language are inferred by FILENAME. + + The "notifying" part is done via a "$TARGET.next" file, that + is, a ".next" file is created to notify "$TARGET" about which + item is next to it via the content of the file. The same + applies for ".prev" files. + + + Examples: + + Generate the ".next" and ".prev" files for english pastebins: + + $ index src/en/pastebin/index.series + EOF +} + + +for flag in "$@"; do + case "$flag" in + --) + break + ;; + --help) + usage + help + exit + ;; + *) + ;; + esac +done + +while getopts 'h' flag; do + case "$flag" in + h) + usage + help + exit + ;; + *) + usage >&2 + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) + + +. src/lib.sh + +FILENAME="${1:-}" +eval "$(assert_arg "$FILENAME" 'FILENAME')" +DIR="$(dirname "$FILENAME")" + + +find "$DIR"/*.sortdata 2>/dev/null | + sort -n | + xargs cat | + awk ' + BEGIN { split("", items) } + { items[NR] = $0 } + END { + first = 1 + last = length(items) + for (i in items) { + item = items[i] + if (i != first) { + file = item ".prev" + prev = items[i-1] + print prev > file + } + if (i != last) { + file = item ".next" + nextt = items[i+1] + print nextt > file + } + } + } + ' + +touch "$FILENAME" |