all repos — eureka @ 3eeac950d3e2fcc9204bd9ec0ec26764d63ac82a

static site generator based on the 100r.co engine

update docs, add honk syndication
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE-----

iHUEABYKAB0WIQT/foVVmI9pK13hPWFohAcXSWbK8wUCZvYLFAAKCRBohAcXSWbK
832QAP91u6hXziouN0Y71lXOUlCFGSk6OSolfF/l6lkW7w3RfAEAheOSRKtVKK/9
1FNjdDOACy8Jf0VWVazJ0lpYnd5rugY=
=513W
-----END PGP SIGNATURE-----
commit

3eeac950d3e2fcc9204bd9ec0ec26764d63ac82a

parent

15cc1c55b519749daa4ec61f6322963c330d44c7

10 files changed, 115 insertions(+), 54 deletions(-)

jump to
M .clang-format.clang-format

@@ -13,7 +13,6 @@ IndentCaseLabels: true

SpaceBeforeParens: ControlStatements AlignAfterOpenBracket: AlwaysBreak BinPackArguments: false -BinPackArguments: false PointerAlignment: Left BreakBeforeBraces: Attach SortIncludes: false
M LICENSELICENSE

@@ -1,4 +1,4 @@

-Copyright 2021 Derek Stevens +Copyright 2021 Iris Lightshard Copyright 2021 Devine Lu Linvega 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:
M README.mdREADME.md

@@ -17,6 +17,8 @@ 4. Edit your `inc/meta.nav.htm` to create your `nav` structure (see the markup section below).

5. Create a new page, eg `inc/my_first_page.htm` (see the markup section below). 6. Edit your `inc/meta.nav.htm` again to reference your new page. 7. Run `./build.sh` again! You will be warned of any orphaned files. +8. Deploy with `./deploy.sh`. `--syndicate` will syndicate the latest twtxt to the honknet. +9. Revert changes and restore local with the live site with `./deploy.sh --resync`. ## build options

@@ -33,6 +35,8 @@

## debugging If you run into issues with your markup crashing `eureka`, edit the `build.sh` file to uncomment the linux debug build line and comment the fast build; this will show you a stack trace of where you are running into buffer overflows, and give you a hint of where your markup is messed up. To see the individual file that has the error, also uncomment the line in `fpinject()` that prints the file names. + +If you find a bug, let me know. # markup

@@ -128,14 +132,14 @@ - **TAG\_BODY\_SIZE**: max size for an individual markup body (ie, a markup token as above, minus the curly brackets and the rune), in bytes

- **NAME**: the title of the site - **DOMAIN**: currently unused - **LOGO_HTML**: HTML to put in the header h1 verbatim - - **ABOUT_HTML**: HTML content for the front page, placed between `<header>` and `<nav>` + - **ABOUT_HTML**: HTML content for the front page - **CONTACT_HTML**: the contact info line at the bottom of every page (except the front page, where it would typically already be in **@ABOUT** - **FOOTER_HTML**: arbitrary footer HTML - **LICENSE_HTML**: the license link at the bottom of every page - **SITEROOT**: the path where the rendered HTML is placed; include trailing slash - **MAINCSS** and **FRONTCSS**: to differentiate styles used for the landing page and the rest of the site - **TWTXT**: path to the twtxt file relative to the SITEROOT; if you don't want twtxt on the front page, use a nonexistent filename + - **IS_HTML5_VIDEO_ENABLED**: if videos are embedded or just linked to with a poster image + - **IS_NAV_IN_HEADER**: if the nav is inside the header or its sibling -# deployment -Static sites are dead easy to deploy. Included in the repo is the deployment script I use - you can easily adapt this to your own use case.
M build.shbuild.sh

@@ -16,13 +16,15 @@ touch inc/meta.nav.htm

fi # Lint -clang-format -i main.c config.h +if which clang-format > /dev/null; then + clang-format -i main.c config.h +fi # Cleanup rm -f ./main # Linux(debug) -#cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wuninitialized -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined main.c -o main +# cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wuninitialized -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined main.c -o main # Linux(fast) cc main.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o main
M config.def.hconfig.def.h

@@ -1,28 +1,21 @@

/* clang-format off */ #define SITEMAP "all_pages" -#define DOMAIN "https://nilfm.cc" -#define DEPLOY_DEST "nilix@nilfm.cc:~/lib/nilfm/" +#define DOMAIN "https://amotherfucking.website" +#define DEPLOY_DEST "usr@amotherfucking.website:/opt/site/" #define DEPLOY_IDENT "id_sub" #define TAG_BODY_SIZE 4096 -#define LOGO_HTML "<img src='/img/nilfm_blackHole_128.png' alt='blackhole://nilFM'/>" -#define MAINCSS "/nilfm.css?v=20230819.0" -#define FOOTER_HTML "<div style='float:right;text-align:center;'><a href='https://hacklab.nilfm.cc' target='_blank'><img src='/img/git.svg' alt='nilFM hack lab'/></a>&nbsp;\n" \ -"<a href='https://cafe.nilfm.cc/u/nilix' target='_blank'><img src='/img/honk.svg' alt='honk'/></a>&nbsp;\n" \ -"<a href='https://webring.xxiivv.com' target='_blank'><img src='/img/webring.svg' alt='xxiivv webring'/></a>&nbsp;\n" \ -"<a href='https://lightcrystal.systems' target='_blank'><img src='/img/lightcrystal_bw_small.svg' alt='lightcrystal.systems'/>&nbsp;\n" \ -"" -#define LICENSE_HTML "<a rel='license' target='_blank' href='/legal.html'><img src='/img/cc.svg' alt='legal stuff'/></a></div>" -#define DESC "lair of drkste aka nilix: software artisan, digital philosopher" +#define LOGO_HTML "<img src='/img/logo.png' alt='a website'/>" +#define MAINCSS "/main.css" +#define FOOTER_HTML "peekaboo" +#define LICENSE_HTML "<a rel='license' target='_blank' href='/legal.html'>legal</a>" +#define DESC "website eeeeeeee" #define IS_NAV_IN_HEADER 01 #define LEXICON_SIZE 1024 -#define CONTACT_HTML "contact: <a href='mailto:nilix@nilfm.cc' class='mono'>nilix@nilfm.cc</a><br/><a href='/serv/76CD8BF07977D23EC494EA93F54E0D40695271D4.asc' style='font-family:monospace;display:inline-block;max-width:24ch;'>76CD 8BF0 7977 D23E C494 EA93 F54E 0D40 6952 71D4</a>\n" \ -"" -#define FRONTCSS "/nilfm.css?v=20230819.0" +#define CONTACT_HTML "<a href='mailto:person@domain.net' class='mono'contact me</a>" +#define FRONTCSS "/front.css" #define SITEROOT "../www/" #define TWTXT "/twtxt.txt" -#define ABOUT_HTML "Derek Stevens &lt;<a style='font-family:monospace;' href='mailto:nilix@nilfm.cc'>nilix@nilfm.cc</a>&gt;<br/>\n" \ -"software artisan, digital philosopher<br/><br/>\n" \ -"<a href='/serv/76CD8BF07977D23EC494EA93F54E0D40695271D4.asc' style='font-family:monospace;display:inline-block;max-width:24ch;'>76CD 8BF0 7977 D23E C494 EA93 F54E 0D40 6952 71D4</a>\n" \ -"" -#define NAME "nilFM" +#define ABOUT_HTML "<h2>Welcome to this website</h2>" +#define NAME "a website" +#define IS_HTML5_VIDEO_ENABLED 0 /* clang-format on */
M deploy.shdeploy.sh

@@ -2,9 +2,14 @@ #!/bin/sh

DEST=$(grep "#define DEPLOY_DEST" config.h | awk '{print $3}' | sed -e 's/"//g') IDENT=$(grep "#define DEPLOY_IDENT" config.h | awk '{print $3}' | sed -e 's/"//g') +SITEROOT=$(grep "#define SITEROOT" config.h | awk '{print $3}' | sed -e 's/"//g') +TWTXT=$(grep "#define TWTXT" config.h | awk '{print $3}' | sed -e 's/"//g') -if [ -z "$1" ]; then +if [ "$1" = "--resync" ]; then + rsync -avk -e "ssh -i ~/.ssh/${IDENT}" --delete ${DEST} ../ +else rsync -avK -e "ssh -i ~/.ssh/${IDENT}" --delete ../ ${DEST} -elif [ "$1" = "--resync" ]; then - rsync -avk -e "ssh -i ~/.ssh/${IDENT}" --delete ${DEST} ../ + if [ "$1" = "--syndicate" ] && [ $? -eq 0 ]; then + ./underbbs.sh honk "$(head -n 1 ${SITEROOT}/${TWTXT})" + fi fi
M main.cmain.c

@@ -2,7 +2,7 @@ #define _GNU_SOURCE

#include <stdio.h> #include <stdlib.h> -#include <sys/dir.h> +#include <dirent.h> #include <sys/stat.h> #include <time.h>

@@ -74,6 +74,7 @@ char buf[1024] = {0};

char line[256]; char datebuf[16] = {0}; char msgbuf[240] = {0}; + char urlbuf[256] = {0}; char *l, *d, *m; FILE* twtxt = fopen(SITEROOT TWTXT, "r");

@@ -83,6 +84,7 @@ return 1;

} else { int i = 0; while (fgets(line, 256, twtxt) && i < 3) { + int has_url = 0; if (*line == '#') { continue; }

@@ -93,11 +95,31 @@ }

while (*l != '\t') { l++; } - scat(msgbuf, l); - scat(buf, "<tr><td style='white-space:nowrap;vertical-align: top;'>"); + while (*l) { + if (*l == '|') { + has_url = 1; + break; + } + ccat(msgbuf, *l++); + } + l++; + scat(urlbuf, l); + scat( + buf, + "<tr><td class='twtxt-date' style='white-space:nowrap;vertical-align: " + "top;'>"); scat(buf, datebuf); - scat(buf, ":</td><td> "); - scat(buf, msgbuf); + scat(buf, "</td><td class='twtxt-twt'> "); + + if (has_url) { + scat(buf, "<a href='"); + scat(buf, urlbuf); + scat(buf, "'>"); + scat(buf, msgbuf); + scat(buf, "</a>"); + } else { + scat(buf, msgbuf); + } scat(buf, "</td></tr>\n"); d = datebuf; while (*d) {

@@ -367,14 +389,19 @@ }

} thumbtrans(src, thumb); - fprintf( - f, - "<video id='%s' src='%s' controls preload='metadata' poster='%s'>\n", - id, - href, - thumb); - fprintf(f, "<a href='%s'><img src='%s' alt=''%s'></a>\n", href, thumb, alt); - fprintf(f, "</video>\n"); + if (IS_HTML5_VIDEO_ENABLED) { + fprintf( + f, + "<video id='%s' src='%s' controls preload='metadata' poster='%s'>\n", + id, + href, + thumb); + } + + fprintf(f, "<a href='%s'><img src='%s' alt='%s'></a>\n", href, thumb, alt); + if (IS_HTML5_VIDEO_ENABLED) { + fprintf(f, "</video>\n"); + } return 1; }
M thumbnailer.shthumbnailer.sh

@@ -5,14 +5,12 @@ SIZE=500

# transform path to /img/*/.thumb/ pathtrans() { - filename=$(echo $1 | awk -F/ '{print $NF}') - filename=$(echo ${filename} | awk 'BEGIN{FS=OFS="."}{NF--; print $0}') - transform=$(echo $1 | awk 'BEGIN{FS=OFS="/"}{NF--; print $0}') - if [ ! -d ${transform}/.thumb ]; then - mkdir ${transform}/.thumb/ + filename=$(basename "${1%.*}") + pathname="${1%/*}" + if [ ! -d ${pathname}/.thumb ]; then + mkdir ${pathname}/.thumb/ fi - transform=${transform}/.thumb/${filename}.png - echo ${transform} + echo "${pathname}/.thumb/${filename}.png" } # generate thumbnails in /img/*/.thumb/

@@ -23,19 +21,19 @@ return

fi if [ ! -f ${output} ]; then echo "Stripping metadata from $1" - convert $1 -strip $1 + convert "$1" -strip "$1" echo "Generating thumbnail for $1" - convert $1 -strip -auto-orient -resize ${SIZE} -dither FloydSteinberg -colors 16 ${output} + convert "$1" -strip -auto-orient -resize ${SIZE} -dither FloydSteinberg -colors 16 ${output} fi } -if [ -z $1 ]; then +if [ -z "$1" ]; then echo "usage: $0 [build|clean]" else case $1 in "build") echo "Updating thumbnails cache" - for x in $(find ${SRC}/*/*); do resize $x; done;; + for x in $(find ${SRC}/*/*); do resize "$x"; done;; "clean") echo "Cleaning thumbnails cache" rm -rf ${SRC}/*/.thumb
M tw.shtw.sh

@@ -5,7 +5,7 @@ twtxt=$(grep "#define TWTXT" config.h | awk '{print $3}' | sed -e 's/"//g')

twt(){ self=$(mktemp) new=$(mktemp) - echo "$(date -Is)\t$@" > ${self} + echo "$(/sbin/date -Is)\t$@" > ${self} cat ${self} ${siteroot}${twtxt} > ${new} cp ${new} ${siteroot}${twtxt} rm ${new}
A underbbs.sh

@@ -0,0 +1,33 @@

+#!/bin/sh + +. ~/.config/underbbs/cli + +helpme() { + echo "later" +} + +syndicate_honk() { + # authenticate to the honknet + local token=$(curl -X POST -F "username=${HONK_USERNAME}" -F "password=${HONK_PASSWORD}" -F "gettoken=1" ${HONK_URL}/dologin) + # it's gonna be honked + local result=$(curl -X POST -F "action=honk" -F "token=${token}" -F "noise=$@" ${HONK_URL}/api) + echo $result +} + +if [ -z "$2" ]; then + helpme + exit +fi + +adapter=$1 + +shift + +case $adapter in + honk) + noise=$(echo "$@" | sed -e 's/|/\|/') + syndicate_honk "$noise" + ;; + *) + helpme ;; +esac