davidvozdotnet

davidvoz.net source code
git clone https://git.davidvoz.net/davidvozdotnet.git
Log | Files | Refs

commit 4f9eed8d678f2c4e9efe00924c63f1b8ab1fa332
Author: David Voznyarskiy <31452046-davidvoz@users.noreply.gitlab.com>
Date:   Wed,  7 Jan 2026 00:07:58 -0800

added script to build the website; init commit

Diffstat:
Abuild | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+), 0 deletions(-)

diff --git a/build b/build @@ -0,0 +1,74 @@ +#!/bin/bash +set -Eeuo pipefail + +SRC="src" +DEPLOY="deploy" +TEMPLATE="$SRC/template.html" +SERVER="/var/www/davidvoz.net" +RSYNC_OPTS="-avz --delete" + +GREEN="\033[32m" +RED="\033[31m" +BLUE="\033[34m" +RESET="\033[0m" + +error_help() { + echo + echo -e "${RED}ERROR${RESET}" + echo " sh build.sh will generate $DEPLOY where files are ready" + echo " sh build.sh release will have $DEPLOY be rsynced to your server" +} + +trap 'error_help; exit 1' ERR + +release() { + echo -e "${GREEN}releasing to server${RESET}" + rsync $RSYNC_OPTS "$DEPLOY/" "$SERVER" + echo -e "${GREEN}done${RESET}" +} + +building() { + find "$SRC" -type f -name '*.md' | while read -r md; do + rel="${md#$SRC/}" + html="$DEPLOY/${rel%.md}.html" + + mkdir -p "$(dirname "$html")" + + pandoc "$md" --standalone --template="$TEMPLATE" -o "$html" + + echo -e " ${BLUE}generated${RESET} $html" + done +} + +copying() { + find "$SRC" -type f \ + ! -name '*.md' \ + ! -name 'template.html' \ + | while read -r file; do + + rel="${file#$SRC/}" + dest="$DEPLOY/$rel" + + mkdir -p "$(dirname "$dest")" + cp "$file" "$dest" + done +} + +case "${1-}" in + release|-r) + release + exit 0 + ;; +esac + +echo -e "${GREEN}cleaning${RESET}" +rm -rf "$DEPLOY" +mkdir -p "$DEPLOY" + +echo -e "${GREEN}building markdown${RESET}" +building + +echo -e "${GREEN}copying files${RESET}" +copying + +echo -e "${GREEN}done${RESET}"