diff options
| author | Joe Carstairs <me@joeac.net> | 2026-06-09 21:29:10 +0100 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2026-06-09 21:29:10 +0100 |
| commit | ce1ebb3ad3f705a1a8e3764e6c18f1af12eed795 (patch) | |
| tree | 3164a91894fc279a41fe368ead15d686ce358baf /http/bin | |
| parent | 0065d36bc8dab85e639fa35945ef289f68182975 (diff) | |
extracts longlog metadata including updated date
Diffstat (limited to 'http/bin')
| -rwxr-xr-x | http/bin/blog | 5 | ||||
| -rwxr-xr-x | http/bin/extract_longlog_meta | 34 |
2 files changed, 38 insertions, 1 deletions
diff --git a/http/bin/blog b/http/bin/blog index 49bef7f..7038e4a 100755 --- a/http/bin/blog +++ b/http/bin/blog @@ -37,9 +37,12 @@ layout="default" postprocess_cmd="echo" use_filenames_for_titles=0 -while getopts "i:l:p:t" opt +while getopts "a:i:l:p:t" opt do case $opt in + a) + extract_args_cmd="$OPTARG" + ;; i) log_name="$OPTARG" ;; diff --git a/http/bin/extract_longlog_meta b/http/bin/extract_longlog_meta new file mode 100755 index 0000000..054c994 --- /dev/null +++ b/http/bin/extract_longlog_meta @@ -0,0 +1,34 @@ +#!/bin/sh -e + +POST_TITLE="${POST_TITLE:-}" +DATE_PUBLISHED="" +DATE_UPDATED="" + +while read line +do + if [ "$(echo "$line" | cut -c1-2)" = "# " ] + then + POST_TITLE="$(echo "$line" | cut -c3-)" + elif [ "$(echo "$line" | cut -c1-14)" = "Published on: " ] + then + DATE_PUBLISHED="$(date --date="$(echo "$line" | cut -c15-)" +%Y-%m-%d)" + elif [ "$(echo "$line" | cut -c1-12)" = "Updated on: " ] + then + DATE_UPDATED="$(date --date="$(echo "$line" | cut -c13-)" +%Y-%m-%d)" + fi +done + +if [ -n "$POST_TITLE" ] +then + echo "POST_TITLE=\"${POST_TITLE}\"" +fi + +if [ -n "$DATE_PUBLISHED" ] +then + echo "DATE_PUBLISHED=\"${DATE_PUBLISHED}\"" +fi + +if [ -n "$DATE_UPDATED" ] +then + echo "DATE_UPDATED=\"${DATE_UPDATED}\"" +fi |
