From c15fa62d64974ab8f2b6e3ee2544a975cc9388a4 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Fri, 29 Dec 2023 23:38:45 +0100 Subject: [PATCH] implement header & footer substitution system --- README.md | 3 +++ genlog.sh | 18 ++++++++++++++++-- html/substitutes/.gitignore | 4 ++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 html/substitutes/.gitignore 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 21d48ac..23a45fb 100755 --- a/genlog.sh +++ b/genlog.sh @@ -36,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 @@ -52,7 +66,7 @@ do # 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 /usr/local/bin/gmnitohtml < "$gmi_file" > "$tempdir/body.html" diff --git a/html/substitutes/.gitignore b/html/substitutes/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/html/substitutes/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore