Gitweb:
http://git.exim.org/exim-website.git/commitdiff/7e380e72021a4fcc57295367a71f14176343ad23
Commit: 7e380e72021a4fcc57295367a71f14176343ad23
Parent: 2aff12fd871ba9c9f15498abdc98fccd3b3a79c4
Author: Mike Cardwell <github@???>
AuthorDate: Wed Sep 7 12:55:07 2011 +0100
Committer: Mike Cardwell <github@???>
CommitDate: Wed Sep 7 12:55:07 2011 +0100
Display a warning to the user if they're viewing old versions of the
documentation
---
script/gen.pl | 16 ++++++++++++++++
templates/doc/chapter.xsl | 12 +++++++++++-
templates/doc/index.xsl | 10 +++++++++-
templates/web/doc/chapter.css | 35 +++++++++++++++++++++++++++++++++++
templates/web/doc/chapter.js | 14 ++++++++++++++
templates/web/doc/index.css | 7 +++++++
templates/wrapper.xsl | 5 ++++-
7 files changed, 96 insertions(+), 3 deletions(-)
diff --git a/script/gen.pl b/script/gen.pl
index edbaa93..3cf3acd 100755
--- a/script/gen.pl
+++ b/script/gen.pl
@@ -111,6 +111,13 @@ sub do_doc {
->appendTextChild( 'canonical_url',
"${canonical_url}exim-html-current/doc/html/spec_html/" . ( $type eq 'spec' ? 'index' : 'filter' ) . ".html" );
+ ## Add a url for the latest version of this document
+ if( $version ne $opt{latest} ){
+ $xml->documentElement()
+ ->appendTextChild( 'current_url',
+ "../../../../exim-html-current/doc/html/spec_html/" . ( $type eq 'spec' ? 'index' : 'filter' ) . ".html" );
+ }
+
## Fixup the XML
xref_fixup( $xml, $prepend_chapter );
@@ -153,6 +160,15 @@ sub do_doc {
$prepend_chapter, $counter
)
);
+ if( $version ne $opt{latest} ){
+ $chapter->appendTextChild(
+ 'current_url',
+ sprintf(
+ '../../../../exim-html-current/doc/html/spec_html/%sch%02d.html',
+ $prepend_chapter, $counter
+ )
+ );
+ }
}
## Create an XML document from the chapter
diff --git a/templates/doc/chapter.xsl b/templates/doc/chapter.xsl
index 6fd6d8c..06d9eb9 100644
--- a/templates/doc/chapter.xsl
+++ b/templates/doc/chapter.xsl
@@ -48,6 +48,16 @@
<!-- Chapter Wrapper -->
<div id="chapter" class="chapter{@class}">
+ <xsl:if test="current_url">
+ <p id="old_version_warning">
+ <span class="closebar"><a href="#" title="Close">X</a></span>
+ <strong>WARNING:</strong>
+ <xsl:text> This documentation is for an old version of Exim (</xsl:text>
+ <a href="{current_url}">latest</a>
+ <xsl:text>)</xsl:text>
+ </p>
+ </xsl:if>
+
<!-- Chapter Title -->
<h2 id="{@id}" class="{@class}">
<xsl:value-of select="concat('Chapter ',chapter_id,' - ',title)"/>
@@ -97,6 +107,6 @@
</xsl:template>
<!-- Ignore -->
- <xsl:template match="chapter_id|prev_url|next_url|canonical_url"/>
+ <xsl:template match="chapter_id|prev_url|next_url|canonical_url|current_url"/>
</xsl:stylesheet>
diff --git a/templates/doc/index.xsl b/templates/doc/index.xsl
index d76fa1d..8e08d4a 100644
--- a/templates/doc/index.xsl
+++ b/templates/doc/index.xsl
@@ -30,13 +30,21 @@
<!-- CONTENT -->
<xsl:template match="/book">
+ <xsl:if test="current_url">
+ <p id="old_version_warning">
+ <strong>WARNING:</strong>
+ <xsl:text> This documentation is for an old version of Exim (</xsl:text>
+ <a href="{current_url}">latest</a>
+ <xsl:text>)</xsl:text>
+ </p>
+ </xsl:if>
<div id="info">
<xsl:apply-templates select="bookinfo"/>
</div>
<div id="options" class="hidden">
<img src="{$docroot}/doc/plus-12x12.png" width="12" height="12" class="expand"/>
<img src="{$docroot}/doc/minus-12x12.png" width="12" height="12" class="collapse"/>
- <xsl:text>Expand/Collapse all Chapters</xsl:text>
+ <xsl:text>Expand/Collapse all Chapters</xsl:text>
</div>
<div id="index">
<ul id="chapters">
diff --git a/templates/web/doc/chapter.css b/templates/web/doc/chapter.css
index 1565158..3eab804 100644
--- a/templates/web/doc/chapter.css
+++ b/templates/web/doc/chapter.css
@@ -1,3 +1,38 @@
+#old_version_warning {
+ text-align: center;
+ padding: 0.1em;
+ margin: 0;
+ font-size: 1.4em;
+}
+
+body.with-js #old_version_warning {
+ display: none;
+ text-align: left;
+ position: fixed;
+ top: 20%;
+ left: 30%;
+ width: 40%;
+ background-color: #fff;
+ border: 1px solid #000;
+ padding: 1em;
+ z-index: 10000;
+}
+
+#old_version_warning span.closebar {
+ float: right;
+ position: relative;
+ right: -0.5em;
+ top: -0.5em;
+}
+
+#old_version_warning span.closebar a {
+ text-decoration: none;
+}
+
+body.no-js #old_version_warning span.closebar {
+ display: none;
+}
+
.previous_page, .next_page {
font-size: 1.2em;
}
diff --git a/templates/web/doc/chapter.js b/templates/web/doc/chapter.js
index 988bf6a..add4bd3 100644
--- a/templates/web/doc/chapter.js
+++ b/templates/web/doc/chapter.js
@@ -1,3 +1,17 @@
+// Warnings about reading old version of documentation
+(function ($) {
+ if( $.grep( document.cookie.split(/\s*;\s*/), function(a){return a === 'old_version_warning_removed=true' ? true : false }).length === 0 ){
+ $('#old_version_warning')
+ .show()
+ .find('span.closebar a')
+ .click(function(e){
+ $('#old_version_warning').remove();
+ document.cookie="old_version_warning_removed=true";
+ e.preventDefault();
+ });
+ }
+})(jQuery);
+
// Sidebar table of contents
(function ($) {
diff --git a/templates/web/doc/index.css b/templates/web/doc/index.css
index eff4aa3..63ea01f 100644
--- a/templates/web/doc/index.css
+++ b/templates/web/doc/index.css
@@ -1,3 +1,10 @@
+#old_version_warning {
+ text-align: center;
+ padding: 0.1em;
+ margin: 0;
+ font-size: 1.4em;
+}
+
#options {
padding: 1em 0 0 2em;
}
diff --git a/templates/wrapper.xsl b/templates/wrapper.xsl
index a1cfa68..ecd810e 100644
--- a/templates/wrapper.xsl
+++ b/templates/wrapper.xsl
@@ -40,7 +40,10 @@
<xsl:copy-of select="$html.head.append"/>
</head>
- <body>
+ <body class="no-js">
+ <!-- Changed body classname from "no-js" to "with-js" for styling purposes -->
+
+ <script type="text/javascript"><![CDATA[document.body.className=(' '+document.body.className+' ').replace('no-js','with-js');]]></script>
<!-- Header -->