orrg

online rss & atom feed reader for gemini
git clone https://git.clttr.info/orrg.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit 91fa217cdd71e89b519ad14d891e148fa0be3023
parent f847c41903390f842e3b4a1b1d7b4c6a99b30327
Author: René Wagner <rwa@clttr.info>
Date:   Sat,  9 Apr 2022 19:14:38 +0200

use gmni instead of gcat

closes #4

Diffstat:
MREADME.md | 2+-
Dgcat | 72------------------------------------------------------------------------
Morrg.pl | 2+-
3 files changed, 2 insertions(+), 74 deletions(-)

diff --git a/README.md b/README.md @@ -39,5 +39,5 @@ Given this restrictions is not suitable for high traffic feeds which are updated - DateTime - DateTime::Format::ISO8601 - HTML::Strip -- Python 3 for `gcat` +- gmni (from https://git.sr.ht/~sircmpwn/gmni or https://src.clttr.info/rwa/cgmnlm) - wget diff --git a/gcat b/gcat @@ -1,72 +0,0 @@ -#!/usr/bin/env python3 - -import cgi -import os -import socket -import ssl -import sys -import urllib.parse - -def absolutise_url(base, relative): - # Absolutise relative links - if "://" not in relative: - # Python's URL tools somehow only work with known schemes? - base = base.replace("gemini://","http://") - relative = urllib.parse.urljoin(base, relative) - relative = relative.replace("http://", "gemini://") - return relative - -if len(sys.argv) != 2: - print("Usage:") - print("gcat gemini://gemini.circumlunar.space") - sys.exit(1) - -url = sys.argv[1] -parsed_url = urllib.parse.urlparse(url) -if parsed_url.scheme == "": - url = "gemini://"+url - parsed_url = urllib.parse.urlparse(url) - -if parsed_url.scheme != "gemini": - print("Sorry, Gemini links only.") - sys.exit(1) -if parsed_url.port is not None: - useport = parsed_url.port -else: - useport = 1965 -# Do the Gemini transaction -while True: - s = socket.create_connection((parsed_url.hostname, useport)) - context = ssl.SSLContext() - context.check_hostname = False - context.verify_mode = ssl.CERT_NONE - s = context.wrap_socket(s, server_hostname = parsed_url.netloc) - s.sendall((url + '\r\n').encode("UTF-8")) - # Get header and check for redirects - fp = s.makefile("rb") - header = fp.readline() - print(header.decode("UTF-8"), end="") - header = header.decode("UTF-8").strip() - status, mime = header.split()[:2] - # Handle input requests - if status.startswith("1"): - # Prompt - query = input("INPUT" + mime + "> ") - url += "?" + urllib.parse.quote(query) # Bit lazy... - # Follow redirects - elif status.startswith("3"): - url = absolutise_url(url, mime) - parsed_url = urllib.parse.urlparse(url) - # Otherwise, we're done. - else: - break -# Fail if transaction was not successful -if status.startswith("2"): - if mime.startswith("text/"): - # Decode according to declared charset - mime, mime_opts = cgi.parse_header(mime) - body = fp.read() - body = body.decode(mime_opts.get("charset","UTF-8")) - print(body, end="") - else: - print(fp.read(), end="") diff --git a/orrg.pl b/orrg.pl @@ -112,7 +112,7 @@ sub feed_get my $content; if ( $query =~ /^https\:\/\// ) { $content = `wget -qO - $query`; } if ( $query =~ /^gemini\:\/\// ) { - $content = `./gcat $query`; + $content = `gmni -L -j once -i $query`; $content =~ /20\W/ or return undef; $content =~ s/^[0-9]{0,2}\W.+\r\n//; }