qr-code-website-generator/genHTML.sh

104 lines
2.6 KiB
Bash
Raw Normal View History

2019-02-11 15:36:19 +01:00
#!/bin/bash
# clear out the old files and copy back the files
[ -x output ] && rm -rf output/ && mkdir output
[ ! -x output ] && mkdir output # just in case ö_ö
cp -r ressources-orig output/ressources
2019-02-11 15:36:19 +01:00
insHeader(){
#takes $1 for the title
cat <<< '<!DOCTYPE html><html lang="de">'
2019-02-11 15:36:19 +01:00
cat <<< '<head>
2019-02-11 15:36:19 +01:00
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="https://getbootstrap.com/favicon.ico">
2019-02-11 15:36:19 +01:00
<!-- please dont judge me, im not getting paid for this. -->'
cat <<< "<title>$1</title>"
cat <<< '<!-- Bootstrap core CSS -->
<link href="ressources/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="ressources/sticky-footer-navbar.css" rel="stylesheet">
2019-02-11 15:36:19 +01:00
</head>'
}
insNavbar(){
2019-02-11 15:36:19 +01:00
cat <<< '<header><nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">'
cat <<< '<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>'
cat <<< '<div class="collapse navbar-collapse" id="navbarCollapse">'
cat <<< '<ul class="navbar-nav mr-auto">'
cat <<< '<a class="navbar-brand" href="#">Navigation</a>'
for navitem in content/*.html
do
pagename=$(basename $navitem .html)
if [[ "$navitem" == "$content" ]]
then
cat <<< '<li class="nav-item active">'
cat <<< "<a class=\"nav-link\" href=\"#\">$pagename</a>"
else
cat <<< '<li class="nav-item">'
cat <<< "<a class=\"nav-link\" href=\"$(basename $navitem)\">$pagename</a>"
fi
cat <<< '</li>'
done
cat <<< '</ul>'
cat <<< '</div>'
cat <<< '</nav></header>'
# end navbar content
}
insFooter(){
cat <<< '
<!--<script src="ressources/lib/web/viewer.js"></script>-->
<script src="ressources/jquery-3.js"></script>
<script src="ressources/popper.js"></script>
<script src="ressources/bootstrap.js"></script>
'
cat <<< '<footer class="footer">
<div class="container">
<span class="text-muted">© 2019, BFI St. Stefan</span>
</div>
</footer>
'
2019-02-11 15:36:19 +01:00
cat <<< '</body></html>'
}
genHTML(){
content=$1
# name of the file without ending as title for the webpage
insHeader $(basename $content .html)
# insert the navigation bar
insNavbar
# insert the body
cat <<< '<body>'
# main content
cat $content
# insert the script links and footer
insFooter
}
2019-02-11 15:36:19 +01:00
for content in content/*.html
do
genHTML $content > output/$(basename $content)
done