[Ed.2024-02-16: site no longer hosted at Neocities - moved to VPS.]
[Ed.2022-11-05: replaced github/gitlab links with codeberg link]
If you were to browse one of the GeoCities archives you might stumble across one of my old homepages. One being an ITC Class project providing (poorly written) walkthroughs for a handful of adventure games, the other being a classic early-2000s GIF and MIDI meddle. The joy of making my own homepage, making mistakes and breaking things while learnig, is one of many reasons I gravitated towards Neocities for my web hosting, as opposed to the multitudtrue At first it was all fun and games. I became a Neocities supporter. Decided to play with static site generation. Then hit a bit of a wall. How to update my site without having to manually upload files?
I started using a ugly-as-sin bash script to upload my site (generated with Hugo by the way). Due to a sudden increase in spare time, unemployment ahoy, I suddenly had the time to fiddle around with it and make the script a bit more functional and somewhat cross-distro compatible. So it only seems fair to share–on the off chance someone else might find it handy.
The script as it stands is fairly basic:
- Generate a list of files in a given directory. Hash each file to look for changes.
- If an item appears in the new file list, but not in the old one (either the file path/name or SHA-1 does not match), add it to a list of files to be uploaded.
- Upload via the Neocities REST API (using curl), either asking for a password or reading it from a file depending on your configuration. ???? (Complete lack of) profit.
The hash list, along with the configuration file, are kept in ~/.config/NU+sh/. This is in part because it should make it easier to implement some of the planned features –such as being able to upload multiple sites to different Neocities URLs–and partially an attempt to follow some kind of standard as to where dot/config files should live.
One of my goals is writing scripts that can be used on a wide number of Linux distros, so I’ve stuck to the GNU CoreUtils, GNU FindUtils, and POSIX standardized utilities. So no custom commands or programs that migth have made this easier.
Here is a Codeberg repo for those that are on Linux and want to give it a try. Haven’t made up my mind as to which git community provider I prefer to use yet, so decided to give them both a try. While the script is fairly bare-bones at the moment there is a list of planned features. Feel free to reach out with suggested changes or ideas either via my listed contact details or via one of the git repo’s mentioned above.
It’s been 4 intensive days, but worth it. More posts to follow once the planned features are (slowly) rolled out. As a proof that it functions, I decided to use it to upload this post and general site update.