aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitali64 <vitali64pmemail@protonmail.com>2022-01-07 12:27:28 +0100
committerVitali64 <vitali64pmemail@protonmail.com>2022-01-07 12:27:28 +0100
commit9c249fe503b27a6b8aa9d80f7b6f69d0f3f0b17e (patch)
tree2868d77dadb669cd0319302d7bb917e056a1d336
parentbfd21f4ff1876fb8060e8b03fde37b1f0851a943 (diff)
downloadseen-9c249fe503b27a6b8aa9d80f7b6f69d0f3f0b17e.tar.gz
seen-9c249fe503b27a6b8aa9d80f7b6f69d0f3f0b17e.zip
add rss on the same seen.sh script
I don't know why I added RSS on a separate script but now, it's all on *1* script. That makes seen smaller.
-rw-r--r--README.md17
-rwxr-xr-xrs.sh36
-rw-r--r--rss.cfg5
-rwxr-xr-xseen.sh38
4 files changed, 43 insertions, 53 deletions
diff --git a/README.md b/README.md
index 83f6cd5..189a442 100644
--- a/README.md
+++ b/README.md
@@ -12,24 +12,28 @@
- Works on BSD systems (such as MacOS and OpenBSD)
-- Only depends on `markdown`/`hoedown`
+- Depends on pandoc
- Less than 100 SLOC
### How to use
-First, install `markdown` or `hoedown` because this script uses it heavily.
+First, install `markdown`/`hoedown` because this script uses it heavily.
Put your markdown files on `articles/<name of file>.md` (create the directory if it doesn't exist).
-You also need to create a config file. Put it in `articles/<name of file>.cfg`. It should use the same name your markdown file uses.
-
-Example :
+You also need to create a config file. Put it in `articles/<name of file>.cfg`. It should use the same name your markdown file uses:
name="Hello World"
desc="Welcome to my blog!"
date="9th December 2021"
+You can create RSS feeds too, just modify the `rss.cfg` file to your liking:
+
+ rssEnabled="y" # Enable RSS
+ rssBlogTitle="foobar's blog"
+ rssBlogDescription="foobar loves cooking!!!!!!!"
+
And run the following:
$ chmod +x seen.sh
@@ -44,6 +48,3 @@ Seen supports other options too, for more info, run the following:
$ ./seen.sh --help
-You can create RSS feeds too, just modify the `rss.cfg` file to your liking and:
-
- $ ./seen.sh --rss
diff --git a/rs.sh b/rs.sh
deleted file mode 100755
index bfd63da..0000000
--- a/rs.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/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.
-# Please see the LICENSE file for more details.
-die() {
- echo "-> [$(date +%R)] (!) ERROR: Unexpected error, please report : $1 (!)"
- exit 1
-}
-articles="$(find articles/*.md|sed -e 's@.md@@g' -e 's@articles/@@g')" || die "Unknown error" # Articles
-echo "-> [$(date +%R)] Generating RSS feed ..."
-# Set the defaults
-rssBlogTitle="blog"
-rssBlogDescription="It's a blog"
-. "./rss.cfg" # Override the defaults
-# Header of the RSS XML file
-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"
-for line in ${articles} # Items
-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
-printf '%s\n' '</channel>' >> "www/rss.xml"
-printf '%s\n' '</rss>' >> "www/rss.xml"
diff --git a/rss.cfg b/rss.cfg
index ff0b896..69a1b47 100644
--- a/rss.cfg
+++ b/rss.cfg
@@ -1,6 +1,7 @@
# This is for your RSS configuration.
-# RSS is optional and is in a separate
-# script you need to run manually.
+# RSS is optional. If you want RSS, simply
+# set the `rssEnabled` variable to `y`
+rssEnabled="n"
rssBlogTitle="blog"
rssBlogDescription="It's a blog"
diff --git a/seen.sh b/seen.sh
index b6e68c9..5e12b2d 100755
--- a/seen.sh
+++ b/seen.sh
@@ -11,7 +11,6 @@ usage() {
echo "--help : Print this help message"
echo "--clear : Remove generated blog"
echo "--license : Show license"
- echo "--rss : Create an RSS feed (runs ./rs.sh)"
}
die() {
echo "-> [$(date +%R)] (!) ERROR: Unexpected error, please report : $1 (!)"
@@ -25,22 +24,20 @@ if [ "$1" = "--clear" ]; 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
cat "./LICENSE"
exit 0
elif [ "$1" = "" ]; then
- echo "-> [$(date +%R)] No options specified, generating blog ..."
+ echo
else
echo "-> [$(date +%R)] (!) ERROR : Invalid option, cannot continue. (!)"
usage
exit 1
fi
mkdir -p "www" || die "Cannot create www/ directory: mkdir -p returns an error!" # Create the www/ folder if removed
+# ---HTML---
cat "templates/header.html" > www/index.html || die "Cannot insert header into index.html!" # Erase www/index.html and insert the header
articles="$(find articles/*.md|sed -e 's@.md@@g' -e 's@articles/@@g')" || die "Unknown error" # Detect articles
# Set the defaults
@@ -56,8 +53,35 @@ do
cat "templates/footer.html" >> "www/articles/${line}.html" || die "Cannot insert footer into ${line}.html!" # Insert the footer into the article page
cp -r templates/*.css www/. # Add css files if present
echo "-> [$(date +%R)] Adding ${line} entry to index.html ..." # Add an entry in index.html
- sed -e "s@path-of-article@articles/${line}@" -e "s@name-of-article@${name}@" \
- -e "s@date-of-article@${date}@" -e "s@description-of-article@${desc}@" \
+ sed -e "s@path-of-article@articles/${line}@" -e "s@name-of-article@${name}@" -e "s@date-of-article@${date}@" -e "s@description-of-article@${desc}@" \
"templates/article.html">> "www/index.html" || die "Cannot add entry to index.html!"
done
cat "templates/footer.html" >> "www/index.html" # Insert the footer into the index.html
+# ---RSS---
+# Set the defaults
+rssEnabled="n"
+rssBlogTitle="blog"
+rssBlogDescription="It's a blog"
+. "./rss.cfg" # Override the defaults
+if [ "${rssEnabled}" = "n" ]; then
+ echo "-> [$(date +%R)] RSS is disabled, skipping..."
+ exit 0
+fi
+# Header of the RSS XML file
+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"
+for line in ${articles} # Items
+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
+printf '%s\n' '</channel>' >> "www/rss.xml"
+printf '%s\n' '</rss>' >> "www/rss.xml"