aboutsummaryrefslogtreecommitdiff
path: root/blogthis
diff options
context:
space:
mode:
Diffstat (limited to 'blogthis')
-rwxr-xr-xblogthis65
1 files changed, 65 insertions, 0 deletions
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
+