aboutsummaryrefslogtreecommitdiff
path: root/site/menu.pl
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2022-01-28 08:34:22 +0000
committerOmar Polo <op@omarpolo.com>2022-01-28 08:34:22 +0000
commitac42bb6c7f9f30028fbc63f623bf4bba99b725ad (patch)
tree2dd917d40e125248dd3a44bd30ceaad5a1f103fc /site/menu.pl
parent964686ce0b77d06b8c954366db56e9a8d098b1d5 (diff)
change how the site is built
copy the kamid/site "framework" here too; in other words: don't maintain two copies of every page! \o/
Diffstat (limited to 'site/menu.pl')
-rwxr-xr-xsite/menu.pl39
1 files changed, 39 insertions, 0 deletions
diff --git a/site/menu.pl b/site/menu.pl
new file mode 100755
index 0000000..6c65eea
--- /dev/null
+++ b/site/menu.pl
@@ -0,0 +1,39 @@
+#!/usr/bin/env perl
+
+use v5.10;
+use strict;
+use warnings;
+
+my $page = shift or die 'missing page';
+my $outtype = shift or die 'missing output type';
+my @pages = ();
+
+while (<>) {
+ chomp;
+ @pages = (@pages, $_);
+}
+
+my $did = 0;
+for (@pages) {
+ my ($href, $text) = m/^([^\s]*)\s*(.*)$/;
+
+ if ($outtype eq 'gemini') {
+ if ($href ne $page) {
+ say "=> $href $text";
+ }
+ } else {
+ if (!$did) {
+ $did = 1;
+ } else {
+ print "| ";
+ }
+
+ if ($href eq $page) {
+ print "$text ";
+ } else {
+ print "<a href='$href'>$text</a> ";
+ }
+ }
+}
+
+say "";