qr-code-website-generator/genHTML.sh

115 lines
3.2 KiB
Bash
Raw Permalink 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>'
#dropdown for metallic
cat <<< '
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="dropdown-metallic" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Metallic</a>
<div class="dropdown-menu" aria-labelledby="dropdown-metallic">
'
for navitem in content/Metallic-*.html
2019-02-11 15:36:19 +01:00
do
pagename=$(basename $navitem .html)
cat <<< "<a class=\"dropdown-item\" href=\"$(basename $navitem)\">$pagename</a>"
2019-02-11 15:36:19 +01:00
done
cat <<< '</div></li>'
#dropdown for itlab
cat <<< '
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="dropdown-itlab" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">IT-LAB</a>
<div class="dropdown-menu" aria-labelledby="dropdown-itlab">
'
for navitem in content/IT-LAB-*.html
do
pagename=$(basename $navitem .html)
cat <<< "<a class=\"dropdown-item\" href=\"$(basename $navitem)\">$pagename</a>"
done
cat <<< '</div></li>'
cat <<< '</ul></div></nav></header>'
2019-02-11 15:36:19 +01:00
# 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