t* fefes blog on gopher URI git clone git://git.codevoid.de/fefe-gopher DIR Log DIR Files DIR Refs DIR LICENSE --- DIR commit c90b61ac6a1acf7795602af1558ff0e0290a62ad DIR parent 3c36629b925ebdbdc68695110bba454bf68a9467 URI Author: Stefan Hagen <sh+git[at]codevoid[dot]de> Date: Thu, 7 Jun 2018 18:44:12 +0200 Fix ^t design for real. Skip empty link sections Diffstat: M fefe.dcgi | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) --- DIR diff --git a/fefe.dcgi b/fefe.dcgi t@@ -53,6 +53,7 @@ foreach my $channel ($root->findnodes('channel')) { # Encode to proper utf8 my $description = encode("UTF-8", $item->findvalue('description')); + $description =~ s|<a href="/|<a href="https://blog.fefe.de/|ig; # Search for links my $LX = new HTML::LinkExtractor(); t@@ -76,6 +77,10 @@ foreach my $channel ($root->findnodes('channel')) { my $links = ""; foreach my $link ($LX->links) { foreach my $linkitem (@$link) { + + # skip empty links (image links for example) + if(!$linkitem->{_TEXT}) { next; } + $c++; $description_clean =~ s/(\Q$linkitem->{_TEXT}\E)/$1\[$c]/gi; t@@ -91,15 +96,20 @@ foreach my $channel ($root->findnodes('channel')) { # Wrap to 80 character width $description_clean = wrap("","",$description_clean)."\n"; - # fix geomyidae ^t design - $description_clean =~ s/^t/&&/g; - # nobody needs more that one newline. $description_clean =~ s/\n\n(\n)*/\n\n/g; + # fix geomyidae ^t design + $description_clean =~ s/\t/ /g; + $description_clean =~ s/\nt/\ntt/g; + # print! - print $description_clean, "\nLinks:\n", $links, "\n"; - print "***********************************************************************\n\n"; + print $description_clean; + # print links if there were any. + if($links) { + print "\nLinks:\n", $links; + } + print "\n***********************************************************************\n\n"; } } print "[1|<- go back|/|codevoid.de|70]";