aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xblogarticledate17
-rwxr-xr-xblogrss74
-rwxr-xr-xblogsend26
-rwxr-xr-xblogsitemap33
-rwxr-xr-xblogsitemap.options12
-rwxr-xr-xblogthis65
6 files changed, 227 insertions, 0 deletions
diff --git a/blogarticledate b/blogarticledate
new file mode 100755
index 0000000..6eb73a1
--- /dev/null
+++ b/blogarticledate
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+
+# resets blog articles file date to the date indicated
+# in the article
+postDir=/home/philip/web/articles/2025
+
+mapfile -t postArray < <(ls -t "$postDir"/*.html)
+for posts in "${postArray[@]}"; do
+ post="$posts"
+ postdate=$(grep -o '>.*</h5>' "$post" | sed 's/\(>\|<\/h5>\)//g')
+ echo "$postdate"
+ #[[CC]YY]MMDDhhmm[.ss]
+ postdate="${postdate//-}0000"
+ echo Date="$postdate"
+ echo Item="$post"
+ touch -a -m -t "$postdate" "$post"
+done
diff --git a/blogrss b/blogrss
new file mode 100755
index 0000000..5e83aeb
--- /dev/null
+++ b/blogrss
@@ -0,0 +1,74 @@
+#!/usr/bin/env bash
+
+link=https://wittamore.fr/articles/2026
+description='Ramblings from Brittany, France'
+rsslink=https://wittamore.fr/rss.xml
+feedname=/home/philip/web/rss.xml
+postDir=/home/philip/web/articles/2026
+updated=$(date --iso-8601=ns)
+
+# Build RSS header & footer
+header () {
+echo "<?xml version='1.0' encoding='UTF-8' ?>
+<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'>" > ~/feedtop
+echo "
+<channel>
+<title>Bloggings - wittamore.fr</title>
+<link>https://wittamore.com</link>
+<description>Ramblings from Brittany, France</description>
+<lastBuildDate>$updated</lastBuildDate>
+<atom:link href='$rsslink' rel='self' type='application/rss+xml' />
+" >> ~/feedtop
+}
+
+footer () {
+echo "
+</channel>
+
+</rss>
+" >> ~/feedbottom
+}
+
+# Function: Build Item add to feed
+
+item () {
+ echo "<item>
+ <title>$fullTitle</title><pubDate>$postdate</pubDate>
+ <link>$linkadd</link>
+ <guid>$linkadd</guid>
+ <category> </category>
+ <description>$description</description>
+</item>" >> ~/feed
+}
+
+# Function: Concatenate everything
+
+combine () {
+ header
+ footer
+ cat ~/feedtop ~/feed > ~/feedtb
+ cat ~/feedtb ~/feedbottom > $feedname
+ rm ~/feedtop ~/feed ~/feedtb ~/feedbottom
+}
+
+# Run through files and create rss.xml
+
+if [[ -f $feedname ]]; then
+ rm $feedname
+fi
+touch $feedname
+mapfile -t postArray < <(ls -t "$postDir"/*.html)
+postNum=0
+for posts in "${postArray[@]}"; do
+ ((postNum+=1))
+ post=$posts
+ fullTitle=$(grep -o '>.*</h2>' "$post" | sed 's/\(>\|<\/h2>\)//g')
+ postdate=$(grep -o '>.*</h5>' "$post" | sed 's/\(>\|<\/h5>\)//g')
+ postname=${post##*/}
+ linkadd="$link"/"$postname"
+ description=$(sed -n '/<h4>.*/,/*.<\/h4>/{p;q;}' "$post" | sed -e 's/<[^>]\+>/ /g' -e 's|<h4>||g' -e 's|</h4>||g' -e 's|"||g')
+ item "$post"
+done
+ combine
+exit
+
diff --git a/blogsend b/blogsend
new file mode 100755
index 0000000..905857e
--- /dev/null
+++ b/blogsend
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+
+# blogsend
+
+# folders
+localdir=~/web
+
+# update git
+echo "-- Updating git"
+cd $localdir || exit
+git add *
+git commit -m 'file update'
+git push origin master
+
+# update remote http root
+echo "-- Updating remote web root"
+ssh -q soc << EOF
+cd /srv/http/wittamore.fr || exit
+pwd
+git pull
+EOF
+
+printf "Done.\n"
+
+exit 0
+
diff --git a/blogsitemap b/blogsitemap
new file mode 100755
index 0000000..8924287
--- /dev/null
+++ b/blogsitemap
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+cd /home/philip/web
+
+# url configuration
+URL="https://wittamore.fr/"
+
+# values: always hourly daily weekly monthly yearly never
+FREQ="weekly"
+
+# begin new sitemap
+exec 1> sitemap.xml
+
+# print head
+echo '<?xml version="1.0" encoding="UTF-8"?>'
+echo '<!-- generator="Milkys Sitemap Generator, https://github.com/mcmilk/sitemap-generator" -->'
+echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'
+
+# print urls
+IFS=$'\r\n' GLOBIGNORE='*' command eval "OPTIONS=($(cat $0.options))"
+find . -type f "${OPTIONS[@]}" -printf "%TY-%Tm-%Td%p\n" | \
+while read -r line; do
+ DATE=${line:0:10}
+ FILE=${line:12}
+ echo "<url>"
+ echo " <loc>${URL}${FILE}</loc>"
+ echo " <lastmod>$DATE</lastmod>"
+ echo " <changefreq>$FREQ</changefreq>"
+ echo "</url>"
+done
+
+# print foot
+echo "</urlset>"
diff --git a/blogsitemap.options b/blogsitemap.options
new file mode 100755
index 0000000..ed34f09
--- /dev/null
+++ b/blogsitemap.options
@@ -0,0 +1,12 @@
+-prune
+! -iname robots.txt
+! -iname sitemap.\*
+! -iname favicon.\*
+! -iname rss.\*
+! -iname style.\*
+! -iname .\*
+! -path ./images/\*
+! -path ./fonts/\*
+
+
+
diff --git a/blogthis b/blogthis
new file mode 100755
index 0000000..ec0eaf5
--- /dev/null
+++ b/blogthis
@@ -0,0 +1,65 @@
+#!/usr/bin/env bash
+
+# create text, assemble html file, add to articles, upload
+
+#web is a symlink to $HOME/src/web/example.com
+ROOT="$HOME/web"
+
+mkdir -p $ROOT/.tmp
+cd $ROOT/.tmp || exit
+EDITFILE="middle.html"
+DATE=$(date +%Y-%m-%d)
+
+read -r -p "Enter title: " TITLE
+read -r -e -i "$DATE" -p "Enter date: " input
+read -r -p "Enter description: " DESCRIPTION
+
+ARTICLEDATE="${input:-$DATE}"
+YEAR=$(echo "$ARTICLEDATE" | cut -c 1-4)
+DEST="$ROOT/articles/$YEAR"
+
+echo "<h2>$TITLE</h2>" > $EDITFILE
+echo "<h5>$ARTICLEDATE</h5>" >> $EDITFILE
+echo "<h4>$DESCRIPTION</h4>" >> $EDITFILE
+
+micro +4:1 "$EDITFILE"
+
+FIXEDTITLE=${TITLE// /-}
+ARTICLE="$FIXEDTITLE.html"
+
+echo "<!doctype html>
+<html lang=\"en\">
+ <head>
+ <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" >
+ <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
+ <link rel=\"stylesheet\" href=\"/style.css\">
+ <link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">
+ <title>$TITLE</title>
+ </head>
+ <body>
+ <header>
+ <h1>Bloggings</h1>
+ <a href=\"/index.php\">Back</a>
+ </header>
+ <main>
+ <article>" > "$ARTICLE"
+
+cat "$EDITFILE" >> "$ARTICLE"
+
+echo " </article>
+ </main>
+ <footer>
+ <p>ยง</p>
+ </footer>
+ </body>
+</html>" >> "$ARTICLE"
+mv "$ARTICLE" "$DEST"
+echo "saved as $DEST/$ARTICLE"
+
+echo "--------------------------"
+read -rp "Update the sitemap and rss feed, then upload to your server? ; " choix
+
+if [ "$choix" != "n" ] ; then
+ blogsitemap; blogrss ; blogsend
+fi
+