Broken project to implement a cross-protocol browser in textual
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: