--- /dev/null
+#!/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,
+ });
# 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,
#!/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
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,
+ });
+++ /dev/null
-<!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">
-< 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>
+++ /dev/null
-<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>
--- /dev/null
+<!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">
+< 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>
--- /dev/null
+<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>
--- /dev/null
+<item>
+<title>[% author %] - [% rss_title %]</title>
+<link>https://xolatile.top/[% date %]</link>
+<description>[% description %]</description>
+<pubDate>[% pubdate %]</pubDate>
+</item>
--- /dev/null
+<!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="/">< 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">> 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>
--- /dev/null
+<li><a href="/[% date %]">[% date %]</a> [% author %] - [% rss_title %]</li>
+++ /dev/null
-<item>
-<title>[% author %] - [% rss_title %]</title>
-<link>https://xolatile.top/[% date %]</link>
-<description>[% description %]</description>
-<pubDate>[% pubdate %]</pubDate>
-</item>