💾 Archived View for gmn.clttr.info › sources › orrg.git › tree › popular.pl.txt captured on 2024-08-25 at 00:38:04.
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
#!/usr/bin/perl # Copyright René Wagner 2020 # licenced under BSD 3-Clause licence # https://src.clttr.info/rwa/orrg use strict; no warnings 'experimental'; use URI::Escape; 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', '', undef); } write_response('SUCCESS', 'text/gemini', create_response()); exit; sub create_response { my @body = (); push @body, ('# most popular feeds', ''); my $populars = popular_get(); if ( defined($populars) ) { my @sorted = sort { $a <=> $b } @$populars; my $c = 0; foreach (reverse @sorted) { my ($cnt, $uri, $name) = split / /, $_, 3; push @body, '=> ./orrg.pl?'. uri_escape($uri) .' '. ($name eq '' ? $uri : $name); ++$c < 10 or last; } } else { push @body, 'No feeds found'; } push @body, ('', '', '=> ./index.pl [home]'); return @body; }