From 0892937941d401b1cd4fe041a1fa5eda9287a677 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Tue, 9 Jun 2026 18:19:16 +0100 Subject: [PATCH] parameterises postprocess cmd in blog script --- http/Makefile | 4 ++-- http/bin/blog | 17 +++++++++++++---- http/bin/gmi2upphtml | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) mode change 100755 => 100644 http/bin/blog diff --git a/http/Makefile b/http/Makefile index eb8e440..3f20d3f 100644 --- a/http/Makefile +++ b/http/Makefile @@ -6,12 +6,12 @@ out: microlog blog $(shell find src -type f) $(shell find share -type f) $(shell microlog: src/microlog src/microlog: $(shell find -L blogs/microlog -type f) bin/blog - ./bin/blog -i microlog -l microlog -t + ./bin/blog -i microlog -l microlog -t -p gmi2upphtml blog: src/blog src/blog: $(shell find -L blogs/blog -type f) bin/blog - ./bin/blog -i blog -l blog + ./bin/blog -i blog -l blog -p gmi2upphtml .PHONY: clean clean: diff --git a/http/bin/blog b/http/bin/blog old mode 100755 new mode 100644 index a16a692..357b2bc --- a/http/bin/blog +++ b/http/bin/blog @@ -7,7 +7,7 @@ export LAYOUTS="$(realpath share/layouts)" usage() { >&2 cat << USAGE -usage: blog -i LOG [-l LAYOUT] [-t] +usage: blog -i LOG [-p POSTPROCESS_CMD] [-l LAYOUT] [-t] options: @@ -18,6 +18,10 @@ options: If provided, the layout under \$LAYOUTS to use for the generated upphtml files. If not provided, uses the default layout. + -p POSTPROCESS_CMD + If provided, a shell command to post-process the source files into + upphtml. The shell will be provided with a variable, POST_TITLE. + -t If enabled, use filenames as post titles USAGE @@ -25,9 +29,10 @@ USAGE log_name="" layout="default" +postprocess_cmd="echo" use_filenames_for_titles=0 -while getopts "i:l:t" opt +while getopts "i:l:p:t" opt do case $opt in i) @@ -36,6 +41,9 @@ do l) layout_name="$OPTARG" ;; + p) + postprocess_cmd="$OPTARG" + ;; t) use_filenames_for_titles=1 ;; @@ -78,10 +86,11 @@ do if [ $use_filenames_for_titles -eq 1 ] then title="$name" - cat "$entry" | gmi2upphtml "$title" > "$dest" + cat "$entry" | POST_TITLE="$title" eval "$postprocess_cmd" > "$dest" else title="$(grep --regexp "^\# " --max-count 1 "$entry" | cut -c3-)" - cat "$entry" | grep --regexp "^\# " --invert-match | gmi2upphtml "$title" > "$dest" + export POST_TITLE="$title" + cat "$entry" | grep --regexp "^\# " --invert-match | eval "$postprocess_cmd" > "$dest" fi echo "${title}" > "${dest}.args" echo "Processed ${entry#$(dirname ${BLOGS})/} to ${dest#$(dirname ${SRC})/}" diff --git a/http/bin/gmi2upphtml b/http/bin/gmi2upphtml index 608f4e8..f19f447 100755 --- a/http/bin/gmi2upphtml +++ b/http/bin/gmi2upphtml @@ -1,6 +1,6 @@ #!/bin/sh -e -post_title="${1:-}" +post_title="${POST_TITLE:-}" is_in_list=0 is_in_link_block=0