From 282cd835e27e8ff21e8d8a0acf2859e96a1cdc0f Mon Sep 17 00:00:00 2001 From: JustineSmithies Date: Sat, 13 May 2023 16:20:58 +0100 Subject: Initial commit --- LICENSE | 21 ++++++++++ Makefile | 15 +++++++ README.md | 27 ++++++++++++ blarg | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++ footer.html | 15 +++++++ header.html | 95 +++++++++++++++++++++++++++++++++++++++++ index.md | 6 +++ pages/about.md | 15 +++++++ public/email.png | Bin 0 -> 1043 bytes public/git.png | Bin 0 -> 713 bytes public/mastodon.png | Bin 0 -> 1112 bytes public/tux-1.png | Bin 0 -> 15490 bytes 12 files changed, 313 insertions(+) create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 100755 blarg create mode 100644 footer.html create mode 100644 header.html create mode 100644 index.md create mode 100644 pages/about.md create mode 100644 public/email.png create mode 100644 public/git.png create mode 100644 public/mastodon.png create mode 100644 public/tux-1.png diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2d7f01c --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Karl Bartel + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..817ab08 --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +build: + ./blarg + # rsync -r public/ build/public +clean: + rm -rf build/* + +watch: + while true; do \ + ls -d .git/* * posts/* pages/* header.html | entr -cd make ;\ + done + +deploy: build + + +.PHONY: build clean watch deploy diff --git a/README.md b/README.md new file mode 100644 index 0000000..2eb3a36 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# blarg + +`blarg` is a minimal blog engine based on [blog.sh](https://github.com/karlb/karl.berlin/tree/master) and [blarg](https://git.sr.ht/~bt/barf). + +Features: + +* Requires only a posix shell, a markdown processor and git +* Handle both blog posts and normal pages +* No boilerplate, just create a markdown file +* Show creation and update timestamps (taken from git history) + +See the [blog post](http://www.karl.berlin/blog.html) for more details. + +## Quickstart + +* Clone this repository `git clone https://codeberg.org/JustineSmithies/blarg` +* Put your blog posts as markdown files into `posts` +* Place any images into the public folder +* Run `./blarg` and your posts will show up in `build/index-with-drafts.html` +* Commit posts in git to add timestamps and have them show up in `build/index.html` +* Copy the content of `build` to your webserver, so that other people can read your blog + +Feel free to [contact me](justine@smithies.me.uk) if you have any questions. + +# Warning ! + +This repo also contains the content for my personal blog and homepage (https://justine.smithies.me.uk). So if you want to use `blarg` please remember to delete the contents of the posts folder and any files in the public folder too. diff --git a/blarg b/blarg new file mode 100755 index 0000000..ee5af8c --- /dev/null +++ b/blarg @@ -0,0 +1,119 @@ +#!/bin/sh +set -eu +MARKDOWN=pandoc +IFS=' ' + +# Create tab separated file with filename, title, creation date, last update +index_tsv() { + for f in "$1"/*.md + do + created=$(git log --pretty='format:%aI' "$f" 2> /dev/null | tail -1) + updated=$(git log --pretty='format:%aI' "$f" 2> /dev/null | head -1) + title=$(sed -n '/^# /{s/# //p; q}' "$f") + printf '%s\t%s\t%s\t%s\n' "$f" "${title:="No Title"}" "${created}" "${updated}" + done +} + +index_html() { + # Print header + title=$(sed -n '/^# /{s/# //p; q}' index.md) + sed "s/{{TITLE}}/$title/" header.html + + # Intro text + $MARKDOWN index.md + + # Posts + while read -r f title created updated; do + link=$(echo "$f" | sed -E 's|.*/(.*).md|\1.html|') + created=$(echo "$created" | sed -E 's/T.*//') + # Reverse date from YYYY-MM-DD to DD-MM-YY + created=$(echo "$created" | awk -F'-' '{printf("%02d-%02d-%02d\n",$3,$2,$1)}') + echo "$created — $title
" + done < "$1" + + # Print footer after post list + year=$(date +"%Y") + sed "s/{{YEAR}}/$year/" footer.html +} + +atom_xml() { + uri=$(sed -rn '/atom.xml/ s/.*href="([^"]*)".*/\1/ p' header.html) + host=$(echo "$uri" | sed -r 's|.*//([^/]+).*|\1|') + first_commit_date=$(git log --pretty='format:%ai' . | cut -d ' ' -f1 | tail -1) + + cat < + + $(sed -n '/^# /{s/# //p; q}' index.md) + + $(date --iso=seconds) + + $(git config user.name) + + tag:$host,$first_commit_date:default-atom-feed +EOF + + while read -r f title created updated; do + day=$(echo "$created" | sed 's/T.*//') + content=$($MARKDOWN "$f" | sed 's/&/\&/g; s//\>/g; s/"/\"/g; s/'"'"'/\'/g') + + cat < + $title + $content + + tag:$host,$day:$f + $created + $updated + +EOF + done < "$1" + + echo '' +} + +write_page() { + filename=$1 + target=$(echo "$filename" | sed -r 's|\w+/(.*).md|build/\1.html|') + # year=$(date +"%Y") + created=$(echo "$3" | sed 's/T.*//') + # Reverse date from YYYY-MM-DD to DD-MM-YY + created=$(echo "$created" | awk -F'-' '{printf("%02d-%02d-%02d\n",$3,$2,$1)}') + updated=$(echo "$4" | sed 's/T.*//') + # Reverse date from YYYY-MM-DD to DD-MM-YY + updated=$(echo "$updated" | awk -F'-' '{printf("%02d-%02d-%02d\n",$3,$2,$1)}') + dates_text="Published on ${created}" + if [[ "$created" == "00-00-00" ]]; then + dates_text="" + elif [ "$created" != "$updated" ]; then + dates_text="$dates_text ( Updated ${updated} )" + fi + title=$2 + + $MARKDOWN "$filename" | \ + sed -e '1,/h1>/{/h1>/a '$dates_text'' -e '}' | \ + cat header.html - | \ + sed "s/{{TITLE}}/$title/" \ + > "$target" && sed "s/{{YEAR}}/$year/" footer.html >> "$target" + +} + +rm -fr build && mkdir build + +# Blog posts +index_tsv posts | sort -rt " " -k 3 > build/posts.tsv +index_html build/posts.tsv > build/index.html +atom_xml build/posts.tsv > build/atom.xml +while read -r f title created updated; do + write_page "$f" "$title" "$created" "$updated" +done < build/posts.tsv + +# Pages +index_tsv pages > build/pages.tsv +while read -r f title created updated; do + write_page "$f" "$title" "$created" "$updated" +done < build/pages.tsv + +# Create public directory if it doesn't exist and sync with build/public +mkdir -p public/ +rsync -r public/ build/public diff --git a/footer.html b/footer.html new file mode 100644 index 0000000..c2306ea --- /dev/null +++ b/footer.html @@ -0,0 +1,15 @@ + diff --git a/header.html b/header.html new file mode 100644 index 0000000..ef7aa83 --- /dev/null +++ b/header.html @@ -0,0 +1,95 @@ + + + + + + + Justine Smithies blog + + + +
+ +
+
diff --git a/index.md b/index.md new file mode 100644 index 0000000..8093e1d --- /dev/null +++ b/index.md @@ -0,0 +1,6 @@ + +### Welcome to my blog + +Subscribe to the [Atom feed](atom.xml) to get all new posts on this site. + +## Blog Posts diff --git a/pages/about.md b/pages/about.md new file mode 100644 index 0000000..cb4472b --- /dev/null +++ b/pages/about.md @@ -0,0 +1,15 @@ +# About Justine Smithies + +### Who is this nerd? + +I'm Justine I'm a marine electronics engineer to trade which basically means I install / repair anything on fishing / oil vessels from satellite internet and sat TV to autopilots, radars, VHFs and navigational equipment. + +I've been a Linux user since around 2000. Redhat was my first ever disrubution followed by Mandrake, I then progressed to the dev team on the distro LRs Linux that basically compiled from scratch according to the users hardware and was LFS based. An old copy of what's left of the original website can be found using Wayback Machine [here](http://web.archive.org/web/20030207074913/http://www.lrs-linux.co.uk/index.php). + +I'm also a long time [Arch Linux](https://archlinux.org/) user and have periodically tried distro hopping to see what I maybe missing out on and to keep up with the latest goings on but I always end up coming back pretty fast. My window manager of choice is [Qtile](https://github.com/qtile/qtile) running under Wayland and you can find my dotfiles for it [here](https://codeberg.org/JustineSmithies/qtile-wayland-dotfiles). + +Did I tell you "BTW I use Arch" ? 😉 + +Other hobbies include retro 8 bit computers of which I've owned a fair few. Among them were an Apple II Europlus, ZX80 and 81, Sinclair Spectrum 48 and 128 +3, Acorn Electron, TRS80 CoCo, Amstrad CPC464 and 6128. I've also had the [ZX Evolution](http://www.nedopc.com/zxevo/zxevo_eng.php) a Russian made Sinclair Spectrum clone with added modern peripherals. I'm also hoping to build an RC2014 Z80 based computer or build my own from scratch too. + +I love good food and wines too, especially when I get time to cook myself. I'm quite varied in tastes food wise as I like pretty much anything but I'd have to say food from the Mediteranean region is my all time favourite. Although I'm open to people opening my eyes to dishes I've never tried before too. diff --git a/public/email.png b/public/email.png new file mode 100644 index 0000000..1a56e82 Binary files /dev/null and b/public/email.png differ diff --git a/public/git.png b/public/git.png new file mode 100644 index 0000000..be6b920 Binary files /dev/null and b/public/git.png differ diff --git a/public/mastodon.png b/public/mastodon.png new file mode 100644 index 0000000..c5ff36f Binary files /dev/null and b/public/mastodon.png differ diff --git a/public/tux-1.png b/public/tux-1.png new file mode 100644 index 0000000..1c53837 Binary files /dev/null and b/public/tux-1.png differ -- cgit v1.2.3