From 6defb268fb85ff0aa06b4f372fdac6f0783a8022 Mon Sep 17 00:00:00 2001 From: Atlas Cove <5618106+Atlas48@users.noreply.github.com> Date: Sun, 22 Jan 2023 14:52:56 +0000 Subject: [PATCH] update tape.pl --- src/_tape/dat.pm | 16 ---------------- src/_tape/push.sh | 7 +++++++ src/_tape/string.pl | 28 ++++++++++++++++------------ src/_tape/tape.pm | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 28 deletions(-) delete mode 100644 src/_tape/dat.pm create mode 100755 src/_tape/push.sh create mode 100644 src/_tape/tape.pm diff --git a/src/_tape/dat.pm b/src/_tape/dat.pm deleted file mode 100644 index 5f706e5..0000000 --- a/src/_tape/dat.pm +++ /dev/null @@ -1,16 +0,0 @@ -package tape; -use strict; use warnings; -use Exporter qw(Export); -our @EXPORT = qw(fn titles); -my %fn = ( - 'txti' => sub { - }, - 'md' => sub { - }, - 'org' => sub { - } -); -my %titles = ( - "not_found.txti" => "404 - Page Not Found", - "index.txti" => "Atlas48's Archives" -); diff --git a/src/_tape/push.sh b/src/_tape/push.sh new file mode 100755 index 0000000..feb2818 --- /dev/null +++ b/src/_tape/push.sh @@ -0,0 +1,7 @@ +declare -a excl +#while read i; do +# excl+=($i) +#done < tapeignore.txt +#unset i +cd ../.. +rclone sync neo:/ ./ diff --git a/src/_tape/string.pl b/src/_tape/string.pl index 67d1d12..60ad8db 100755 --- a/src/_tape/string.pl +++ b/src/_tape/string.pl @@ -1,20 +1,24 @@ #!/usr/bin/env perl use strict; use warnings; -use "dat.pm"; -use Text::Textile; -use Text::Markdown; -use Org::To::HTML -if($ARGV[1][0]=='_') { - print STDERR "Skipping file: $ARGV[1], ignored."; +use File::Slurp; use File::Basename; +push(@INC,dirname(__FILE__)); +use tape; +my $fi = $ARGV[1]; +if(substr($fi,0,1)=='_') { + print STDERR "Skipping file: $fi, ignored."; exit 0; } -my @fi = split(/\./, $ARGV[1]) -if(!exists($fn{$fi[1]}) { - print STDERR "Skipping file: $ARGV[1], no way to process extension."; +my @fc = split(/\./, $fi); +my $fo = $fc[0].'.html'; +if(!exists($fc{$fc[1]}) { + print STDERR "Skipping file: $fi, no way to process extension."; exit 1; } -open $if, "<$ARGV[1]"; +my $out=tape::render{$fc[1]}(read_file($fi); open $of, ">_tmp"; -$fn{$fi[1]}($if); -close $if; +if(exists($tape::titles{$fi})) { + print $of `m4 -DTITLE=$tape::titles{$fi} main.html.m4<<. +$out +.`; +} close $of; diff --git a/src/_tape/tape.pm b/src/_tape/tape.pm new file mode 100644 index 0000000..b48d072 --- /dev/null +++ b/src/_tape/tape.pm @@ -0,0 +1,40 @@ +package tape; +use strict; use warnings; +use Text::Textile; +use Text::Markdown; +use Org::Parser; use Org::To::HTML; +use CSS::Sass; +use Exporter qw(Export); +use constant { + true => 1, + false => 0 +} +our @EXPORT = qw(render titles); +sub scss { + my $sassc = CSS::Sass->new; + return $sassc->compile($_[0])[0]; +} +my %render = ( + 'txti' => sub { + my $p = Text::Textile->new; + $p->css(false); + return $p->process($_[0]); + }, + 'md' => sub { + my $p = Text::Markdown->new; + return $p->markdown($_[0]); + }, + 'org' => sub { + my $p = Org::Parser->new; + my $o = Org::To::HTML->new; + return $o->export_document($p->parse($_[0])); + }, + 'sass' => sub { + return scss(sass2scss($_[0])); + }, + 'scss' => &scss +); +my %titles = ( + "not_found.txti" => "404 - Page Not Found", + "index.txti" => "Atlas48's Archives" +);