t* fefes blog on gopher URI git clone git://git.codevoid.de/fefe-gopher DIR Log DIR Files DIR Refs DIR LICENSE --- DIR commit c376a2704d93bbbc6104f211fdf1ce0961b52286 DIR parent 1f3177c6fbe58e3f4ef62b99a7f7828d91129538 URI Author: Stefan Hagen <git[at]codevoid[dot]de> Date: Mon, 14 May 2018 15:45:05 +0200 Reduced width to 72ch and clearer quotes Diffstat: M fefe.dcgi | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) --- DIR diff --git a/fefe.dcgi b/fefe.dcgi t@@ -1,19 +1,19 @@ #!/usr/local/bin/perl # LICENSE: WTFPL -# THE CODE IS PROVIDED "AS IS". DO WITH IT WHAT YOU WANT +# THE CODE IS PROVIDED "AS IS". DO WITH IT WHAT YOU WANT. # Copyright 2018 Stefan Hagen <sh dot vimcode dot de> use strict; use warnings; -use Encode; use XML::LibXML qw( ); use LWP::UserAgent; use HTML::LinkExtractor; use HTML::Restrict; use Text::Wrap; -$Text::Wrap::columns=80; +$Text::Wrap::columns=72; +use Encode; print ' ___ __ ___ _ t@@ -21,9 +21,9 @@ print ' | _|/ -_)| _|/ -_)(_-< | _ \| |/ _ \/ _` | |_| \___||_| \___|/__/ |___/|_|\___/\__, | On Gopher (inofficial) |___/ -------------------------------------------------------------------------------- +----------------------------------------------------------------------- [h| Visit Fefes Blog on the Internet|URL:https://blog.fefe.de|codevoid.de|70] -------------------------------------------------------------------------------- +----------------------------------------------------------------------- '; t@@ -62,8 +62,8 @@ foreach my $channel ($root->findnodes('channel')) { # Replace some HTML elements my $HR = HTML::Restrict->new(); $description =~ s/<p>/\n\n/g; - $description =~ s/<blockquote>/\n\n /g; - $description =~ s/<\/blockquote>/\n\n/g; + $description =~ s/<blockquote>/\n\n--- QUOTE ---\n/g; + $description =~ s/<\/blockquote>/\n---- END ----\n\n/g; # Strip remaining html my $description_clean = $HR->process($description); t@@ -81,7 +81,7 @@ foreach my $channel ($root->findnodes('channel')) { # shorten links my $short = $linkitem->{href}; - if(length($short) > 70) { $short = substr($short,0,70)." ..."; } + if(length($short) > 62) { $short = substr($short,0,62)." ..."; } # add link to output scalar $links .= sprintf("[h|[%i]: %s|URL:%s|codevoid.de|70]\n", $c, $short, $linkitem->{href}); t@@ -99,10 +99,11 @@ foreach my $channel ($root->findnodes('channel')) { # print! print $description_clean, "\nLinks:\n", $links, "\n"; - print "*******************************************************************************\n\n"; + print "***********************************************************************\n\n"; } } + # TODO: # * consolidate regex and call the regex parser only twice (before parsing => strip / replace html, # after parsing => format output)