From 45429d9a357c6a1b00dfc4c5a5ef8bdd9525652f Mon Sep 17 00:00:00 2001 From: Adam Waldenberg Date: Wed, 26 Jun 2013 02:36:13 +0200 Subject: [PATCH] Added a "htmlembedded" output format. This format behaves the same as the old "html" output. Consequently, the ordinary "html" output now hot-links the JQuery script to ajax.googleapis.com. This results in a generated file with roughly half the stitching code compared to previously. --- gitinspector/format.py | 10 +++++++--- gitinspector/html/html.header | 2 +- gitinspector/outputable.py | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/gitinspector/format.py b/gitinspector/format.py index a56fef3..c4f6487 100644 --- a/gitinspector/format.py +++ b/gitinspector/format.py @@ -25,7 +25,7 @@ import basedir import os import zipfile -__available_formats__ = ["html", "text", "xml"] +__available_formats__ = ["html", "htmlembedded", "text", "xml"] __default_format__ = __available_formats__[1] __selected_format__ = __default_format__ @@ -56,10 +56,9 @@ def __get_zip_file_content__(name, file_name="/html/flot.zip"): return content.decode("utf-8", "replace") def output_header(): - if __selected_format__ == "html": + if __selected_format__ == "html" or __selected_format__ == "htmlembedded": base = basedir.get_basedir() html_header = __output_html_template__(base + "/html/html.header") - jquery_js = __get_zip_file_content__("jquery.js") tablesorter_js = __get_zip_file_content__("jquery.tablesorter.min.js", "/html/jquery.tablesorter.min.js.zip") flot_js = __get_zip_file_content__("jquery.flot.js") pie_js = __get_zip_file_content__("jquery.flot.pie.js") @@ -69,6 +68,11 @@ def output_header(): logo_file.close() logo = base64.b64encode(logo) + if __selected_format__ == "htmlembedded": + jquery_js = ">" + __get_zip_file_content__("jquery.js") + else: + jquery_js = " src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js\">" + print(html_header.format(version = version.__version__, jquery = jquery_js, jquery_tablesorter = tablesorter_js, diff --git a/gitinspector/html/html.header b/gitinspector/html/html.header index 4b95db2..d9f2cfb 100644 --- a/gitinspector/html/html.header +++ b/gitinspector/html/html.header @@ -3,7 +3,7 @@ Generated by gitinspector {version} - + diff --git a/gitinspector/outputable.py b/gitinspector/outputable.py index c521d21..9f2899d 100644 --- a/gitinspector/outputable.py +++ b/gitinspector/outputable.py @@ -32,7 +32,7 @@ class Outputable(object): print(_("XML output not yet supported in") + " \"" + self.__class__.__name__ + "\".") def output(outputable): - if format.get_selected() == "html": + if format.get_selected() == "html" or format.get_selected() == "htmlembedded": outputable.output_html() elif format.get_selected() == "text": outputable.output_text()