From 53267404848b8d5a09d76e1d06ab595f28e6dfaf Mon Sep 17 00:00:00 2001 From: sakrecoer Date: Fri, 31 Jul 2026 11:38:11 +0200 Subject: [PATCH 1/4] formatting madness --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d9bff1..caed132 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Hugo is Static Site Generator. It should be available in your packet manager. Download nak binary from https://github.com/fiatjaf/nak/releases/latest and put it in your path (the dirty way). Note that the example bellow downloads a version that migh be outdated at the time you are reading this. #### Example for Linux AMD64 -``` +```bash wget https://github.com/fiatjaf/nak/releases/download/v0.20.2/nak-v0.20.2-linux-amd64 chmod +x nak-linux-amd64 sudo mv nak-linux-amd64 /usr/local/bin/nak @@ -142,10 +142,14 @@ chmod +x deploy.sh Add to crontab (runs every 30 minutes) # Edit crontab +```bash crontab -e +``` # Add this line: +```bash */30 * * * * /path/to/your-cloned-git/deploy.sh +``` Alternative: Different intervals From 390b7e5c7052ed5f36b50ad08e81d7a3a3a4b85e Mon Sep 17 00:00:00 2001 From: sakrecoer Date: Fri, 31 Jul 2026 11:38:50 +0200 Subject: [PATCH 2/4] we don't track the file that is customized --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index d7f4147..ed87891 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ public resources .hugo_build.lock data +fetch-and-convert.sh +deploy.sh From 05016b454cc7126bfd6f813548a3551ce70f10ae Mon Sep 17 00:00:00 2001 From: sakrecoer Date: Fri, 31 Jul 2026 11:40:10 +0200 Subject: [PATCH 3/4] kill the customized fetch script --- fetch-and-convert.sh | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100755 fetch-and-convert.sh diff --git a/fetch-and-convert.sh b/fetch-and-convert.sh deleted file mode 100755 index 9043721..0000000 --- a/fetch-and-convert.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -# Configuration -PUBKEY="setto@basspistol.org" -RELAY="wss://basspistol.org" -DATA_DIR="data" - -# Clean up old JSON files (optional) -# rm -f data/*/*.json - -# Define kind mappings -declare -A KINDS -KINDS[0]="profile/profile" -KINDS[30023]="longform/blog" -KINDS[36787]="music/tracks" -KINDS[20]="pictures/photos" -KINDS[22]="videos/videos" - -# Fetch each kind -for kind in "${!KINDS[@]}"; do - output="${KINDS[$kind]}" - echo "Fetching kind $kind..." - - # Create directory if it doesn't exist - mkdir -p "$DATA_DIR/$(dirname "$output")" - - # Fetch and convert to JSON - nak req -k "$kind" -a "$PUBKEY" "$RELAY" | jq -s '.' > "$DATA_DIR/$output.json" - - echo "Saved to $DATA_DIR/$output.json" -done - -echo "All data fetched and converted!" -echo "JSONL files have been removed." - -echo "Building website" From b74ca38c2643ecb918fc3be5993e630b7fe225a7 Mon Sep 17 00:00:00 2001 From: sakrecoer Date: Fri, 31 Jul 2026 11:40:36 +0200 Subject: [PATCH 4/4] add the example scripts --- exemple.deploy.sh | 20 ++++++++++++++++++++ exemple.fetch-and-convert.sh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 exemple.deploy.sh create mode 100755 exemple.fetch-and-convert.sh diff --git a/exemple.deploy.sh b/exemple.deploy.sh new file mode 100644 index 0000000..5f2c191 --- /dev/null +++ b/exemple.deploy.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# Configuration +SITE_DIR="/path/to/your-cloned-git" +WEBROOT="/probably/var/www/html" +LOG_FILE="$HOME/nostr-site-deploy.log" + +date '+%Y-%m-%d %H:%M:%S' > $LOG_FILE # we wipe the log file from rpevious entries, because no history here is super important + +cd $SITE_DIR +/usr/bin/git pull >> $LOG_FILE +/usr/bin/bash fetch-and-convert.sh >> $LOG_FILE +/snap/bin/hugo --cleanDestinationDir --minify >> $LOG_FILE + +# Optional and potentially dangerous: the generator will creates a random file name (fingerprint) for css and js to be picked up when you do changes to it. If you don't remove them, over time your directory will bloat. A new file is only created if there are changes. +# This can be dangerous because if you set the webroot wrong, you're going to nuke stuff you wasn't supposed to. +#/usr/bin/rm $WEBROOT/css/* +#/usr/bin/rm $WEBROOT/js/* + +/usr/bin/rsync -av $SITE_DIR $WEBROOT/ >> $LOG_FILE diff --git a/exemple.fetch-and-convert.sh b/exemple.fetch-and-convert.sh new file mode 100755 index 0000000..3b0d960 --- /dev/null +++ b/exemple.fetch-and-convert.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Configuration +PUBKEY="YOUR_PUBKEY" +RELAY="wss://mega.supercool.relay" +DATA_DIR="data" + +# Clean up old JSON files (optional) +# rm -f data/*/*.json + +# Define kind mappings +declare -A KINDS +KINDS[0]="profile/profile" +KINDS[30023]="longform/blog" +KINDS[36787]="music/tracks" +KINDS[20]="pictures/photos" +KINDS[22]="videos/videos" + +# Fetch each kind +for kind in "${!KINDS[@]}"; do + output="${KINDS[$kind]}" + echo "Fetching kind $kind..." + + # Create directory if it doesn't exist + mkdir -p "$DATA_DIR/$(dirname "$output")" + + # Fetch and convert to JSON + nak req -k "$kind" -a "$PUBKEY" "$RELAY" | jq -s '.' > "$DATA_DIR/$output.json" + + echo "Saved to $DATA_DIR/$output.json" +done + +echo "All data fetched and converted!" +echo "JSONL files have been removed." + +echo "Building website"