If $SWG_PRINT_MISSING environment variable is set, then warning will be
print for links leading to non-existent pages.
+If $SWG_DO_SRC=0 environment variable is set, then no links and source
+pages will be generated. Pure HTML output.
+
How to forcefully change the title of the generated HTML page?
Use sed/perl to replace "<title>..." line in it.
$0 html PAGE >PAGE.html
$0 gen-index CAT >CAT.html
-By default SWG_DO_BACKS=1 is set. SWG_PRINT_MISSING=0.
+By default SWG_DO_BACKS=1 is set.
+SWG_PRINT_MISSING=0. SWG_DO_SRC=1.
Do not forget about .swgignore with regular expressions.
END_USAGE
;
my $DoBacks = ((not exists $ENV{SWG_DO_BACKS}) or
($ENV{SWG_DO_BACKS} eq q{1})) ? 1 : 0;
+my $DoSrc = ((not exists $ENV{SWG_DO_SRC}) or
+ ($ENV{SWG_DO_SRC} eq q{1})) ? 1 : 0;
my %Mtimes;
my %CatFiles;
<html><head>
<title>$title</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
-<link rel=\"alternate\" type=\"text/plain\" title=\"src\" href=\"$fn.txt\" />
+END_HTML
+;
+ print {$out} "<link rel=\"alternate\" type=\"text/plain\" title=\"src\" href=\"$fn.txt\" />\n" if $DoSrc;
+ print {$out} <<"END_HTML"
</head>
<body>
<pre>
END_HTML
+;
}
my $indent = q{};
my sub procline;
foreach my $cat (keys %CatFiles) {
make_path "$ARGV[1]/$cat";
next if (exists $Mtimes{"${cat}index"});
- $fn = "$ARGV[1]/${cat}index.txt";
- open $fh, q{>:encoding(UTF-8)}, $fn or croak "$!";
- genIndex $fh, $cat;
- close $fh or croak "$!";
- utime $now, $now, $fn;
+ if ($DoSrc) {
+ $fn = "$ARGV[1]/${cat}index.txt";
+ open $fh, q{>:encoding(UTF-8)}, $fn or croak "$!";
+ genIndex $fh, $cat;
+ close $fh or croak "$!";
+ utime $now, $now, $fn;
+ }
$fn = "$ARGV[1]/${cat}index.html";
open $fh, q{>:encoding(UTF-8)}, $fn or croak "$!";
genHTML $fh, $cat, genIndex2Buf $cat;
} else {
utime $mtime, $mtime, "$ARGV[1]/$pth.html";
}
- copy $pth, "$ARGV[1]/$pth.txt" or croak "$!";
- utime $mtime, $mtime, "$ARGV[1]/$pth.txt";
+ if ($DoSrc) {
+ copy $pth, "$ARGV[1]/$pth.txt" or croak "$!";
+ utime $mtime, $mtime, "$ARGV[1]/$pth.txt";
+ }
}
} elsif ($ARGV[0] eq q{info}) {
print "Autogenerated by swg $VERSION\n";