#!/usr/bin/env sh # Site specific settings DOMAIN="https://iiogama.0x212.com" TITLE="iiogama@0x212.com" DESCRIPTION="Some dude compulsively online, like so many others" COPYRIGHT="Copyright $(date +%Y), Thai Noodles" #AUTHOR="Thai Noodles, (iiogama@0x212.com)" CONTENT_DIR="content" #ASSET_DIR="assets" OUTPUT_DIR="_output" build_pages() { rsync -r --exclude="*.html" --exclude="*.xml" "$CONTENT_DIR/" "$OUTPUT_DIR/" #rsync -r "$ASSET_DIR/" "$OUTPUT_DIR/" find $CONTENT_DIR -type f -name "*.html" | while read -r file; do OUTPUT_FILE="$(echo "$file" | sed "s/$CONTENT_DIR/$OUTPUT_DIR/")" if [ ! -f "$OUTPUT_FILE" ]; then printf '\n' > "$OUTPUT_FILE" printf '\n' >> "$OUTPUT_FILE" sed "s!!&$TITLE!" "templates/_head.html" >> "$OUTPUT_FILE" printf '<body>\n' >> "$OUTPUT_FILE" cat "templates/_nav.html" "$file" "templates/_footer.html" >> "$OUTPUT_FILE" printf '</body>\n' >> "$OUTPUT_FILE" printf '</html>\n' >> "$OUTPUT_FILE" fi done } build_feeds() { find $CONTENT_DIR -type f -name "*.xml" | while read -r file; do OUTPUT_FILE="$(echo "$file" | sed "s/$CONTENT_DIR/$OUTPUT_DIR/")" if [ ! -f "$OUTPUT_FILE" ]; then printf '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n' > "$OUTPUT_FILE" printf '<?xml-stylesheet href="style.xsl" type="text/xsl"?>\n' >> "$OUTPUT_FILE" printf '<rss version="2.0">\n' >> "$OUTPUT_FILE" printf '<channel>' >> "$OUTPUT_FILE" printf '<title>%s\n' "$TITLE" >> "$OUTPUT_FILE" printf '%s\n' "$DOMAIN" >> "$OUTPUT_FILE" printf '%s\n' "$DESCRIPTION" >> "$OUTPUT_FILE" printf '%s\n' "$COPYRIGHT" >> "$OUTPUT_FILE" cat "$file" >> "$OUTPUT_FILE" printf '\n' >> "$OUTPUT_FILE" printf '\n' >> "$OUTPUT_FILE" fi done } case "$1" in build) build_pages build_feeds #xsltproc "$OUTPUT_DIR/index.xml" > "$OUTPUT_DIR/blog/index.html" ;; esac