Changeset - fb5760e8ba43
[Not reviewed]
default
0 3 0
domruf - 11 years ago 2014-08-18 21:04:36
dominikruf@gmail.com
support other analytic systems then just Google Analytics

Fallback to Google Analytics code if the string starts with "UA-"
3 files changed with 20 insertions and 17 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/base.py
Show inline comments
 
@@ -305,6 +305,19 @@ class BaseController(WSGIController):
 
        c.visual.gravatar_url = rc_config.get('gravatar_url')
 

	
 
        c.ga_code = rc_config.get('ga_code')
 
        # TODO: replace undocumented backwards compatibility hack with db upgrade and rename ga_code
 
        if c.ga_code and '<' not in c.ga_code:
 
            c.ga_code = '''<script type="text/javascript">
 
                var _gaq = _gaq || [];
 
                _gaq.push(['_setAccount', '%s']);
 
                _gaq.push(['_trackPageview']);
 

	
 
                (function() {
 
                    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
 
                    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
 
                    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
 
                    })();
 
            </script>''' % c.ga_code
 
        c.site_name = rc_config.get('title')
 
        c.clone_uri_tmpl = rc_config.get('clone_uri_tmpl')
 

	
kallithea/templates/admin/settings/settings_global.html
Show inline comments
 
@@ -24,10 +24,11 @@ ${h.form(url('admin_settings_global'), m
 

	
 
            <div class="field">
 
                <div class="label">
 
                    <label for="ga_code">${_('Google Analytics code')}:</label>
 
                    <label for="ga_code">${_('Analytics HTML block')}:</label>
 
                </div>
 
                <div class="input">
 
                    ${h.text('ga_code',size=30)}
 
                    ${h.textarea('ga_code', cols=80, rows=10)}
 
                    <span class="help-block">${_('HTML with JavaScript for web analytics systems like Google Analytics or Piwik. This will be added at the bottom of every page.')}</span>
 
                </div>
 
            </div>
 

	
kallithea/templates/base/root.html
Show inline comments
 
@@ -22,21 +22,6 @@
 

	
 
        ${self.css()}
 

	
 
        %if c.ga_code:
 
        <!-- Analytics -->
 
        <script type="text/javascript">
 
            var _gaq = _gaq || [];
 
            _gaq.push(['_setAccount', '${c.ga_code}']);
 
            _gaq.push(['_trackPageview']);
 

	
 
            (function() {
 
                var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
 
                ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
 
                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
 
                })();
 
        </script>
 
        %endif
 

	
 
        ## JAVASCRIPT ##
 
        <%def name="js()">
 
            <script type="text/javascript">
 
@@ -149,5 +134,9 @@
 
      <![endif]-->
 

	
 
      ${next.body()}
 

	
 
      %if c.ga_code:
 
      ${h.literal(c.ga_code)}
 
      %endif
 
    </body>
 
</html>
0 comments (0 inline, 0 general)