From d8e1a4c7bd4ddd129c58dc412465e895b44b6dbb Mon Sep 17 00:00:00 2001
From: Thierry Carrez <thierry@openstack.org>
Date: Wed, 27 Mar 2013 16:29:09 +0100
Subject: [PATCH] Make status.o.o header and footer reusable

Externalize the top menu and footer section of status.openstack.org so
that it can be reused by child pages without them having to know about
each other. Fixes bug 1129239.

Note: this does not make child pages other than the default page use the
reusable header/footer: that should be pushed in subsequent commits.

Additionally, clean up unused .js links that result in 404s.

Change-Id: I75e2d827648cb648a2887f4b036342f18690ab92
Reviewed-on: https://review.openstack.org/25530
Reviewed-by: James E. Blair <corvus@inaugust.com>
Approved: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Tested-by: Jenkins
---
 .../openstack_project/files/status/common.js  | 94 +++++++++++++++++++
 .../openstack_project/files/status/index.html | 73 ++------------
 modules/openstack_project/manifests/static.pp |  6 ++
 3 files changed, 107 insertions(+), 66 deletions(-)
 create mode 100644 modules/openstack_project/files/status/common.js

diff --git a/modules/openstack_project/files/status/common.js b/modules/openstack_project/files/status/common.js
new file mode 100644
index 0000000000..e6f4cd0cc1
--- /dev/null
+++ b/modules/openstack_project/files/status/common.js
@@ -0,0 +1,94 @@
+// Copyright 2013 OpenStack Foundation
+// //
+// // Licensed under the Apache License, Version 2.0 (the "License"); you may
+// // not use this file except in compliance with the License. You may obtain
+// // a copy of the License at
+// //
+// //      http://www.apache.org/licenses/LICENSE-2.0
+// //
+// // Unless required by applicable law or agreed to in writing, software
+// // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// // License for the specific language governing permissions and limitations
+// // under the License.
+
+function header(activeTabName) {
+  tabsName = new Array();
+  tabsLink = new Array();
+  tabsName[0] = 'Status'; tabsLink[0] = 'http://status.openstack.org/';
+  tabsName[1] = 'Zuul'; tabsLink[1] = 'http://status.openstack.org/zuul/';
+  tabsName[2] = 'Rechecks'; tabsLink[2] = 'http://status.openstack.org/rechecks/';
+  tabsName[3] = 'Release'; tabsLink[3] = 'http://status.openstack.org/release/';
+  tabsName[4] = 'Reviews'; tabsLink[4] = 'http://status.openstack.org/reviews/';
+  tabsName[5] = 'Bugday'; tabsLink[5] = 'http://status.openstack.org/bugday/';
+
+  document.write(
+   '<div class="container">'+
+   '<div id="header">'+
+   '<div class="span-5">'+
+   ' <h1 id="logo"><a href="http://status.openstack.org/">Open Stack</a></h1>'+
+   '</div>\n'+
+   '<div class="span-19 last blueLine">'+
+   '<div id="navigation" class="span-19">'+
+   '<ul id="Menu1">\n')
+
+  for (var i = 0; i < tabsName.length; i++) {
+      document.write('<li><a id="menu-'+tabsName[i]+'" href="'+tabsLink[i]+'"')
+      if (tabsName[i] == activeTabName) {
+          document.write(' class="current"');
+      }
+      document.write('>'+tabsName[i]+'</a></li>\n');
+  }
+
+  document.write(
+   '</ul>'+
+   '</div>'+
+   '</div>'+
+   '</div>')
+}
+
+function footer() {
+ document.write(
+  '<div class="container">'+
+  '<hr>'+
+  '<div id="footer">'+
+  '<div class="span-4">'+
+  '<h3>OpenStack</h3>'+
+  '<ul>'+
+  ' <li><a href="http://www.openstack.org/projects/">Projects</a></li>'+
+  ' <li><a href="http://www.openstack.org/openstack-security/">OpenStack Security</a></li>'+
+  ' <li><a href="http://www.openstack.org/projects/openstack-faq/">Common Questions</a></li>'+
+  ' <li><a href="http://www.openstack.org/blog/">Blog</a></li>'+
+  '</ul>'+
+  '</div>\n'+
+  '<div class="span-4">'+
+  '<h3>Community</h3>'+
+  '<ul>'+
+  ' <li><a href="http://www.openstack.org/community/">User Groups</a></li>'+
+  ' <li><a href="http://www.openstack.org/events/">Events</a></li>'+
+  ' <li><a href="http://www.openstack.org/jobs/">Jobs</a></li>'+
+  ' <li><a href="http://www.openstack.org/companies/">Companies</a></li>'+
+  ' <li><a href="http://wiki.openstack.org/HowToContribute">Contribute</a></li>'+
+  '</ul>'+
+  '</div>\n'+
+  '<div class="span-4">'+
+  '<h3>Documentation</h3>'+
+  '<ul>'+
+  ' <li><a href="http://docs.openstack.org/">OpenStack Manuals</a></li>'+
+  ' <li><a href="http://docs.openstack.org/diablo/openstack-compute/starter/content/">Getting Started</a></li>'+
+  ' <li><a href="http://wiki.openstack.org/">Wiki</a></li>'+
+  '</ul>'+
+  '</div>\n'+
+  '<div class="span-4 last">'+
+  '<h3>Branding &amp; Legal</h3>'+
+  '<ul>'+
+  ' <li><a href="http://www.openstack.org/brand/">Logos &amp; Guidelines</a></li>'+
+  ' <li><a href="http://www.openstack.org/brand/openstack-trademark-policy/">Trademark Policy</a></li>'+
+  ' <li><a href="http://www.openstack.org/privacy/">Privacy Policy</a></li>'+
+  ' <li><a href="http://wiki.openstack.org/CLA">OpenStack CLA</a></li>'+
+  '</ul>'+
+  '</div>'+
+  '</div>'+
+  '</div>')
+}
+
diff --git a/modules/openstack_project/files/status/index.html b/modules/openstack_project/files/status/index.html
index a7c58da3f1..82e7d2be40 100644
--- a/modules/openstack_project/files/status/index.html
+++ b/modules/openstack_project/files/status/index.html
@@ -16,11 +16,9 @@
 </style>
 
     <TITLE>OpenStack Project Status</TITLE>
-
-<script type="text/javascript" src="jquery.min.js"></script>
-<script type="text/javascript" src="jquery-visibility.min.js"></script>
-<script type="text/javascript" src="status.js"></script>
-
+    
+    <script type="text/javascript"
+            src="http://status.openstack.org/common.js"></script>
     
     <!-- Google Fonts -->
     <link href='http://fonts.googleapis.com/css?family=PT+Sans&amp;subset=latin' rel='stylesheet' type='text/css'/>
@@ -50,26 +48,8 @@
 	</div>
       </div>
     </div>
-    <div class="container">
-      <div id="header">
-	<div class="span-5">
-	  <h1 id="logo"><a href="/">Open Stack</a></h1>
-	</div>
-	<div class="span-19 last blueLine">
-	  
-	  <div id="navigation" class="span-19">
-	    <ul id="Menu1">
-	      <li><a href="/" class="current" >Status</a></li>
-  	      <li><a href="/zuul/">Zuul</a></li>
-  	      <li><a href="/rechecks/">Rechecks</a></li>
-  	      <li><a href="/release/">Release</a></li>
-	      <li><a href="/reviews/">Reviews</a></li>
-	      <li><a href="/bugday/">Bugday</a></li>
- 	    </ul>
-	  </div>
-	</div>
-      </div>
-    </div>
+
+    <script type="text/javascript">header('Status');</script>
 
     <div id="blurb-container">
       <h1>OpenStack Infrastructure and Project Status</h1>
@@ -116,46 +96,7 @@
 
     </div>
 
-    <div class="container">
-      <hr />
-      <div id="footer">
-	<div class="span-4">
-	  <h3>OpenStack</h3>
-	  <ul>
-	    <li><a href="http://www.openstack.org/projects/">Projects</a></li>
-	    <li><a href="http://www.openstack.org/openstack-security/">OpenStack Security</a></li>
-	    <li><a href="http://www.openstack.org/projects/openstack-faq/">Common Questions</a></li>
-	    <li><a href="http://www.openstack.org/blog/">Blog</a></li>
-	  </ul>
-	</div>
-	<div class="span-4">
-	  <h3>Community</h3>
-	  <ul>
-	    <li><a href="http://www.openstack.org/community/">User Groups</a></li>
-	    <li><a href="http://www.openstack.org/events/">Events</a></li>
-	    <li><a href="http://www.openstack.org/jobs/">Jobs</a></li>
-	    <li><a href="http://www.openstack.org/companies/">Companies</a></li>
-	    <li><a href="http://wiki.openstack.org/HowToContribute">Contribute</a></li>
-	  </ul>
-	</div>
-	<div class="span-4">
-	  <h3>Documentation</h3>
-	  <ul>
-	    <li><a href="http://docs.openstack.org/">OpenStack Manuals</a></li>
-	    <li><a href="http://docs.openstack.org/diablo/openstack-compute/starter/content/">Getting Started</a></li>
-	    <li><a href="http://wiki.openstack.org/">Wiki</a></li>
-	  </ul>
-	</div>
-	<div class="span-4 last">
-	  <h3>Branding &amp; Legal</h3>
-	  <ul>
-	    <li><a href="http://www.openstack.org/brand/">Logos &amp; Guidelines</a></li>
-	    <li><a href="http://www.openstack.org/brand/openstack-trademark-policy/">Trademark Policy</a></li>
-	    <li><a href="http://www.openstack.org/privacy/">Privacy Policy</a></li>
-	    <li><a href="http://wiki.openstack.org/CLA">OpenStack CLA</a></li>
-	  </ul>
-	</div>
-      </div>
-    </div>
+    <script type="text/javascript">footer();</script>
+
   </BODY>
 </html>
diff --git a/modules/openstack_project/manifests/static.pp b/modules/openstack_project/manifests/static.pp
index fd28b521fc..1521a9a4c0 100644
--- a/modules/openstack_project/manifests/static.pp
+++ b/modules/openstack_project/manifests/static.pp
@@ -146,6 +146,12 @@ class openstack_project::static (
     require => File['/srv/static/status'],
   }
 
+  file { '/srv/static/status/common.js':
+    ensure  => present,
+    source  => 'puppet:///modules/openstack_project/status/common.js',
+    require => File['/srv/static/status'],
+  }
+
   cron { 'gziplogs':
     user        => 'root',
     minute      => '0',