From 6a79e636fc00465221dcd792e494848d89fa7921 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 17 Oct 2023 14:28:44 +0300 Subject: [csg] Renamed output to destination --- csg | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/csg b/csg index 35be37e..be67a02 100755 --- a/csg +++ b/csg @@ -4,16 +4,16 @@ ### Help message csg_help() { - echo 'Usage: csg [] + echo 'Usage: csg [] Arguments: - Folder which contains source files - Folder in which the generated site will be put - Format string for page title - Accepts any text or HTML, & is replaced with contents - title (first h1 header). - Optional, folder which contains awk script for editing of - generated webpages. + Folder which contains source files + Folder in which the generated site will be put + Format string for page title + Accepts any text or HTML, & is replaced with contents + title (first h1 header). + Optional, folder which contains awk script for editing of + generated webpages. Variables (you can predefine): CSG_TIMESTAMP_FILE File path for git-based timestamps (when git exists) @@ -42,10 +42,10 @@ SOURCE="$1" [ ! -r "$SOURCE" ] && echo "[Error] No read access to $SOURCE ()!" \ && csg_help 2 -OUTPUT="$(realpath "$2")" -[ ! -d "$OUTPUT/.." ] && echo "[Error] Parent directory of $2 () isn't a directory or doesn't exist!" \ +DESTINATION="$(realpath "$2")" +[ ! -d "$DESTINATION/.." ] && echo "[Error] Parent directory of $2 () isn't a directory or doesn't exist!" \ && csg_help 1 -[ ! -w "$OUTPUT/.." ] && echo "[Error] No write access to parent directory of $2 ()!" \ +[ ! -w "$DESTINATION/.." ] && echo "[Error] No write access to parent directory of $2 ()!" \ && csg_help 2 TITLEF="$3" @@ -119,7 +119,7 @@ then for file in $(find . -type f -name '*.md') do dates=($(git log --follow --pretty=format:%ad --date="format:%d %B %Y" -- "$file")) - line="$OUTPUT${file:1:-2}html\t${dates[@]: -3:3}\t${dates[@]:0:3}" + line="$DESTINATION${file:1:-2}html\t${dates[@]: -3:3}\t${dates[@]:0:3}" echo -e "$line" >> "$CSG_TIMESTAMP_FILE" done } @@ -135,14 +135,14 @@ then fi ### Stage 1 -### Copy everything from SOURCE to OUTPUT -startTimer "[Stage 1] Moving files to output" +### Copy everything from SOURCE to DESTINATION +startTimer "[Stage 1] Moving files to destination" (cd "$SOURCE" && \ find . -type f -not -name "\.*" -not -name '_header.html' -not -name '_footer.html' | \ - cpio -pdu "$OUTPUT" >/dev/null 2>&1) + cpio -pdu "$DESTINATION" >/dev/null 2>&1) -find "$OUTPUT" -type f -name "*index.md" -links +1 | while read -r file +find "$DESTINATION" -type f -name "*index.md" -links +1 | while read -r file do mv "$file" "${file%md}html" done @@ -155,7 +155,7 @@ while read -r reg; read -r scripts do cat $scripts > "$CSG_TMP_DIR/csg-${#scr_path[@]}.awk" scr_path+=("$CSG_TMP_DIR/csg-${#scr_path[@]}.awk") - scr_recip+=("$(find $OUTPUT -type f -regex "$reg")") + scr_recip+=("$(find $DESTINATION -type f -regex "$reg")") done < <($CSG_AWK ' { # Remove first field @@ -259,6 +259,6 @@ do [ "${scr_recip[$i]}" != "${scr_recip[$i]/${file%md}html/}" ] && scripts+=" -f ${scr_path[$i]} " done transform-file "$file" "$scripts" & -done < <(find "$OUTPUT" -type f -name "*.md") +done < <(find "$DESTINATION" -type f -name "*.md") wait endTimer "[Stage 2] Done" -- cgit v1.3.1-23-gd82d