Permalink
Browse files

Add a GOOGLE_ANALYTICS_CODE setting to enable Google Analytics

  • Loading branch information...
oldpatricka committed Feb 11, 2013
1 parent 7848c2a commit e003f17ecb78153d4a1ad2b454b162f71b4ba4a5
@@ -1,7 +1,6 @@
<!DOCTYPE html>
<html lang="en">
-
-<head>
+ <head>
<title>{% block title %}Nimbus{% endblock %}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -21,75 +20,92 @@
{% block headscripts %}{% endblock %}
-</head>
-
-<body {% block bodytag %}{% endblock %}>
-
-<div id="nimbus_logo" class="hidden-phone outer-container">
-<!--NIMBUS-->
-<img src="/static/images/nimbus_logo.png" />
-</div>
-
-<div class="container-fluid outer-container">
- <div class="row-fluid">
- <div class="topbar navbar">
- <div class="navbar-inner">
- <div class="container">
- <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </a>
- <a href="/phantom" class="brand">Phantom</a>
- <div class="nav-collapse">
- <ul class="nav">
- <li id="nav-profile"><a href="/phantom/profile">Profile</a></li>
- <li id="nav-launchconfig"><a href="/phantom/launchconfig">Launch Configurations</a></li>
- <li id="nav-domains"><a href="/phantom/domain">Domains</a></li>
- <li id="nav-logout"><a href="/accounts/logout">Logout</a></li>
- </ul>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="row-fluid">
- <div class="span12 well">
- {% block nimbus_body %}{% endblock %}
- </div>
- </div>
-</div>
-
-<br class="clear" />
-<div id="footer" class="container-fluid outer-container">
- <div class="row-fluid">
- <div class="navbar">
- <div class="navbar-inner">
- <small>
- <ul class="nav">
- <li><a href="/" title="Home"><span class="first">Home</span></a></li>
- <li><a href="http://www.nimbusproject.org/about/" title="About">About Nimbus</a></li>
- <li><a href="/doc/nimbus/faq/" title="FAQ">FAQ</a></li>
- <li><a href="/doc/nimbus/" title="Documentation">Documentation</a></li>
- <li><a href="http://www.nimbusproject.org/contact/" title="Community Resources">Community Resources</a></li>
- <li><a href="http://www.nimbusproject.org/downloads/" title="Software">Download</a></li>
-
- <li><a href="http://www.nimbusproject.org/pubs/" title="Publications">Publications</a></li>
- <li class="last"><a href="http://www.nimbusproject.org/news/" title="News">News</a></li>
- <li><a href="#">&copy; University of Chicago</a></li>
- </ul>
- </small>
- </div>
- </div>
- </div>
-</div>
-
-
-<br class="clear" />
-
-<div id="bottom"><p>&nbsp;</p></div>
-
-</body>
-</html>
+ <script type="text/javascript">
+ {% load value_from_settings %}
+ var gaAccount = '{% value_from_settings GOOGLE_ANALYTICS_CODE %}';
+
+ if (gaAccount !== '') {
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', gaAccount]);
+ _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>
+
+ </head>
+
+ <body {% block bodytag %}{% endblock %}>
+
+ <div id="nimbus_logo" class="hidden-phone outer-container">
+ <!--NIMBUS-->
+ <img src="/static/images/nimbus_logo.png" />
+ </div>
+ <div class="container-fluid outer-container">
+ <div class="row-fluid">
+ <div class="topbar navbar">
+ <div class="navbar-inner">
+ <div class="container">
+ <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </a>
+ <a href="/phantom" class="brand">Phantom</a>
+ <div class="nav-collapse">
+ <ul class="nav">
+ <li id="nav-profile"><a href="/phantom/profile">Profile</a></li>
+ <li id="nav-launchconfig"><a href="/phantom/launchconfig">Launch Configurations</a></li>
+ <li id="nav-domains"><a href="/phantom/domain">Domains</a></li>
+ <li id="nav-logout"><a href="/accounts/logout">Logout</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row-fluid">
+ <div class="span12 well">
+ {% block nimbus_body %}{% endblock %}
+ </div>
+ </div>
+ </div>
+
+ <br class="clear" />
+ <div id="footer" class="container-fluid outer-container">
+ <div class="row-fluid">
+ <div class="navbar">
+ <div class="navbar-inner">
+ <small>
+ <ul class="nav">
+ <li><a href="/" title="Home"><span class="first">Home</span></a></li>
+ <li><a href="http://www.nimbusproject.org/about/" title="About">About Nimbus</a></li>
+ <li><a href="/doc/nimbus/faq/" title="FAQ">FAQ</a></li>
+ <li><a href="/doc/nimbus/" title="Documentation">Documentation</a></li>
+ <li><a href="http://www.nimbusproject.org/contact/" title="Community Resources">Community Resources</a></li>
+ <li><a href="http://www.nimbusproject.org/downloads/" title="Software">Download</a></li>
+
+ <li><a href="http://www.nimbusproject.org/pubs/" title="Publications">Publications</a></li>
+ <li class="last"><a href="http://www.nimbusproject.org/news/" title="News">News</a></li>
+ <li><a href="#">&copy; University of Chicago</a></li>
+ </ul>
+ </small>
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+ <br class="clear" />
+
+ <div id="bottom"><p>&nbsp;</p></div>
+
+ </body>
+ </html>
No changes.
@@ -0,0 +1,19 @@
+from django import template
+from django.conf import settings
+
+register = template.Library()
+
+@register.tag
+def value_from_settings(parser, token):
+ try:
+ # split_contents() knows not to split quoted strings.
+ tag_name, var = token.split_contents()
+ except ValueError:
+ raise template.TemplateSyntaxError, "%r tag requires a single argument" % token.contents.split()[0]
+ return ValueFromSettings(var)
+
+class ValueFromSettings(template.Node):
+ def __init__(self, var):
+ self.arg = template.Variable(var)
+ def render(self, context):
+ return getattr(settings, str(self.arg), "")

0 comments on commit e003f17

Please sign in to comment.