[pypy-svn] r70157 - pypy/trunk/pypy/doc

hpk at codespeak.net hpk at codespeak.net
Wed Dec 16 20:37:32 CET 2009


Author: hpk
Date: Wed Dec 16 20:37:31 2009
New Revision: 70157

Modified:
   pypy/trunk/pypy/doc/confrest.py
Log:
add google analytics tracking to pypy web page - this way we can probably get a clue what pages people are currently looking at/bailing out. 



Modified: pypy/trunk/pypy/doc/confrest.py
==============================================================================
--- pypy/trunk/pypy/doc/confrest.py	(original)
+++ pypy/trunk/pypy/doc/confrest.py	Wed Dec 16 20:37:31 2009
@@ -5,6 +5,17 @@
 html = py.xml.html
 
 class PyPyPage(Page): 
+    googlefragment = """
+<script type="text/javascript">
+var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+</script>
+<script type="text/javascript">
+try {
+var pageTracker = _gat._getTracker("UA-7778406-2");
+pageTracker._trackPageview();
+} catch(err) {}</script>
+"""
     def fill_menubar(self):
         self.menubar = html.div(
             html.a("home", 
@@ -31,6 +42,14 @@
     def get_doclink(self, target):
         return relpath(self.targetpath.strpath,
                        self.project.docpath.join(target).strpath)
+
+    def unicode(self, doctype=True): 
+        page = self._root.unicode() 
+        page = page.replace("</body>", self.googlefragment + "</body>")
+        if doctype: 
+            return self.doctype + page 
+        else: 
+            return page 
         
 
 class Project(Project): 



More information about the Pypy-commit mailing list