diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/reproducible_common.py | 30 | ||||
-rwxr-xr-x | bin/reproducible_html_pkg_sets.py | 33 | ||||
-rw-r--r-- | bin/templates/basic_page.mustache | 20 |
3 files changed, 38 insertions, 45 deletions
diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py index 95b652e3..70a4f62c 100755 --- a/bin/reproducible_common.py +++ b/bin/reproducible_common.py @@ -155,6 +155,8 @@ 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')) +basic_page_template = renderer.load_template( + os.path.join(TEMPLATE_PATH, 'basic_page')) html_header = Template("""<!DOCTYPE html> <html> @@ -278,32 +280,28 @@ 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): - now = datetime.utcnow().strftime('%Y-%m-%d %H:%M UTC') - html = '' meta_refresh = '<meta http-equiv="refresh" content="%d">' % \ refresh_every if refresh_every is not None else '' - html += html_header.substitute( - page_title=title, - meta_refresh=meta_refresh) + context = { + 'page_title': title, + 'meta_refresh': meta_refresh, + } if not noheader: - html += create_main_navigation( + context['main_navigation_html'] = create_main_navigation( page_title=title, suite=suite, arch=arch, displayed_page=displayed_page, ) - # Add the 'mainbody' div only if including a header - html += "<div class='mainbody'>" - html += body + main_html = body if style_note: - html += renderer.render(pkg_legend_template, {}) + main_html += renderer.render(pkg_legend_template, {}) if not noendpage: - html += create_default_page_footer(now) - if not noheader: - # If the header was included, we need to end the 'mainbody' div after - # the 'mainbody' content - html += '</div>' - html += '</body>\n</html>' + now = datetime.utcnow().strftime('%Y-%m-%d %H:%M UTC') + main_html += create_default_page_footer(now) + context['main_html'] = main_html + html = renderer.render(basic_page_template, context) + try: os.makedirs(destfile.rsplit('/', 1)[0], exist_ok=True) except OSError as e: diff --git a/bin/reproducible_html_pkg_sets.py b/bin/reproducible_html_pkg_sets.py index 89652aa5..f5dc9fab 100755 --- a/bin/reproducible_html_pkg_sets.py +++ b/bin/reproducible_html_pkg_sets.py @@ -24,8 +24,6 @@ pkgset_navigation_template = renderer.load_template( os.path.join(TEMPLATE_PATH, 'pkgset_navigation')) pkgset_details_template = renderer.load_template( os.path.join(TEMPLATE_PATH, 'pkgset_details')) -basic_page_template = renderer.load_template( - os.path.join(TEMPLATE_PATH, 'basic_page')) pkg_legend_template = renderer.load_template( os.path.join(TEMPLATE_PATH, 'pkg_symbol_legend')) @@ -140,20 +138,13 @@ def create_pkgset_navigation(suite, arch, view=None): def create_index_page(suite, arch): title = 'Package sets in %s/%s for Reproducible Builds' % (suite, arch) - now = datetime.utcnow().strftime('%Y-%m-%d %H:%M UTC') - page_context = { - 'main_html': create_pkgset_navigation(suite, arch) + - create_default_page_footer(now), - 'main_navigation_html': create_main_navigation(title, suite, arch, - 'pkg_set'), - } - body = renderer.render(basic_page_template, page_context) + body = create_pkgset_navigation(suite, arch) destfile = os.path.join(DEBIAN_BASE, 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, - noheader=True, noendpage=True) + write_html_page(title=title, body=body, destfile=destfile, suite=suite, + arch=arch, displayed_page='pkg_set') def gen_other_arch_context(archs, suite, pkgset_name): @@ -184,8 +175,8 @@ def stats_thumb_file_href(suite, arch, pkgset_name): def create_pkgset_page_and_graphs(suite, arch, stats, pkgset_name): - html = "" - html += create_pkgset_navigation(suite, arch, pkgset_name) + html_body = "" + html_body += create_pkgset_navigation(suite, arch, pkgset_name) pkgset_context = ({ 'pkgset_name': pkgset_name, 'suite': suite, @@ -241,23 +232,15 @@ def create_pkgset_page_and_graphs(suite, arch, stats, pkgset_name): stats["count_" + cutename] != 0): pkgset_context['status_details'].append(details_context) - html += renderer.render(pkgset_details_template, pkgset_context) - now = datetime.utcnow().strftime('%Y-%m-%d %H:%M UTC') - html += create_default_page_footer(now) + html_body += renderer.render(pkgset_details_template, pkgset_context) title = 'Reproducible Builds %s package set for %s/%s for' % \ (pkgset_name, suite, arch) - - body = renderer.render(basic_page_template, { - 'main_html': html, - 'main_navigation_html': create_main_navigation(title, suite, arch, - 'pkg_set'), - }) page = "pkg_set_" + pkgset_name + ".html" destfile = os.path.join(DEBIAN_BASE, suite, arch, page) log.info("Creating meta pkgset page for %s in %s/%s.", pkgset_name, suite, arch) - write_html_page(title=title, body=body, destfile=destfile, - noheader=True, noendpage=True) + write_html_page(title=title, body=html_body, destfile=destfile, suite=suite, + arch=arch, displayed_page='pkg_set') def create_pkgset_graph(png_file, suite, arch, pkgset_name): diff --git a/bin/templates/basic_page.mustache b/bin/templates/basic_page.mustache index 99fee20f..1239a4a0 100644 --- a/bin/templates/basic_page.mustache +++ b/bin/templates/basic_page.mustache @@ -1,4 +1,16 @@ -{{{main_navigation_html}}} -<div class="mainbody"> -{{{main_html}}} -</div> +<!DOCTYPE html> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <meta name="viewport" content="width=device-width" /> + {{meta_refresh}} + <link href="/static/style.css" type="text/css" rel="stylesheet" /> + <title>{{page_title}}</title> + </head> + <body class="wrapper"> + {{{main_navigation_html}}} + <div class="mainbody"> + {{{main_html}}} + </div> + </body> +</html> |