Summary Files Commits Branches @commit @diff @stats
path: root / generate-hooks / create-description.awk
diff options
context:
space:
mode:
Commit0187e255a811bebb0dad3624f2c6d78b829d15c5 (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-01-17 16:15:28 +0200
Committer
 Syndamia <kamen@syndamia.com>
2023-01-17 16:15:28 +0200
Files68efd3520e72c8c8c553fdda7b9391d9ec4e9feb /generate-hooks/create-description.awk
syndamia.com-0187e255a811bebb0dad3624f2c6d78b829d15c5.tar
syndamia.com-0187e255a811bebb0dad3624f2c6d78b829d15c5.tar.gz
syndamia.com-0187e255a811bebb0dad3624f2c6d78b829d15c5.zip
Parentda000c477625bb533688df84bd95ba3a3aff3246 (diff)
[awk] Reworked generation to happen via a combined script, updated scripts and added info in scripts readme
1 files changed, 0 insertions, 40 deletions
-rw-r--r--generate-hooks/create-description.awk40
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("&#8217;", "'", 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, "<p") > 0)
- stop = appToDesc($0)
- }
- close(ARGV[1]) # FILENAME isn't set during BEGIN
-}
-
-"\\[DESCRIPTION\\]" {
- gsub("\\[DESCRIPTION\\]", desc)
-}
-
-{
- print
-}