💾 Archived View for oakc.smol.pub › smolpubwintest captured on 2023-11-04 at 11:06:03. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
This is a quick test of the Smol.Pub Windows Client I bodged together from scripts. It only works in Windows 10 with some external programs (assuming it works at all).
The main script uses busybox-win32 and is an ash-script adaptation of the CLI client:
#!/bin/sh host=https://smol.pub validate_post() { arr0="$(head -n 1 "$1")" arr1="$(head -n 2 "$1"|tail -n 1)" if [[ "${arr0:0:2}" != "# " ]] || [[ "$arr1" != "" ]] then echo "First line needs to start with a title (# Hello World)" echo "Second line needs to be left blank." test "${arr0:0:2}" == "# " && echo "(Line 1 fine)" test "$arr1" == "" && echo "(Line 2 fine)" return 1 fi return 0 } if [ $# -eq 2 ] && [ $1 == '--key' ] then mkdir -p ~/.config echo "$2" > ~/.config/.smolpub echo "Set API Key to '$2'." else tdir="$(mktemp -d)" cat "$1" >"$tdir/post.txt" dos2unix "$tdir/post.txt" validate_post "$tdir/post.txt" || exit 1 if [ $# -eq 1 ] then echo "Posting..." p1=$(basename "$1") slug="${p1%.*}" slug="$(echo $slug|tr A-Z a-z)" title="$(head -n 1 "$1")" title="${title:2}" status=$(curl -s -o /dev/null -w "%{http_code}"\ --form-string title="$title"\ --form-string slug="$slug"\ --form-string content="$(tail -n +3 "$1")"\ -b smolpub="$(cat ~/.config/.smolpub)"\ $host/posts/save) if [ $status -ne 302 ] then echo "Updating post... ($status)" curl --form-string title="$title"\ --form-string slug="$slug"\ --form-string content="$(tail -n +3 "$1")"\ -b smolpub="$(cat ~/.config/.smolpub)"\ $host/posts/$slug/update else echo "Posted!" fi fi fi