Display a warning to the user if they're viewing old versions of the
authorMike Cardwell <github@grepular.com>
Wed, 7 Sep 2011 11:55:07 +0000 (12:55 +0100)
committerMike Cardwell <github@grepular.com>
Wed, 7 Sep 2011 11:55:07 +0000 (12:55 +0100)
documentation

script/gen.pl
templates/doc/chapter.xsl
templates/doc/index.xsl
templates/web/doc/chapter.css
templates/web/doc/chapter.js
templates/web/doc/index.css
templates/wrapper.xsl

index edbaa934a724c84f8c80db7ad438a798d07e9550..3cf3acd52e32929f48cea8d0ace4f80856fa349f 100755 (executable)
@@ -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
index 6fd6d8c99702c49d60c1ccc2d4c12acb7d5f3bd0..06d9eb982b3240c2b53f933b5baf17124c0556c7 100644 (file)
          <!-- 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)"/>
       </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>
index d76fa1d12835b3f41a7d4a927fb5d8ca7d073305..8e08d4a23708a39232aa228b2b5bed6ab85de07e 100644 (file)
 
    <!-- 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">
index 15651586336a7c5be7667b97f4c4f049ff96a619..3eab804dda503772542bb668e13f1c336c9a0ff5 100644 (file)
@@ -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;
 }
index 988bf6a45ecf1c3911806577c89d3f4c60c1a846..add4bd3184415e1a0b2102a25889491050cd97b5 100644 (file)
@@ -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 ($) {
 
index eff4aa33f46ed6f60cc8099b5f9e481f9a631c12..63ea01fddfddc6a7b7b5d8d90df8824aeeccf8c0 100644 (file)
@@ -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;
 }
index a1cfa68944fa2ef43abff578e04a720aebb13020..ecd810e4c31b6df1f807f82c0d020ce6353511be 100644 (file)
             
                <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 -->