From 51e19b2266bb31b76cacdbfeafa58b28a3ef8b70 Mon Sep 17 00:00:00 2001 From: sl Date: Sat, 14 Jun 2025 23:46:57 +0000 Subject: [PATCH] bin/{corehandlers.rc, werc.rc, werclib.rc}: handle .gmi and .gem --- bin/werc.rc | 2 +- bin/werclib.rc | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/werc.rc b/bin/werc.rc index 0d006a3..101834e 100755 --- a/bin/werc.rc +++ b/bin/werc.rc @@ -12,7 +12,7 @@ difs=$ifs # Used to restore default ifs when needed # Expected input: ls -F style, $sitedir/path/to/files/ # dirfilter='s/\*$//; s,/+\./+,/,g; s,^\./,,; /\/[._][^\/]/d; /'$forbidden_uri_chars'/d; /\/sitemap\.xml$/d; /\/index\.(md|html|txt|tpl)$/d; /\/(robots|sitemap)\.txt$/d; /_werc\/?$/d; ' -dirclean=' s/\.(md|html|txt)$//; ' +dirclean=' s/\.(gmi|gem|md|html|txt)$//; ' # Careful, the proper p9p path might not be set until initrc.local is sourced path=(. /bin ./bin) diff --git a/bin/werclib.rc b/bin/werclib.rc index bcebf91..0e095fc 100755 --- a/bin/werclib.rc +++ b/bin/werclib.rc @@ -97,6 +97,10 @@ fn get_md_title { sed -n -e '1N; /^.*\n===*$/N; /.*\n===*\n *$/!b' -e 's/\n==*\n//p' < $1 } +fn get_gmi_title { + sed -e 's/^# //;q' < $1 +} + fn get_html_title { t=`{sed -n '32q; s/^.*<[Tt][Ii][Tt][Ll][Ee]> *([^<]+) *(<\/[Tt][Ii][Tt][Ll][Ee]>.*)?$/\1/p' < $1} @@ -110,6 +114,10 @@ fn get_html_title { fn get_file_title { if (~ $1 *.md) get_md_title $1 + if not if(~ $1 *.gmi) + get_gmi_title $1 + if not if(~ $1 *.gem) + get_gmi_title $1 if not if(~ $1 *.html) get_html_title $1 if not if(~ $1 */) {