]> git.xolatile.top Git - emil-xolatile.top.git/commitdiff
sneed
authorEmil Williams <emilemilemil@cock.li>
Mon, 4 Aug 2025 15:26:53 +0000 (15:26 +0000)
committerEmil Williams <emilemilemil@cock.li>
Mon, 4 Aug 2025 15:26:53 +0000 (15:26 +0000)
bloog/bloog.pl [new file with mode: 0755]
bloog/html.pl
bloog/rss.pl [changed mode: 0755->0644]
bloog/template.html [deleted file]
bloog/template.xml [deleted file]
bloog/template/article.html [new file with mode: 0644]
bloog/template/feed.xml [new file with mode: 0644]
bloog/template/feed_item.xml [new file with mode: 0644]
bloog/template/index.html [new file with mode: 0644]
bloog/template/index_item.html [new file with mode: 0644]
bloog/template_item.xml [deleted file]

diff --git a/bloog/bloog.pl b/bloog/bloog.pl
new file mode 100755 (executable)
index 0000000..aedae3f
--- /dev/null
@@ -0,0 +1,106 @@
+#!/bin/perl
+# feed.xml generator
+# remember to put the last 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 92a1eeaba528187ec35188d37cf469e7c8508633..763e99aff47221826ceee60d7b9ed6d1b430aa00 100755 (executable)
@@ -3,7 +3,6 @@
 # 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;
-use feature "switch";
 
 my $template = Template->new({
     INTERPOLATE  => 1,
old mode 100755 (executable)
new mode 100644 (file)
index a380bc0..57516bc
@@ -1,25 +1,28 @@
 #!/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);
 
 my $template = Template->new({
+    INCLUDE_PATH => 'template',
     INTERPOLATE  => 1,
                             }) || die "$Template::ERROR\n";
 
-my @items = ();
+my @rss_items = ();
+my @index_items = ();
 my $last_time = '';
+my $fh;
 
 foreach $argnum (0 .. $#ARGV) {
     my $buffer;
-    open(my $fh, '<', $ARGV[$argnum]) or die "Can't open $filename: $!";
+    open($fh, '<', $ARGV[$argnum]) or die $!;
+    # general data
     chomp(my $date = <$fh>);
-    
     chomp(my $author      = <$fh>);
     chomp(my $rss_title   = <$fh>);
-    $_ = <$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
@@ -28,17 +31,76 @@ foreach $argnum (0 .. $#ARGV) {
         pubdate     => $pubdate,
         author      => $author,
         rss_title   => $rss_title,
+        rss_title   => $html_title,
         description => $description,
     };
-    $template->process('template_item.xml', $data, \$buffer)
+    # rss item
+    $template->process('feed_item.xml', $data, \$buffer)
         || die $template->error(), "\n";
-    push(@items, $buffer);
+    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;
 }
 
-my $data = {
-    items => \@items,
-    last_time => $last_time,
-};
+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->process('template.xml', $data)
-    || die $template->error(), "\n";
+template_write('feed.xml', 'out/feed.xml', {
+    items => \@rss_items,
+    last_time => $last_time,
+               });
diff --git a/bloog/template.html b/bloog/template.html
deleted file mode 100644 (file)
index ed84e10..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<!DOCTYPE html>
-<html prefix="og: http://ogp.me/ns#" lang="en">
-<head>
-<link rel="canonical">
-<link rel="icon" type="image/png" sizes="32x32" href="/favicon.png">
-<link rel="stylesheet" type="text/css" href="/style.css">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<meta name="viewport" content="width=device-width, initial-scale=0.5">
-<title id="title">
-[% rss_title %]
-</title>
-</head>
-<body>
-<center>
-<a id="back" href="/bloog">
-&lt; Back
-</a>
-</center>
-<div id="title">
-<a href="[% date %]">[% date %]</a> [% author %] - [% html_title %]
-</div>
-<center>
-[% description %]
-</center>
-[% FOREACH i IN paragraphs %][% i %][% END %]<center>
-<a href="https://xolatile.top/feed.xml">
-  <img src="/rss.svg" alt="RSS" width="26" height="26">
-</a>
-<p>Copyright © emil $CURRENT_YEAR Public Domain</p>
-</center>
-</body>
-</html>
diff --git a/bloog/template.xml b/bloog/template.xml
deleted file mode 100644 (file)
index 2ba8f04..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<rss version="2.0">
-<channel>
-<title>xolatile.top</title>
-<link>https://xolatile.top/</link>
-<description>Greatest Man To Ever Exist</description>
-<lastBuildDate>[% last_time %]</lastBuildDate>
-[% FOREACH i IN items %][% i %][% END %]</channel>
-</rss>
diff --git a/bloog/template/article.html b/bloog/template/article.html
new file mode 100644 (file)
index 0000000..ed84e10
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html prefix="og: http://ogp.me/ns#" lang="en">
+<head>
+<link rel="canonical">
+<link rel="icon" type="image/png" sizes="32x32" href="/favicon.png">
+<link rel="stylesheet" type="text/css" href="/style.css">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<meta name="viewport" content="width=device-width, initial-scale=0.5">
+<title id="title">
+[% rss_title %]
+</title>
+</head>
+<body>
+<center>
+<a id="back" href="/bloog">
+&lt; Back
+</a>
+</center>
+<div id="title">
+<a href="[% date %]">[% date %]</a> [% author %] - [% html_title %]
+</div>
+<center>
+[% description %]
+</center>
+[% FOREACH i IN paragraphs %][% i %][% END %]<center>
+<a href="https://xolatile.top/feed.xml">
+  <img src="/rss.svg" alt="RSS" width="26" height="26">
+</a>
+<p>Copyright © emil $CURRENT_YEAR Public Domain</p>
+</center>
+</body>
+</html>
diff --git a/bloog/template/feed.xml b/bloog/template/feed.xml
new file mode 100644 (file)
index 0000000..2ba8f04
--- /dev/null
@@ -0,0 +1,8 @@
+<rss version="2.0">
+<channel>
+<title>xolatile.top</title>
+<link>https://xolatile.top/</link>
+<description>Greatest Man To Ever Exist</description>
+<lastBuildDate>[% last_time %]</lastBuildDate>
+[% FOREACH i IN items %][% i %][% END %]</channel>
+</rss>
diff --git a/bloog/template/feed_item.xml b/bloog/template/feed_item.xml
new file mode 100644 (file)
index 0000000..62017b1
--- /dev/null
@@ -0,0 +1,6 @@
+<item>
+<title>[% author %] - [% rss_title %]</title>
+<link>https://xolatile.top/[% date %]</link>
+<description>[% description %]</description>
+<pubDate>[% pubdate %]</pubDate>
+</item>
diff --git a/bloog/template/index.html b/bloog/template/index.html
new file mode 100644 (file)
index 0000000..674e51c
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html prefix="og: http://ogp.me/ns#" lang="en">
+<head>
+<link rel="canonical">
+<link rel="icon" type="image/png" sizes="32x32" href="/favicon.png">
+<link rel="stylesheet" type="text/css" href="/style.css">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<meta name="viewport" content="width=device-width, initial-scale=0.5">
+<title id="title">Bloog Index</title>
+</head>
+<body>
+<center>
+<a id="back" href="/">&lt; Back</a>
+<div id="title">
+Bloog Index
+</div>
+<a href="https://xolatile.top/feed.xml">
+  <img src="/rss.svg" alt="RSS" width="26" height="26">
+</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>
+</body>
+</html>
diff --git a/bloog/template/index_item.html b/bloog/template/index_item.html
new file mode 100644 (file)
index 0000000..870f01d
--- /dev/null
@@ -0,0 +1 @@
+<li><a href="/[% date %]">[% date %]</a> [% author %] - [% rss_title %]</li>
diff --git a/bloog/template_item.xml b/bloog/template_item.xml
deleted file mode 100644 (file)
index 62017b1..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<item>
-<title>[% author %] - [% rss_title %]</title>
-<link>https://xolatile.top/[% date %]</link>
-<description>[% description %]</description>
-<pubDate>[% pubdate %]</pubDate>
-</item>