implement header & footer substitution system
This commit is contained in:
parent
dcc71d9896
commit
c15fa62d64
3 changed files with 23 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
18
genlog.sh
18
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"
|
||||
|
|
|
|||
4
html/substitutes/.gitignore
vendored
Normal file
4
html/substitutes/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
||||
Loading…
Add table
Add a link
Reference in a new issue