Add header.html and footer.html
This commit is contained in:
parent
a23adbc2e7
commit
bf0a43941e
|
@ -13,3 +13,8 @@ Example:
|
|||
```
|
||||
webify-gemini.sh /var/gemini/users/lovetocode999/ /home/lovetocode999/public_html/ gemini://gemini.ctrl-c.club/~lovetocode999/ http://ctrl-c.club/~lovetocode999/
|
||||
```
|
||||
|
||||
This script also creates three files in the specified HTML directory:
|
||||
* style.css: This file controls the styling of the generated website.
|
||||
* footer.html: Specifies a site-wide footer
|
||||
* header.html: Specifies a site-wide header
|
||||
|
|
|
@ -106,6 +106,16 @@ pre {}
|
|||
body {}" > "$htmlDirectory/style.css"
|
||||
fi
|
||||
|
||||
# Make sure $htmlDirectory/footer.html exists
|
||||
if ! test -f "$htmlDirectory/footer.html"; then
|
||||
touch "$htmlDirectory/footer.html"
|
||||
fi
|
||||
|
||||
# Make sure $htmlDirectory/header.html exists
|
||||
if ! test -f "$htmlDirectory/header.html"; then
|
||||
touch "$htmlDirectory/header.html"
|
||||
fi
|
||||
|
||||
# Convert all the gemtext files into html files, and copy them into the user's
|
||||
# public_html directory
|
||||
for file in $(findFilesWithoutExtension)
|
||||
|
@ -121,12 +131,22 @@ do
|
|||
|
||||
# Run the file through awk, passing the gemini address, web address and
|
||||
# title to awk as varables
|
||||
awk -v title="$title" -v geminiAddress="$geminiAddress" -v webAddress="$webAddress" '
|
||||
awk -v title="$title" -v webAddress="$webAddress" '
|
||||
BEGIN {
|
||||
# header.html
|
||||
# Split the file by spaces
|
||||
FPAT = "([^ ]+)"
|
||||
# Print the start of the html file, up to the <body> tag
|
||||
print "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <title>"title"</title>\n <link rel=\"stylesheet\" href=\""webAddress"/style.css\">\n</head>\n<body>"
|
||||
}
|
||||
{
|
||||
print " "$0;
|
||||
}
|
||||
' "$htmlDirectory/header.html" > "$htmlDirectory/$file.html"
|
||||
awk -v geminiAddress="$geminiAddress" -v webAddress="$webAddress" '
|
||||
BEGIN {
|
||||
# Split the file by spaces
|
||||
FPAT = "([^ ]+)"
|
||||
# These varables will be used later on
|
||||
urlcount=0 # Number of urls
|
||||
headnum=0 # Number of headers
|
||||
|
@ -256,9 +276,21 @@ do
|
|||
bullist = !bullist
|
||||
print " </ul>"
|
||||
}
|
||||
}
|
||||
' "$filename" >> "$htmlDirectory/$file.html"
|
||||
awk '
|
||||
BEGIN {
|
||||
# footer.html
|
||||
# Split the file by spaces
|
||||
FPAT = "([^ ]+)"
|
||||
}
|
||||
{
|
||||
print " "$0;
|
||||
}
|
||||
END {
|
||||
# Finally, print a closing </body> and </html>
|
||||
print "</body>\n</html>"
|
||||
}
|
||||
' "$filename" > "$htmlDirectory/$file.html"
|
||||
' "$htmlDirectory/footer.html" >> "$htmlDirectory/$file.html"
|
||||
echo "Converted ${filename} to ${htmlDirectory}/${file}.html"
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue