Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commitdc6d520962eee4890c217a214b98b0dc18415687 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-09-29 12:47:52 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-09-29 17:40:10 +0300
Files6e3efe267635aa83a2ece2bfd782e38b8a694063
syndamia.com-dc6d520962eee4890c217a214b98b0dc18415687.tar
syndamia.com-dc6d520962eee4890c217a214b98b0dc18415687.tar.gz
syndamia.com-dc6d520962eee4890c217a214b98b0dc18415687.zip
Parent147e2923478959bc3cfa1cae37ada14a3b99fbe4 (diff)
[hooks/filelists] Reworked how ftags function
1 files changed, 69 insertions, 20 deletions
-rw-r--r--generate-hooks/create-file-lists.awk89
diff --git a/generate-hooks/create-file-lists.awk b/generate-hooks/create-file-lists.awk
index 086d9dd..113bca6 100644
--- a/generate-hooks/create-file-lists.awk
+++ b/generate-hooks/create-file-lists.awk
@@ -13,11 +13,11 @@
#
# &&fos
# Description
-# &&fs0
+# &&file0
# <td>Data 1</td>
# <td>Data 1.1</td>
# <td>Data 1.2</td>
-# &&fs
+# &&file
# <td>Data 2</td>
# <td>Data 2.1</td>
# <td>Data 2.2</td>
@@ -29,7 +29,7 @@
# <td>Data 1</td>
# <td>Data 1.1</td>
# <td>Data 1.2</td>
-# &&fs
+# &&file
# <td>Data 2</td>
# <td>Data 2.1</td>
# <td>Data 2.2</td>
@@ -37,46 +37,95 @@
#
# 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, when files are in a folder. 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.
+# &&file0 must only be used on before the very first file data, when files are in a folder. 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 fairly intuitive abbreviations:
# &&nos no folder start (start file list, without making a folder)
# &&fos folder start
-# &&fs0 file start of first file in folder (must only be used when items are in a folder!)
-# &&fs file start
+# &&file0 file start of first file in folder (must only be used when items are in a folder!)
+# &&file file start
# &&nod no folder end (end file list, without having made a folder)
# &&fod folder end
BEGIN {
- nam[1] = "nos"
- rep[1] = "<table class=\"file-list\"><tr>"
- nam[2] = "fos"
- rep[2] = "<details class=\"file-wrapper\"><summary>"
- nam[3] = "fs0"
- rep[3] = "</summary><table class=\"file-list\"><tr>"
- nam[4] = "fs"
- rep[4] = "</tr><tr>"
- nam[5] = "nod"
- rep[5] = "</tr></table>"
- nam[6] = "fod"
- rep[6] = "</tr></table></details>"
+ fileStarted = 0
+ noFolder = 1
+ searchEndP = 0
+
+ # Special formatting
+ nam[1] = "folder"
+ rep[1] = "<details class=\"file-wrapper\"><summary>"
+ nam[2] = "file"
+ rep[2] = "</tr><tr>"
+ nam[3] = "&#47;files" # /files
+ rep[3] = "</tr></table></details>"
+ nam[4] = "fd"
+ rep[4] = "" # Not used, refer to substitute function
+
+ nam[5] = "ft-photo"
+ rep[5] = "photo-tabler.svg"
+ nam[6] = "ft-text"
+ rep[6] = "file-text-tabler.svg"
+ nam[7] = "ft-zip"
+ rep[7] = "file-zip-tabler.svg"
+ nam[8] = "ft-movie"
+ rep[8] = "movie-tabler.svg"
+ nam[9] = "ft-markdown"
+ rep[9] = "markdown-tabler.svg"
for (i = 1; i <= length(nam); i++) {
pat[i] = "&#38;&#38;" nam[i]
+ if (index(nam[i], "ft") == 1)
+ rep[i] = "<td><img class=\"file-icon unzoomable\" src=\"/img/" rep[i] "\"></td>"
}
}
function substitute(ind) {
gsub(/(<p>|<\/p>)/, "")
- gsub(pat[ind], rep[ind])
+
+ # &&file
+ if (ind == 2 && fileStarted == 0) {
+ if (noFolder == 1)
+ gsub("&#38;&#38;file", "<table class=\"file-list\"><tr>")
+ else
+ gsub("&#38;&#38;file", "</summary><table class=\"file-list\"><tr>")
+ fileStarted = 1
+ }
+ # &&/files
+ else if (ind == 3 && noFolder == 1) {
+ gsub("&#38;&#38;&#47;files", "</tr></table>")
+ }
+ # &&fd
+ else if (ind == 4) {
+ gsub(/&#38;&#38;fd[ \t]*/, "<td>")
+ gsub(/$/, "</td>")
+ }
+ else
+ gsub(pat[ind], rep[ind])
+
+ # &&folder
+ if (ind == 1) {
+ noFolder = 0
+ searchEndP = 1
+ }
+ # &&/files
+ else if (ind == 3) {
+ fileStarted = 0
+ noFolder = 1
+ }
}
/^[ \t]*(<p>|)&#38;&#38;/ {
for (i = 1; i <= length(nam); i++) {
- if (index($0, nam[i]) != 0)
+ if (index($0, pat[i]) != 0)
substitute(i)
}
}
+searchEndP == 1 && /<\/p>/ {
+ gsub(/<\/p>/, "")
+ searchEndP = 0
+}
+
{
print
}