2020-10-23 23:08:10 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Auther: Skiqqy
|
|
|
|
|
|
|
|
HOST="https://github.com/"
|
|
|
|
|
|
|
|
conv () {
|
|
|
|
# Take a file and convert it to html by making substitutes.
|
|
|
|
|
|
|
|
# ^/name -> https://github.com/name
|
|
|
|
# */name.domain -> https://name.domain
|
|
|
|
sed -E "s|(\\^/)([^ \)]*)|^\/<a href=$HOST/\2>\2</a>|g" |
|
|
|
|
sed -E "s|(\\*/)([^ \)]*)|*\/<a href=https:\/\/\2/>\2</a>|g" |
|
|
|
|
|
|
|
|
sed -E '/%%BODY%%/r /dev/stdin' raw/template.html |
|
|
|
|
sed -E '/%%BODY%%/d'
|
|
|
|
}
|
|
|
|
|
2020-10-23 23:10:05 +00:00
|
|
|
mkdir -p site
|
2020-10-23 23:08:10 +00:00
|
|
|
for file in raw/*.txt
|
|
|
|
do
|
|
|
|
case $file in
|
|
|
|
*index.txt)
|
|
|
|
path=index.html
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
path=${file/raw/site}
|
|
|
|
path=${path/txt/html}
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
echo "Building $file"
|
|
|
|
conv < "$file" > $path
|
|
|
|
done
|