From 55af141af8e0e504bdf8489070861f061095448b Mon Sep 17 00:00:00 2001 From: Valerie R Young Date: Thu, 30 Jun 2016 08:38:20 -0400 Subject: reproducible debian: add mustache script for main page navigation Signed-off-by: Mattia Rizzolo Signed-off-by: Holger Levsen --- bin/reproducible_common.py | 132 +++++---------------------------- bin/templates/main_navigation.mustache | 88 ++++++++++++++++++++++ 2 files changed, 106 insertions(+), 114 deletions(-) create mode 100644 bin/templates/main_navigation.mustache (limited to 'bin') diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py index d2077772..2340644f 100755 --- a/bin/reproducible_common.py +++ b/bin/reproducible_common.py @@ -147,7 +147,10 @@ default_page_footer_template = renderer.load_template( TEMPLATE_PATH + '/default_page_footer') pkg_legend_template = renderer.load_template( TEMPLATE_PATH + '/pkg_symbol_legend') - +project_links_template = renderer.load_template( + os.path.join(TEMPLATE_PATH, 'project_links')) +main_navigation_template = renderer.load_template( + os.path.join(TEMPLATE_PATH, 'main_navigation')) html_header = Template(""" @@ -177,88 +180,6 @@ def create_default_page_footer(date): 'jenkins_url': JENKINS_URL, }) -html_head_page = Template((tab*2).join((""" -
-

$page_title

- -$project_links -
""" % DEBIAN_URL ).splitlines(True))) - -html_project_links = Template((tab*2).join(""" - -""".splitlines(True))) - url2html = re.compile(r'((mailto\:|((ht|f)tps?)\://|file\:///){1}\S+)') # filter used on the index_FTBFS pages and for the reproducible.json @@ -325,25 +246,19 @@ def convert_into_hms_string(duration): return duration -def _gen_pkg_sets_link(suite, arch): - html = '' - if suite != 'experimental': - html = '
  • package sets
  • ' - return html - -def _gen_arch_links(suite, arch): - html = '
  • ' - for a in ARCHS: - html += ' ' + a + '  ' - html += '
  • ' - return html - -def _gen_suite_links(suite, arch): - html = '
  • ' - for s in SUITES: - html += ' ' + s + '  ' - html += '
  • ' - return html +# See bash equivelent: reproducible_common.sh's "write_page_header()" +def create_main_navigation(page_title, suite, arch): + context = { + 'page_title': page_title, + 'suite': suite, + 'arch': arch, + 'project_links_html': renderer.render(project_links_template), + 'experimental': False, + 'suite_list': [{'s': s} for s in SUITES], + 'arch_list': [{'a': a} for a in ARCHS], + 'debian_url': DEBIAN_URL, + } + return renderer.render(main_navigation_template, context) def write_html_page(title, body, destfile, suite=defaultsuite, arch=defaultarch, noheader=False, style_note=False, noendpage=False, packages=False, refresh_every=None): @@ -355,19 +270,8 @@ def write_html_page(title, body, destfile, suite=defaultsuite, arch=defaultarch, page_title=title, meta_refresh=meta_refresh) if not noheader: - link_archs = _gen_arch_links(suite, arch) - link_suites = _gen_suite_links(suite, arch) - link_pkgsets = _gen_pkg_sets_link(suite, arch) - project_links=html_project_links.substitute() + html += create_main_navigation(title, suite, arch) - html += html_head_page.substitute( - page_title=title, - suite=suite, - arch=arch, - link_archs=link_archs, - link_suites=link_suites, - link_pkgsets=link_pkgsets, - project_links=project_links) html += body if style_note: html += renderer.render(pkg_legend_template, {}) diff --git a/bin/templates/main_navigation.mustache b/bin/templates/main_navigation.mustache new file mode 100644 index 00000000..1a8a60ac --- /dev/null +++ b/bin/templates/main_navigation.mustache @@ -0,0 +1,88 @@ +
    +

    {{page_title}}

    + + {{{project_links_html}}} +
    -- cgit v1.2.3-54-g00ecf