oh look, it's "that weird console guy writes a blog software again" day! but this time it's in lowercase. in fact, it is
so much lowercase that i even
post this in lowercase!
Application Name | zb |
Version | n/a |
Short description | a self-contained blog software |
Supported OSes | all that run rust |
Web page | https://code.rosaelefanten.org/zb |
Download link | attached |
Author | hi. |
descriptionthis is my approach at creating a self-contained website. the whole site will be embedded as a zip archive right in the server binary file, so it is probably the most portable website you'll ever have.
one of zb's unique features it that it will render html, markdown and org-mode files, so if you prefer to write .org files instead of html, zb has you covered.
motivation
i first saw the concept of single binary websites in ted unangst's blog where he complained that go couldn't do this just as easily, because of its broken support for embedded zip files. as i play with both go and rust every now and then, i thought "how hard could it be to do it in rust?".
quite surprisingly (for me), it wasn't really hard at all.
how do i use this?
you'll need a zip file, containing your website. for the default start page, zb will search for one of the following files in the root path:
1. index.htm
2. index.html
3. index.md
4. index.org
if you prefer to use a different file name, you can pass --defaultpage name.ext when starting the application.
everything else in that zip file can be any file of your choice. relative references between them will work. (if they don't, please file a bug.)
first steps...
- use the attached zb.exe binary or
- install rust, then build zb with cargo:
fossil clone https://code.rosaelefanten.org/zb
cd zb
cargo build --release
now, concatenate your zb.exe with your zip file. assuming your zip file is named index.zip:
# powershell
cmd /c copy /b .\zb.exe+.\index.zip .\final-site.exe
# cmd
copy /b .\zb.exe+.\index.zip .\final-site.exe
once done ...
run the concatenated binary (in this example, final-site.exe) and your website will be delivered from port 8000. (you can change that: final-site --port 8081 would make it run on port 8081 instead.) from now on, every time you want to update your website, just create a new zip file and repeat the concatenation. (it should be easy to automatize that task.)
automatic converted html routing
it is important to note that the file extensions for .org, .md and html files are optional, so the file stuff/demofile.md can be reached over localhost:8000/stuff/demofile as well.
the search order for all files is:
1. /[path]
2. /[path].md
3. /[path].org
4. /[path].htm
5. /[path].html
planned featuresnone, but i accept patches.
tipsdon't try this at home.