diff options
| author | Philip Wittamore <philip@wittamore.com> | 2026-05-05 21:42:52 +0200 |
|---|---|---|
| committer | Philip Wittamore <philip@wittamore.com> | 2026-05-05 21:42:52 +0200 |
| commit | fd5ca9551ce75d8856451de7928b000cb3b1c779 (patch) | |
| tree | a7e9f7113dfb383f4514d3c1dc88161561590e72 /blogthis | |
update
Diffstat (limited to 'blogthis')
| -rwxr-xr-x | blogthis | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/blogthis b/blogthis new file mode 100755 index 0000000..7a0fab4 --- /dev/null +++ b/blogthis @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +# create text, assemble html file, add to articles + +#web is a symlink to /home/philip/src/web/wittamore.com +ROOT=/home/philip/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 charset=\"utf-8\"> + <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"> + <link rel=\"stylesheet\" href=\"/style.css\"> + <title>$TITLE</title> + </head> + <body> + <header> + <h1>Bloggings</h1> + <a href=\"/index.php\">Back</a> + <hr> + </header> + <!-- article start -->" > "$ARTICLE" +cat "$EDITFILE" >> "$ARTICLE" +echo '<!-- article end --> +<p> </p> +<hr> +<p>ยง</p> + </body> +</html>' >> "$ARTICLE" +mv "$ARTICLE" "$DEST" +echo "saved as $DEST/$ARTICLE" |
