summary refs log tree commit diff
path: root/browset.py
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2023-01-28 17:22:30 -0500
committerZach DeCook <zachdecook@librem.one>2023-01-28 17:22:30 -0500
commit241528e32b7614598badcca42b4faee23217bf27 (patch)
tree404ff43a1fe5aa8d0bd04774724a86f7a875f29a /browset.py
parent88eac6043213185757075b6d182d5398ac412031 (diff)
downloadbrowset-241528e32b7614598badcca42b4faee23217bf27.tar.gz
Top button: fix behavior by using modified urllib.parse
Diffstat (limited to 'browset.py')
-rwxr-xr-xbrowset.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/browset.py b/browset.py
index 3c01c29..d2c23b2 100755
--- a/browset.py
+++ b/browset.py
@@ -12,6 +12,7 @@ from protocol.data import DataProtocol
 from protocol.http import HttpProtocol
 from protocol.about import AboutProtocol
 from subprocess import Popen, DEVNULL
+from gemurllib.parse import urljoin
 
 protocols = {
     "gemini": GeminiProtocol,
@@ -28,6 +29,7 @@ class Browset(App):
         Binding("ctrl+q,ctrl+c", "app.quit", "Quit", show=True),
         Binding("ctrl+left", "back()", "Back", show=False),
         Binding("ctrl+right", "soon()", "Soon", show=False),
+        Binding("ctrl+up", "top()", "Top", show=False),
         Binding("ctrl+o", "external_open()", "Open Externally"),
     ]
     history = []
@@ -38,7 +40,7 @@ class Browset(App):
         yield Footer()
         yield Container(
             Button("🔙", variant='primary', name='back', classes='mobile'), # ⏪
-            Button("🔝", name='../'), # ⏫
+            Button("🔝", variant='primary', name='top'), # ⏫
             Button("🔜", variant='primary', name='soon'), # ⏩
             Button("🔄", variant='primary', name='refresh'), # 🔁
             
@@ -57,10 +59,10 @@ class Browset(App):
           self.action_back()
         elif event.button.name == 'soon':
           self.action_soon()
+        elif event.button.name == 'top':
+          self.action_top()
       else:
         url = event.button.name
-        if not ":" in url:
-            url = GeminiProtocol.relativeURL(url, self.url)
         self._do_url(url)
 
 
@@ -84,8 +86,15 @@ class Browset(App):
       if len(self.fistory):
         url = self.fistory.pop()
         self._do_url(url, clearF=False)
+    def action_top(self):
+      if self.url[-1] == '/':
+        self._do_url('../')
+      elif self.url:
+        self._do_url('./')
 
     def _do_url(self, url, histore=True, setbar=True, clearF=True):
+        if not ":" in url:
+          url = urljoin(self.url,url)
         if clearF:
             self.fistory = []
         if setbar: