guestbook

Having your website hosted on pubnix is a bit different than running your own server. Mainly you don't have control over the webserver itself, so while you can serve static websites just fine, you can't really do anything more interactive. So naturally since joining ^C I wanted to make something at least a bit interactive. You might be able to do some interaction via php, but that's hardly any challange and I really don't want to learn php.

So what are the options? Well, I can always just create program listening at some high port and send requests to it. Using rubys builtin socket library I can do just that. I'll make it listen on port 3700 and start simple loop to listen for incoming requests.

How will I get a request? Simple html form will do:

<form action="http://ctrl-c.club:3700">
   <label>Write something in</label><br>
   <textarea name="post" rows="6"></textarea><br>
   <input type="submit" value="Submit">
</form>

It will prompt the user if they really want to send the data, but I deem it acceptable.

This will however also redirect to response, so I just respond with html page containing:

<meta http-equiv="refresh"
  content="0;url=https://ctrl-c.club/~de_alchmst/guestbook">

It will redirect user back to the original guestbook page.

Next I take timestamp using:

Time.now.strftime("%Y-%B-%d %H:%M:%S")

This way there isn't any arguing about date format. Then I the posted message and make sure it can't cause any formatting problems. Since I read input directly from url, I use the builtin cgi library to decode it back to normal text.

Finally I just add the message and time into index files in public_html and public_gemini. (Also why is one named after markup and other after protocol again?)

finally run it with:

./guestbook &
disown

to make it survive after terminating shell and don't forget to use htop to give it some niceness level, since it won't be used very often. (13 for now)

Unfortunately, this means that it isn't possible to post here from gemini, but I might look into that later. I don't think that would be possible though, since while on the web I can always return to http and not worry about encryption. On gemini however, encryption is required and I would need access to server private key to to read what the user wants to post. But hey, at least it's minimal web with no JS that can be viewed in terminal browser.

source

Edit

I have added redirect through headers and link if not supported. You still have to refresh site manually in lynx, since it has some sort of cashing.

Other edit

also have a setup script now