File: makesite

package info (click to toggle)
latexml 0.8.8-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 31,920 kB
  • sloc: xml: 109,048; perl: 30,224; sh: 179; javascript: 28; makefile: 13
file content (129 lines) | stat: -rwxr-xr-x 4,038 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::RealBin/../blib/lib", $FindBin::RealBin;
use LaTeXML::Util::Pathname;
use Carp;
use Getopt::Long qw(:config no_ignore_case);
use Pod::Usage;
use MakeTools;

#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Build the LaTeXML site
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Assume we're running from LaTeXML's doc directory.
my $DOCDIR = $FindBin::RealBin;
# Use latexml from blib!
my $LATEXMLDIR = "$DOCDIR/..";
$ENV{PATH} = "$LATEXMLDIR/blib/script:$ENV{PATH}";

#my $WEBDIR = "/local/www/site/htdocs/DigitalMathLib/LaTeXML";
my $WEBDIR = "/local/www/site/htdocs/LaTeXML";

my $identity = "makesite (part of LaTeXML)";
my ($force,  $help,       $verbosity) = (0, 0, 0);
my ($dosite, $doexamples, $domanual)  = (1, 1, 1);
GetOptions("force!" => \$force,
  "help"      => \$help,
  verbose     => sub { $verbosity++; },
  quiet       => sub { $verbosity--; },
  "site!"     => \$dosite,
  "examples!" => \$doexamples,
  "manual!"   => \$domanual,
  "webdir=s"  => \$WEBDIR,
) or pod2usage(-message => $identity, -exitval => 1, -verbose => 0, -output => \*STDERR);
pod2usage(-message => $identity, -exitval => 1, -verbose => 2, -output => \*STDOUT) if $help;

$WEBDIR = pathname_absolute($WEBDIR);

BEGIN { $SIG{__DIE__} = \&confess; }

# Sanity check
if (!($dosite || $doexamples || $domanual)) {
  heading("Nothing to do... (see --help)");
  exit(0); }

my $tmp;
if (!(($tmp = pathname_mkdir($WEBDIR)) && -w $tmp)) {
  die "Destination '$WEBDIR' is not writable; please set --webdir (see --help):\n  $!"; }

#======================================================================
setVerbosity($verbosity);

heading("Copying resources");
# copy images referenced from the CSS.
copy("$DOCDIR/graphics/latexml.png", "$WEBDIR/images/latexml.png");
copy("$DOCDIR/graphics/mascot.png",  "$WEBDIR/images/mascot.png");
copy("$DOCDIR/graphics/scratch.png", "$WEBDIR/images/scratch.png");
###copy("$DOCDIR/graphics/favicon.ico","$WEBDIR/images/favicon.ico");
copy("$DOCDIR/latexmldoc.css", "$WEBDIR/latexmldoc.css");
# And other things
copy("$LATEXMLDIR/Changes", "$WEBDIR/Changes");

getReleaseInfo("$WEBDIR/releases");

if ($dosite) {
  heading("Generating site pages");
  latexml("$DOCDIR/site/index.tex", "$WEBDIR/index.html",
    dependencies => ["$DOCDIR/sty/latexmldoc.sty.ltxml", "$DOCDIR/sty/latexmlreleases.tex"],
    postoptions  => [
      "--format=html5",
      "--split",
      "--css=latexmldoc.css",
      "--nonumbersections",
      "--splitnaming=labelrelative",
      "--icon=favicon.ico",
      "--javascript=LaTeXML-maybeMathjax.js",
      "--path=$DOCDIR",
    ],
    force => $force);
}

if ($doexamples) {
  heading("Generating examples");
  my @examples = (qw(tabular));
  foreach my $example (@examples) {
    heading("Generating example $example");
    my $source   = "$DOCDIR/site/examples/$example/$example.tex";
    my $destname = "$WEBDIR/examples/$example/$example";
    copy($source, "$destname.tex");
    latexml($source, "$destname.html", force => $force);
    pdflatex($source, force => $force);
    copy("$DOCDIR/site/examples/$example/$example.pdf", "$destname.pdf"); }
}

if ($domanual) {
  heading("Generating manual");
  system("$DOCDIR/makemanual",
    "--webdir", $WEBDIR,
    ($force          ? ("--force") : ()),
    ($verbosity == 0 ? ()
      : ($verbosity > 0
        ? (map { ("--verbose") } 1 .. $verbosity)
        : (map { ("--quiet") } 1 .. (-$verbosity)))),
  ) == 0 or die "Failed to make manual";
}

#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

__END__

=head1 NAME

C<makesite> makes LaTeXML's site

=head1 SYNOPSIS

makesite [options]

Options:

  --force   Forces rebuilding even when timestamps dont indicate it.
  --help    Shows this help message.
  --quiet   Runs more quietly
  --verbose Runs more noisily
  --webdir  Directory to place generated website in. Defaults to
            '/local/www/site/htdocs/LaTeXML'

=cut