From 76a3d50d6cdddfd5546624b625ebffad1443db58 Mon Sep 17 00:00:00 2001 From: Paul Dino Jones Date: Tue, 22 Jun 2021 13:47:02 -0400 Subject: [PATCH] Initial commit for BoomerCMS --- .gitignore | 7 +++ generate.sh | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++ readme.md | 24 ++++++++++ settings.sh | 12 +++++ 4 files changed, 177 insertions(+) create mode 100644 .gitignore create mode 100755 generate.sh create mode 100644 readme.md create mode 100644 settings.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..31eac56 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +web/* +*.html +index.groff +now.groff + + +## Category Pages diff --git a/generate.sh b/generate.sh new file mode 100755 index 0000000..79abe0c --- /dev/null +++ b/generate.sh @@ -0,0 +1,134 @@ +#!/bin/sh + +mkdir -p web + +. ./settings.sh + +DateStamp() { + sed -i '$ d' $1 + echo -n "

Page Last Edited: " >> $1 + echo -n "$2" | sed -s 's/Date: //' >> $1 + echo "

" >> $1 + echo -n "" >> $1 + +} + +# CAT comes from settings.sh +GetCategory() { + USECATEGORY=$1 + for i in $(seq 1 $CATCOUNT) + do + A=CAT$i + B=CATNAME$i + A=$(eval echo \$$A) + B=$(eval echo \$$B) + test "$1" = "$A" && USECATEGORY="$B" + test "$1" = "$B" && USECATEGORY="$1" + done +} + +# create index page +rm index.groff +custom_index=`cat index_custom.groff` +echo ".B \"""$SITEDESCRIPTION""\"" >> index.groff +echo "" >> index.groff +echo ".MTO "$MAILTO >> index.groff +echo "" >> index.groff +for i in $(seq 1 $CATCOUNT) +do + A=CAT$i + B=CATNAME$i + A=$(eval echo \$$A) + B=$(eval echo \$$B) + PAGEFILENAME=$(echo "$A" | tr '[A-Z]' '[a-z]') + echo ".URL "$PAGEFILENAME".html \""$B"\"" >> index.groff + echo "" >> index.groff +done +cat index_custom.groff >> index.groff +# generate index page +groff -ms -mwww -T html index.groff > web/index.html + +# generate sub pages +for i in $(seq 1 $CATCOUNT) +do + A=CAT$i + B=CATNAME$i + A=$(eval echo \$$A) + B=$(eval echo \$$B) + PAGEFILENAME=$(echo "$A" | tr '[A-Z]' '[a-z]') + rm -f "$PAGEFILENAME".groff + test -f "$PAGEFILENAME"_custom.groff && cat "$PAGEFILENAME"_custom.groff >> $PAGEFILENAME.groff + echo "" >> $PAGEFILENAME.groff + echo ".B \"Recent Posts\"" >> $PAGEFILENAME.groff + for f in posts/*/*/* + do + LINK=$(echo $f | sed "s/.groff/.html/g") + CATEGORY=$(grep -r -m1 ".CAT" "$f" | sed "s/.CAT //g") + TITLE=$(grep -r -m1 ".TL" "$f" | sed "s/.TL/ /g" | sed "s/_/ /g") + test "$CATEGORY" = "$A" && echo "" >> $PAGEFILENAME.groff + test "$CATEGORY" = "$B" && echo "" >> $PAGEFILENAME.groff + test "$CATEGORY" = "$A" && echo -n ".URL " >> $PAGEFILENAME.groff + test "$CATEGORY" = "$A" && echo -n $LINK" " >> $PAGEFILENAME.groff + test "$CATEGORY" = "$B" && echo -n ".URL " >> $PAGEFILENAME.groff + test "$CATEGORY" = "$B" && echo -n $LINK" " >> $PAGEFILENAME.groff + test "$CATEGORY" = "$A" && echo "\""$TITLE"\"" >> $PAGEFILENAME.groff + test "$CATEGORY" = "$B" && echo "\""$TITLE"\"" >> $PAGEFILENAME.groff + done + rm -f web/$PAGEFILENAME.html + groff -ms -mwww -T html $PAGEFILENAME.groff > web/$PAGEFILENAME.html +done + +# turn posts into html +for f in posts/*/*/* + do + mkdir -p "web/"$(dirname $f)"/" + GENERATED="web/"$(dirname $f)"/"$(basename $f .groff).html + + groff -ms -mwww -T html $f > $GENERATED + #groff -ms -mwww -T html $f > "web/"$(dirname $f)"/"$(basename $f .groff).html + + DateStamp $GENERATED "$(git log -1 --date=format:'%Y-%m-%d %H:%M:%S' -- $f | tail -n3 | head -n1)" +done + +# datesstamp htmls +for f in web/*.html + do + useDate="$(git log --date=format:'%Y-%m-%d %H:%M:%S' -1 -- $(basename $f .html)_custom.groff | tail -n3 | head -n1)" + test "$useDate" = "" && useDate="$(date +'%Y-%m-%d %H:%M:%S')" + DateStamp $f "$useDate" +done + +rm -f now.groff +grep -r ".TL" posts/ | sed "s/.groff/.html/g" | sed "s/posts/\n.URL posts/g" | sed "s/:.TL / /g" >> now.groff +groff -ms -mwww -T html now.groff > web/now.html +DateStamp web/now.html "$(date +'%Y-%m-%d %H:%M:%S')" + +echo " + $SITENAME + $SITENAME + $SITEADDRESS + $SITEDESCRIPTION + BoomerCMS" > web/rss.xml +for f in posts/*/*/* + do + USECATEGORY= + GENERATED="/"$(dirname $f)"/"$(basename $f .groff).html + DATE=$(git log --date=rfc --diff-filter=A -- "$f" | grep "Date:"| sed "s/Date: //g") + echo " " >> web/rss.xml + SPACES=" " + TITLE=$(grep -r -m1 ".TL" "$f" | sed "s/.TL //g" | sed "s/_/ /g") + CATEGORY=$(grep -r -m1 ".CAT" "$f" | sed "s/.CAT //g") + AUTHOR=$(grep -r -m1 ".AU" "$f" | sed "s/.AU //g") + GetCategory $CATEGORY + echo "$SPACES$TITLE" >> web/rss.xml + echo "$SPACES$SITEADDRESS$GENERATED" >> web/rss.xml + echo "$SPACES$TITLE" >> web/rss.xml + echo "$SPACES$AUTHOR" >> web/rss.xml + echo "$SPACES$USECATEGORY" >> web/rss.xml + echo "$SPACES$DATE" >> web/rss.xml + echo "$SPACES$SITEADDRESS$GENERATED" >> web/rss.xml + echo " " >> web/rss.xml + done +echo " " >> web/rss.xml +echo "" >> web/rss.xml + diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..97813d7 --- /dev/null +++ b/readme.md @@ -0,0 +1,24 @@ +# BoomerCMS +A content management system that restores the glory of the past. + +1. Groff Based - write pages in [groff](https://www.gnu.org/software/groff/) syntax - using ms and www macro packages +2. Shell Only - html and rss feed is generated by a shell script - POSIX shell complient! - NO BASH! +3. No JS or CSS by default + +# Rationale +Social Media has taken the world by storm, and we think it is not the best for society. Inspired by the [blog post](http://spacefreak18.xyz) we invision +a world where we use free and open and pre existing internet technologies. RSS feeds for status updates instead of Twitter, Email/Xmpp for chat instead +of WhatsApp (or DMs), and a personal web page instead of a Facebook. This project attempts to fill that need of simple, minimal, bloat-free web pages. +It started life as just a shell script I was using to generate my site, and I made a few generalizations and enhancements to make it useable for a +wider audience. + +# Setup +1. Fork this repo +2. Modify settings.sh to your preferences. Do not create files with the same name as the pretty name for your categories. BoomerCMS automatically +generates the file groff file. I recommend adding those to your .gitignore. +3. Put custom content into the posts directory and in the parent directory in files named with the structure MyCategory_custom.groff +4. Refer to the sample site and sample repo. + +# Installation +Setup your webserver to point to the location of your forked BoomerCMS repository with correct privileges. +Optionally setup a cronjob to automatically run git pull and generate.sh for automated periodic deploys. diff --git a/settings.sh b/settings.sh new file mode 100644 index 0000000..2f07bbb --- /dev/null +++ b/settings.sh @@ -0,0 +1,12 @@ +SITENAME="My Website" +SITEADDRESS=https://example.com +SITEDESCRIPTION="My Personal Web Pages" +MAILTO=me@example.com + +CATCOUNT=3 +CAT1=ABOUT +CATNAME1="About Me" +CAT2=HOBBIES +CATNAME2="My Hobbies" +CAT3=EXAMPLE +CATNAME3="Example Category"