mirror of
https://github.com/ejwa/gitinspector.git
synced 2024-11-16 08:38:26 +01:00
The scripts from the flot archive are now included in the HTML output.
The gitinspector piclet was also added to the generated HTML.
This commit is contained in:
parent
ffdad930cf
commit
6ee7ad71ab
2 changed files with 32 additions and 14 deletions
35
format.py
35
format.py
|
@ -18,9 +18,11 @@
|
|||
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
import base64
|
||||
import os
|
||||
import terminal
|
||||
import version
|
||||
import zipfile
|
||||
|
||||
__available_formats__ = ["html", "text", "xml"]
|
||||
__default_format__ = __available_formats__[1]
|
||||
|
@ -39,26 +41,37 @@ def is_interactive_format():
|
|||
global __selected_format__
|
||||
return __selected_format__ == "text"
|
||||
|
||||
def __output_html_template__(name, *parameters):
|
||||
def __output_html_template__(name):
|
||||
template_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), name)
|
||||
file_r = open(template_path, "rb")
|
||||
template = file_r.read().decode("utf-8", "replace")
|
||||
print(template.format(*parameters))
|
||||
return file_r.read().decode("utf-8", "replace")
|
||||
|
||||
def __get_zip_file_content__(name):
|
||||
zip_file = zipfile.ZipFile("html/flot.zip", "r")
|
||||
content = zip_file.read(name)
|
||||
zip_file.close()
|
||||
return content
|
||||
|
||||
def output_header():
|
||||
if __selected_format__ == "html":
|
||||
__output_html_template__("html/html.header", version.__version__)
|
||||
elif __selected_format__ == "text":
|
||||
pass
|
||||
else:
|
||||
html_header = __output_html_template__("html/html.header")
|
||||
jquery_js = __get_zip_file_content__("jquery.js")
|
||||
flot_js = __get_zip_file_content__("jquery.flot.js")
|
||||
|
||||
logo_file = open("html/gitinspector_piclet.png", "rb")
|
||||
logo = logo_file.read()
|
||||
logo_file.close()
|
||||
logo = base64.b64encode(logo)
|
||||
|
||||
print(html_header.format(version.__version__, jquery_js, flot_js, logo))
|
||||
elif __selected_format__ == "xml":
|
||||
print("<gitinspector>")
|
||||
|
||||
def output_footer():
|
||||
if __selected_format__ == "html":
|
||||
__output_html_template__("html/html.footer")
|
||||
elif __selected_format__ == "text":
|
||||
pass
|
||||
else:
|
||||
html_footer = __output_html_template__("html/html.footer")
|
||||
print(html_footer)
|
||||
elif __selected_format__ == "xml":
|
||||
print("</gitinspector>")
|
||||
|
||||
def call_output_function(html_function, text_function, xml_function, *parameters):
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Output generated by gitinspector {0}.</title>
|
||||
<title>Generated by gitinspector {0}.</title>
|
||||
<script type="application/javascript">{1}</script>
|
||||
<script type="application/javascript">{2}</script>
|
||||
</head>
|
||||
<body>
|
||||
<img src="data:image/png;base64,{3}" />
|
||||
<p>The output below has been generated by <a href="http://gitinspector.googlecode.com">gitinspector</a>;
|
||||
the statistical analysis tool for git repositories.<p>
|
||||
|
|
Loading…
Reference in a new issue