diff options
-rw-r--r-- | LICENSE | 21 | ||||
-rw-r--r-- | Makefile | 15 | ||||
-rw-r--r-- | README.md | 27 | ||||
-rwxr-xr-x | blarg | 119 | ||||
-rw-r--r-- | footer.html | 15 | ||||
-rw-r--r-- | header.html | 95 | ||||
-rw-r--r-- | index.md | 6 | ||||
-rw-r--r-- | pages/about.md | 15 | ||||
-rw-r--r-- | public/email.png | bin | 0 -> 1043 bytes | |||
-rw-r--r-- | public/git.png | bin | 0 -> 713 bytes | |||
-rw-r--r-- | public/mastodon.png | bin | 0 -> 1112 bytes | |||
-rw-r--r-- | public/tux-1.png | bin | 0 -> 15490 bytes |
12 files changed, 313 insertions, 0 deletions
@@ -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. @@ -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 — <a href=\"$link\">$title</a><br/>" + 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 <<EOF +<?xml version="1.0" encoding="utf-8"?> +<feed xmlns="http://www.w3.org/2005/Atom"> + <title>$(sed -n '/^# /{s/# //p; q}' index.md)</title> + <link href="$uri" rel="self" /> + <updated>$(date --iso=seconds)</updated> + <author> + <name>$(git config user.name)</name> + </author> + <id>tag:$host,$first_commit_date:default-atom-feed</id> +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; s/'"'"'/\'/g') + + cat <<EOF + <entry> + <title>$title</title> + <content type="html">$content</content> + <link href="$(echo "$f" | sed -E 's|posts/(.*).md|\1.html|')"/> + <id>tag:$host,$day:$f</id> + <published>$created</published> + <updated>$updated</updated> + </entry> +EOF + done < "$1" + + echo '</feed>' +} + +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 <small><b>'$dates_text'</b></small>' -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 @@ +<footer role="contentinfo"> + <small> + <span><a href="#">↑ Back to Top</a></span><br><br> + Built with <a href="https://codeberg.org/JustineSmithies/blarg">blarg</a> a modified version of <a href="https://git.sr.ht/~bt/barf">barf</a>. + The code for this site is licensed under <a href="https://codeberg.org/JustineSmithies/blarg/LICENSE">MIT</a>. <br> + Here's the blog's <a href="atom.xml">RSS feed</a>. <br><br> + ©2022 - {{YEAR}} Justine Smithies - + <img src="./public/mastodon.png" alt="Fosstodon" width="16" height="16" style="vertical-align:middle;"> + <a rel="me" href="https://fosstodon.org/@JustineSmithies">Mastodon</a> + <img src="./public/git.png" alt="Codeberg" width="16" height="16" style="vertical-align:middle;"> + <a href="https://codeberg.org/JustineSmithies">Git</a> + <img src="./public/email.png" alt="Email" width="16" height="16" style="vertical-align:middle;"> + <a href="mailto:justine@smithies.me.uk">Email</a> + </small> +</footer> diff --git a/header.html b/header.html new file mode 100644 index 0000000..ef7aa83 --- /dev/null +++ b/header.html @@ -0,0 +1,95 @@ +<!doctype html> +<html lang="en"> +<head> + <!-- <link rel="stylesheet" href="https://cdn.simplecss.org/simple.css"> --> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Justine Smithies blog</title> + <link href="https://justine.smithies.me.uk/atom.xml" type="application/atom+xml" rel="alternate" title="Atom feed for blog posts" /> + <style> + body { + font-family: sans-serif; + margin: 0 auto; + max-width: 48rem; + line-height: 1.45; + padding: 0.5rem 0 1.6rem; + } + a { + color: #000000; + font-weight: bold; + } + a:link { + text-decoration: none; + } + a:hover { + text-decoration: underline; + } + main { + <!-- padding: 0 1.4rem; --> + hyphens: auto; + } + code { + border: 1px solid; + padding: 0.1rem 0.3rem; + tab-size: 4; + } + pre { + border: 1px solid; + } + pre code { + display: block; + overflow-x: auto; + padding: 0.3rem 0.6rem; + } + nav ul { + margin: 0; + padding: 0; + display: flex; + justify-content: center; + } + nav li { + list-style: none; + } + nav li * { + display: block; + padding: 0 0.4rem; + color: black; + } + nav li strong { + padding-left: 1.5rem; + padding-right: 1rem; + } + nav a { + text-decoration: none; + } + nav a:hover { + + } + header { + border-bottom: 1px dashed grey; + margin: 0rem 0; + padding: 1rem 15px; + text-align: center; + } + footer { + border-top: 1px dashed grey; + margin: 2rem 0; + padding: 1rem 15px; + text-align: center; + color: #000000; + } + </style> +</head> +<header> +<nav> + <ul> + <li><img src="public/tux-1.png" alt="Tux" style="width:100px;height:100px;"></li> + <li><h1>Justine Smithies blog</h1>Adventures of a Linux chick</li> + </ul> + <ul> + <li><a href="index.html">Home</a></li> + <li><a href="about.html">About</a></li> + </ul> +</nav> +</header> +<main> 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 Binary files differnew file mode 100644 index 0000000..1a56e82 --- /dev/null +++ b/public/email.png diff --git a/public/git.png b/public/git.png Binary files differnew file mode 100644 index 0000000..be6b920 --- /dev/null +++ b/public/git.png diff --git a/public/mastodon.png b/public/mastodon.png Binary files differnew file mode 100644 index 0000000..c5ff36f --- /dev/null +++ b/public/mastodon.png diff --git a/public/tux-1.png b/public/tux-1.png Binary files differnew file mode 100644 index 0000000..1c53837 --- /dev/null +++ b/public/tux-1.png |