From 71b4064c2ab055734dad3eb795f1e076603d58a1 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Fri, 6 Dec 2024 13:17:32 +0000 Subject: Fix comment.sh by testing on tilde.club --- bin/mail/comment.sh | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/bin/mail/comment.sh b/bin/mail/comment.sh index 6c95dc3..be86070 100755 --- a/bin/mail/comment.sh +++ b/bin/mail/comment.sh @@ -3,21 +3,29 @@ # Save incoming mail as comment # Usage: # Step1. Add script into forward(5) for MDA -# echo '| --output_dir=' >>~/.forward +# Some MDA won't accept arguments for command. If --output_dir is not specified, +# directory of this script would be used instead +# +# echo '| --output_dir ' >>~/.forward # # Step2. Insert related html file into target page, the following example use element -# Please replace for your target page: +# * Please replace for your target page, relative to value of --output_dir +# * Set for mail address which can achive MDA +# * Change in data attribute of based on routing if necessary +# +# #
-# [Comment on this page] -# +# [Comment on this page] +# # #
+# # 1. Check mail is for comment {{{ @@ -43,9 +51,10 @@ while [[ "$1" =~ ^-- && ! "$1" == "--" ]]; do shift done -output_dir=${output_dir:?} -markdown_bin=${markdown_bin:-markdown} -[ -x $(which $markdown_bin) ] || markdown_bin=cat +export PATH=/bin:/usr/bin:/usr/local/bin:~/.local/bin +output_dir=${output_dir:-$(dirname $0)} +markdown_bin=${markdown_bin:-$(which markdown)} +[ -x "$markdown_bin" ] || markdown_bin=cat # }}} # 3. Read header fields {{{ @@ -74,10 +83,11 @@ if [ $path = "" ]; then fi # get output path -[[ "$path" =~ '/$' ]] && path+=index +[[ "$path" =~ /$ ]] && path+=index path=${path#/} path=${path/.html} output=$output_dir/${path}.comment.html +umask 022; mkdir -p $(dirname $output) # }}} # 5. Get comment from mail body {{{ @@ -93,6 +103,7 @@ fi # }}} # 6. Write comment to output file {{{ +umask 133 # add basic html layout for output file if necessary {{{ if [ ! -f $output ] || ! xmllint --html --nofixup-base-uris $output &>/dev/null; then <<-LAYOUT cat >$output @@ -161,4 +172,4 @@ COMMENT # }}} -# vim:fdm=marker +# vim:fdm=marker fdl=0 -- cgit v1.2.3-70-g09d2