From 57e9d1666dcaae4d952a166d3af1c67aa1b1b251 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 17 Oct 2023 15:49:26 +0300 Subject: [s2] Timestamps are now passed as variables to scripts --- csg | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/csg b/csg index 05c70e5..d571e88 100755 --- a/csg +++ b/csg @@ -128,7 +128,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="$DESTINATION${file:1:-2}html\t${dates[@]: -3:3}\t${dates[@]:0:3}" + line="$DESTINATION${file:1:-2}html\t${dates[@]: -3:3} ${dates[@]:0:3}" echo -e "$line" >> "$CSG_TIMESTAMP_FILE" done } @@ -229,6 +229,12 @@ transform-file() { startedGathering && /^$/ { exit } END { print desc }' "$file")" local words="$($CSG_AWK '{total += NF} END{print total}' "$file")" + local timestamps=($($CSG_AWK -v file="$file" ' + BEGIN { FS = "\t" } + $1 == file { + print $2 + exit + }' "$file")) # Generate $CSG_MD_TO_HTML "$file" > "$outf" @@ -238,6 +244,8 @@ transform-file() { -v title="$title" \ -v description="$descr" \ -v words="$words" \ + -v created="${timestamps[@]:0:3}" \ + -v edited="${timestamps[@]:4}" \ $scr_libs $scripts -f "$CSG_TMP_DIR/csg-print.awk" \ "$outf" > "$outf.tmp" mv "$outf.tmp" "$outf" -- cgit v1.3.1-23-gd82d