From 0187e255a811bebb0dad3624f2c6d78b829d15c5 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 17 Jan 2023 16:15:28 +0200 Subject: [awk] Reworked generation to happen via a combined script, updated scripts and added info in scripts readme --- awk-edits/File-lists.awk | 165 ++++++++++++++++++++++++++++++ awk-edits/Flags.awk | 30 ++++++ awk-edits/Group-contents.awk | 20 ++++ awk-edits/Header-Title.awk | 26 +++++ awk-edits/Header-description.awk | 36 +++++++ awk-edits/Heading-anchors.awk | 12 +++ awk-edits/Pagenav.awk | 39 +++++++ awk-edits/Presentation.awk | 141 ++++++++++++++++++++++++++ awk-edits/README.md | 25 +++++ awk-edits/_print.awk | 3 + awk-edits/post-pagenav.awk | 4 + generate-dev.sh | 25 +++-- generate-hooks/README.md | 15 --- generate-hooks/create-description.awk | 40 -------- generate-hooks/create-file-lists.awk | 169 ------------------------------- generate-hooks/create-flags.awk | 31 ------ generate-hooks/create-header-anchors.awk | 16 --- generate-hooks/create-pagenav.awk | 48 --------- generate-hooks/create-presentation.awk | 145 -------------------------- generate-hooks/create-title.awk | 30 ------ generate-hooks/group-contents.awk | 24 ----- generate.sh | 10 +- 22 files changed, 524 insertions(+), 530 deletions(-) create mode 100644 awk-edits/File-lists.awk create mode 100644 awk-edits/Flags.awk create mode 100644 awk-edits/Group-contents.awk create mode 100644 awk-edits/Header-Title.awk create mode 100644 awk-edits/Header-description.awk create mode 100644 awk-edits/Heading-anchors.awk create mode 100644 awk-edits/Pagenav.awk create mode 100644 awk-edits/Presentation.awk create mode 100644 awk-edits/README.md create mode 100644 awk-edits/_print.awk create mode 100644 awk-edits/post-pagenav.awk delete mode 100644 generate-hooks/README.md delete mode 100644 generate-hooks/create-description.awk delete mode 100644 generate-hooks/create-file-lists.awk delete mode 100644 generate-hooks/create-flags.awk delete mode 100644 generate-hooks/create-header-anchors.awk delete mode 100644 generate-hooks/create-pagenav.awk delete mode 100644 generate-hooks/create-presentation.awk delete mode 100644 generate-hooks/create-title.awk delete mode 100644 generate-hooks/group-contents.awk diff --git a/awk-edits/File-lists.awk b/awk-edits/File-lists.awk new file mode 100644 index 0000000..8903b95 --- /dev/null +++ b/awk-edits/File-lists.awk @@ -0,0 +1,165 @@ +# +# == About == +# +# Each file list is a "details" element, that contains a table, each row being a different file +# or alternatively, just the table on it's own. +# +# -- Result HTML -- +# +#
+# Folder Info +# +# File Data +#
+#
+# or +# +# File Data +#
+ +# +# == ftags == +# +# &&folder The text right afterwards is the title of the folder. All files +# are hidden inside the collapsed details tag (click to show). +# The file table is indented. You cannot have a folder inside a folder. +# It can be omitted, and the files table will be shown as-is. +# +# &&file Everything that follows this tag is the data for a file. You should +# use &&fd to specify columns of information! Depending on the context, +# it might be flrepllaced with the start of a table, closing the summary +# and starting table, or closing and opening a table row. +# +# &&/files This tag must exist at the bottom of a file list, no matter if it was +# started with or without a &&folder. +# +# &&fd Defines a column of information for a file (row). Practically, it is +# flrepllaced with , and is added to the end of the line. +# If you don't use it, make sure to have the leading and trailing td tags! +# +# &&ft-TYPE Depending on TYPE, it inserts an image tag that contains the file "icon" +# for the corresponding type. +# Available values for TYPE: photo, text, zip, movie, markdown +# +# -- Placement/Flow -- +# +# All ftags, except &&fd, can be placed on their own line (empty line above and below) +# or before/after another ftag. +# Folder title must be inside the same paragraph as the ftag itself. This means that, +# after +# every &&folder ftag, the text can continue directly next to it and/or on new lines, +# without there being any empty lines (you can add those with
or two spaces at +# line end). +# +# -- Example Usage -- +# +# (I like to indent a bit &&fd ftags, for readability's sake, but you don't have to) +# +# &&file +# &&ft-text +# &&fd Notes +# &&fd 10 KB +# &&/files +# +# &&folder Math +# &&file +# &&ft-text +# &&fd Homework 1 +# &&file +# &&ft-text +# &&fd Homework 2 +# &&/files +# +# &&folder Art Project
+# Status: 70% complete
+# Note: Reserach Van Gogh paintings +# +# &&file +# &&fd Painting 1 +# &&fd 100% Complete +# +# &&file +# &&fd Painting 2 +# &&fd 40% Complete +# +# &&/files + +BEGIN { + fileStarted = 0 + noFolder = 1 + searchEndP = 0 # Used to remove trailing

in file row + + # Special formatting + flname[1] = "folder" + flrepl[1] = "
" + flname[2] = "file" + flrepl[2] = "" + flname[3] = "/files" # /files + flrepl[3] = "
" + flname[4] = "fd" + flrepl[4] = "" # Not used, refer to fileSubstitute function + + flname[5] = "ft-photo" + flrepl[5] = "photo-tabler.svg" + flname[6] = "ft-text" + flrepl[6] = "file-text-tabler.svg" + flname[7] = "ft-zip" + flrepl[7] = "file-zip-tabler.svg" + flname[8] = "ft-movie" + flrepl[8] = "movie-tabler.svg" + flname[9] = "ft-markdown" + flrepl[9] = "markdown-tabler.svg" + + for (i = 1; i <= length(flname); i++) { + flpat[i] = "&&" flname[i] + if (index(flname[i], "ft") == 1) + flrepl[i] = "" + } +} + +function fileSubstitute(ind) { + gsub(/(

|<\/p>)/, "") + + # &&file + if (ind == 2 && fileStarted == 0) { + if (noFolder == 1) + gsub("&&file", "") + else + gsub("&&file", "
") + fileStarted = 1 + } + # &&/files + else if (ind == 3 && noFolder == 1) { + gsub("&&/files", "
") + } + # &&fd + else if (ind == 4) { + gsub(/&&fd[ \t]*/, "") + gsub(/$/, "") + } + else + gsub(flpat[ind], flrepl[ind]) + + # &&folder + if (ind == 1) { + noFolder = 0 + searchEndP = 1 + } + # &&/files + else if (ind == 3) { + fileStarted = 0 + noFolder = 1 + } +} + +/^[ \t]*(

|)&&/ { + for (i = 1; i <= length(flname); i++) { + if (index($0, flpat[i]) != 0) + fileSubstitute(i) + } +} + +searchEndP == 1 && /<\/p>/ { + gsub(/<\/p>/, "") + searchEndP = 0 +} diff --git a/awk-edits/Flags.awk b/awk-edits/Flags.awk new file mode 100644 index 0000000..6f62916 --- /dev/null +++ b/awk-edits/Flags.awk @@ -0,0 +1,30 @@ +# +# == About == +# +# A collection of ftags that generate an image HTML tag, containing the specified +# flag. This is done, because these tags need to have the unzoomable class, which +# you can't specify in Markdown. + +# == ftags == +# +# &&gb Great Britain flag +# +# -- Placement/Flow -- +# +# They can reside absolutely anywhere in text. + +BEGIN { + flag[1] = "gb" + flagTitle[1] = "ENG" + + for (i = 1; i <= length(flag); i++) { + flagExp[i] = "&&" flag[i] + flagTag[i] = "\""" + } +} + +{ + for (i = 1; i <= length(flagExp); i++) { + gsub(flagExp[i], flagTag[i]) + } +} diff --git a/awk-edits/Group-contents.awk b/awk-edits/Group-contents.awk new file mode 100644 index 0000000..d984eef --- /dev/null +++ b/awk-edits/Group-contents.awk @@ -0,0 +1,20 @@ +# +# == About == +# +# This script surrounds the "Contents" heading, as well as the list itself, in a div wrapper element +# For it to work properly, the contents heading must be h2 and have it's id as "contents", +# and there must be a paragraph element after the item list + +BEGIN { + started = 0 +} + +/h2 id="contents"/ { + print "

" + started = 1 +} + +started == 1 && /

/ { + print "

" + started = 0 +} diff --git a/awk-edits/Header-Title.awk b/awk-edits/Header-Title.awk new file mode 100644 index 0000000..16247e8 --- /dev/null +++ b/awk-edits/Header-Title.awk @@ -0,0 +1,26 @@ +# +# == About == +# +# Every page has a og:title meta tag, which has to be generated from the page +# itself. The title tag is automatically filled in by ssg. +# The value for the meta tag is "[TITLE]" and it gets replaced with all text +# inside first h1 header tag. + +BEGIN { + h1Index = 0 + + # When this loop finishes, $0 will have the first line containing an h1 header + # tag, and h1Index will have it's starting position + while (h1Index == 0 && getline < ARGV[1]) + h1Index = index($0, "]*>/, "") + title = substr($0, h1Index, index($0, "]*>/, "", l) ; gsub("’", "'", l) + gsub(/[^a-zA-Z0-9 '.]/, "", l) + gsub(/^[ \t]*/, "", l) ; gsub(/[ \t]*$/, "", l) + + desc = desc l + if (length(desc) >= 200) { + desc = substr(desc, 1, 197) "..." + return 1 + } + return 0 +} + +BEGIN { + stop = 0 + + # Loop over the whole file, extract all text in first couple of paragraphs, + # store it in desc (but no more than 200 characters will be saved) + while(stop == 0 && getline < ARGV[1]) { + if (index($0, " 0) + stop = appToDesc($0) + } + close(ARGV[1]) # FILENAME isn't set during BEGIN +} + +"\\[DESCRIPTION\\]" { + gsub("\\[DESCRIPTION\\]", desc) +} diff --git a/awk-edits/Heading-anchors.awk b/awk-edits/Heading-anchors.awk new file mode 100644 index 0000000..e4367c7 --- /dev/null +++ b/awk-edits/Heading-anchors.awk @@ -0,0 +1,12 @@ +# +# == About == +# +# ssg generates an id for every heading. That's why after every heading there +# can be a hyperlink to itself. However, because of the current styling, such a +# hyperlink is required (except for h1). + +/[ \t]*\"🔗\"") +} diff --git a/awk-edits/Pagenav.awk b/awk-edits/Pagenav.awk new file mode 100644 index 0000000..46589fb --- /dev/null +++ b/awk-edits/Pagenav.awk @@ -0,0 +1,39 @@ +# +# == About == +# +# I call pagenav the stuff directly below the first h1. These include file dates +# and GitLab source link. +# Currently it only works for blog and tutorial pages. +# +# This is by far the most hard-coded and inefficient awk script in the generate-hooks. +# Creation and last edited dates are taken from git commits, and getting the correct info +# by file name can easily only be done with git log, which unfortunately is very slow. +# Another issue is that it depends on the build directories in build scripts, meaning +# it won't work without modification if you try to build it somewhere else. + +BEGIN { + fileCheck = ARGV[1] # FILENAME isn't available in BEGIN + + if (match(fileCheck, /(blog|tutorials)\/.*\//) == 0) { + found = 1 + } + else { + found = 0 + gsub(/^.*\/(synd|tiny.synd|website|tiny.website)\//, "", fileCheck); gsub(/\.html/, ".md", fileCheck) + + system("git log --follow --pretty=format:%ad --date=\"format:%d %B %Y\" -- src/" fileCheck " > /tmp/syndamiadotcom-pagenav") + + dateCreate = "" + dateEdited = "" + while ((getline < "/tmp/syndamiadotcom-pagenav") > 0) { + if (dateEdited == "") dateEdited = $0 + dateCreate = $0 + } + + elem = ORS \ +"
" ORS \ +" Created: " dateCreate " || Edited: " dateEdited "" ORS \ +" || GitLab source" ORS \ +"
" + } +} diff --git a/awk-edits/Presentation.awk b/awk-edits/Presentation.awk new file mode 100644 index 0000000..f0bbb4a --- /dev/null +++ b/awk-edits/Presentation.awk @@ -0,0 +1,141 @@ +# +# == About == +# +# This is my way of making slide-based presentations. In short, it just groups +# Markdown formatting into rectangles and adds options for layout formatting. +# Each slide is the size of a landscape-oriented A4 sheet of paper. Light/dark +# mode settings are respected (of course). +# Currently, this appliest only to pages under the "talks" folder. + +# +# == ftags == +# +# &&presentation Must appear before any other presentation ftags. +# It "loads" everything necessary for a presentation, that being +# the navigation bar and logic script (which also inserts the +# custom stylesheet). +# Can be only one per page. Also refer to -- Surroundings -- +# +# &&slide Everything below this tag is part of a slide. Each slide is +# presented in the order it appears in. +# &&/slide Ends (the last started) slide. +# +# &&frow A row of paragraphs, where each item is evenly sized and is +# spaced out horizontally. In the HTML, it is a simple flexbox. +# This is one of the two main ways to configure how content is +# laid out on a slide. +# &&/frow Every HTML element/paragraph between &&frow and &&/frow is an +# item that will be laid out. +# +# &&fcol A column of paragraphs, where each item is evenly sized and is +# spaced out vertically. In the HTML, it is a simple flexbox. +# This is one of the two main ways to configure how content is +# laid out on a slide. +# &&/fcol Every HTML element/paragraph between &&fcol and &&/fcol is an +# item that will be laid out. +# +# &&flexer An empty container, which can be used as a blank space item +# inside &&frow or &&fcol. In the styling, it just has `flex: 1`. +# +# &¢ered Aligns text to the center, literally. +# &&/centered Text between &¢ered and &&/centered is aligned. +# +# &&fright Aligns element and the text inside to the right. In the styling, +# it just has text-align and float set to right. +# &&/fright Text between &&fright and &&/fright is aligned to the right +# +# &&fontSIZE Changes to font size to SIZE, in pixels. Default size is 24px. +# Available values for SIZE: 18, 20, 27, 30, 37 +# &&/font Text between &&fontSIZE and &&/font is sized accordingly +# +# -- Surroundings -- +# +# As stated, there can only be one presentation per page. +# Everything that is around a presentation and it's slides is normally hidden +# during presenting mode, but will show up if you try to print the presentation. +# Exceptions to this rule are headings and paragraphs, which won't show up in +# presenting mode or during print. +# +# -- Placement/Flow -- +# +# All ftags can be placed on their own line, or in a line with other ftags. +# The only requirement is that such a line must start with an ftag, ftags in the +# middle of text aren't recognized. +# +# -- Example Usage -- +# +# Refer to src/talks/demo.md + +BEGIN { + nopresentation=substr(ARGV[1], "talks") == 0 # FILENAME isn't available yet + + # Exceptions to the normal format + names[ 1] = "presentation" + ended[ 1] = 0 + names[ 2] = "/font" # all font ftags can be closed with a &&/font + ended[ 2] = 0 + + names[ 3] = "slide" + ended[ 3] = 1 + names[ 4] = "centered" + ended[ 4] = 1 + names[ 5] = "flexer" + ended[ 5] = 2 + names[ 6] = "frow" + ended[ 6] = 1 + names[ 7] = "fcol" + ended[ 7] = 1 + names[ 8] = "font18" + ended[ 8] = 0 + names[ 9] = "font20" + ended[ 9] = 0 + names[10] = "font27" + ended[10] = 0 + names[11] = "font30" + ended[11] = 0 + names[12] = "font35" + ended[12] = 0 + names[13] = "fright" + ended[13] = 1 + + pres = ORS \ +"" ORS \ +" " + + pat[1] = "&&presentation" + rep[1] = pres + pat[2] = "&&/font" + rep[2] = "" + + for (i = 3; i <= length(names); i++) { + pat[i] = "&&" names[i] + rep[i] = "
" + + if (ended[i] == 1) { + cpat[i] = "&&/" names[i] + crep[i] = "
" + } + else if (ended[i] == 2) { + rep[i] = rep[i] "" + } + } +} + +function presentationSubstitute(ind) { + gsub(/(

|<\/p>)/, "") + gsub(pat[ind], rep[ind]) + if (ended[ind] == 1) + gsub(cpat[ind], crep[ind]) +} + +nopresentation == 0 && /^[ \t]*(

|)&&/ { + for (i = 1; i <= length(names); i++) { + if (index($0, names[i]) != 0) + presentationSubstitute(i) + } +} diff --git a/awk-edits/README.md b/awk-edits/README.md new file mode 100644 index 0000000..a9d1c77 --- /dev/null +++ b/awk-edits/README.md @@ -0,0 +1,25 @@ +All `.awk` files in this folder are ran by `generate.sh` and `generate-dev.sh`, after ssg and lowdown have created all HTML pages. These files are meant to work on the resultant HTML. + +For improved efficiency, rather than running every script seperately, they are meant to be concatinated into one script (`generate.sh` and `generate-dev.sh` combine them in `/tmp/syndamiadotcom-awk`), which is ran for each HTML file. +This forces us to work with the following constraints: + +- NO awk script should print the current line (print should only be used to add new lines) + The script that starts with '\_' contains the print of the current line, all scripts that start with a capital letter are ran before it and all with small letter - after. + + If we print the current line in every script, the concatenated will print the current line multiple times +- Variable names between scripts must be unique +- `exit` mustn't be used! + Instead, use a variable and then add a check to every relevant rule. + +## ftags + +ftags are strings/words in the Markdown source files, that start with "&&" and continue with any (valid) sequence of characters. The name initially stood for "file tags", since I got the idea while making the file lists functionality. Now I like to think of them as "format tags", since they are used for so much more. + +On the "backend", they just get replaced with specific HTML. List of scripts that handle ftags: + +|Script|ftags| +|---|---| +|`File-lists.awk`|`&&folder`, `&&file`, `&&/files`, `&&ft-TYPE` *(TYPE is one of `photo`, `text`, `zip`, `movie`, `markdown`)*| +|`Flags.awk`|`&&gb`| +|`Presentation.awk`|`&&presentation`, `&&slide`, `&&/slide`, `&&flexer`, `&¢ered`, `&&/centered`, `&&fow`, `&&/fow`, `&&fcol`, `&&/fcol`, `&&fontSIZE` *(SIZE is one of `18`, `20`, `27`, `30`, `37`)*, `&&/font`| + +Information regarding their usage can be found at the top of their respective script file. diff --git a/awk-edits/_print.awk b/awk-edits/_print.awk new file mode 100644 index 0000000..fcf69c6 --- /dev/null +++ b/awk-edits/_print.awk @@ -0,0 +1,3 @@ +{ + print +} diff --git a/awk-edits/post-pagenav.awk b/awk-edits/post-pagenav.awk new file mode 100644 index 0000000..4587cae --- /dev/null +++ b/awk-edits/post-pagenav.awk @@ -0,0 +1,4 @@ +found == 0 && / /dev/null -allnormfiles=$(find '/var/www/synd' -type f -name "*.html") dur=0 - -for script in $(find "./generate-hooks" -type f -name "*.awk"); do +startTimer () { dur="$(date +%s%N)" - for file in $allnormfiles; do - awk -f "$script" "$file" > tmp && mv -f tmp "$file" - done +} +endTimer () { dur="$(echo "scale=4 ; ($(date +%s%N) - $dur) / 1000000000" | bc -l)" - printf "%.3fs $script\n" $dur -done + printf "%.3fs $1\n" $dur +} + +startTimer + find './awk-edits' -type f -name "[A-Z]*.awk" -exec cat {} + > /tmp/syndamiadotcom-awk + find './awk-edits' -type f -name "_*.awk" -exec cat {} + >> /tmp/syndamiadotcom-awk + find './awk-edits' -type f -name "[a-z]*.awk" -exec cat {} + >> /tmp/syndamiadotcom-awk +endTimer "generation of /tmp/syndamiadotcom-awk" + +startTimer + for file in $(find '/var/www/synd' -type f -name "*.html"); do + awk -f '/tmp/syndamiadotcom-awk' "$file" > tmp && mv -f tmp "$file" + done +endTimer "/tmp/syndamiadotcom-awk" # # Tiny version diff --git a/generate-hooks/README.md b/generate-hooks/README.md deleted file mode 100644 index 3371de2..0000000 --- a/generate-hooks/README.md +++ /dev/null @@ -1,15 +0,0 @@ -All `.awk` files in this folder are ran by `generate.sh` and `generate-dev.sh`, after ssg and lowdown have created all HTML pages. These files are meant to work on the resultant HTML. - -## ftags - -ftags are strings/words in the Markdown source files, that start with "&&" and continue with any (valid) sequence of characters. The name initially stood for "file tags", since I got the idea while making the file lists functionality. Now I like to think of them as "format tags", since they are used for so much more. - -On the "backend", they just get replaced with specific HTML. List of scripts that handle ftags: - -|Script|ftags| -|---|---| -|`make-file-lists.awk`|`&&folder`, `&&file`, `&&/files`, `&&ft-TYPE` *(TYPE is one of `photo`, `text`, `zip`, `movie`, `markdown`)*| -|`make-flags.awk`|`&&gb`| -|`make-presentation.awk`|`&&presentation`, `&&slide`, `&&/slide`, `&&flexer`, `&¢ered`, `&&/centered`, `&&fow`, `&&/fow`, `&&fcol`, `&&/fcol`, `&&fontSIZE` *(SIZE is one of `18`, `20`, `27`, `30`, `37`)*, `&&/font`| - -Information regarding their usage can be found at the top of their respective script file. diff --git a/generate-hooks/create-description.awk b/generate-hooks/create-description.awk deleted file mode 100644 index 8c0d753..0000000 --- a/generate-hooks/create-description.awk +++ /dev/null @@ -1,40 +0,0 @@ -# -# == About == -# -# Every page has a description and og:description meta tags. These descriptions -# are generated from the paragraphs, inside the given page. -# The value for those meta tags is "[DESCRIPTION]" and it gets replaced with -# either all of the text on the page, or only the first 200 characters. - -function appToDesc(l) { - gsub(/<[^>]*>/, "", l) ; gsub("’", "'", l) - gsub(/[^a-zA-Z0-9 '.]/, "", l) - gsub(/^[ \t]*/, "", l) ; gsub(/[ \t]*$/, "", l) - - desc = desc l - if (length(desc) >= 200) { - desc = substr(desc, 1, 197) "..." - return 1 - } - return 0 -} - -BEGIN { - stop = 0 - - # Loop over the whole file, extract all text in first couple of paragraphs, - # store it in desc (but no more than 200 characters will be saved) - while(stop == 0 && getline < ARGV[1]) { - if (index($0, " 0) - stop = appToDesc($0) - } - close(ARGV[1]) # FILENAME isn't set during BEGIN -} - -"\\[DESCRIPTION\\]" { - gsub("\\[DESCRIPTION\\]", desc) -} - -{ - print -} diff --git a/generate-hooks/create-file-lists.awk b/generate-hooks/create-file-lists.awk deleted file mode 100644 index 7d18bdd..0000000 --- a/generate-hooks/create-file-lists.awk +++ /dev/null @@ -1,169 +0,0 @@ -# -# == About == -# -# Each file list is a "details" element, that contains a table, each row being a different file -# or alternatively, just the table on it's own. -# -# -- Result HTML -- -# -#

-# Folder Info -# -# File Data -#
-#
-# or -# -# File Data -#
- -# -# == ftags == -# -# &&folder The text right afterwards is the title of the folder. All files -# are hidden inside the collapsed details tag (click to show). -# The file table is indented. You cannot have a folder inside a folder. -# It can be omitted, and the files table will be shown as-is. -# -# &&file Everything that follows this tag is the data for a file. You should -# use &&fd to specify columns of information! Depending on the context, -# it might be replaced with the start of a table, closing the summary -# and starting table, or closing and opening a table row. -# -# &&/files This tag must exist at the bottom of a file list, no matter if it was -# started with or without a &&folder. -# -# &&fd Defines a column of information for a file (row). Practically, it is -# replaced with , and is added to the end of the line. -# If you don't use it, make sure to have the leading and trailing td tags! -# -# &&ft-TYPE Depending on TYPE, it inserts an image tag that contains the file "icon" -# for the corresponding type. -# Available values for TYPE: photo, text, zip, movie, markdown -# -# -- Placement/Flow -- -# -# All ftags, except &&fd, can be placed on their own line (empty line above and below) -# or before/after another ftag. -# Folder title must be inside the same paragraph as the ftag itself. This means that, -# after -# every &&folder ftag, the text can continue directly next to it and/or on new lines, -# without there being any empty lines (you can add those with
or two spaces at -# line end). -# -# -- Example Usage -- -# -# (I like to indent a bit &&fd ftags, for readability's sake, but you don't have to) -# -# &&file -# &&ft-text -# &&fd Notes -# &&fd 10 KB -# &&/files -# -# &&folder Math -# &&file -# &&ft-text -# &&fd Homework 1 -# &&file -# &&ft-text -# &&fd Homework 2 -# &&/files -# -# &&folder Art Project
-# Status: 70% complete
-# Note: Reserach Van Gogh paintings -# -# &&file -# &&fd Painting 1 -# &&fd 100% Complete -# -# &&file -# &&fd Painting 2 -# &&fd 40% Complete -# -# &&/files - -BEGIN { - fileStarted = 0 - noFolder = 1 - searchEndP = 0 # Used to remove trailing

in file row - - # Special formatting - nam[1] = "folder" - rep[1] = "
" - nam[2] = "file" - rep[2] = "" - nam[3] = "/files" # /files - rep[3] = "
" - 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] = "&&" nam[i] - if (index(nam[i], "ft") == 1) - rep[i] = "" - } -} - -function substitute(ind) { - gsub(/(

|<\/p>)/, "") - - # &&file - if (ind == 2 && fileStarted == 0) { - if (noFolder == 1) - gsub("&&file", "") - else - gsub("&&file", "
") - fileStarted = 1 - } - # &&/files - else if (ind == 3 && noFolder == 1) { - gsub("&&/files", "
") - } - # &&fd - else if (ind == 4) { - gsub(/&&fd[ \t]*/, "") - gsub(/$/, "") - } - else - gsub(pat[ind], rep[ind]) - - # &&folder - if (ind == 1) { - noFolder = 0 - searchEndP = 1 - } - # &&/files - else if (ind == 3) { - fileStarted = 0 - noFolder = 1 - } -} - -/^[ \t]*(

|)&&/ { - for (i = 1; i <= length(nam); i++) { - if (index($0, pat[i]) != 0) - substitute(i) - } -} - -searchEndP == 1 && /<\/p>/ { - gsub(/<\/p>/, "") - searchEndP = 0 -} - -{ - print -} diff --git a/generate-hooks/create-flags.awk b/generate-hooks/create-flags.awk deleted file mode 100644 index d07901d..0000000 --- a/generate-hooks/create-flags.awk +++ /dev/null @@ -1,31 +0,0 @@ -# -# == About == -# -# A collection of ftags that generate an image HTML tag, containing the specified -# flag. This is done, because these tags need to have the unzoomable class, which -# you can't specify in Markdown. - -# == ftags == -# -# &&gb Great Britain flag -# -# -- Placement/Flow -- -# -# They can reside absolutely anywhere in text. - -BEGIN { - flag[1] = "gb" - title[1] = "ENG" - - for (i = 1; i <= length(flag); i++) { - flagExp[i] = "&&" flag[i] - flagTag[i] = "\""" - } -} - -{ - for (i = 1; i <= length(flagExp); i++) { - gsub(flagExp[i], flagTag[i]) - } - print -} diff --git a/generate-hooks/create-header-anchors.awk b/generate-hooks/create-header-anchors.awk deleted file mode 100644 index f6d2815..0000000 --- a/generate-hooks/create-header-anchors.awk +++ /dev/null @@ -1,16 +0,0 @@ -# -# == About == -# -# ssg generates an id for every heading. That's why after every heading there -# can be a hyperlink to itself. However, because of the current styling, such a -# hyperlink is required (except for h1). - -/[ \t]*\"🔗\"") -} - -{ - print -} diff --git a/generate-hooks/create-pagenav.awk b/generate-hooks/create-pagenav.awk deleted file mode 100644 index d539837..0000000 --- a/generate-hooks/create-pagenav.awk +++ /dev/null @@ -1,48 +0,0 @@ -# -# == About == -# -# I call pagenav the stuff directly below the first h1. These include file dates -# and GitLab source link. -# Currently it only works for blog and tutorial pages. -# -# This is by far the most hard-coded and inefficient awk script in the generate-hooks. -# Creation and last edited dates are taken from git commits, and getting the correct info -# by file name can easily only be done with git log, which unfortunately is very slow. -# Another issue is that it depends on the build directories in build scripts, meaning -# it won't work without modification if you try to build it somewhere else. - -BEGIN { - fileCheck = ARGV[1] # FILENAME isn't available in BEGIN - - if (match(fileCheck, /(blog|tutorials)\/.*\//) == 0) { - found = 1 - } - else { - found = 0 - gsub(/^.*\/(synd|tiny.synd|website|tiny.website)\//, "", fileCheck); gsub(/\.html/, ".md", fileCheck) - - system("git log --follow --pretty=format:%ad --date=\"format:%d %B %Y\" -- src/" fileCheck " > /tmp/syndamiadotcom-pagenav") - - dateCreate = "" - dateEdited = "" - while ((getline < "/tmp/syndamiadotcom-pagenav") > 0) { - if (dateEdited == "") dateEdited = $0 - dateCreate = $0 - } - - elem = ORS \ -"

" ORS \ -" Created: " dateCreate " || Edited: " dateEdited "" ORS \ -" || GitLab source" ORS \ -"
" - } -} - -{ - print -} - -found == 0 && /