From d57b985c382d3a88f1a22f354e0ec989d18caeb2 Mon Sep 17 00:00:00 2001 From: Adam Stück Date: Sat, 14 Sep 2024 22:27:15 +0200 Subject: switch to wruby site generator --- .build.yml | 17 ++++--- LICENSE | 4 +- Makefile | 11 ++-- _config.yml | 21 ++++++++ barf | 158 --------------------------------------------------------- footer.html | 5 +- header.html | 8 +-- index.md | 2 +- pages/posts.md | 3 ++ wruby.rb | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 195 insertions(+), 184 deletions(-) create mode 100644 _config.yml delete mode 100755 barf create mode 100644 pages/posts.md create mode 100644 wruby.rb diff --git a/.build.yml b/.build.yml index ee27fdb..2f0766c 100644 --- a/.build.yml +++ b/.build.yml @@ -1,25 +1,28 @@ -image: alpine/edge +image: alpine/latest oauth: pages.sr.ht/PAGES:RW packages: + - ruby + - ruby-dev + - go - hut - rsync secrets: - 4c5cebdb-c744-4dfb-a69a-30b9bdfe048c sources: - https://git.sr.ht/~adamski/adast.dk - - https://git.sr.ht/~bt/smu environment: deploy: srht@adast.dk mirror: mirror.adast.dk site: adamski.srht.site tasks: -- smu: | - cd smu - sudo make install -- package: | +- install-gems: | + sudo gem install bundler 'kramdown:2.4.0' 'rss:0.3.0' +- build: | cd adast.dk make build - tar -C build -cvz . > ../site.tar.gz +- package: | + cd adast.dk/build + tar -cvz . > ../../site.tar.gz - upload: | sshopts="ssh -o StrictHostKeyChecking=no" rsync --rsh="$sshopts" -ruz --delete adast.dk/build/ $deploy:/var/www/adast.dk diff --git a/LICENSE b/LICENSE index 8653a47..81774c2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ MIT License -Copyright (c) 2023 Bradley Taunt -Copyright (c) 2023 Adam Stück +Copyright (c) 2024 Bradley Taunt +Copyright (c) 2024 Adam Stück Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile index b16a580..9d7e5a1 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,8 @@ build: - sh ./barf - rsync -r public/ build/public + rm -rf build && mkdir build + ruby wruby.rb clean: rm -rf build/* -watch: - while true; do \ - ls -d .git/* * posts/* pages/* header.html | entr -cd make ;\ - done - -.PHONY: build clean watch +.PHONY: build clean diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..1080622 --- /dev/null +++ b/_config.yml @@ -0,0 +1,21 @@ +site_url: 'https://adast.dk' +site_name: 'adast' +author_name: 'Adam Stück' + +directories: + posts: 'posts' + pages: 'pages' + public: 'public' + output: 'build' + posts_output: 'build/posts' + pages_output: 'build/' + +files: + header: 'header.html' + footer: 'footer.html' + root_index: 'index.md' + posts_index: 'pages/posts.md' + rss: 'build/index.rss' + +misc: + post_count: 5 diff --git a/barf b/barf deleted file mode 100755 index 098ee07..0000000 --- a/barf +++ /dev/null @@ -1,158 +0,0 @@ -#!/bin/sh - -domain="https://adast.dk" - -# Check the operating system -os_name=$(uname -s) - -if [ "$os_name" = "OpenBSD" ]; then - alias sed=gsed - alias date=gdate - alias rsync=openrsync -elif [ "$os_name" = "Darwin" ]; then - alias sed=gsed - alias date=gdate -fi - -set -eu -MARKDOWN=smu -IFS=' ' - -# Create tab separated file with filename, title, creation date, last update -index_tsv() { - for f in "$1"/*.md - do - title=$(sed -n '/^# /{s/# //p; q}' "$f") - printf '%s\t%s\t%s\t%s\n' "$f" "${title:="No Title"}" - done -} - -index_html() { - # Print header - title=$(sed -n '/^# /{s/# //p; q}' index.md) - sed "s/{{TITLE}}/$title/" header.html - - # Intro text - $MARKDOWN index.md - - echo '" - - # Print footer after post list - cat footer.html -} - -atom_xml() { - uri=$(sed -rn '/atom.xml/ s/.*href="([^"]*)".*/\1/ p' header.html) - first_commit_date=$(git log --pretty='format:%ai' . | cut -d ' ' -f1 | tail -1) - - cat < - - $(sed -n '/^# /{s/# //p; q}' index.md) - - $(date +%FT%TZ) - - $(git config user.name) - - $domain,$first_commit_date:default-atom-feed/ -EOF - - while read -r f title created; do - - content=$($MARKDOWN "$f" | sed 's/&/\&/g; s//\>/g; s/"/\"/g; s/'"'"'/\'/g') - post_link=$(echo "$f" | sed -E 's|posts/(.*).md|\1|') - basic_date=$(echo $(head -3 "$f" | tail -1)) - published_date=$(date -d $basic_date -u +%Y-%m-%dT10:%M:%SZ) - - cat < - $title - $content - - $domain/$post_link - $published_date - $published_date - -EOF - done < "$1" - - echo '' -} - -rss_xml() { - uri=$(sed -rn '/rss.xml/ s/.*href="([^"]*)".*/\1/ p' header.html) - first_commit_date=$(git log --pretty='format:%ai' . | cut -d ' ' -f1 | tail -1) - - cat < - - - $(sed -n '/^# /{s/# //p; q}' index.md) - $domain/rss.xml - Adam Stück's blog - $(date -u +"%a, %d %b %Y %H:%M:%S %z") - $(date -u +"%a, %d %b %Y %H:%M:%S %z") - Custom RSS Generator - 1800 -EOF - - while read -r f title created; do - content=$($MARKDOWN "$f" | sed 's/&/\&/g; s//\>/g; s/"/\"/g; s/'"'"'/\'/g') - post_link=$(echo "$f" | sed -E 's|posts/(.*).md|\1|') - basic_date=$(echo $(head -3 "$f" | tail -1)) - published_date=$(date -d "$basic_date" -u +"%a, %d %b %Y %H:%M:%S %z") - - cat < - $title - $content - $domain/$post_link - $domain/$post_link - $published_date - -EOF - done < "$1" - - echo '' - echo '' -} - -write_page() { - filename=$1 - directory=$(echo $(basename "$filename" .md)) - $(mkdir -p build/$directory) - target=$(echo "$filename" | sed -r 's|\w+/(.*).md|build/\1/index.html|') - created=$(echo $(head -3 "$filename" | tail -1)) - title=$2 - - $MARKDOWN "$filename" | \ - cat header.html - |\ - sed "s|{{TITLE}}|$title|" \ - > "$target" && cat footer.html >> "$target" -} - -rm -rf 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 -rss_xml build/posts.tsv > build/rss.xml -while read -r f title created; do - write_page "$f" "$title" "$created" -done < build/posts.tsv - -# Pages -index_tsv pages > build/pages.tsv -while read -r f title created; do - write_page "$f" "$title" "$created" -done < build/pages.tsv diff --git a/footer.html b/footer.html index 301a703..ba57ae1 100644 --- a/footer.html +++ b/footer.html @@ -10,11 +10,12 @@
  • Now
  • Contact
  • Donate
  • +
  • RSS
  • ↑ Top of the page
  • - Feeds: Atom | RSS
    - Built with barf.
    + Built with wruby.
    + Maintained with ♥ for the web.
    The content for this site is CC-BY-SA.
    The code for this site is MIT.
    diff --git a/header.html b/header.html index b687008..971a627 100644 --- a/header.html +++ b/header.html @@ -6,12 +6,8 @@ {{TITLE}} - - - + +