aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitali64 <vitali64pmemail@protonmail.com>2021-12-23 19:30:03 +0100
committerVitali64 <vitali64pmemail@protonmail.com>2021-12-23 19:30:03 +0100
commit5f1f59214ddafe12906d76ee68a980505e3f69b4 (patch)
tree1fc596ed3d9fd608d4d576c4f690c77380dc0547
parentd5e389a570c724b568763df7b55440d7c9c28c4b (diff)
downloadseen-5f1f59214ddafe12906d76ee68a980505e3f69b4.tar.gz
seen-5f1f59214ddafe12906d76ee68a980505e3f69b4.zip
Minor tweaks, and add RSS support
-rw-r--r--articles/Hello_World.md2
-rwxr-xr-xrs.sh63
-rw-r--r--rss.cfg6
-rwxr-xr-xseen.sh51
4 files changed, 104 insertions, 18 deletions
diff --git a/articles/Hello_World.md b/articles/Hello_World.md
index f29ea98..788d2a0 100644
--- a/articles/Hello_World.md
+++ b/articles/Hello_World.md
@@ -13,3 +13,5 @@ Thanks for using `seen`.
`seen` is licensed under the GNU GPLv3 License as published by the FSF,
for more information, please read the LICENSE file at the root of the repo.
+
+~ Vitali64
diff --git a/rs.sh b/rs.sh
new file mode 100755
index 0000000..19255fd
--- /dev/null
+++ b/rs.sh
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+# Seen, a simple static blog generator
+#
+# Copyright (C) 2021 Vitali64 <vitali64pmemail@protonmail.com>
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+die() {
+ echo "-> [$(date +%R)] (!) ERROR: Unexpected error, please report : $1 (!)"
+ exit 1
+}
+
+# Articles
+articles="$(find articles/*.md|sed -e 's@.md@@g' -e 's@articles/@@g')" || die "Unknown error"
+
+echo "Copyright (C) 2021 Vitali64 <vitali64pmemail@protonmail.com>"
+echo "This program comes with ABSOLUTELY NO WARRANTY."
+echo "This is free software, and you are welcome to modify it,"
+echo "use it where you see fit, and redistribute it"
+echo "under certain conditions; type './seen.sh --license' for details."
+echo
+echo "-> [$(date +%R)] Generating RSS feed ..."
+
+touch "www/rss.xml"
+
+# Set the defaults
+rssBlogTitle="blog"
+rssBlogDescription="It's a blog"
+. "./rss.cfg" # Override the defaults
+# Header of the RSS XML file
+echo "-> [$(date +%R)] Inserting XML header ..."
+printf '%s\n' '<rss version="2.0">' > "www/rss.xml"
+printf '%s\n' '<channel>' >> "www/rss.xml"
+printf '%s\n' "<title>${rssBlogTitle}</title>" >> "www/rss.xml"
+printf '%s\n' "<link>BLANK</link>" >> "www/rss.xml"
+printf '%s\n' "<description>$rssBlogDescription</description>" >> "www/rss.xml"
+
+# Items
+for line in ${articles}
+do
+ echo "-> [$(date +%R)] Inserting XML ${line} item ..."
+ . "articles/${line}.cfg"
+ printf '%s\n' '<item>' >> "www/rss.xml"
+ printf '%s\n' "<title>${name}</title>" >> "www/rss.xml"
+ printf '%s\n' "<description>$(cat articles/${line}.md)</description>" >> "www/rss.xml"
+ printf '%s\n' '</item>' >> "www/rss.xml"
+done
+
+# Footer of the RSS XML file
+echo "-> [$(date +%R)] Inserting XML footer ..."
+printf '%s\n' '</channel>' >> "www/rss.xml"
+printf '%s\n' '</rss>' >> "www/rss.xml"
+
+echo "-> [$(date +%R)] RSS generation done!"
diff --git a/rss.cfg b/rss.cfg
new file mode 100644
index 0000000..ff0b896
--- /dev/null
+++ b/rss.cfg
@@ -0,0 +1,6 @@
+# This is for your RSS configuration.
+# RSS is optional and is in a separate
+# script you need to run manually.
+
+rssBlogTitle="blog"
+rssBlogDescription="It's a blog"
diff --git a/seen.sh b/seen.sh
index 0ecf446..16bc980 100755
--- a/seen.sh
+++ b/seen.sh
@@ -2,7 +2,7 @@
# Seen, a simple static blog generator
#
-# Copyright (C) 2021 Vitali64 <vitali64pmemail@protonmail.com
+# Copyright (C) 2021 Vitali64 <vitali64pmemail@protonmail.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@@ -15,11 +15,13 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
usage() {
- echo "Usage : ./seen [OPTIONS]"
+ echo "Usage : ./seen [OPTIONS]"
echo
- echo "--help : Print this help message"
- echo "--clear : Remove generated blog"
- echo "--rm : Remove everything and start from scratch"
+ echo "--help : Print this help message"
+ echo "--clear : Remove generated blog"
+ echo "--rm : Remove everything and start from scratch"
+ echo "--license : Show license"
+ echo "--rss : Create an RSS feed (runs ./rs.sh)"
}
die() {
@@ -28,19 +30,7 @@ die() {
}
echo "Seen, a simple static blog generator"
-echo " Copyright (C) 2021 Vitali64 <vitali64pmemail@protonmail.com"
-echo " This program is free software: you can redistribute it and/or modify"
-echo " it under the terms of the GNU General Public License as published by"
-echo " the Free Software Foundation, either version 3 of the License, or"
-echo " (at your option) any later version."
-echo
-echo " This program is distributed in the hope that it will be useful,"
-echo " but WITHOUT ANY WARRANTY; without even the implied warranty of"
-echo " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
-echo " GNU General Public License for more details."
-echo
-echo " You should have received a copy of the GNU General Public License"
-echo " along with this program. If not, see <https://www.gnu.org/licenses/>."
+echo
if [ "$1" = "--clear" ]; then
echo "-> [$(date +%R)] Deleting generated blog ..."
@@ -53,6 +43,25 @@ elif [ "$1" = "--rm" ]; then
elif [ "$1" = "--help" ]; then
usage
exit 0
+elif [ "$1" = "--rss" ]; then
+ . "./rs.sh"
+ exit 0
+elif [ "$1" = "--license" ]; then
+ echo "Copyright (C) 2021 Vitali64 <vitali64pmemail@protonmail.com>"
+ echo
+ echo "This program is free software: you can redistribute it and/or modify"
+ echo "it under the terms of the GNU General Public License as published by"
+ echo "the Free Software Foundation, either version 3 of the License, or"
+ echo "(at your option) any later version."
+ echo
+ echo "This program is distributed in the hope that it will be useful,"
+ echo "but WITHOUT ANY WARRANTY; without even the implied warranty of"
+ echo "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
+ echo "GNU General Public License for more details."
+ echo
+ echo "You should have received a copy of the GNU General Public License"
+ echo "along with this program. If not, see <https://www.gnu.org/licenses/>."
+ exit 0
elif [ "$1" = "" ]; then
echo "-> [$(date +%R)] No options specified, generating blog ..."
else
@@ -61,6 +70,12 @@ else
exit 1
fi
+echo "Copyright (C) 2021 Vitali64 <vitali64pmemail@protonmail.com>"
+echo "This program comes with ABSOLUTELY NO WARRANTY."
+echo "This is free software, and you are welcome to modify it,"
+echo "use it where you see fit, and redistribute it"
+echo "under certain conditions; type './seen.sh --license' for details."
+
# Create the www/ folder if removed
mkdir -p "www" || die "Cannot create www/ directory: mkdir -p returns an error!"