commit c9db15162aada10e4eaed8a36da7bf20bf2a2396 Author: fliegerjohn Date: Sun Aug 27 23:06:41 2023 +0200 Initial Commit. First test worked. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5a8e332 --- /dev/null +++ b/LICENSE @@ -0,0 +1,14 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + 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. + diff --git a/easywebsite.sh b/easywebsite.sh new file mode 100755 index 0000000..3362f50 --- /dev/null +++ b/easywebsite.sh @@ -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!"