topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Tuesday October 15, 2024, 1:39 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: NANY 2023: zb, a zip blog  (Read 6622 times)

Tuxman

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,504
    • View Profile
    • Donate to Member
NANY 2023: zb, a zip blog
« on: August 29, 2022, 06:04 PM »
NANY 2023 Entry Information

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.

description

this 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 features

none, but i accept patches.

tips

don't try this at home.
« Last Edit: September 01, 2022, 06:57 PM by Tuxman »

sphere

  • Participant
  • Joined in 2018
  • *
  • default avatar
  • Posts: 176
    • View Profile
    • Donate to Member
Re: NANY 2023: zb, a zip blog
« Reply #1 on: April 13, 2023, 10:03 PM »
very cool

Tuxman

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,504
    • View Profile
    • Donate to Member
Re: NANY 2023: zb, a zip blog
« Reply #2 on: April 14, 2023, 05:08 AM »
Glad you like it!