Summary Files Commits Branches @commit @diff @stats
path: root / generate-hooks / make-descriptions.sh
diff options
context:
space:
mode:
Commit62daf522a1e51c4a1d9d8b31d2a0093da86ebc5d (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-09-28 17:15:36 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-09-29 17:40:09 +0300
Files7474bc314afde18b6e53bb6702f54a04c5a87ed1 /generate-hooks/make-descriptions.sh
syndamia.com-62daf522a1e51c4a1d9d8b31d2a0093da86ebc5d.tar
syndamia.com-62daf522a1e51c4a1d9d8b31d2a0093da86ebc5d.tar.gz
syndamia.com-62daf522a1e51c4a1d9d8b31d2a0093da86ebc5d.zip
Parenta8b5c3c03b37ebf90e7ee8c9cb7c8f913f50c79a (diff)
[hooks] Reworked all hooks to use awk for their logic
1 files changed, 3 insertions, 13 deletions
-rwxr-xr-xgenerate-hooks/make-descriptions.sh16
diff --git a/generate-hooks/make-descriptions.sh b/generate-hooks/make-descriptions.sh
index 1ea7a9f..9895f2e 100755
--- a/generate-hooks/make-descriptions.sh
+++ b/generate-hooks/make-descriptions.sh
@@ -5,21 +5,11 @@ if [ -z "$1" ]; then
exit
fi
-# Loop through all HTML files in given directory
- # 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
- # take all lines that aren't blank
- description=$(egrep -o "p>[^&]([^&]+)<\/p" $file | sed "s/p>\|<\/p//g;s/<.*//g" | grep .)
-
- # Get the first 200 characters only when it's longer than 200 characters
- if [ ${#description} -gt 200 ]; then
- description="${description::200}..."
- fi
+awkloc="$(dirname "$0")/create-description.awk"
- # Escape all non-acceptable characters (thanks https://www.unix.com/302989284-post3.html)
- description=$(echo $description | sed 's/[^a-zA-Z 0-9]/\\&/g')
+# Loop through all HTML files in given directory
for file in $1; do
+ description=$(awk -f "$awkloc" $file)
# Replace all "[DESCRIPTION]" text in current file with what we selected (inside description)
sed -i "s/\[DESCRIPTION\]/$description/g" $file