From 8dc7f8361fa2cec36d5837174034376e4ae39ca1 Mon Sep 17 00:00:00 2001 From: "Jean (east-high-Nerd)" Date: Fri, 22 May 2026 22:41:54 -0400 Subject: [PATCH] Updated variable names to lower/camel case --- rss.sh | 44 ++++++++++++++++++------------------- update-recent-blog-posts.sh | 6 ++--- webgen.sh | 20 ++++++++--------- website.conf.template | 8 +++---- 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/rss.sh b/rss.sh index 3fa1649..a5bbd7b 100755 --- a/rss.sh +++ b/rss.sh @@ -2,32 +2,32 @@ set -euo pipefail -BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")" -DATE="$(TZ=UTC date -R)" +baseDir="$(realpath "$(dirname "${0}")")" +date="$(TZ=UTC date -R)" -source "${BASEDIR}/website.conf" +source "${baseDir}/website.conf" shopt -s extglob -LINKS=($(find -P "${WEBROOT}/blog/" | grep 'index\.html' | grep -v 'blog/index\.html' | sed 's|index.html||g; s|.*/blog|blog|g' | sort)) +links=($(find -P "${webroot}/blog/" | awk '/index\.html/ && !/blog\/index\.html/ {sub(/index\.html/,"")sub(/.*\/blog/,"blog");print|"sort"}')) -MENU="@(${LINKS[0]}" +menu="@(${links[0]}" -for ((i=1;i<${#LINKS[@]};i++)); do - MENU+="|${LINKS[${i}]}" +for ((i=1;i<${#links[@]};i++)); do + menu+="|${links[${i}]}" done -MENU+=")" +menu+=")" printf 'Select the link you wish to use\n' -select LINK in "${LINKS[@]}" +select link in "${links[@]}" do - case ${LINK} in - ${MENU}) + case ${link} in + ${menu}) break ;; *) @@ -39,37 +39,37 @@ done shopt -u extglob -TITLE="$(cat "${WEBROOT}/${LINK}/index.html" | grep -A1 '' | grep '\[' | sed 's|.*\[ ||g; s| \| easthighNerd \].*||')" +title="$(cat "${webroot}/${link}/index.html" | awk '/<title>/{getline;print}' | sed 's|.*\[ ||g; s| \| easthighNerd \].*||')" printf 'Description of blog post:\n' -read -r DESCRIPTION +read -r description -cat "${WEBROOT}/blog/feed.rss" | sed '/<last.*$/Q' | tee "${WEBROOT}/blog/feed.rss.tmp" &> /dev/null +cat "${webroot}/blog/feed.rss" | sed '/<last.*$/Q' | tee "${webroot}/blog/feed.rss.tmp" &> /dev/null -cat << EOF | tee --append "${WEBROOT}/blog/feed.rss.tmp" &> /dev/null +cat << EOF | tee --append "${webroot}/blog/feed.rss.tmp" &> /dev/null <lastBuildDate> - ${DATE} + ${date} </lastBuildDate> <item> <title> - ${TITLE} + ${title} - ${WEBSITE_URL}/${LINK} + ${websiteUrl}/${link} $(uuidgen) - ${DATE} + ${date} - ${DESCRIPTION} + ${description} EOF -cat "${WEBROOT}/blog/feed.rss" | sed '1,29d' | tee --append "${WEBROOT}/blog/feed.rss.tmp" &> /dev/null +cat "${webroot}/blog/feed.rss" | sed '1,29d' | tee --append "${webroot}/blog/feed.rss.tmp" &> /dev/null -mv "${WEBROOT}/blog/feed.rss.tmp" "${WEBROOT}/blog/feed.rss" +mv "${webroot}/blog/feed.rss.tmp" "${webroot}/blog/feed.rss" diff --git a/update-recent-blog-posts.sh b/update-recent-blog-posts.sh index f2b7f75..4b24052 100755 --- a/update-recent-blog-posts.sh +++ b/update-recent-blog-posts.sh @@ -2,9 +2,9 @@ set -euo pipefail -BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")" +baseDir="$(realpath "$(dirname "${0}")")" -source "${BASEDIR}/website.conf" +source "${baseDir}/website.conf" -cat "${MARKDOWN_DIR}/blog.md" | sed 's|^5\..*||; s|^4\.|5\.|; s|^3\.|4\.|; s|^2\.|3\.|; s|^1\.|1\. \n2\.|' | tee "${MARKDOWN_DIR}/blog.md" &> /dev/null +cat "${markdownDir}/blog.md" | sed 's|^5\..*||; s|^4\.|5\.|; s|^3\.|4\.|; s|^2\.|3\.|; s|^1\.|1\. \n2\.|' | tee "${markdownDir}/blog.md" &> /dev/null diff --git a/webgen.sh b/webgen.sh index da65c3b..8a15483 100755 --- a/webgen.sh +++ b/webgen.sh @@ -2,27 +2,27 @@ set -euo pipefail -BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")" +baseDir="$(realpath "$(dirname "${0}")")" -source "${BASEDIR}/website.conf" +source "${baseDir}/website.conf" -for MARKDOWN_FILE in $(find -P "${MARKDOWN_DIR}/" | grep '\.md'); do - PAGE_DIR="${WEBROOT}/$(cat "${MARKDOWN_FILE}" | grep -m1 '^page_dir: ' | head -1 | sed 's|page_dir: ||; s|^/||')" - TEMPLATE="${TEMPLATE_DIR}/$(cat "${MARKDOWN_FILE}" | grep -m1 '^template: ' | head -1 | sed 's|template: ||').html" +for markdownFile in $(find -P "${markdownDir}/" | grep '\.md'); do + pageDir="${webroot}/$(cat "${markdownFile}" | grep -m1 '^page_dir: ' | head -1 | sed 's|page_dir: ||; s|^/||')" + template="${templateDir}/$(cat "${markdownFile}" | grep -m1 '^template: ' | head -1 | sed 's|template: ||').html" - if [[ ! -d "${PAGE_DIR}/" ]]; then + if [[ ! -d "${pageDir}/" ]]; then # Makes the folder the current page being (re)generated goes in if it does not already exist. mkdir \ -p \ - "${PAGE_DIR}/" + "${pageDir}/" fi # pandoc does its magic here pandoc \ --from markdown \ --to html \ - --template "${TEMPLATE}" \ - --output "${PAGE_DIR}/index.html" \ - "${MARKDOWN_FILE}" + --template "${template}" \ + --output "${pageDir}/index.html" \ + "${markdownFile}" done diff --git a/website.conf.template b/website.conf.template index 2d97f43..8fda7d1 100644 --- a/website.conf.template +++ b/website.conf.template @@ -1,4 +1,4 @@ -WEBROOT="" -MARKDOWN_DIR="" -TEMPLATE_DIR="" -WEBSITE_URL='https://www.example.net' +webroot="" +markdownDir="" +templateDir="" +websiteUrl='https://www.example.net'