logo

drewdevault.com

[mirror] blog and personal website of Drew DeVault git clone https://hacktivis.me/git/mirror/drewdevault.com.git

HN-over-Gemini.gmi (1903B)


  1. I had an idea today: I wonder if we could convert HTML to Gemtext by using the guts of Firefox's reader view to simplify it to a reasonable subset of HTML first?
  2. The answer is yes.
  3. It works best with article-style content, so to illustrate this, I've create a mirror of Hacker News in geminispace that converts the linked articles to Gemtext for better viewing in your favorite Gemini client.
  4. NOTE 2021-03-07: This link no longer works; I shut it off due to bugs in my Gemini server. I'll fix them eventually :)
  5. => /cgi-bin/hn.py Browse Hacker News over Gemini
  6. Note that it's kind of finicky (and, to be honest, so is gmnisrv), so we can hopefully expect it to become more stable over time as I improve gmnisrv and flush out the bugs. In the meantime, be patient with it, and maybe hit refresh if it doesn't work the first time. I might expand the featureset a bit as well, adding comments, user pages, pages other than the front page, and so on.
  7. The HTML to Gemtext conversion works even better than I expected. The guts of it are in a small JavaScript program:
  8. => gemini://drewdevault.com/cgi-bin/web.sh?https://git.sr.ht/~sircmpwn/gci-scripts/tree/master/web2gmi.js web2gmi.js (viewed on git.sr.ht via the readability converter!)
  9. This can stand alone pretty well on its own, so I might refactor things to convert this less from a purpose-built HN viewer and into a more general-purpose gemini-to-web gateway. Patches also welcome, if anyone wants to help out with that.
  10. The other component is just a little bit of rigging to consult the HN API, render the front page as Gemtext, and handle the linkage to the web to gemtext converter.
  11. => gemini://drewdevault.com/cgi-bin/web.sh?https://git.sr.ht/~sircmpwn/gci-scripts/tree/master/hn.py hn.py (via git.sr.ht)
  12. The source code is available in my CGI scripts repository:
  13. => https://git.sr.ht/~sircmpwn/gci-scripts gci-scripts (HTTP)
  14. Cheers!