#!/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 '\n' >> "$OUTPUT_FILE"
cat "templates/_nav.html" "$file" "templates/_footer.html" >> "$OUTPUT_FILE"
printf '\n' >> "$OUTPUT_FILE"
printf '\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 '\n' > "$OUTPUT_FILE"
printf '\n' >> "$OUTPUT_FILE"
printf '\n' >> "$OUTPUT_FILE"
printf '' >> "$OUTPUT_FILE"
printf '%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