diff -ru werc_orig/bin/corehandlers.rc werc/bin/corehandlers.rc --- werc_orig/bin/corehandlers.rc 2020-05-22 18:37:05.013460000 -0700 +++ werc/bin/corehandlers.rc 2021-03-12 20:40:25.921794000 -0800 @@ -7,7 +7,7 @@ # /./ to deal with p9p's ls failure to follow dir symlinks otherwise ls -F $sitedir/./$req_paths_list >[2]/dev/null \ | { - sed $dirfilter'/\/[^_.\/][^\/]*(\.(md|txt|html)|\/)$/!d; s!^'$sitedir'!!; '$dirclean + sed $dirfilter'/\/[^_.\/][^\/]*(\.(md|txt|html|gmi|gem)|\/)$/!d; s!^'$sitedir'!!; '$dirclean if(! ~ $#synth_paths 0) echo $synth_paths | tr ' ' $NEW_LINE } | sort -u | awk -F/ ' function p(x, y, s) { for(i=0; i < x-y; i+=1) print s } @@ -53,6 +53,12 @@ fn md_handler { $formatter $1 } +fn gmi_handler { awk '/^=>/ { print "["substr($0, index($0,$3))"]("$2")" }; # reformat links + /^[^=][^>]/ { print }; # print non-links as-is + /^[ ]*$/ { print }' $1 | $formatter +} + + fn tpl_handler { template $* } fn html_handler { @@ -100,6 +106,14 @@ if not if(test -f $local_path.html) { local_file=$local_path.html handler_body_main=(html_handler $local_file) + } + if not if(test -f $local_path.gem) { + local_file=$local_path.gem + handler_body_main=(gmi_handler $local_file) + } + if not if(test -f $local_path.gmi) { + local_file=$local_path.gmi + handler_body_main=(gmi_handler $local_file) } # Global tpl (eg sitemap.tpl), should take precedence over txt handler! if not if(test -f tpl^$req_path^.tpl) diff -ru werc_orig/bin/werc.rc werc/bin/werc.rc --- werc_orig/bin/werc.rc 2021-03-12 01:16:33.675404000 -0800 +++ werc/bin/werc.rc 2021-03-12 20:40:41.650833000 -0800 @@ -12,7 +12,7 @@ # 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 -ru werc_orig/bin/werclib.rc werc/bin/werclib.rc --- werc_orig/bin/werclib.rc 2021-03-12 01:16:33.677462000 -0800 +++ werc/bin/werclib.rc 2021-03-12 20:41:11.463979000 -0800 @@ -97,6 +97,10 @@ 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_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 */) {