]> git.xolatile.top Git - emil-xolatile.top.git/commitdiff
rss
authorEmil Williams <emilemilemil@cock.li>
Mon, 4 Aug 2025 15:34:58 +0000 (15:34 +0000)
committerEmil Williams <emilemilemil@cock.li>
Mon, 4 Aug 2025 15:34:58 +0000 (15:34 +0000)
bloog/bloog.pl

index aedae3ff96bf4520c08d7d8f4aa1036d0f0a3d71..98909c13219cfbb8ced3bf5f71af4ac4c8873fbe 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/perl
-# feed.xml generator
-# remember to put the last chronologically at the end of the ARGV list
+# everything generator
+# remember to put the last one chronologically at the end of the ARGV list
 use Template;
 use Time::Piece;
 use POSIX qw(strftime);
@@ -16,10 +16,9 @@ my $last_time = '';
 my $fh;
 
 foreach $argnum (0 .. $#ARGV) {
-    my $buffer;
     open($fh, '<', $ARGV[$argnum]) or die $!;
     # general data
-    chomp(my $date = <$fh>);
+    chomp(my $date        = <$fh>);
     chomp(my $author      = <$fh>);
     chomp(my $rss_title   = <$fh>);
     chomp(my $html_title  = <$fh>);
@@ -34,10 +33,12 @@ foreach $argnum (0 .. $#ARGV) {
         rss_title   => $html_title,
         description => $description,
     };
+    my $buffer = '';
     # rss item
     $template->process('feed_item.xml', $data, \$buffer)
         || die $template->error(), "\n";
     push(@rss_items, $buffer);
+    $buffer = '';
     # index item
     $template->process('index_item.html', $data, \$buffer)
         || die $template->error(), "\n";
@@ -47,7 +48,7 @@ foreach $argnum (0 .. $#ARGV) {
     my @paragraphs = ();
     my $pre = 0;
     my $raw = 0;
-    while (my $line = <STDIN>) {
+    while (my $line = <$fh>) {
         chomp(my $short = $line);
         if ($short eq '' && not $pre && not $raw) {
             unless (substr($buffer, 0, 1) eq '<' && raw) {
@@ -78,7 +79,7 @@ foreach $argnum (0 .. $#ARGV) {
         push(@paragraphs, $buffer);
     }
     my $article;
-    $data->paragraphs = \@paragraphs;
+    $data{paragraphs} = \@paragraphs;
     $template->process('article.html', $data, \$article)
         || die $template->error(), "\n";
     close $fh;