Adds a check about the item author and a backup if one is not there. Tidied up some CSS

This commit is contained in:
Jacob Haddon 2024-02-20 20:07:47 -05:00
parent cf59c9248d
commit 38400c7b82

View File

@ -1,5 +1,5 @@
#!/usr/bin/perl
use cPanelUserConfig; #for cpanel servers
# use cPanelUserConfig; #for cpanel servers
use 5.010;
use strict;
@ -63,6 +63,7 @@ my %list;
# Make the list of URLS while parsing DATA
my $listHTML = "<div class=\'listHTML\'><ul>\n";
# Go through each URL in the DATA section and make the new list
while ( my $url = <DATA>) {
chomp $url;
@ -96,6 +97,15 @@ while ( my $url = <DATA>) {
$testItem->{'feedURL'} = $_;
$testItem->{'feedName'} = $rss1->{'channel'}{'title'};
# Find Author tags
if ($testItem->{'dc'}{'creator'}) {
$testItem->{'itemAuthor'} = $testItem->{'dc'}{'creator'};
} elsif ($testItem->{'author'}) {
$testItem->{'itemAuthor'} = $testItem->{'author'}
} else {
$testItem->{'itemAuthor'} = $rss1->{'channel'}{'title'};
} # if author
# Clean up some of the artifacts in the RSS feed 'description' section
$testItem->{'description'} =~ s/\n\s*/\n/g; # get rid of excess white space
$testItem->{'description'} =~ s/(<a(.+?)<\/a>)$//s; # link at end of description
@ -151,7 +161,7 @@ foreach my $name (reverse sort keys %list) {
link => $list{$name}->{'link'},
description => $list{$name}->{'description'},
pubDate => $list{$name}->{'pubDate'},
author => $list{$name}->{'dc'}{'creator'},
author => $list{$name}->{'itemAuthor'},
source => $list{$name}->{'feedName'},
sourceUrl => $list{$name}->{'feedURL'},
); # $rss->channel
@ -204,9 +214,7 @@ my $html = <<"HTML_END";
body{
margin:40px auto;
max-width:650px;
line-height:1.6;
font-size:18px;
font-family: Baskerville, TimesNewRoman, Times New Roman, Times, Georgia, serif;
font: 18px/1.6 baskerville, palatino, 'palatino linotype', georgia,serif;
padding:0 10px:
word-break: break-word;
}
@ -239,7 +247,7 @@ my $html = <<"HTML_END";
<h1>$title</h1>
<p>$description</p>
<p>This site is updated every Sunday morning</p>
<p>This site is in BETA and will update daily as we test things out and add URLs. Let us know if there are sites that should be included!</p>
<p>updated: $printDate</p>
</header>
@ -305,12 +313,13 @@ close(FH);
###################################
sub formatDate {
# takes a date, and converts it to a formatted string
my $testDate = $_[0];
$testDate =~ s/((\+|\-)(\d\d\d\d))//;
# Convert to a TIME object
my $t = Time::Piece->strptime($testDate);
return($t->strftime('%a, %d %b %Y %H:%M:%S'));
}
} # sub formatDate
# FIN
@ -326,10 +335,10 @@ https://kelliowen.com/feed/
https://mercedesmyardley.com/feed/
https://mehitobel.com/feed/
http://antoncancre.blogspot.com/feeds/posts/default?alt=rss
https://marysangi.wordpress.com/feed/
https://www.toddkeisling.com/news?format=rss
https://www.jfgonzalez.org/news?format=rss
https://www.briankeene.com/news?format=rss
https://ghoulish.rip/feed/
https://www.cemeterydance.com/extras/feed/
https://www.gwendolynkiste.com/Blog/feed/
https://katherinesilvaauthor.substack.com/feed
@ -339,3 +348,13 @@ http://jacobhaddon.com/feed/
http://apokrupha.com/feed/
https://ellendatlow.com/feed/
https://paulaguran.com/
https://amandaheadlee.com/feed/
https://theimbloglio.wordpress.com/feed/
https://kennethwcain.com/feed/
https://wellwortharead.blogspot.com/feeds/posts/default?alt=rss
http://robertfordauthor.com/feed/
https://tinyfrights.com/feed/
https://weightlessbooks.com/feed/
https://www.crystallakepub.com/feed/
https://lynnehansen.zenfolio.com/blog.rss
https://www.bevvincent.com/feed/