From: Emil Williams Date: Mon, 4 Aug 2025 15:26:53 +0000 (+0000) Subject: sneed X-Git-Url: https://git.xolatile.top/?a=commitdiff_plain;h=b1f32cc6ca9f1bcdba656157c4f1d11911d26d08;p=emil-xolatile.top.git sneed --- diff --git a/bloog/bloog.pl b/bloog/bloog.pl new file mode 100755 index 0000000..aedae3f --- /dev/null +++ b/bloog/bloog.pl @@ -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 = ) { + chomp(my $short = $line); + if ($short eq '' && not $pre && not $raw) { + unless (substr($buffer, 0, 1) eq '<' && raw) { + push(@paragraphs, "

\n" . $buffer . "

\n"); + } else { + push(@paragraphs, $buffer); + } + $buffer = ''; + } elsif ($short eq '.pre') { + $pre = ~ $pre; + if ($pre) { + $buffer .= "
\n";
+            } else {
+                $buffer .= "
\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, "

\n" . $buffer . "

\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, + }); diff --git a/bloog/html.pl b/bloog/html.pl index 92a1eea..763e99a 100755 --- a/bloog/html.pl +++ b/bloog/html.pl @@ -3,7 +3,6 @@ # converts a set of paragraphs delimed by \n\n into a

'd article. # ignores .pre until .pre, ignores .raw until .raw use Template; -use feature "switch"; my $template = Template->new({ INTERPOLATE => 1, diff --git a/bloog/rss.pl b/bloog/rss.pl old mode 100755 new mode 100644 index a380bc0..57516bc --- a/bloog/rss.pl +++ b/bloog/rss.pl @@ -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 = ) { + chomp(my $short = $line); + if ($short eq '' && not $pre && not $raw) { + unless (substr($buffer, 0, 1) eq '<' && raw) { + push(@paragraphs, "

\n" . $buffer . "

\n"); + } else { + push(@paragraphs, $buffer); + } + $buffer = ''; + } elsif ($short eq '.pre') { + $pre = ~ $pre; + if ($pre) { + $buffer .= "
\n";
+            } else {
+                $buffer .= "
\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, "

\n" . $buffer . "

\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 index ed84e10..0000000 --- a/bloog/template.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - -[% rss_title %] - - - -
- -< Back - -
-
-[% date %] [% author %] - [% html_title %] -
-
-[% description %] -
-[% FOREACH i IN paragraphs %][% i %][% END %]
- - RSS - -

Copyright © emil $CURRENT_YEAR Public Domain

-
- - diff --git a/bloog/template.xml b/bloog/template.xml deleted file mode 100644 index 2ba8f04..0000000 --- a/bloog/template.xml +++ /dev/null @@ -1,8 +0,0 @@ - - -xolatile.top -https://xolatile.top/ -Greatest Man To Ever Exist -[% last_time %] -[% FOREACH i IN items %][% i %][% END %] - diff --git a/bloog/template/article.html b/bloog/template/article.html new file mode 100644 index 0000000..ed84e10 --- /dev/null +++ b/bloog/template/article.html @@ -0,0 +1,32 @@ + + + + + + + + + +[% rss_title %] + + + +
+ +< Back + +
+
+[% date %] [% author %] - [% html_title %] +
+
+[% description %] +
+[% FOREACH i IN paragraphs %][% i %][% END %]
+ + RSS + +

Copyright © emil $CURRENT_YEAR Public Domain

+
+ + diff --git a/bloog/template/feed.xml b/bloog/template/feed.xml new file mode 100644 index 0000000..2ba8f04 --- /dev/null +++ b/bloog/template/feed.xml @@ -0,0 +1,8 @@ + + +xolatile.top +https://xolatile.top/ +Greatest Man To Ever Exist +[% last_time %] +[% FOREACH i IN items %][% i %][% END %] + diff --git a/bloog/template/feed_item.xml b/bloog/template/feed_item.xml new file mode 100644 index 0000000..62017b1 --- /dev/null +++ b/bloog/template/feed_item.xml @@ -0,0 +1,6 @@ + +[% author %] - [% rss_title %] +https://xolatile.top/[% date %] +[% description %] +[% pubdate %] + diff --git a/bloog/template/index.html b/bloog/template/index.html new file mode 100644 index 0000000..674e51c --- /dev/null +++ b/bloog/template/index.html @@ -0,0 +1,30 @@ + + + + + + + + +Bloog Index + + +
+< Back +
+Bloog Index +
+ + RSS + +
+
    +[% FOREACH i IN items %] +
  • [% i %]
  • +[% END %] +
  • 20250628 Emil - 3chen! > dead site
  • +
  • 20250617 Emil - Well<br/>Would You Look At The Time
  • +
  • 20250614 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.
  • +
+ + diff --git a/bloog/template/index_item.html b/bloog/template/index_item.html new file mode 100644 index 0000000..870f01d --- /dev/null +++ b/bloog/template/index_item.html @@ -0,0 +1 @@ +
  • [% date %] [% author %] - [% rss_title %]
  • diff --git a/bloog/template_item.xml b/bloog/template_item.xml deleted file mode 100644 index 62017b1..0000000 --- a/bloog/template_item.xml +++ /dev/null @@ -1,6 +0,0 @@ - -[% author %] - [% rss_title %] -https://xolatile.top/[% date %] -[% description %] -[% pubdate %] -