💾 Archived View for supernovas.space › gemlog › 2021-06-26-new-search-function.gmi captured on 2024-12-17 at 09:57:26. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-09-08)
-=-=-=-=-=-=-
I mentioned before I wanted to try some more advanced gemini features, and here is my attempt at a search function for my gemlog. Thanks to some help from the people on the #gemini IRC channel correcting my rusty shell programming I got it working. The cgi script will do a grep search of all the gemlog post files for the provided search term and display the links to all the files that matched the search term. If you are just learning how gemini works this is a good place to start.
Here is the final script:
search.gmi #!/bin/bash # From gemini://gemini.susa.net/sitemap_script.gmi function urldecode() { # Replace-ALL (//) '+' with <space> : "${*//+/ }"; # Replace-ALL (//) '%' with escape-x and evaluate (-e) on echo echo -e "${_//%/\\x}"; } # Prompt for search term if none provided if ["$QUERY_STRING" == ""] then echo