Hoagiebin improvements

Published 2025-10-21

tag(s): #smallweb #meta #programming

I don't think I've written this many "techie" posts in a row since I started the blog 🤔

In this post I mentioned that I now have a small dynamic site. Yes, it is written in Common Lisp. How could it not be? 😎 Here is the repo.
I set up the site, and created a Pastebin clone, which seemed like an easy enough thing to get started with web development in CL.[1]

You can play with it here: Hoagiebin

Original state

Now, the version I published on the the very first try worked only via curl. The next day I added a page to paste text.
A couple days ago, I figured it could support file uploads from the browser too, and while thinking about it I realized it had...other problems.

Improvement 1: paste rendering

Take for example this paste created from the main function in Colibrí:

A screenshot of unformatted text in a browser window.
(direct link to image)

Even before testing it, I knew it would display like crap. Because the text was returned as-is, without even setting the Content-Type response header.
I had two options[2], set the header to text/plain, or render the output in a pair of <pre><code> tags. The advantage in the second case is that I can also set a nice title for the page. So I did that:

A screenshot of monospaced text in a browser window.
(direct link to image)

Later, when testing, I realized I also needed to escape HTML characters.
And I put this feature behind (brittle) detection, via the User Agent request header, of whether the request came from a browser or something else.
So that curl requests still get plain text directly.[3]

Improvement 2: upload from file

The renovated Hoagiebin homepage has a button to upload files. Pretty early on I thought I didn't want validation of file types, but after testing for a bit, that opened the door to a bunch of errors. Instead of trying to predict the problems, the error message is printed back in a very plain page, with a link to go back.

I find this one the most "scary" features in the tool, but I think I did just enough to prevent something/someone from breaking the site.
If they aren't actively trying, I mean. I am sure there are a lot of ways to break it :) but my concern was that it wouldn't break during normal usage.
And also, the textarea is probably as vulnerable as the uploads... 🤷

Improvement 3: HTML templates and nicer(?) pages

Ahhh, who doesn't love a good template, right? That's how all the posts in this site start their life as: a "sample" file with some example markup, and some markers here and there.
I moved the all three pages in Colibrí out of the code, and into template files. And then I added a bunch of other pages! And made the pages more beautiful...for my extremely limited design sensibilities. I mean, look around this site. Right?

But, I still didn't want to invest the time to learn a proper HTML generation framework (I think the one I would use is Spinneret), in part because I am only replacing one or two values in each template. And also because I wanted to focus in Hunchentoot and the routing part first.

Other code cleanup tidbits, and what did I learn

I moved around some of the code, because I think long term, the colibri.lisp source file will have only the routing/pure web parts, and I will divide the system in smaller files, one for each site (hoagiebin.lisp, tool2.lisp, etc).
So I removed more things from the routing definitions and moved them to individual functions. And the vibe that gives me is that of ASP.NET MVC applications, and the routes would be the Controller part.
But that's were the similarities end. So far?

I will still keep everything in the same package, as I don't anticipate anything I can build being big enough to justify living in a separate namespace (that's what packages are in CL, more or less).

And then I had to deal a bit with reading and changing headers, and revisit with-output-to-string, which I discovered somewhat recently. I could have imported another library for that string clean up, and probably eventually will. But for this single project, that is all.

What's next

Earlier this morning I could have shared a snippet using Hoagiebin, but felt like I shouldn't because the tool was unstable and ugly. It still is ugly, but I would like to think now it is stable, which is why I am writing this post talking about it.

And other than fixing bugs in it, I don't know what else I could add.
OK, there are things to add, stuff like syntax highlighting for example. But I have no interest in such features.[4]
All that is left now is using the site, and thinking of the next tool.
Or finishing the dict server...

Footnotes
  1. It's been ages since I did any web development, regardless of platform.
  2. I mean, I thought of two options. Of course there were more 🤷
  3. I think I should have set the response header to text for curl and friends...But I am only realizing this now :)
  4. First, look at the rest of this site. Second, remember how my Emacs theme is minimal to the point of using almost no colors? So, yep, not adding syntax highlighting to Hoagiebin.

Share your thoughts (via email)

Back to top

Back to homepage