Summary Files Commits Branches @commit @diff @stats
path: root / generate-hooks / make-file-lists.sh
diff options
context:
space:
mode:
Commit1fe3d39788cfb0a167ff562fa121c90ea3b445c7 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-07-04 16:41:27 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-07-04 16:41:27 +0300
Files548480d4dbd98da7e1d06f1d9c339a871600af21 /generate-hooks/make-file-lists.sh
syndamia.com-1fe3d39788cfb0a167ff562fa121c90ea3b445c7.tar
syndamia.com-1fe3d39788cfb0a167ff562fa121c90ea3b445c7.tar.gz
syndamia.com-1fe3d39788cfb0a167ff562fa121c90ea3b445c7.zip
Parent287748bcd9d17462219699d01bb0d043812a9a8e (diff)
Reworked how HTML-editing scripts are handled
1 files changed, 47 insertions, 0 deletions
-rwxr-xr-xgenerate-hooks/make-file-lists.sh47
diff --git a/generate-hooks/make-file-lists.sh b/generate-hooks/make-file-lists.sh
new file mode 100755
index 0000000..3952728
--- /dev/null
+++ b/generate-hooks/make-file-lists.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+# This is a really rudementary way to make making file lists less HTML-y
+# I made it so:
+# 1) You don't have to write quite as much HTML
+# 2) The Data columns for each file get to be formatted as Markdown (<td> is not recognized as a block-level element, so the stuff inside get formatted https://kristaps.bsd.lv/lowdown/lowdown.5.html#HTML_Blocks)
+
+# Very roughly, each file list has the same structure:
+# <details><summary>Folder Info</summary> <table> <tr>File Data</tr> </table> </details>
+
+# In Markdown you type in something like (without the "# " in front):
+#
+# &&fos
+# Description
+# &&fs0
+# <td>Data 1</td>
+# <td>Data 1.1</td>
+# <td>Data 1.2</td>
+# &&fs
+# <td>Data 2</td>
+# <td>Data 2.1</td>
+# <td>Data 2.2</td>
+# &&fod
+#
+# And the lines starting with && (I'll call them ftags) get replaced by some HTML. The <td></td> around each file Data is mandatory.
+# &&fs0 must only be used on before the very first file data. There must be no empty lines, lines mustn't start with spaces, there mustn't be anything around ftags and ftags have to be on their own lines.
+# The commands have intuitive abbreviations:
+# &&fos folder start
+# &&fs0 file start of first file
+# &&fs file start
+# &&fod folder end
+
+if [ -z "$1" ]; then
+ echo First parameter must be a path
+ exit
+fi
+
+for file in $(find "$1" -type f -name "*.html"); do
+ # Replaces "&&fos" with "<details class="file-wrapper"><summary>"
+ sed -i 's/^<p>&#38;&#38;fos$/<details class="file-wrapper"><summary>/g' "$file"
+ # Replaces "&&fs0" with "</summary><table class="file-list"><tr>"
+ sed -i 's/^&#38;&#38;fs0$/<\/summary><table class="file-list"><tr>/g' "$file"
+ # Replaces "&&fs" with "</tr><tr>"
+ sed -i 's/^&#38;&#38;fs$/<\/tr><tr>/g' "$file"
+ # Replaces "&&fod" with "</tr></table></details>"
+ sed -i 's/^&#38;&#38;fod<\/p>$/<\/tr><\/table><\/details>/g' "$file"
+done