diff --git a/lib/schnitzelpress/config.rb b/lib/schnitzelpress/config.rb index c5d98fb..68b177a 100644 --- a/lib/schnitzelpress/config.rb +++ b/lib/schnitzelpress/config.rb @@ -15,6 +15,7 @@ class Config field :disqus_id, :type => String field :google_analytics_id, :type => String field :gauges_id, :type => String + field :gosquared_id, :type => String field :twitter_id, :type => String field :cache_timestamp, :type => DateTime diff --git a/lib/views/admin/config.haml b/lib/views/admin/config.haml index da26169..b848154 100644 --- a/lib/views/admin/config.haml +++ b/lib/views/admin/config.haml @@ -22,6 +22,9 @@ = form_field config, :google_analytics_id, :label => "Google Analytics ID" .six.columns = form_field config, :gauges_id, :label => "Gauges ID" + .row + .six.columns + = form_field config, :gosquared_id, :label => "GoSquared ID" .buttons %input{:type => 'submit', :value => 'Update Configuration'} diff --git a/lib/views/layout.haml b/lib/views/layout.haml index 2134a31..bbc7e2f 100644 --- a/lib/views/layout.haml +++ b/lib/views/layout.haml @@ -28,5 +28,7 @@ = partial 'google_analytics' - if production? && config.gauges_id.present? = partial 'gauges' + - if production? && config.gosquared_id.present? + = partial 'gosquared' %script{ :type => 'text/javascript', :src => "/assets/schnitzelpress.#{ASSET_TIMESTAMP}.js" } diff --git a/lib/views/partials/_gosquared.haml b/lib/views/partials/_gosquared.haml new file mode 100644 index 0000000..935d013 --- /dev/null +++ b/lib/views/partials/_gosquared.haml @@ -0,0 +1,16 @@ +:javascript + var GoSquared = {}; + GoSquared.acct = '#{config.gosquared_id}'; + (function(w){ + function gs(){ + w._gstc_lt = +new Date; + var d = document, g = d.createElement("script"); + g.type = "text/javascript"; + g.src = "//d1l6p2sc9645hc.cloudfront.net/tracker.js"; + var s = d.getElementsByTagName("script")[0]; + s.parentNode.insertBefore(g, s); + } + w.addEventListener ? + w.addEventListener("load", gs, false) : + w.attachEvent("onload", gs); + })(window);