]> git.proxmox.com Git - pve-docs.git/blobdiff - asciidoc-pve.in
update copyright year to current
[pve-docs.git] / asciidoc-pve.in
index b8a9fb2e073d03198a63d0a0c6e6568f14bf6cda..70848ca79df250b98723b719b87f8e933cf79b7f 100644 (file)
@@ -23,13 +23,13 @@ while (<main::DATA>) { $data_str .= $_; }
 
 my $fileinfo = decode_json($data_str);
 
-my $tmpprefix = ".asciidoc-pve-tmp_";
+my $tmpprefix = '.asciidoc-pve-tmp'.$$.'_';
 
 my $adoc_source_dir = "/usr/share/pve-doc-generator";
 
 # inside pve-docs source dir?
-if (-f "attributes.txt" && -f "pve-admin-guide.adoc") {
-    $adoc_source_dir = "."
+if (-f "asciidoc-pve.in" && -f "pve-admin-guide.adoc") {
+    $adoc_source_dir = getcwd();
 }
 
 my $prepared_files = {};
@@ -268,7 +268,7 @@ sub compile_asciidoc {
        die "too many arguments...\n";
 
     my $outfilemap = $fileinfo->{outfile}->{$env}->{$infile} ||
-       die "no output file mapping '$infile => $outfile' ($env)";
+       die "no output file mapping for '$infile' ($env)";
 
     if ($man_target eq 'html') {
        $outfilemap .= '.html';
@@ -276,8 +276,12 @@ sub compile_asciidoc {
        $outfilemap .= '-plain.html';
     }
 
-    die "wrong output file name '$outfile != $outfilemap' ($env)"
-       if $outfile ne $outfilemap;
+    if (defined($outfile)) {
+       die "wrong output file name '$outfile != $outfilemap' ($env)"
+           if $outfile ne $outfilemap;
+    } else {
+       $outfile = $outfilemap;
+    }
 
     defined($fileinfo->{titles}->{$env}) ||
        die "unknown environment '$env'";
@@ -296,7 +300,12 @@ sub compile_asciidoc {
 
     $leveloffset = - $doctype;
 
-    my $date = `date`;
+    my $date;
+    if (defined($ENV{SOURCE_DATE_EPOCH})) {
+       $date = `date -d "\@$ENV{SOURCE_DATE_EPOCH}"`;
+    } else {
+       $date = `date`;
+    }
     chomp $date;
 
     my $attributes = {
@@ -304,6 +313,7 @@ sub compile_asciidoc {
        leveloffset => $leveloffset,
        revnumber => $release,
        revdate => $date,
+       'footer-style' => 'revdate',
     };
 
     my $mansection = $fileinfo->{mansection}->{$env}->{$infile};
@@ -337,7 +347,9 @@ sub compile_asciidoc {
        # section like footnotes, so we cannot use a2x.
        # We use xmlto instead.
 
-       my $cmd = ['asciidoc', '-dmanpage', '-bdocbook', '-a', 'docinfo1'];
+       my $cmd = ['asciidoc', '-dmanpage', '-bdocbook',
+                  '-f', "$adoc_source_dir/asciidoc/asciidoc-pve.conf",
+                  '-a', 'docinfo1'];
 
        foreach my $key (keys %$attributes) {
            my $value = $attributes->{$key};
@@ -379,19 +391,16 @@ sub compile_asciidoc {
        $attributes->{icons} = undef;
        $attributes->{'data-uri'} = undef;
 
-       my $cmd = ['asciidoc'];
+       my $cmd = ['asciidoc',
+                  '-f', "$adoc_source_dir/asciidoc/asciidoc-pve.conf",
+           ];
 
        if (($env eq 'wiki') ||
            (($env eq 'manvolnum') && ($man_target eq 'wiki'))) {
 
-           push @$cmd, '-s';
-
-           if (-f "./asciidoc/mediawiki.conf") {
-               my $cwd = getcwd();
-               push @$cmd, '-b', "$cwd/asciidoc/mediawiki";
-           } else {
-               push @$cmd, '-b', "mediawiki";
-           }
+           push @$cmd, '-b', "$adoc_source_dir/asciidoc/mediawiki";
+       } else {
+           push @$cmd, '-b', "$adoc_source_dir/asciidoc/pve-html";
        }
 
        foreach my $key (keys %$attributes) {