From 6ec9a6fc1d43c8d2a1495e147157dc545175b129 Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Sat, 27 Jun 2015 01:04:51 +0200 Subject: Generate static pages with a watcher and serve files with a simple http server --- gen.sh | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'gen.sh') diff --git a/gen.sh b/gen.sh index 9fbf044..6d5f3c7 100755 --- a/gen.sh +++ b/gen.sh @@ -1,24 +1,35 @@ #!/bin/bash - -MARKDOWN_DIR="Pages" +MARKDOWN_DIR="Markdown" MARKDOWN_DIR_LENGTH=$(expr 1 + ${#MARKDOWN_DIR}) +HTML_DIR="Page" -HTML_DIR="Html" +# clean_html_files: IO () +clean_html_files () { + rm -rf "$HTML_DIR" +} +# write_html_file: FilePath -> FilePath -> IO () +write_html_file () { + mkdir -p $(dirname "$2") + cat Fragments/begin.html > "$2" + pandoc -t html "$1" >> "$2" + cat Fragments/end.html >> "$2" +} +echo "" +echo "> Generating HTML files…" +clean_html_files -SELECTOR="${MARKDOWN_DIR}/**/*.md" +SELECTOR="${MARKDOWN_DIR}/*.md ${MARKDOWN_DIR}/**/*.md" for FILENAME in $SELECTOR; do WITHOUT_DIR=${FILENAME:$MARKDOWN_DIR_LENGTH} WITHOUT_EXT=${WITHOUT_DIR%.*} HTML_FILENAME="$HTML_DIR/$WITHOUT_EXT.html" - # echo $FILENAME - # echo $HTML_FILENAME - - # echo "pandoc -o $HTML_FILENAME $FILENAME" - # pandoc -o "\"$HTML_FILENAME\"" "\"$FILENAME\"" + write_html_file "$FILENAME" "$HTML_FILENAME" done -pandoc -o Html/accessoires/eponges.html Pages/accessoires/eponges.md +write_html_file "$MARKDOWN_DIR/Index.md" index.html + +echo "> Done !" -- cgit v1.2.3