Initial Commit. First test worked.

This commit is contained in:
Fliegerjohn 2023-08-27 23:06:41 +02:00
commit c9db15162a
2 changed files with 87 additions and 0 deletions

14
LICENSE Normal file
View file

@ -0,0 +1,14 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

73
easywebsite.sh Executable file
View file

@ -0,0 +1,73 @@
#!/bin/bash
#
## Easywebsite
#
# Create a html file out of your Markdownfiles.
# On top it will set a header and onto the botton a footer.
#
## Variables
#
# Workdir with the *.md files to convert
workdir="$1"
# HTML-template for pandoc
template="template/html.template"
# Head of Website
header="template/head.html"
footer="template/foot.html"
# Serverconfig
# Server to upload if there is none set "false"
webserver="false"
# User of webserver
webserveruser=""
# Port to connect with sftp
sftpport="22"
#
## Funktions
#
convertfiles() {
echo "Convert your Markdownfiles to HTML-Files..."
cd $workdir #Switch to workdir
find . -name \*.md -type f -exec pandoc --template=$template -B $header -A $footer -o {}.html {} \;
find . -depth -name '*.md.html' -execdir bash -c 'mv -i "$1" "${1//md.html/html}"' bash {} \;
echo "Files converted!"
}
cleaning() {
#Ask for permission to cleanup and cleanup
printf "Do you really want to clean up $workdir with all subdirs except *template/*? *Yes* or *No*: "
read cleanupok
if [[ $cleanupok == "Yes" ]]; then
echo "Cleaning up $workdir..."
cd $workdir #Switch to workdir
find . -name \*.html -type f ! -path '*/template/*' -delete
elif [[ $cleanupok == "No" ]]; then
echo "Don't clean up!"
else
echo "Don't clean up! Argument was wrong..."
fi
}
#
## Main
#
echo workdir
cleaning
convertfiles
echo="Files converted and uploaded!"