aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitali64 <vitali64pmemail@protonmail.com>2021-12-23 20:16:37 +0100
committerVitali64 <vitali64pmemail@protonmail.com>2021-12-23 20:16:37 +0100
commit4f2d203efe9920a98f766dab7fbb708648ccfdcb (patch)
tree758ef8e8fe9f17c6111748603cd2362aff6582a9
parent1c8799a5dc7635fdeea9ea2b17c3a45ecb5c538f (diff)
downloadseen-4f2d203efe9920a98f766dab7fbb708648ccfdcb.tar.gz
seen-4f2d203efe9920a98f766dab7fbb708648ccfdcb.zip
Try reducing number of lines to <100 SLOC
-rwxr-xr-xrs.sh14
-rwxr-xr-xseen.sh32
2 files changed, 12 insertions, 34 deletions
diff --git a/rs.sh b/rs.sh
index d037cc8..bfd63da 100755
--- a/rs.sh
+++ b/rs.sh
@@ -5,20 +5,13 @@
# 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/>.
+# Please see the LICENSE file for more details.
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"
+articles="$(find articles/*.md|sed -e 's@.md@@g' -e 's@articles/@@g')" || die "Unknown error" # Articles
echo "-> [$(date +%R)] Generating RSS feed ..."
-touch "www/rss.xml"
# Set the defaults
rssBlogTitle="blog"
rssBlogDescription="It's a blog"
@@ -29,8 +22,7 @@ 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}
+for line in ${articles} # Items
do
echo "-> [$(date +%R)] Inserting XML ${line} item ..."
. "articles/${line}.cfg"
diff --git a/seen.sh b/seen.sh
index 5653dd7..b6e68c9 100755
--- a/seen.sh
+++ b/seen.sh
@@ -5,12 +5,7 @@
# 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/>.
+# Please see the LICENSE file for more details.
usage() {
echo "Usage : ./seen [OPTIONS]"
echo "--help : Print this help message"
@@ -45,18 +40,14 @@ else
usage
exit 1
fi
-# Create the www/ folder if removed
-mkdir -p "www" || die "Cannot create www/ directory: mkdir -p returns an error!"
-# Erase www/index.html and insert the header
-cat "templates/header.html" > www/index.html || die "Cannot insert header into index.html!"
-# Detect articles
-articles="$(find articles/*.md|sed -e 's@.md@@g' -e 's@articles/@@g')" || die "Unknown error"
+mkdir -p "www" || die "Cannot create www/ directory: mkdir -p returns an error!" # Create the www/ folder if removed
+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
name="(!) no name (!)"
desc="(!) no description (!)"
date="1st January 1970"
-# In the 'for' loop
-for line in ${articles}
+for line in ${articles} # In the 'for' loop
do
. "articles/${line}.cfg" || die "Cannot read ${line}.cfg file!" # Override the defaults
mkdir "www/articles" -p
@@ -64,14 +55,9 @@ do
markdown "articles/${line}.md" >> "www/articles/${line}.html" || hoedown "articles/${line}.md" >> "www/articles/${line}.html" || die "Cannot convert ${line}.md to html!" # Convert the markdown text to html
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
- # Add an entry in index.html
- echo "-> [$(date +%R)] Adding ${line} entry to 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}@" \
+ 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}@" \
"templates/article.html">> "www/index.html" || die "Cannot add entry to index.html!"
done
-# Insert the footer into the index.html
-cat "templates/footer.html" >> "www/index.html"
+cat "templates/footer.html" >> "www/index.html" # Insert the footer into the index.html