[Qa-jenkins-scm] [jenkins.debian.net] 06/11: reproducible debian: add cross arch/suite navigation for many pages

Holger Levsen holger at layer-acht.org
Sun Jul 24 15:46:18 UTC 2016


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch master
in repository jenkins.debian.net.

commit a93cd8dbb2de5474ec20b728f09395575d81cac2
Author: Valerie R Young <spectranaut at riseup.net>
Date:   Sat Jul 16 10:17:26 2016 -0400

    reproducible debian: add cross arch/suite navigation for many pages
    
    From the left navigation "suite/arch" section, you can now navigation between
    suite and architecture specific results for the following pages: packages sets,
    packages with notes, packages without notes, packages tested in 24/48hs, all
    packages state pages and all packages page.
    
    Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
 bin/reproducible_common.py             | 40 ++++++++++++++++++++++++++++------
 bin/reproducible_common.sh             | 18 ++++++++-------
 bin/reproducible_html_indexes.py       |  7 +++++-
 bin/reproducible_html_pkg_sets.py      | 11 ++++++++--
 bin/templates/main_navigation.mustache | 13 +++++++++--
 5 files changed, 69 insertions(+), 20 deletions(-)

diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py
index de60cbd..e9d9356 100755
--- a/bin/reproducible_common.py
+++ b/bin/reproducible_common.py
@@ -55,6 +55,7 @@ REPRODUCIBLE_JSON = BASE + '/reproducible.json'
 REPRODUCIBLE_TRACKER_JSON = BASE + '/reproducible-tracker.json'
 REPRODUCIBLE_DB = '/var/lib/jenkins/reproducible.db'
 
+DEBIAN_URI = '/debian'
 DBD_URI = '/debian/dbd'
 DBDTXT_URI = '/debian/dbdtxt'
 LOGS_URI = '/debian/logs'
@@ -256,20 +257,41 @@ def convert_into_hms_string(duration):
     return duration
 
 
-# See bash equivelent: reproducible_common.sh's "write_page_header()"
-def create_main_navigation(page_title, suite, arch, displayed_page=None):
+def gen_suite_arch_nav_context(suite, arch, suite_arch_nav_template=None,
+                               ignore_experimental=False):
+    # if a template is not passed in to navigate between suite and archs
+    # for the current page, we use the suite/arch summary view
+    if not suite_arch_nav_template:
+        suite_arch_nav_template = '/debian/{{suite}}/index_suite_{{arch}}_stats.html'
     suite_list = []
     for s in SUITES:
+        include_suite = True
+        if s == 'experimental' and ignore_experimental:
+            include_suite = False
         suite_list.append({
             's': s,
-            'class': 'current' if s == suite else ''
+            'class': 'current' if s == suite else '',
+            'uri': renderer.render(suite_arch_nav_template,
+                                   {'suite': s, 'arch': arch})
+                   if include_suite else '',
         })
     arch_list = []
     for a in ARCHS:
         arch_list.append({
             'a': a,
-            'class': 'current' if a == arch else ''
+            'class': 'current' if a == arch else '',
+            'uri': renderer.render(suite_arch_nav_template,
+                                   {'suite': suite, 'arch': a}),
         })
+    return (suite_list, arch_list)
+
+
+# See bash equivelent: reproducible_common.sh's "write_page_header()"
+def create_main_navigation(page_title, suite, arch, displayed_page=None,
+                           suite_arch_nav_template=None,
+                           ignore_experimental=False):
+    suite_list, arch_list = gen_suite_arch_nav_context(suite, arch,
+        suite_arch_nav_template, ignore_experimental)
     context = {
         'page_title': page_title,
         'suite': suite,
@@ -278,12 +300,13 @@ def create_main_navigation(page_title, suite, arch, displayed_page=None):
         'suite_list': suite_list,
         'arch_list': arch_list,
         'debian_uri': DEBIAN_DASHBOARD_URI,
+        'cross_suite_arch_nav': True if suite_arch_nav_template else False,
     }
     if suite != 'experimental':
         # there are not package sets in experimental
         context['include_pkgset_link'] = True
-    # this argument controls which of the main page navigation items will be
-    # highlighted.
+    # the "display_page" argument controls which of the main page navigation
+    # items will be highlighted.
     if displayed_page:
        context[displayed_page] = True
     return renderer.render(main_navigation_template, context)
@@ -291,7 +314,8 @@ def create_main_navigation(page_title, suite, arch, displayed_page=None):
 
 def write_html_page(title, body, destfile, suite=defaultsuite, arch=defaultarch,
                     noheader=False, style_note=False, noendpage=False,
-                    packages=False, refresh_every=None, displayed_page=None):
+                    packages=False, refresh_every=None, displayed_page=None,
+                    suite_arch_nav_template=None, ignore_experimental=False):
     meta_refresh = '<meta http-equiv="refresh" content="%d">' % \
         refresh_every if refresh_every is not None else ''
     context = {
@@ -304,6 +328,8 @@ def write_html_page(title, body, destfile, suite=defaultsuite, arch=defaultarch,
             suite=suite,
             arch=arch,
             displayed_page=displayed_page,
+            suite_arch_nav_template=suite_arch_nav_template,
+            ignore_experimental=ignore_experimental,
         )
     main_html = body
     if style_note:
diff --git a/bin/reproducible_common.sh b/bin/reproducible_common.sh
index ac5116b..293aff7 100755
--- a/bin/reproducible_common.sh
+++ b/bin/reproducible_common.sh
@@ -197,16 +197,17 @@ write_page_header() {
 	# Create json for suite links (a list of objects)
 	suite_links="\"suite_list\": ["
 	comma=0
-	for i in $SUITES ; do
-		if [ "$i" = "$SUITE" ] ; then
+	for s in $SUITES ; do
+		if [ "$s" = "$SUITE" ] ; then
 			class="current"
 		else
 			class=''
 		fi
+		uri="/debian/${s}/index_suite_${ARCH}_stats.html"
 		if [ $comma == 1 ] ; then
-			suite_links+=", {\"s\": \"$i\", \"class\": \"$class\"}"
+			suite_links+=", {\"s\": \"${s}\", \"class\": \"$class\", \"uri\": \"$uri\"}"
 		else
-			suite_links+="{\"s\": \"$i\", \"class\": \"$class\"}"
+			suite_links+="{\"s\": \"${s}\", \"class\": \"$class\", \"uri\": \"$uri\"}"
 			comma=1
 		fi
 	done
@@ -215,16 +216,17 @@ write_page_header() {
 	# Create json for arch links (a list of objects)
 	arch_links="\"arch_list\": ["
 	comma=0
-	for i in ${ARCHS} ; do
-		if [ "$i" = "$ARCH" ] ; then
+	for a in ${ARCHS} ; do
+		if [ "$a" = "$ARCH" ] ; then
 			class="current"
 		else
 			class=''
 		fi
+		uri="/debian/$SUITE/index_suite_${a}_stats.html"
 		if [ $comma == 1 ] ; then
-			arch_links+=", {\"a\": \"$i\", \"class\": \"$class\"}"
+			arch_links+=", {\"a\": \"${a}\", \"class\": \"$class\", \"uri\": \"$uri\"}"
 		else
-			arch_links+="{\"a\": \"$i\", \"class\": \"$class\"}"
+			arch_links+="{\"a\": \"${a}\", \"class\": \"$class\", \"uri\": \"$uri\"}"
 			comma=1
 		fi
 	done
diff --git a/bin/reproducible_html_indexes.py b/bin/reproducible_html_indexes.py
index 46a0b23..a46f62a 100755
--- a/bin/reproducible_html_indexes.py
+++ b/bin/reproducible_html_indexes.py
@@ -44,6 +44,7 @@ Reference doc for the folowing lists:
     - force the suite/arch to the defaults
   + notes: if true the query also takes the value "status"
 
+
 Technically speaking, a page can be empty (we all love nonsense) but every
 section must have at least a `query` defining what to file in.
 """
@@ -521,6 +522,7 @@ def build_page(page, suite=None, arch=None):
             html1, footnote1 = build_page_section(page, section, suite, arch)
             html += html1
             footnote = True if footnote1 else footnote
+    suite_arch_nav_template = None
     if gpage:
         destfile = DEBIAN_BASE + '/index_' + page + '.html'
         desturl = DEBIAN_URL + '/index_' + page + '.html'
@@ -529,8 +531,11 @@ def build_page(page, suite=None, arch=None):
         destfile = DEBIAN_BASE + '/' + suite + '/' + arch + '/index_' + page + '.html'
         desturl = DEBIAN_URL + '/' + suite + '/' + arch + '/index_' + \
                   page + '.html'
+        suite_arch_nav_template = DEBIAN_URI + '/{{suite}}/{{arch}}/index_' + \
+                                  page + '.html'
     write_html_page(title=title, body=html, destfile=destfile, suite=suite,
-                    arch=arch, style_note=True, displayed_page=page)
+                    arch=arch, style_note=True, displayed_page=page,
+                    suite_arch_nav_template=suite_arch_nav_template)
     log.info('"' + title + '" now available at ' + desturl)
 
 
diff --git a/bin/reproducible_html_pkg_sets.py b/bin/reproducible_html_pkg_sets.py
index f5dc9fa..7a81ac6 100755
--- a/bin/reproducible_html_pkg_sets.py
+++ b/bin/reproducible_html_pkg_sets.py
@@ -141,10 +141,14 @@ def create_index_page(suite, arch):
     body = create_pkgset_navigation(suite, arch)
     destfile = os.path.join(DEBIAN_BASE, suite, arch,
                             "index_pkg_sets.html")
+    suite_arch_nav_template = DEBIAN_URI + \
+                              '/{{suite}}/{{arch}}/index_pkg_sets.html'
     log.info("Creating pkgset index page for %s/%s.",
              suite, arch)
     write_html_page(title=title, body=body, destfile=destfile, suite=suite,
-                    arch=arch, displayed_page='pkg_set')
+                    arch=arch, displayed_page='pkg_set',
+                    suite_arch_nav_template=suite_arch_nav_template,
+                    ignore_experimental=True)
 
 
 def gen_other_arch_context(archs, suite, pkgset_name):
@@ -237,10 +241,13 @@ def create_pkgset_page_and_graphs(suite, arch, stats, pkgset_name):
             (pkgset_name, suite, arch)
     page = "pkg_set_" + pkgset_name + ".html"
     destfile = os.path.join(DEBIAN_BASE, suite, arch, page)
+    suite_arch_nav_template = DEBIAN_URI + '/{{suite}}/{{arch}}/' + page
     log.info("Creating meta pkgset page for %s in %s/%s.",
               pkgset_name, suite, arch)
     write_html_page(title=title, body=html_body, destfile=destfile, suite=suite,
-                    arch=arch, displayed_page='pkg_set')
+                    arch=arch, displayed_page='pkg_set',
+                    suite_arch_nav_template=suite_arch_nav_template,
+                    ignore_experimental=True)
 
 
 def create_pkgset_graph(png_file, suite, arch, pkgset_name):
diff --git a/bin/templates/main_navigation.mustache b/bin/templates/main_navigation.mustache
index 1846a2e..8b9de72 100644
--- a/bin/templates/main_navigation.mustache
+++ b/bin/templates/main_navigation.mustache
@@ -1,15 +1,22 @@
 <a href="{{debian_uri}}"><h2>Debian Dashboard</h2></a>
 <ul class="menu">
+  {{^cross_suite_arch_nav}}
   <h4>Suite/Architecture Overviews</h4>
+  {{/cross_suite_arch_nav}}
+  {{#cross_suite_arch_nav}}
+  <h4>Change Suite/Architecture</h4>
+  {{/cross_suite_arch_nav}}
   <li>
     Tested architectures:
     <ul class="children">
       <li>
       {{#arch_list}}
+        {{#uri}}
         <a class='{{class}}'
-           href="/debian/{{suite}}/index_suite_{{a}}_stats.html">
+           href="{{uri}}">
           {{a}}
         </a>
+        {{/uri}}
       {{/arch_list}}
       </li>
     </ul>
@@ -18,10 +25,12 @@
     <ul class="children">
       <li>
       {{#suite_list}}
+        {{#uri}}
         <a class='{{class}}'
-           href="/debian/{{s}}/index_suite_{{arch}}_stats.html">
+           href="{{uri}}">
           {{s}}
         </a>
+        {{/uri}}
       {{/suite_list}}
       </li>
     </ul>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git



More information about the Qa-jenkins-scm mailing list