💾 Archived View for supernovas.space › gemlog › 2023-08-19-gemini-page-counter.gmi captured on 2023-12-28 at 15:06:23. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-09-08)
-=-=-=-=-=-=-
Remember the page hit counters popular on 90s websites? I find gemini[1] sites take me back to that era, so I was thinking it would be fun to recreate that on my gemini site[2]. Using CGI it is pretty simple, and I will show you how.
1: https://gemini.circumlunar.space/
I was thinking about how I wanted to do it. The easiest thing to do is just have a number stored somewhere and increment it by one when the page loads. Yes, that would be simple and effective, but what if I wanted to look at trends? I can record the timestamp of the page view into a running log. Gemini also has client certificates that can identify unique users, so I can also record certificate hashes to see unique page views. OK, this is getting too much like modern creepy Google Analytics. I think I just want to record the timestamp and that's it!
You will need a gemini server that can run CGI. I am using gemserv and chose to use BASH as my CGI language for this task. Here is the script for my index.gmi page:
#!/bin/bash echo