diff --git a/README.md b/README.md index d9042f2..7b8741b 100644 --- a/README.md +++ b/README.md @@ -37,4 +37,7 @@ or you can optionally add a text at the end of the HTML page title as the second argument ```./genlog.sh /path/to/your/choosen/folder "Your custom title"``` +you can also put your own `header.html` or `footer.html` in the `html/substitutes` folder +so they will be used instead of the default ones and you can freely personalize them + this project uses the [HotChocolateLicence](https://codeberg.org/OniriCorpe/HotChocolateLicence) diff --git a/genlog.sh b/genlog.sh index 8ca7d24..8ff7783 100755 --- a/genlog.sh +++ b/genlog.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash -:' LICENCE +: ' +LICENCE THE "HOT CHOCOLATE LICENSE ☕" (HCL revision 1312.2): OniriCorpe wrote this file. As long as you retain this @@ -10,7 +11,8 @@ disabled comrades, etc), you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a hot chocolate or any other non-alcoholic drink that suits me in return. -OniriCorpe 🏴' +OniriCorpe 🏴 +' # some useful things @@ -34,9 +36,23 @@ else fi +# if header or footer file exists in the substitutes folder, use it instead of the default ones +if [ -f html/substitutes/header.html ]; then + header_template="html/substitutes/header.html" +else + header_template="html/header.html" +fi + +if [ -f html/substitutes/footer.html ]; then + footer_template="html/substitutes/footer.html" +else + footer_template="html/footer.html" +fi + + # get the current date for the footer (UTC and ISO 8601 with hours and minutes) date=$(date -u --iso-8601=minutes) -sed "s/GEN_DATE/${date}/" html/footer.html > "$tempdir/footer.html" +sed "s/GEN_DATE/${date}/" "$footer_template" > "$tempdir/footer.html" # finding recursively all ".gmi" files on the working path @@ -46,15 +62,29 @@ do # deleting the '#' of the first line and save it as title title="$(sed -n '1{s/# //p}' "$gmi_file") $2" # escaping eventual '&' (otherwise causing a bug where it is replaced by '<\!-- TITLE -->') + # shellcheck disable=SC2001 title=$(echo "$title" | sed "s#\\\g") # in the header.html, replacing the "<\-- TITLE -->" by the previously # saved title, and save the modified file in our temporary directory - sed "s#<\!-- TITLE -->#${title}#" html/header.html > "$tempdir/header.html" + sed "s#<\!-- TITLE -->#${title}#" "$header_template" > "$tempdir/header.html" - # convertig .gmi files in .html + # converting .gmi files in .html /usr/local/bin/gmnitohtml < "$gmi_file" > "$tempdir/body.html" + cp "$tempdir/body.html" "$tempdir/work-body.html" + + # trick to support h4 titles + while IFS= read -r line; do + if echo $ "$line" | grep -q "