diff options
| author | Philip Wittamore <philip@wittamore.com> | 2026-05-31 12:28:54 +0200 |
|---|---|---|
| committer | Philip Wittamore <philip@wittamore.com> | 2026-05-31 12:28:54 +0200 |
| commit | 77b8914d9f233321430f9a9a9947c52de9239a72 (patch) | |
| tree | 06c62d7db00b0d6ec8ecc1a223ed30e9d4fa985e /blogthis | |
update
Diffstat (limited to 'blogthis')
| -rwxr-xr-x | blogthis | 65 |
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 + |
