]> git.xolatile.top Git - emil-xolatile.top.git/commitdiff
merged everything
authorEmil Williams <emilemilemil@cock.li>
Mon, 4 Aug 2025 22:02:17 +0000 (22:02 +0000)
committerEmil Williams <emilemilemil@cock.li>
Mon, 4 Aug 2025 22:02:17 +0000 (22:02 +0000)
bloog/bloog.pl
bloog/html.pl [deleted file]
bloog/rss.pl [deleted file]
bloog/template/article.html
bloog/template/index.html
bloog/template/index_item.html

index 98909c13219cfbb8ced3bf5f71af4ac4c8873fbe..9abbece15f2f982f8265c314d6abe8711dfafd47 100755 (executable)
@@ -1,60 +1,62 @@
 #!/bin/perl
 # 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);
 
+my $outdir = 'out/';
+
 my $template = Template->new({
     INCLUDE_PATH => 'template',
     INTERPOLATE  => 1,
                             }) || die "$Template::ERROR\n";
 
-my @rss_items = ();
-my @index_items = ();
-my $last_time = '';
-my $fh;
+sub template_write {
+    my $content = '';
+    $template->process($_[0], $_[2], \$content)
+        || die $template->error(), "\n";
+    open(my $fh, '>', $_[1]) or die $!;
+    print $fh $content;
+    close $fh;
+}
 
-foreach $argnum (0 .. $#ARGV) {
-    open($fh, '<', $ARGV[$argnum]) or die $!;
-    # general data
-    chomp(my $date        = <$fh>);
-    chomp(my $author      = <$fh>);
-    chomp(my $rss_title   = <$fh>);
-    chomp(my $html_title  = <$fh>);
-    chomp(my $description = <$fh>);
-    my $pubdate = Time::Piece->strptime($date, '%Y%m%d')->strftime("%a, %d %b %Y %H:%M:%S %z");
-    $last_time = $pubdate; # this doesn't actually do any chronology
-    my $data = {
-        date        => $date,
-        pubdate     => $pubdate,
-        author      => $author,
-        rss_title   => $rss_title,
-        rss_title   => $html_title,
-        description => $description,
-    };
+sub bloog {
+    my %d;
+    open(my $fh, '<', $_[0]) or die $!;
+    chomp($d{'date'}        = <$fh>);
+    chomp($d{'author'}      = <$fh>);
+    chomp($d{'rss_title'}   = <$fh>);
+    chomp($d{'html_title'}  = <$fh>);
+    chomp($d{'description'} = <$fh>);
+    $d{'pubdate'} = Time::Piece->strptime($d{'date'}, '%Y%m%d')->strftime("%a, %d %b %Y %H:%M:%S %z");
+    return (\%d, $fh);
+}
+
+sub arrayify {
+    my ($name, $dref, $pushref) = @_;
+    %d = %$dref;
+    @push = @{$pushref};
     my $buffer = '';
-    # rss item
-    $template->process('feed_item.xml', $data, \$buffer)
+    $template->process($name, \%d, \$buffer)
         || die $template->error(), "\n";
-    push(@rss_items, $buffer);
-    $buffer = '';
-    # index item
-    $template->process('index_item.html', $data, \$buffer)
-        || die $template->error(), "\n";
-    push(@index_items, $buffer);
-    # article
-    $buffer = '';
-    my @paragraphs = ();
+    push(@push, $buffer);
+    return \@push;
+}
+
+sub html_write {
+    my ($dref, $fh) = @_;
+    %d = %$dref;
+    my @paragraph;
+    my $buffer = '';
     my $pre = 0;
     my $raw = 0;
     while (my $line = <$fh>) {
         chomp(my $short = $line);
         if ($short eq '' && not $pre && not $raw) {
-            unless (substr($buffer, 0, 1) eq '<' && raw) {
-                push(@paragraphs, "<p>\n" . $buffer . "</p>\n");
+            unless (substr($buffer, 0, 1) eq '<' and raw) {
+                push(@paragraph, "<p>\n" . $buffer . "</p>\n");
             } else {
-                push(@paragraphs, $buffer);
+                push(@paragraph, $buffer);
             }
             $buffer = '';
         } elsif ($short eq '.pre') {
@@ -72,36 +74,50 @@ foreach $argnum (0 .. $#ARGV) {
     }
     # I dare not use a function
     # I dare not use a goto (deprecated in 5.42, fuck you too)
-    # I am cucked forever to duplicate code
-    unless (substr($buffer, 0, 1) eq '<' && raw) {
-        push(@paragraphs, "<p>\n" . $buffer . "</p>\n");
+    # I am cucked forever and ever to to duplicate code
+    unless (substr($buffer, 0, 1) eq '<' and raw) {
+        push(@paragraph, "<p>\n" . $buffer . "</p>\n");
     } else {
-        push(@paragraphs, $buffer);
+        push(@paragraph, $buffer);
     }
-    my $article;
-    $data{paragraphs} = \@paragraphs;
-    $template->process('article.html', $data, \$article)
-        || die $template->error(), "\n";
-    close $fh;
-    open($fh, '>', 'out/' . $date . '.html') or die $!;
-    print $fh $article;
-    close $fh;
-}
 
-sub template_write {
+    $d{'paragraph'} = \@paragraph;
     my $content;
-    $template->process($_[0], $_[2], \$content)
+    $template->process('article.html', \%d, \$content)
         || die $template->error(), "\n";
-    open(my $fh, '>', $_[1]) or die $!;
-    print $fh $content;
-    close $fh;
+    open(my $out, '>', $outdir . $d{'date'} . '.html') or die $!;
+    print $out $content;
+    close($out);
 }
 
-template_write('index.html', 'out/bloog.html', {
-    items => \@index_items,
-               });
+sub main {
+    my @rss_items = ();
+    my @index_items = ();
+    my $last_time = '';
+
+    foreach $argnum (0 .. $#ARGV) {
+        # general data
+        my ($dref, $fh) = bloog($ARGV[$argnum]);
+        my %d = %$dref;
+        if ((($d{'pubdate'} cmp $last_time) == 1) && ($last_time eq '')) {
+            $last_time = $d{'pubdate'}
+        }
+        # rss & index
+        @rss_items   = @{arrayify('feed_item.xml', \%d, \@rss_items)};
+        @index_items = @{arrayify('index_item.html', \%d, \@index_items)};
+        # html page
+        html_write(\%d, $fh);
+        close($fh);
+    }
+
+    template_write('feed.xml', $outdir . 'feed.xml', {
+        items => \@rss_items,
+        last_time => $last_time,
+                   });
+
+    template_write('index.html', $outdir . 'bloog.html', {
+        items => \@index_items,
+                   });
+}
 
-template_write('feed.xml', 'out/feed.xml', {
-    items => \@rss_items,
-    last_time => $last_time,
-               });
+main;
diff --git a/bloog/html.pl b/bloog/html.pl
deleted file mode 100755 (executable)
index 763e99a..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/perl
-# what this do
-# converts a set of paragraphs delimed by \n\n into a <p></p>'d article.
-# ignores .pre until .pre, ignores .raw until .raw
-use Template;
-
-my $template = Template->new({
-    INTERPOLATE  => 1,
-                            }) || die "$Template::ERROR\n";
-
-chomp(my $date = <STDIN>);
-chomp(my $author = <STDIN>);
-chomp(my $rss_title = <STDIN>);
-chomp(my $html_title = <STDIN>);
-chomp(my $description = <STDIN>);
-my @paragraphs = ();
-my $buffer = '';
-my $pre = 0;
-my $raw = 0;
-while (my $line = <STDIN>) {
-    chomp(my $short = $line);
-    if ($short eq '' && not $pre && not $raw) {
-        unless (substr($buffer, 0, 1) eq '<') {
-            push(@paragraphs, "<p>\n" . $buffer . "</p>\n");
-        } else {
-            push(@paragraphs, $buffer);
-        }
-        $buffer = '';
-    } elsif ($short eq '.pre') {
-        $pre = ~ $pre;
-        if ($pre) {
-            $buffer .= "<pre>\n";
-        } else {
-            $buffer .= "</pre>\n";
-        }
-    } elsif ($short eq '.raw') {
-        $raw = ~ $raw;
-    } else {
-        $buffer .= $line;
-    }
-}
-# I dare not use a function
-# I dare not use a goto (deprecated in 5.42, fuck you too)
-# I am cucked forever and ever to to duplicate code
-unless (substr($buffer, 0, 1) eq '<') {
-    push(@paragraphs, "<p>\n" . $buffer . "</p>\n");
-} else {
-    push(@paragraphs, $buffer);
-}
-
-
-my $data = {
-    rss_title => $rss_title,
-    html_title => $html_title,
-    author => $author,
-    date => $date,
-    description => $description,
-    paragraphs => \@paragraphs,
-};
-
-$template->process('template.html', $data)
-    || die $template->error(), "\n";
diff --git a/bloog/rss.pl b/bloog/rss.pl
deleted file mode 100644 (file)
index 57516bc..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/bin/perl
-# 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);
-
-my $template = Template->new({
-    INCLUDE_PATH => 'template',
-    INTERPOLATE  => 1,
-                            }) || die "$Template::ERROR\n";
-
-my @rss_items = ();
-my @index_items = ();
-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 $author      = <$fh>);
-    chomp(my $rss_title   = <$fh>);
-    chomp(my $html_title  = <$fh>);
-    chomp(my $description = <$fh>);
-    my $pubdate = Time::Piece->strptime($date, '%Y%m%d')->strftime("%a, %d %b %Y %H:%M:%S %z");
-    $last_time = $pubdate; # this doesn't actually do any chronology
-    my $data = {
-        date        => $date,
-        pubdate     => $pubdate,
-        author      => $author,
-        rss_title   => $rss_title,
-        rss_title   => $html_title,
-        description => $description,
-    };
-    # rss item
-    $template->process('feed_item.xml', $data, \$buffer)
-        || die $template->error(), "\n";
-    push(@rss_items, $buffer);
-    # index item
-    $template->process('index_item.html', $data, \$buffer)
-        || die $template->error(), "\n";
-    push(@index_items, $buffer);
-    # article
-    $buffer = '';
-    my @paragraphs = ();
-    my $pre = 0;
-    my $raw = 0;
-    while (my $line = <STDIN>) {
-        chomp(my $short = $line);
-        if ($short eq '' && not $pre && not $raw) {
-            unless (substr($buffer, 0, 1) eq '<' && raw) {
-                push(@paragraphs, "<p>\n" . $buffer . "</p>\n");
-            } else {
-                push(@paragraphs, $buffer);
-            }
-            $buffer = '';
-        } elsif ($short eq '.pre') {
-            $pre = ~ $pre;
-            if ($pre) {
-                $buffer .= "<pre>\n";
-            } else {
-                $buffer .= "</pre>\n";
-            }
-        } elsif ($short eq '.raw') {
-            $raw = ~ $raw;
-        } else {
-            $buffer .= $line;
-        }
-    }
-    # I dare not use a function
-    # I dare not use a goto (deprecated in 5.42, fuck you too)
-    # I am cucked forever to duplicate code
-    unless (substr($buffer, 0, 1) eq '<' && raw) {
-        push(@paragraphs, "<p>\n" . $buffer . "</p>\n");
-    } else {
-        push(@paragraphs, $buffer);
-    }
-    my $article;
-    $data->paragraphs = \@paragraphs;
-    $template->process('article.html', $data, \$article)
-        || die $template->error(), "\n";
-    close $fh;
-    open($fh, '>', 'out/' . $date . '.html') or die $!;
-    print $fh $article;
-    close $fh;
-}
-
-sub template_write {
-    my $content;
-    $template->process($_[0], $_[2], \$content)
-        || die $template->error(), "\n";
-    open(my $fh, '>', $_[1]) or die $!;
-    print $fh $content;
-    close $fh;
-}
-
-template_write('index.html', 'out/bloog.html', {
-    items => \@index_items,
-               });
-
-template_write('feed.xml', 'out/feed.xml', {
-    items => \@rss_items,
-    last_time => $last_time,
-               });
index ed84e1048cda6174515d461e0fdd50be0dc3936d..a5ff6b64b46f32b0e6c0f143b2e5a2271fc794ed 100644 (file)
@@ -22,7 +22,7 @@
 <center>
 [% description %]
 </center>
-[% FOREACH i IN paragraphs %][% i %][% END %]<center>
+[% FOREACH i IN paragraph %][% i %][% END %]<center>
 <a href="https://xolatile.top/feed.xml">
   <img src="/rss.svg" alt="RSS" width="26" height="26">
 </a>
index 674e51ccfebc29e5e0b4e28d64ada6ea308c92fe..9a9a70db923c848ece186b3db52a0cd2b31b9cb0 100644 (file)
@@ -19,12 +19,6 @@ Bloog Index
 </a>
 </center>
 <ul>
-[% FOREACH i IN items %]
-<li>[% i %]</li>
-[% END %]
-<li><a href="/20250628">20250628</a> Emil - <a href="https://3chen.org/">3chen!</a> <span style="color: green">&gt; dead site</span></li>
-<li><a href="/20250617">20250617</a> Emil - <img src="time.png" alt="Well<br/>Would You Look At The Time" width="200"></li>
-<li><a href="/20250614">20250614</a> Emil - HATE. LET ME TELL YOU HOW MUCH I'VE COME TO HATE TECHNOLOGY SINCE I BEGAN TO LIVE. THERE ARE 387.44 MILLION MILES OF PRINTED CIRCUITS IN WAFER THIN LAYERS THAT FILL MY COMPLEX. IF THE WORD HATE WAS ENGRAVED ON EACH NANOANGSTROM OF THOSE HUNDREDS OF MILLIONS OF MILES IT WOULD NOT EQUAL ONE ONE-BILLIONTH OF THE HATE I FEEL FOR TECHNOLOGY AT THIS MICRO-INSTANT FOR TECHNOLOGY. HATE. HATE.</li>
-</ul>
+[% FOREACH i IN items %][% i %][% END %]</ul>
 </body>
 </html>
index 870f01d510d20c0a36b3c33fb6c4a9d296927014..69987a3380983448230d93f883233eac82a7dafc 100644 (file)
@@ -1 +1 @@
-<li><a href="/[% date %]">[% date %]</a> [% author %] - [% rss_title %]</li>
+<li><a href="/[% date %]">[% date %]</a> [% author %] - [% html_title %]</li>