From 2d38c00f277255c3be3564d783bb06a28789dd3a Mon Sep 17 00:00:00 2001 From: "Jean (east-high-Nerd)" Date: Fri, 4 Jul 2025 20:19:33 -0400 Subject: [PATCH] Initial commit --- rss.sh | 45 +++++++++++++++++++++++++++++++++++++ update-recent-blog-posts.sh | 10 +++++++++ webgen.sh | 28 +++++++++++++++++++++++ website.conf | 4 ++++ 4 files changed, 87 insertions(+) create mode 100755 rss.sh create mode 100755 update-recent-blog-posts.sh create mode 100755 webgen.sh create mode 100644 website.conf diff --git a/rss.sh b/rss.sh new file mode 100755 index 0000000..e40d5fd --- /dev/null +++ b/rss.sh @@ -0,0 +1,45 @@ +#!/bin/bash +set -euo pipefail + + +BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")" +DATE="$(date -R)" + +source "${BASEDIR}/website.conf" + + +printf 'Title of blog post:\n' +read -r TITLE + +printf 'Link to blog post:\n' +read -r LINK +LINK="$(printf "${LINK}" | sed 's|^/||')" + +printf 'Description of blog post:\n' +read -r DESCRIPTION + + +cat << EOF | tee "${WEBROOT}/blog/feed.rss" &> /dev/null +$(cat "${WEBROOT}/blog/feed.rss" | sed '/ + ${DATE} + + + + ${TITLE} + + + ${WEBSITE_URL}/${LINK} + + + $(uuidgen) + + + ${DATE} + + + ${DESCRIPTION} + + +$(cat "${WEBROOT}/blog/feed.rss" | sed '1,29d') +EOF diff --git a/update-recent-blog-posts.sh b/update-recent-blog-posts.sh new file mode 100755 index 0000000..e664b7e --- /dev/null +++ b/update-recent-blog-posts.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -euo pipefail + + +BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")" + +source "${BASEDIR}/website.conf" + + +cat "${WEBROOT}/_markdown/blog.md" | sed 's|^5\..*||; s|^4\.|5\.|; s|^3\.|4\.|; s|^2\.|3\.|; s|^1\.|1\. \n2\.|' | tee "${WEBROOT}/_markdown/blog.md" &> /dev/null diff --git a/webgen.sh b/webgen.sh new file mode 100755 index 0000000..da65c3b --- /dev/null +++ b/webgen.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -euo pipefail + + +BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")" + +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" + + if [[ ! -d "${PAGE_DIR}/" ]]; then + # Makes the folder the current page being (re)generated goes in if it does not already exist. + mkdir \ + -p \ + "${PAGE_DIR}/" + fi + + # pandoc does its magic here + pandoc \ + --from markdown \ + --to html \ + --template "${TEMPLATE}" \ + --output "${PAGE_DIR}/index.html" \ + "${MARKDOWN_FILE}" +done diff --git a/website.conf b/website.conf new file mode 100644 index 0000000..dd5ce7c --- /dev/null +++ b/website.conf @@ -0,0 +1,4 @@ +WEBROOT="${HOME}/Projects/Website" +MARKDOWN_DIR="${HOME}/Projects/Website-Sources/_markdown" +TEMPLATE_DIR="${HOME}/Projects/Website-Sources/_template" +WEBSITE_URL='https://www.easthighnerd.net'