diff options
| author | Zach DeCook <zachdecook@librem.one> | 2023-01-14 14:53:31 -0500 |
|---|---|---|
| committer | Zach DeCook <zachdecook@librem.one> | 2023-01-14 14:53:31 -0500 |
| commit | 03c758af3eaebd6b7c18e1e595d49b0552eb5278 (patch) | |
| tree | 45dffb292dbfadd1775b4d8a5e5e2a9049f177c6 /browset.py | |
| parent | 67bccc9e1a39ac2749806a37cb53b23322645083 (diff) | |
| download | browset-03c758af3eaebd6b7c18e1e595d49b0552eb5278.tar.gz | |
browset: Support data protocol
Diffstat (limited to 'browset.py')
| -rwxr-xr-x | browset.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/browset.py b/browset.py index 37e04b1..292b95d 100755 --- a/browset.py +++ b/browset.py @@ -8,6 +8,7 @@ from mime.gemtext import Gemtext from mime.plaintext import Plaintext from mime.highlightedcode import HighlightedCode,mimetolexer from protocol.gemini import GeminiProtocol +from protocol.data import DataProtocol class Browset(App): url = "" @@ -69,8 +70,16 @@ class Browset(App): if histore: self.history.append(self.url) self.url = url - (mime, fp) = GeminiProtocol.get(url) + protocol = url.split(":")[0] + if protocol == "gemini": + (mime, fp) = GeminiProtocol.get(url) + elif protocol == "data": + (mime, fp) = DataProtocol.get(url) + else: + (mime, fp) = ("error", ["Unsupported protocol: " + protocol]) + self.query_one("#content").remove() + if "text/gemini" in mime: content = Gemtext(fp=fp, id="content") elif mime in mimetolexer: |
