From: Eric Bollengier Date: Sun, 9 Dec 2012 15:58:43 +0000 (+0100) Subject: Add small wrapper to redirect latex label to the exact html page X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6e399b6a86ac376c47c85b6c561989827ee557fc;p=bacula%2Fdocs Add small wrapper to redirect latex label to the exact html page --- diff --git a/docs/tools/index.pl b/docs/tools/index.pl new file mode 100755 index 00000000..9770c089 --- /dev/null +++ b/docs/tools/index.pl @@ -0,0 +1,86 @@ +#!/usr/bin/perl -w +# +# This file is used to redirect bweb to the exact file of the documentation +# +use strict; +use Data::Dumper; +use CGI; + +# Creation mode, put the directory to scan in argument +if (scalar(@ARGV) > 0) { + my %index; + my $dir = $ARGV[0]; + # Index this directory + open(FP, ">.idx") or die "ERROR: unable to open index file"; + + chdir($dir) or die "ERROR: Unable to chdir to $dir"; + + foreach my $l (`grep ' + if ($l =~ m/^([^:]+):/) { + my ($key, $file) = ($2, $1); + if ($key !~ /^(tex2html|\d)/) { + $index{$key} = $file; + } + } + } + + print FP Data::Dumper::Dumper(\%index); + close(FP); + exit; +} + +################################################################ + +my $base = "http://www.baculasystems.com/docs"; +if (!CGI::param()) { + print CGI::redirect($base); + exit 0; +} + +my $version = CGI:param('version') || '6.0'; +if ($version !~ /^(\d+\.\d+)$/) { + print CGI::redirect($base); + exit 0; +} + +$base = "$base/docs/${version}.x-manuals/en/"; + +# Key arg is mandatory +my $key = CGI::param('key'); +if ($key !~ /^([\w\d:\.\-]{1,127})$/) { + print CGI::redirect($base); +} +$key = $1; + +my $manual = CGI::param('manual') || "main"; +if ($manual !~ /^(main|console|operator)$/) { + print CGI::redirect("$base/main/main"); +} +$manual = $1; + +if (!open(FP, ".idx")) { + print CGI::redirect($base); + exit 0; +} + +my $f=''; my $tmpbuffer; +while(read FP,$tmpbuffer,4096) +{ + $f .= $tmpbuffer; +} +close(FP); + +our $VAR1; + +no strict; # I have no idea of the contents of the file +eval "$f" ; +use strict; + +if (exists $VAR1->{$key}) { + print CGI::redirect("$base/$manual/$manual" . $VAR1->{$key} . '#' . $key); + exit 0; +} + +print CGI::redirect($base);