From c58fcbfaa87274b7add52450816dfb478a354be9 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Wed, 28 Sep 2022 15:39:57 +0300 Subject: [hooks] Reworked generate hooks to use a string of all files to work on, rather than having to find it --- generate-dev.sh | 3 ++- generate-hooks/make-descriptions.sh | 4 ++-- generate-hooks/make-file-lists.sh | 4 ++-- generate-hooks/make-flags.sh | 4 ++-- generate-hooks/make-presentation.sh | 4 ++-- generate-hooks/make-titles.sh | 4 ++-- generate.sh | 3 ++- 7 files changed, 14 insertions(+), 12 deletions(-) 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" and "/g; s/^

&&fos$/

/g; s/^&&fs0$/<\/summary>/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 "ENG" sed -i 's/&&gb/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/

&&presentation<\/p>/$presentation/g; s/

&&slide<\/p>/

/g;s/

&&/slide<\/p>/<\/div>/g; s/

&&centered<\/p>/

/g;s/

&&/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" and "(.+)<\/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 # -- cgit v1.3.1-26-gb76a