diff --git a/src/av98/client.py b/src/av98/client.py index 56509e6e..b5c60363 100755 --- a/src/av98/client.py +++ b/src/av98/client.py @@ -122,6 +122,13 @@ class GeminiItem(): def root(self): return GeminiItem(self._derive_url("/")) + def user(self): + if not self.path.startswith("/~"): + raise ValueError("This is not a tilde URL.") + new_path = self.path.split("/")[1] + "/" + print(new_path) + return GeminiItem(self._derive_url(new_path)) + def up(self): pathbits = list(os.path.split(self.path.rstrip('/'))) # Don't try to go higher than root @@ -1046,6 +1053,14 @@ Slow internet connection? Use 'set timeout' to be more patient.""") """Go to root selector of the server hosting current item.""" self._go_to_gi(self.gi.root()) + @needs_gi + def do_user(self, *args): + """If the current URL has a leading ~user/ component, go to its root.""" + try: + self._go_to_gi(self.gi.user()) + except ValueError: + print("The current URL does not appear to start with a tilde dir.") + def do_back(self, *args): """Go back to the previous gemini item.""" if not self.history or self.hist_index == 0: