A review of the review feature

Published 2025-07-03

tag(s): #emacs #programming #meta

The last tea review post, I used for the first time a scoring system, based out of mini-Hoagies. I thought the idea was fun, and for a few days after that I was thinking of more things to review and grade, just to justify the amount of effort. Of course I didn't have any good ideas, and then forgot about it. 🤣

Well, am sipping a tea right now[1], which reminded me of it. And I figured, why not review the score system itself?

Prelude: review of Bigelow Earl Grey (teabag)

It's not bad. Not the worst tea I've ever had. BUT...
The citric flavor is more sour than it should be. Like, compared to Teapigs "strong" Earl Grey, this one is less flavorful and aromatic, but about the same sourness. And the underlying tea is pretty bland too.
Will drink it again, but that has more to do with circumstances than the tea itself.

One star
1 out of 5 Hoagies

The mini-Hoagie image

I thought of using little hoagie roll breads, but they looked like mini hot dogs when in a small size. Or like just a blob, if using a picture of a proper sandwich.

So instead, I took the "front" view of the Hoagie sprites in my homepage, and reduced the size enough that it would look small, but not like a little dot, in my 4K monitor. I also checked that the image size was reasonable in my phone. I won't link the end result, since you can see it in the score below.

One star One star One star One star Half star
4.5 out of 5 Hoagies

The command

The markup template

All this site is based on text templates, where some values get replaced and inserted as needed. Even the RSS feed.
For this template, I ran into a number of challenges.

First, I still had to decide if I wanted scores out of ten, or out of five. I was leaning on out of five, which meant it was important to have the ability to do half-stars half-Hoagies, for more granularity.
It was at this point, and not before, that I decided to go back and create a half-image, which I foresaw (correctly) would make things simpler down the line.

Then I put up a page, not linked anywhere, where I uploaded different iterations of the mark up. The first tests were horrible, though, and I couldn't understand why the images looked huge.
Then I remembered that I have a little CSS on the site - it is hardcoded on each page, because it is part of the "common template" that I don't even think about. And one thing said template does, and it is very important, is to make sure big images don't take up a lot of screen space on mobile:


img {
    width: 80%;
    height: auto;
}
    
Meme image where the author wonders if 3 lines of hardcoded CSS are responsive web
              design.
(direct link to image)

The way this works, for you non-developers out there (although I think I lost them all by now. And developers too, probably), is that ALL images are set to 80% screen width maximum. If I want images to display at their "real" size, I need to override the property, to the default value, which is "don't resize this, display in original size.". So:


(tag-template "<img style=\"object-fit: none; width:auto\" src=\"%s\" alt=\"%s\">\n")
    

The more attentive readers will say "you also define the object-fit CSS property". And I will say, I don't remember why, but I needed that.
I think.

One star One star One star
3 out of 5 Hoagies

Reading a score

Since I wanted to grade things in halves, I tried the lazy way out of reading the score in two parts. Like, 2, and then 5, for 2.5.
When I tested it, it was annoyingly unnatural. But also stupid, because I don't care for a 2.3 or a 2.6. At the same time, I didn't want to have a lot of code to validate, or parse and round up, invalid entries.

Then, while trying out different ways to read the input, it hit me that 1. only I will use this and 2. I only care if the score is not a simple integer. In any other case I can add a half mini-Hoagie.
Hooray for interactive development! I realized these things as I was testing a small skeleton of the final command, that read and printed back the number(s).


(total (read-number "Total score: " 5))
(score (read-number "Score: "))
(add-half (not (= (truncate score) (ceiling score)))))
    

The other thing that I realized was that I didn't need to hardcode total score. Because I wasn't going to show a "grayed out" image, so I wasn't tied to grading things out of 5 or 10 or whatever.

One star One star One star One star One star One star One star One star One star One star
10 out of 5 Hoagies

Really proud of my thinking there.
And also of how silly the one-liner for "add a half" looks: is the integer part of the number the same as the number rounded up? If not, then I have to add a half.

Inserting the text


(insert "<p>\n")
(dotimes (- (truncate score) 1)
  (insert (format tag-template one-hoagie "One star")))
(when add-half
  (insert (format tag-template half-hoagie "Half star")))
(insert (format "<br>\n%s out of %s Hoagies\n</p>" score total))))
    

A younger me would have built a single string with all the mark up, then (insert...) only once.
Many years of Emacs Lisp later, I've grown to love working directly in buffers. As it is supposed be.

One star One star One star One star Half star
4.5 out of 5 Hoagies

The full command


(defun site-insert-score-minihoagies ()
  "Prompt for a score and total, insert minihoagies and text to match."
  (interactive)
  (let* ((one-hoagie "/media/minihoagie.png")
         (half-hoagie "/media/minihalfhoagie.png")
         (tag-template "<img style=\"object-fit: none; width:auto\" src=\"%s\" alt=\"%s\">\n")
         (total (read-number "Total score: " 5))
         (score (read-number "Score: "))
         (add-half (not (= (truncate score) (ceiling score)))))
    (insert "<p>\n")
    (dotimes (- (truncate score) 1)
      (insert (format tag-template one-hoagie "One star")))
    (when add-half
      (insert (format tag-template half-hoagie "Half star")))
    (insert (format "<br>\n%s out of %s Hoagies\n</p>" score total))))
    

Conclusion

This was a waste of everyone's time. Final rating:

Half star
0.5 out of 999 Hoagies

Footnotes
  1. I was at work when drinking the tea. I rarely write there, but it was a slow pre-Holiday afternoon. I am finishing and editing the rest of the post at home.

Share your thoughts (via email)

Back to top

Back to homepage