Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit6a79e636fc00465221dcd792e494848d89fa7921 (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-10-17 14:28:44 +0300
Committer
 Syndamia <kamen@syndamia.com>
2023-10-17 14:28:44 +0300
Filesedfdd49eebe59d56be60ebdb498dfefaf37c0e88
csg-6a79e636fc00465221dcd792e494848d89fa7921.tar
csg-6a79e636fc00465221dcd792e494848d89fa7921.tar.gz
csg-6a79e636fc00465221dcd792e494848d89fa7921.zip
Parentb7bdc5852f8b35c4627c925de739d38925957694 (diff)
[csg] Renamed output to destination
1 files changed, 18 insertions, 18 deletions
-rwxr-xr-xcsg36
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 <source_dir> <output_dir> <title_format> [<scripts_dir>]
+ echo 'Usage: csg <source_dir> <destination_dir> <title_format> [<scripts_dir>]
Arguments:
- <source_dir> Folder which contains source files
- <output_dir> Folder in which the generated site will be put
- <title_format> Format string for page title
- Accepts any text or HTML, & is replaced with contents
- title (first h1 header).
- <scripts_dir> Optional, folder which contains awk script for editing of
- generated webpages.
+ <source_dir> Folder which contains source files
+ <destination_dir> Folder in which the generated site will be put
+ <title_format> Format string for page title
+ Accepts any text or HTML, & is replaced with contents
+ title (first h1 header).
+ <scripts_dir> 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 (<source_dir>)!" \
&& csg_help 2
-OUTPUT="$(realpath "$2")"
-[ ! -d "$OUTPUT/.." ] && echo "[Error] Parent directory of $2 (<output_dir>) isn't a directory or doesn't exist!" \
+DESTINATION="$(realpath "$2")"
+[ ! -d "$DESTINATION/.." ] && echo "[Error] Parent directory of $2 (<destination_dir>) isn't a directory or doesn't exist!" \
&& csg_help 1
-[ ! -w "$OUTPUT/.." ] && echo "[Error] No write access to parent directory of $2 (<output_dir>)!" \
+[ ! -w "$DESTINATION/.." ] && echo "[Error] No write access to parent directory of $2 (<destination_dir>)!" \
&& 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"