diff options
| Commit | c58fcbfaa87274b7add52450816dfb478a354be9 (patch) | |
|---|---|---|
| Author | 2022-09-28 15:39:57 +0300 | |
| Committer | 2022-09-28 15:39:57 +0300 | |
| Files | 5df3cc38e97a7b4940f273e58c7177934ace1673 | |
| syndamia.com-c58fcbfaa87274b7add52450816dfb478a354be9.tar syndamia.com-c58fcbfaa87274b7add52450816dfb478a354be9.tar.gz syndamia.com-c58fcbfaa87274b7add52450816dfb478a354be9.zip | ||
| Parent | 415bddff456082ce36aa1ebeb5b88034303ea225 (diff) | |
[hooks] Reworked generate hooks to use a string of all files to work on, rather than having to find it
7 files changed, 14 insertions, 12 deletions
| -rwxr-xr-x | generate-dev.sh | 3 | ||||
| -rwxr-xr-x | generate-hooks/make-descriptions.sh | 4 | ||||
| -rwxr-xr-x | generate-hooks/make-file-lists.sh | 4 | ||||
| -rwxr-xr-x | generate-hooks/make-flags.sh | 4 | ||||
| -rwxr-xr-x | generate-hooks/make-presentation.sh | 4 | ||||
| -rwxr-xr-x | generate-hooks/make-titles.sh | 4 | ||||
| -rwxr-xr-x | generate.sh | 3 |
diff --git a/generate-dev.sh b/generate-dev.sh index ac61b04..8ed1fb2 100755 --- a/generate-dev.sh +++ b/generate-dev.sh @@ -12,8 +12,9 @@ sudo rm -f /var/www/synd/.files # Generate files sudo ssg src /var/www/synd/ "Syndamia" "https://www.syndamia.com" +allnormfiles=$(find '/var/www/synd' -type f -name "*.html") for file in $(find "./generate-hooks" -type f -name "*.sh"); do - sudo "$file" /var/www/synd + sudo "$file" "$allnormfiles" done # diff --git a/generate-hooks/make-descriptions.sh b/generate-hooks/make-descriptions.sh index 8268019..1ea7a9f 100755 --- a/generate-hooks/make-descriptions.sh +++ b/generate-hooks/make-descriptions.sh @@ -1,12 +1,11 @@ #!/bin/bash if [ -z "$1" ]; then - echo First parameter must be a path + echo First parameter must be string with file paths exit fi # Loop through all HTML files in given directory -for file in $(find "$1" -type f -name "*.html"); do # Get text that matches "p>any amount of characters</p" from current file # remove the "p>" and "</p" from result # make everything that starts with "<" blank @@ -20,6 +19,7 @@ for file in $(find "$1" -type f -name "*.html"); do # Escape all non-acceptable characters (thanks https://www.unix.com/302989284-post3.html) description=$(echo $description | sed 's/[^a-zA-Z 0-9]/\\&/g') +for file in $1; do # Replace all "[DESCRIPTION]" text in current file with what we selected (inside description) sed -i "s/\[DESCRIPTION\]/$description/g" $file diff --git a/generate-hooks/make-file-lists.sh b/generate-hooks/make-file-lists.sh index a930e9d..e407e19 100755 --- a/generate-hooks/make-file-lists.sh +++ b/generate-hooks/make-file-lists.sh @@ -49,11 +49,11 @@ # &&fod folder end if [ -z "$1" ]; then - echo First parameter must be a path + echo First parameter must be string with file paths exit fi -for file in $(find "$1" -type f -name "*.html"); do +for file in $1; do sed -i 's/&&nos$/<table class="file-list"><tr>/g; s/^<p>&&fos$/<details class="file-wrapper"><summary>/g; s/^&&fs0$/<\/summary><table class="file-list"><tr>/g; diff --git a/generate-hooks/make-flags.sh b/generate-hooks/make-flags.sh index 786671d..69d8952 100755 --- a/generate-hooks/make-flags.sh +++ b/generate-hooks/make-flags.sh @@ -7,11 +7,11 @@ # Great Britain - &&gb if [ -z "$1" ]; then - echo First parameter must be a path + echo First parameter must be string with file paths exit fi -for file in $(find "$1" -type f -name "*.html"); do +for file in $1; do # Replaces "&&gb" with "<img src="/img/gb.svg" class="unzoomable" alt="ENG" title="ENG">" sed -i 's/&&gb/<img src="\/img\/gb.svg" class="unzoomable" alt="ENG" title="ENG">/g' "$file" done diff --git a/generate-hooks/make-presentation.sh b/generate-hooks/make-presentation.sh index e219453..dab3243 100755 --- a/generate-hooks/make-presentation.sh +++ b/generate-hooks/make-presentation.sh @@ -26,7 +26,7 @@ # &&/fol Ends (the last started) fol. if [ -z "$1" ]; then - echo First parameter must be a path + echo First parameter must be string with file paths exit fi @@ -41,7 +41,7 @@ presentation=' presentation=$(echo $presentation | sed 's/\//\\\//g') # Loop through all HTML files in given directory -for file in $(find "$1" -type f -wholename "*talks/*.html"); do +for file in $(echo $1 | grep 'talks'); do sed -i "s/<p>&&presentation<\/p>/$presentation/g; s/<p>&&slide<\/p>/<div class=\"slide\">/g;s/<p>&&/slide<\/p>/<\/div>/g; s/<p>&&centered<\/p>/<div class=\"centered\">/g;s/<p>&&/centered<\/p>/<\/div>/g; diff --git a/generate-hooks/make-titles.sh b/generate-hooks/make-titles.sh index bf739ff..1c9ebef 100755 --- a/generate-hooks/make-titles.sh +++ b/generate-hooks/make-titles.sh @@ -1,18 +1,18 @@ #!/bin/bash if [ -z "$1" ]; then - echo First parameter must be a path + echo First parameter must be string with file paths exit fi # Loop through all HTML files in given directory -for file in $(find "$1" -type f -name "*.html"); do # Get text that matches "h1>any amount of characters</h1" from current file # remove the "h1>" and "</h1" from result title=$(egrep -o "h1(.+)>(.+)<\/h1" $file | sed "s/h1[^>]\+>\|<\/h1//g") # Escape all non-acceptable characters (thanks https://www.unix.com/302989284-post3.html) title=$(echo $title | sed 's/[^a-zA-Z 0-9]/\\&/g') +for file in $1; do # Replace all "[TITLE]" text in current file with what we selected (inside title) sed -i "s/\[TITLE\]/$title/g" $file diff --git a/generate.sh b/generate.sh index 9702766..b4535f5 100755 --- a/generate.sh +++ b/generate.sh @@ -13,8 +13,9 @@ rm -f website/.files # Generate files ssg src website "Syndamia" "https://syndamia.com" +allnormfiles=$(find './website' -type f -name "*.html") for file in $(find "./generate-hooks" -type f -name "*.sh"); do - "$file" website + "$file" "$allnormfiles" done # |