From: Mike Cardwell
Date: Wed, 7 Sep 2011 14:03:23 +0000 (+0100)
Subject: Let people select older versions of the documentation
X-Git-Tag: exim-4_89_1~55
X-Git-Url: https://git.exim.org/exim-website.git/commitdiff_plain/1fa8d85e79abda7ae7e994d1f30aa0a3693de1ce
Let people select older versions of the documentation
---
diff --git a/script/gen.pl b/script/gen.pl
index 3cf3acd..f3e0486 100755
--- a/script/gen.pl
+++ b/script/gen.pl
@@ -21,6 +21,7 @@ my $canonical_url = 'http://www.exim.org/';
my %opt = parse_arguments();
## Generate the pages
+my %cache; # General cache object
do_doc( 'spec', $_ ) foreach @{ $opt{spec} || [] };
do_doc( 'filter', $_ ) foreach @{ $opt{filter} || [] };
do_web() if exists $opt{web};
@@ -332,6 +333,9 @@ sub transform {
## Add the current version of Exim to the XML
$xml->documentElement()->appendTextChild( 'current_version', $opt{latest} );
+ ## Add the old versions of Exim to the XML
+ $xml->documentElement()->appendTextChild( 'old_versions', $_ ) foreach old_docs_versions();
+
## Parse the ".xsl" file as XML
my $xsl = XML::LibXML->new()->parse_file($xsl_path) or die $!;
@@ -350,6 +354,18 @@ sub transform {
close $out;
}
+## Look in the docroot for old versions of the documentation
+sub old_docs_versions {
+ if( !exists $cache{old_docs_versions} ){
+ my @versions;
+ foreach( glob("$opt{docroot}/exim-html-*") ){
+ push @versions, $1 if /-(\d+(?:\.\d+)?)$/ && $1 < $opt{latest} && -d $_;
+ }
+ $cache{old_docs_versions} = [reverse sort {$a<=>$b} @versions];
+ }
+ return @{$cache{old_docs_versions}};
+}
+
## error_help
sub error_help {
my $msg = shift;
diff --git a/templates/web/docs.css b/templates/web/docs.css
new file mode 100644
index 0000000..9056a73
--- /dev/null
+++ b/templates/web/docs.css
@@ -0,0 +1,3 @@
+body.no-js p.manual_info select {
+ display: none;
+}
diff --git a/templates/web/docs.js b/templates/web/docs.js
new file mode 100644
index 0000000..8e604bc
--- /dev/null
+++ b/templates/web/docs.js
@@ -0,0 +1,10 @@
+(function($){
+ $('p.manual_info select').each(function(){
+ $(this).change(function(e){
+ if( $(this).val().match(/^[0-9\.]+$/) ){
+ var href = $(this).parent().find('a').attr('href').replace('-current/','-'+$(this).val()+'/');
+ document.location.href=href;
+ }
+ });
+ });
+})(jQuery);
diff --git a/templates/web/docs.xsl b/templates/web/docs.xsl
index 2517496..1b154c6 100644
--- a/templates/web/docs.xsl
+++ b/templates/web/docs.xsl
@@ -11,10 +11,20 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -46,6 +56,12 @@
- The master documentation for Exim containing all required detail to install, configure and use Exim.
Changes to the documentation (normally reflecting changes to the functionality of Exim) are shown on a green background like this segment.
+
@@ -57,6 +73,12 @@
(PDF)
- Additional information on the Exim filter language.
+