orrg

Unnamed repository; edit this file 'description' to name the repository.
git clone git://code.clttr.info/orrg.git
Log | Files | Refs | README | LICENSE

commit 02a05701a382e226b83d63bdad35b0a01209beec
parent c200079891e3277da48e952a1c7decd219c8aa6d
Author: René Wagner <rwagner@rw-net.de>
Date:   Sat, 28 Nov 2020 08:53:03 +0100

introduce lib/orrg.pm

prepare for integration of feed lists

Diffstat:
MREADME.md | 9+++++++--
Aindex.pl | 27+++++++++++++++++++++++++++
Alib/orrg.pm | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
Morrg.pl | 39+++------------------------------------
4 files changed, 90 insertions(+), 38 deletions(-)

diff --git a/README.md b/README.md @@ -3,7 +3,9 @@ *orrg* is a cgi script for [gemini](gemini://gemini.circumlunar.space) servers. It delivers an easy way to consume atom or rss feeds shipped over http(s) within gemini. -Visit the [demo](gemini://gmndemo.clttr.info/orrg.pl?https:%2F%2Fgit.sr.ht%2F~rwa%2Forrg%2Flog%2Frss.xml) ([through http proxy](https://portal.mozz.us/gemini/gmndemo.clttr.info/orrg.pl%3Fhttps:%252F%252Fgit.sr.ht%252F~rwa%252Forrg%252Flog%252Frss.xml)) that shows the commit log of this repo. +Lists of popular and recently visited feeds help you discover new things. + +Visit the [demo](gemini://gmndemo.clttr.info/orrg/orrg.pl?https:%2F%2Fgit.sr.ht%2F~rwa%2Forrg%2Flog%2Frss.xml) ([through http proxy](https://portal.mozz.us/gemini/gmndemo.clttr.info/orrg.pl%3Fhttps:%252F%252Fgit.sr.ht%252F~rwa%252Forrg%252Flog%252Frss.xml)) that shows the commit log of this repo. The demo might break regularly as i use it for integration testing during development. ## features @@ -12,12 +14,15 @@ The demo might break regularly as i use it for integration testing during develo - render feed (channel info & entrys) as a gemini site - include links to originating site and every article - strip html tags from item description +- lists of popular and recently visited feeds Fetching feeds from gemini is currently not supported -> https://todo.sr.ht/~rwa/gmni-perl/4 ## non-features -*orrg* is more of a PoC and will never be a full-fletched feed aggregator with archiving and searching capabilities. +*orrg* will never be a full-fletched feed aggregator with archiving and searching capabilities. + +Given this restrictions is not suitable for highly traffic feeds which are updated very often. But it should work quite well # installation diff --git a/index.pl b/index.pl @@ -0,0 +1,27 @@ +#!/usr/bin/perl +# Copyright René Wagner 2020 +# licenced under BSD 3-Clause licence +# https://git.sr.ht/~rwa/orrg + +use strict; +use DBI; +use lib 'lib/'; +use orrg; + +# enable UTF-8 mode for everything +use utf8; +binmode STDOUT, ':utf8'; +binmode STDERR, ':utf8'; + +if (!defined($ENV{'SERVER_PROTOCOL'}) || $ENV{'SERVER_PROTOCOL'} ne 'GEMINI') { + write_response('CGI_ERROR', 'CGI execution error', undef); +} + +write_response('SUCCESS', 'text/gemini', body()); + +exit; + +sub body +{ + return ('# Welcome to orrg', '', 'orrg is your online rss/atom feed reader for gemini.', '', '=> orrg.pl view a feed', '', '## explore', '', '=> recent.pl top 10 recent feeds', '=> popular.pl top 10 popular feeds', '', '', '=> https://git.sr.ht/~rwa/orrg powered by orrg'); +} diff --git a/lib/orrg.pm b/lib/orrg.pm @@ -0,0 +1,53 @@ +#!/usr/bin/perl +# Copyright René Wagner 2020 +# licenced under BSD 3-Clause licence +# https://git.sr.ht/~rwa/orrg + +package orrg; +use strict; +use Exporter; +our @ISA = qw(Exporter); +our @EXPORT = qw(write_response %RC); # automatically exported subs + +# enable UTF-8 mode for everything +use utf8; +binmode STDOUT, ':utf8'; +binmode STDERR, ':utf8'; + +# define return codes +our %RC = ( + 'INPUT', 10, + 'SENSITIVE_INPUT', 11, + 'SUCCESS', 20, + 'TEMPORARY_REDIRECT', 30, + 'PERMANENT_REDIRECT', 31, + 'TEMPORARY_FAILURE', 40, + 'SERVER_UNAVAILABLE', 41, + 'CGI_ERROR', 42, + 'PROXY_ERROR', 43, + 'SLOW_DOWN', 44, + 'PERMANENT_FAILURE', 50, + 'NOT_FOUND', 51, + 'GONE', 52, + 'PROXY_REQUEST_REFUSE', 53, + 'BAD_REQUEST', 59, + 'CLIENT_CERT_REQUIRED', 60, + 'CERT_NOT_AUTHORISED', 61, + 'CERT_NOT_VALID', 62 +); + +sub write_response +{ + my ($returncode, $meta, @content) = @_; + + if (!defined($RC{$returncode})) { die "Unknown response code!"; } + + printf("%d %s\r\n", $RC{$returncode}, ($meta eq '') ? $returncode : $meta); + foreach (@content) { + print("$_\r\n"); + } + + exit; +} + +1; diff --git a/orrg.pl b/orrg.pl @@ -11,34 +11,14 @@ use HTML::Strip; use DateTime; use DateTime::Format::ISO8601; use POSIX qw(strftime); +use lib 'lib/'; +use orrg; # enable UTF-8 mode for everything use utf8; binmode STDOUT, ':utf8'; binmode STDERR, ':utf8'; -# define return codes -our %RC = ( - 'INPUT', 10, - 'SENSITIVE_INPUT', 11, - 'SUCCESS', 20, - 'TEMPORARY_REDIRECT', 30, - 'PERMANENT_REDIRECT', 31, - 'TEMPORARY_FAILURE', 40, - 'SERVER_UNAVAILABLE', 41, - 'CGI_ERROR', 42, - 'PROXY_ERROR', 43, - 'SLOW_DOWN', 44, - 'PERMANENT_FAILURE', 50, - 'NOT_FOUND', 51, - 'GONE', 52, - 'PROXY_REQUEST_REFUSE', 53, - 'BAD_REQUEST', 59, - 'CLIENT_CERT_REQUIRED', 60, - 'CERT_NOT_AUTHORISED', 61, - 'CERT_NOT_VALID', 62 - ); - if (!defined($ENV{'SERVER_PROTOCOL'}) || $ENV{'SERVER_PROTOCOL'} ne 'GEMINI') { write_response('CGI_ERROR', '', undef); @@ -90,19 +70,6 @@ sub create_response $it->link eq '' or push @body, ('=> '.$it->link.' open entry in browser', ''); } + push @body, ('', '', '=> index.pl [home]'); return @body; } - -sub write_response -{ - my ($returncode, $meta, @content) = @_; - - if (!defined($RC{$returncode})) { die "Unknown response code!"; } - - printf("%d %s\r\n", $RC{$returncode}, ($meta eq '') ? $returncode : $meta); - foreach (@content) { - print("$_\r\n"); - } - - exit; -}