Permalink
Browse files

Add an optional footer to make piwik statistics independant of the pr…

…oject
  • Loading branch information...
1 parent f7d43c2 commit 2a12022fd22a564a8997039a33545e50a03b35e0 @cbonte committed Nov 4, 2012
Showing with 19 additions and 16 deletions.
  1. +18 −1 haproxy-dconv.py
  2. +1 −15 templates/template.html
View
19 haproxy-dconv.py
@@ -32,6 +32,7 @@
from mako.template import Template
from mako.lookup import TemplateLookup
+from mako.exceptions import TopLevelLookupException
from parser import PContext
from parser import remove_indent
@@ -411,6 +412,21 @@ def convert(infile, outfile):
print >> sys.stderr, "Exporting to %s..." % outfile
template = pctxt.templates.get_template('template.html')
+ try:
+ footerTemplate = pctxt.templates.get_template('footer.html')
+ footer = footerTemplate.render(
+ headers = pctxt.context['headers'],
+ document = document,
+ chapters = chapters,
+ chapterIndexes = chapterIndexes,
+ keywords = keywords,
+ keywordsCount = keywordsCount,
+ keyword_conflicts = keyword_conflicts,
+ version = VERSION,
+ date = datetime.datetime.now().strftime("%Y/%m/%d"),
+ )
+ except TopLevelLookupException:
+ footer = ""
fd = open(outfile,'w')
@@ -423,7 +439,8 @@ def convert(infile, outfile):
keywordsCount = keywordsCount,
keyword_conflicts = keyword_conflicts,
version = VERSION,
- date = datetime.datetime.now().strftime("%Y/%m/%d")
+ date = datetime.datetime.now().strftime("%Y/%m/%d"),
+ footer = footer
)
fd.close()
View
16 templates/template.html
@@ -153,20 +153,6 @@
refreshNavigation()
});
</script>
-
-<!-- Piwik -->
-<script type="text/javascript">
-var pkBaseURL = (("https:" == document.location.protocol) ? "https://stats.cdncdn.net/" : "http://stats.cdncdn.net/");
-document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
-</script><script type="text/javascript">
-try {
-var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 4);
-piwikTracker.setCustomVariable (1, 'HaproxyVersion', '${headers['version']}', 'page');
-piwikTracker.setCustomVariable (2, 'HaproxyDconvVersion', '${version}', 'page');
-piwikTracker.trackPageView();
-piwikTracker.enableLinkTracking();
-} catch( err ) {}
-</script><noscript><p><img src="http://stats.cdncdn.net/piwik.php?idsite=4" style="border:0" alt="" /></p></noscript>
-<!-- End Piwik Tracking Code -->
+ ${footer}
</body>
</html>

0 comments on commit 2a12022

Please sign in to comment.