diff options
Created a script that generates the head element descriptions
4 files changed, 42 insertions, 3 deletions
| -rwxr-xr-x | generate-dev.sh | 10 | ||||
| -rwxr-xr-x | generate.sh | 7 | ||||
| -rwxr-xr-x | make-descriptions.sh | 24 | ||||
| -rw-r--r-- | src/_header.html | 4 |
diff --git a/generate-dev.sh b/generate-dev.sh index 5482c64..c29f5b6 100755 --- a/generate-dev.sh +++ b/generate-dev.sh @@ -1,7 +1,15 @@ #! /bin/sh +# Make folder if it doesn't exist if [ ! -d "/var/www/synd" ]; then - sudo -u www-data mkdir /var/www/synd + # User should be www-data (like in generate.sh), but I use Fedora and root is the default one + sudo -u root mkdir /var/www/synd fi + +# Remove record of previously generated files sudo rm -f /var/www/synd/.files + +# Generate files sudo ssg6 src /var/www/synd/ "Syndamia" "https://www.syndamia.com" + +sudo ./make-descriptions.sh /var/www/synd diff --git a/generate.sh b/generate.sh index 5cbbf5b..941a31d 100755 --- a/generate.sh +++ b/generate.sh @@ -1,7 +1,14 @@ #! /bin/sh +# Make folder if it doesn't exist if [ ! -d "website" ]; then sudo -u www-data mkdir website fi + +# Remove record of previously generated files sudo rm -f website/.files + +# Generate files sudo ssg6 src website "Syndamia" "https://www.syndamia.com" + +sudo ./make-descriptions.sh website diff --git a/make-descriptions.sh b/make-descriptions.sh new file mode 100755 index 0000000..44fcdcf --- /dev/null +++ b/make-descriptions.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo First parameter must be a path + 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 lines that start with "<" blank + # take all lines that aren't blank + description=$(egrep -o "p>(.+)<\/p" $file | sed "s/p>\|<\/p//g" | sed "s/^<.*//g" | grep .) + + # Get the first 200 characters + description=${description::200} + + # Escape all non-acceptable characters (thanks https://www.unix.com/302989284-post3.html) + description=$(echo $description | sed 's/[^a-zA-Z 0-9]/\\&/g') + + # Replace all "[DESCRIPTION]" text in current file with what we selected (inside description) + sed -i "s/\[DESCRIPTION\]/$description/g" $file +done diff --git a/src/_header.html b/src/_header.html index 02b7d22..fd19cd7 100644 --- a/src/_header.html +++ b/src/_header.html @@ -10,10 +10,10 @@ <meta name="theme-color" content="#ffffff"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="/styles.css"> - <meta name="description" content="My name is Kamen Mladenov and I am a programming student. Here I will share programming knowledge as well as information about myself and my coding adventures."> + <meta name="description" content="[DESCRIPTION]"> <meta property="og:type" content="website"> <meta property="og:title" content="Syndamia - Kamen Mladenov"> - <meta property="og:description" content="My name is Kamen Mladenov and I am a programming student. Here I will share programming knowledge as well as information about myself and my coding adventures."> + <meta property="og:description" content="[DESCRIPTION]"> <meta property="og:image" content="https://syndamia.com/img/meta-banner.png"> <meta property="og:url" content="https://syndamia.com"> <title></title> |