💾 Archived View for bbs.geminispace.org › u › skyjake › 12063 captured on 2023-12-28 at 16:43:50. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
Lagrange does indeed have a way to do this. It is called "MIME hooks" and it is documented in Help, section 4.
However, I doubt you'll want to use this. The filters you register via MIME hooks are unconditionally run on every matching page. This would make every Gemtext page with links load extremely slowly as it has to finish checking each link before showing the filtered results. Furthermore, you'd run the risk of overburdening slower servers by sending them too many requests at once.
I have been planning to improve the hooks system with things like applying the filter only manually when requested, but it hasn't been a high priority.
Nov 30 · 4 weeks ago
☯️ oldernow · Nov 30 at 14:44:
@skyjake Thanks for the "MIME hooks" documentation pointer!
However, I doubt you'll want to use this. The filters you register via MIME hooks are unconditionally run on every matching page. This would make every Gemtext page with links load extremely slowly as it has to finish checking each link before showing the filtered results. Furthermore, you'd run the risk of overburdening slower servers by sending them too many requests at once.
I'm not understanding the "at once" part of that, as I'm running gemget in a loop, subsequent invocations not running until the one before them completes. Or would hitting a server several times in a row, each spaced two seconds apart still be considered being impolite, as it were?
FWIW, I made improvements to the aforementioned Lua script, leveraging obtaining an exit status from os.execute() instead of parsing gemget stderr from io.popen(). (I think there's a way to get command exit status down the io.popen() path, but I'm not remembering the details, and a quick grep'ing of old scripts didn't reveal anything.). I also noticed gemget has a "--connect-timeout" option. Two seconds will probably cause me to miss out on some links unnecessarily, but then I tend toward impatience and probably wouldn't want to be waiting on such links regardless the content given my Gemini travels have me rough-estimating that maybe 1% of links overall ever lead to something that "really does it for me":
#! /usr/bin/env lua for line in io.stdin:lines() do local url,title = string.match(line, '^=>%s*(%S*)%s*(.*)