All checks were successful
Build and Deploy Hugo / deploy (push) Successful in 18s
49 lines
2.8 KiB
Markdown
49 lines
2.8 KiB
Markdown
---
|
|
title: "Upvoters - Small rust back-end for anonymous likes on static blogs"
|
|
date: 2026-03-21T22:47:50-04:00
|
|
tags: ["Rust", "Hugo", "Web Design", "Self-Host"]
|
|
---
|
|
|
|
## Long Story Short
|
|
|
|
I wrote a little system called [upvoters](https://github.com/aselimov/upvoters) in Rust to handle anonymous upvotes, and it's compatible with Hugo!
|
|
In fact, you should see a little chevron at the bottom of this post to upvote if you like it.
|
|
Check it out if you need something like it!
|
|
|
|
## Motivation
|
|
|
|
I've been working on some website refactors/design changes lately.
|
|
My taste has been influenced recently.
|
|
I may at some point write something about my taste evolution.
|
|
The tl;dr for that article is that I came across an article on [Armin Ronacher's blog](https://lucumr.pocoo.org/about/) and was hugely affected.
|
|
I've been trying to use my little piece of internet land to serve an aesthetic, technical, and minimal blog and his site is what I wish mine was.
|
|
|
|
While I don't have all of Armin's experience or skills, I thought I could at least try to give off a similar vibe with my own site.
|
|
I use Hugo to generate my static blog, so my first try was searching through existing Hugo themes to get a starting point.
|
|
The rest of the story I think works better as an enumeration:
|
|
|
|
1. Came across the [hugo-bearcub theme](https://github.com/clente/hugo-bearcub) by clente.
|
|
2. Looked up [Bear Blog](https://bearblog.dev/).
|
|
3. Looked up the creator of Bear Blog, [Herman Martinus](https://herman.bearblog.dev/).
|
|
4. Read through some of his posts and noticed his little anonymous upvote button.
|
|
5. Thought the anonymous upvote button was super cool and wanted my own.
|
|
|
|
## Upvoters
|
|
|
|
I then spent a couple hours putting together `upvoters`, a little Rust web server to handle this functionality.
|
|
I picked postgres for the db because I run this site (and a few other services like email, matrix, [forgejo](https://forge.alexselimov.com), etc...) using a VPS that already had a postgres setup.
|
|
Probably could've just done SQLite to make it easier on everyone but didn't think about that until later.
|
|
|
|
This service just tracks votes in a single table with the following important variables in the schema:
|
|
|
|
1. `slug`: A unique identifier for each post that is just created from the URL.
|
|
2. `voter_id`: A unique identifier for each voter.
|
|
|
|
Since this is just a personal blog, and exact upvote count doesn't matter, the `voter_id` is a UUID assigned to each user as a cookie upon the first vote.
|
|
Obviously all it takes to "break" the system is clearing your cookies.
|
|
This would allow you to upvote the same post multiple times but the only risk there is me getting delusions of grandeur.
|
|
|
|
## Getting started with it
|
|
|
|
I wrote some instructions in the [upvoters](https://github.com/aselimov/upvoters) readme, but also feel free to email me if you need help setting it up!
|
|
|