update tape.pl

This commit is contained in:
Atlas Cove 2023-01-22 14:52:56 +00:00
parent 57e9d96ad7
commit 6defb268fb
4 changed files with 63 additions and 28 deletions

View File

@ -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"
);

7
src/_tape/push.sh Executable file
View File

@ -0,0 +1,7 @@
declare -a excl
#while read i; do
# excl+=($i)
#done < tapeignore.txt
#unset i
cd ../..
rclone sync neo:/ ./

View File

@ -1,20 +1,24 @@
#!/usr/bin/env perl #!/usr/bin/env perl
use strict; use warnings; use strict; use warnings;
use "dat.pm"; use File::Slurp; use File::Basename;
use Text::Textile; push(@INC,dirname(__FILE__));
use Text::Markdown; use tape;
use Org::To::HTML my $fi = $ARGV[1];
if($ARGV[1][0]=='_') { if(substr($fi,0,1)=='_') {
print STDERR "Skipping file: $ARGV[1], ignored."; print STDERR "Skipping file: $fi, ignored.";
exit 0; exit 0;
} }
my @fi = split(/\./, $ARGV[1]) my @fc = split(/\./, $fi);
if(!exists($fn{$fi[1]}) { my $fo = $fc[0].'.html';
print STDERR "Skipping file: $ARGV[1], no way to process extension."; if(!exists($fc{$fc[1]}) {
print STDERR "Skipping file: $fi, no way to process extension.";
exit 1; exit 1;
} }
open $if, "<$ARGV[1]"; my $out=tape::render{$fc[1]}(read_file($fi);
open $of, ">_tmp"; open $of, ">_tmp";
$fn{$fi[1]}($if); if(exists($tape::titles{$fi})) {
close $if; print $of `m4 -DTITLE=$tape::titles{$fi} main.html.m4<<.
$out
.`;
}
close $of; close $of;

40
src/_tape/tape.pm Normal file
View File

@ -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"
);