Initial commit

This commit is contained in:
2025-07-04 20:19:33 -04:00
parent ee79a276ee
commit 2d38c00f27
4 changed files with 87 additions and 0 deletions

45
rss.sh Executable file
View File

@ -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 '/<last.*$/Q')
<lastBuildDate>
${DATE}
</lastBuildDate>
<item>
<title>
${TITLE}
</title>
<link>
${WEBSITE_URL}/${LINK}
</link>
<guid>
$(uuidgen)
</guid>
<pubDate>
${DATE}
</pubDate>
<description>
${DESCRIPTION}
</description>
</item>
$(cat "${WEBROOT}/blog/feed.rss" | sed '1,29d')
EOF

10
update-recent-blog-posts.sh Executable file
View File

@ -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

28
webgen.sh Executable file
View File

@ -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

4
website.conf Normal file
View File

@ -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'