2023-03-05 19:01:59 +00:00
|
|
|
#! /usr/bin/perl
|
|
|
|
|
|
|
|
if(int(@ARGV)!=2) {
|
|
|
|
die "usage: gemini2html.pl sourcedir targetdir\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$SOURCE=shift;
|
|
|
|
$TARGET=shift;
|
|
|
|
|
|
|
|
@FILES=split(/\n/, `cd $SOURCE; find . -type f`);
|
|
|
|
|
|
|
|
for my $f (@FILES) {
|
|
|
|
print "$f\n";
|
2023-03-18 18:43:19 +00:00
|
|
|
if($f =~ m@/cgi-bin/@) {
|
|
|
|
print "skipping\n";
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2023-03-05 19:01:59 +00:00
|
|
|
$target_dir=$f;
|
|
|
|
$target_dir=~s@/[^/]+$@@;
|
|
|
|
|
|
|
|
if(!-d "$TARGET/$target_dir") {
|
|
|
|
mkdir("$TARGET/$target_dir");
|
|
|
|
}
|
|
|
|
|
|
|
|
if($f =~ /.gmi$/) {
|
|
|
|
$target=$f;
|
|
|
|
$target=~s/\.gmi$/.html/;
|
|
|
|
$target_file=$target;
|
|
|
|
$target_file=~s@.*/@@;
|
|
|
|
|
|
|
|
system("(cat header.md;gemtext2md <$SOURCE/$f)|pandoc --standalone --template template.html - -o $TARGET/$target");
|
|
|
|
open(FILE, ">$TARGET/$f");
|
|
|
|
print FILE "<meta http-equiv=\"refresh\" content=\"0; URL=$target_file\">\n";
|
|
|
|
close FILE;
|
|
|
|
} else {
|
|
|
|
system("cp $SOURCE/$f $TARGET/$f");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|