Rename the gus command to search, and the old search to filter. Add option to set search endpoint.

This commit is contained in:
Solderpunk 2023-11-25 16:16:48 +01:00
parent 0268cd426b
commit 0e91b4f894

View File

@ -67,7 +67,7 @@ _ABBREVS = {
"r": "reload", "r": "reload",
"s": "save", "s": "save",
"se": "search", "se": "search",
"/": "search", "/": "filter",
"t": "tour", "t": "tour",
"u": "up", "u": "up",
} }
@ -246,7 +246,8 @@ class GeminiClient(cmd.Cmd):
"tls_mode" : "tofu", "tls_mode" : "tofu",
"gopher_proxy" : None, "gopher_proxy" : None,
"http_proxy": None, "http_proxy": None,
"cache" : False "cache" : False,
"search_url" : "gemini://geminispace.info/search"
} }
self.log = { self.log = {
@ -901,7 +902,7 @@ Slow internet connection? Use 'set timeout' to be more patient.""")
elif line.strip() == "..": elif line.strip() == "..":
return self.do_up() return self.do_up()
elif line.startswith("/"): elif line.startswith("/"):
return self.do_search(line[1:]) return self.do_filter(line[1:])
# Expand abbreviated commands # Expand abbreviated commands
first_word = line.split()[0].strip() first_word = line.split()[0].strip()
@ -1074,8 +1075,13 @@ Slow internet connection? Use 'set timeout' to be more patient.""")
def do_gus(self, line): def do_gus(self, line):
"""Submit a search query to the Gemini search engine.""" """Submit a search query to the Gemini search engine."""
gus = GeminiItem("gemini://geminispace.info/search") ui_out.warning("[WARNING] The `gus` command is deprecated! Use `search` instead.")
self._go_to_gi(gus.query(line)) self.do_search(line)
def do_search(self, line):
"""Submit a search query a configured Gemini search engine."""
gi = GeminiItem(self.options["search_url"])
self._go_to_gi(gi.query(line))
def do_tour(self, line): def do_tour(self, line):
"""Add index items as waypoints on a tour, which is basically a FIFO """Add index items as waypoints on a tour, which is basically a FIFO
@ -1159,8 +1165,8 @@ Use 'ls -l' to see URLs."""
self._show_lookup(url=True) self._show_lookup(url=True)
self.page_index = 0 self.page_index = 0
def do_search(self, searchterm): def do_filter(self, searchterm):
"""Search index (case insensitive).""" """Filter index on names (case insensitive)."""
results = [ results = [
gi for gi in self.lookup if searchterm.lower() in gi.name.lower()] gi for gi in self.lookup if searchterm.lower() in gi.name.lower()]
if results: if results: