diff --git a/archetypes/posts.md b/archetypes/posts.md index 205fc90..68cad01 100644 --- a/archetypes/posts.md +++ b/archetypes/posts.md @@ -1,5 +1,5 @@ --- title: "{{ replace .Name "-" " " | title }}" date: {{ .Date }} -topics: [] +tags: [] --- diff --git a/content/posts/upvoters.md b/content/posts/upvoters.md new file mode 100644 index 0000000..e61232e --- /dev/null +++ b/content/posts/upvoters.md @@ -0,0 +1,49 @@ +--- +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! + diff --git a/hugo.toml b/hugo.toml index 2a352a3..bfa2da0 100644 --- a/hugo.toml +++ b/hugo.toml @@ -57,3 +57,4 @@ upvoteApi = "https://www.alexselimov.com/api" [params.author] name = "Alex Selimov" +email = "alex@alexselimov.com" diff --git a/themes/hugo-bearcub b/themes/hugo-bearcub index ecceb7a..556c172 160000 --- a/themes/hugo-bearcub +++ b/themes/hugo-bearcub @@ -1 +1 @@ -Subproject commit ecceb7afa9e0973ffc98336474eefe2544b60629 +Subproject commit 556c1725abbfe0601e216896b257858893642010