remove icky analytics code from layouts, move to middleware
This commit is contained in:
parent
9cdfea02b0
commit
fdea2f94ff
5 changed files with 19 additions and 39 deletions
2
Gemfile
2
Gemfile
|
|
@ -41,6 +41,8 @@ group :production do # we don't install these on travis to speed up test runs
|
|||
# reporting
|
||||
gem 'hoptoad_notifier'
|
||||
gem 'newrelic_rpm', :require => false
|
||||
gem 'rack-google-analytics', :require => 'rack/google-analytics'
|
||||
gem 'rack-piwik', :require => 'rack/piwik'
|
||||
end
|
||||
|
||||
# configuration
|
||||
|
|
|
|||
|
|
@ -317,10 +317,12 @@ GEM
|
|||
pg (0.12.2)
|
||||
polyglot (0.3.3)
|
||||
rack (1.2.4)
|
||||
rack-google-analytics (0.10.0)
|
||||
rack-mobile-detect (0.3.0)
|
||||
rack
|
||||
rack-mount (0.6.14)
|
||||
rack (>= 1.0.0)
|
||||
rack-piwik (0.1.2)
|
||||
rack-test (0.5.7)
|
||||
rack (>= 1.0)
|
||||
rails (3.0.11)
|
||||
|
|
@ -503,6 +505,8 @@ DEPENDENCIES
|
|||
omniauth-twitter
|
||||
parallel_tests
|
||||
pg
|
||||
rack-google-analytics
|
||||
rack-piwik
|
||||
rails (= 3.0.11)
|
||||
rails-i18n
|
||||
redcarpet (= 2.0.0)
|
||||
|
|
|
|||
|
|
@ -55,28 +55,6 @@
|
|||
color: purple;
|
||||
background-color: red;
|
||||
}
|
||||
-if AppConfig[:google_a_site]
|
||||
:javascript
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', '#{AppConfig[:google_a_site]}']);
|
||||
_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);
|
||||
})();
|
||||
|
||||
-if AppConfig[:piwik_id]
|
||||
:javascript
|
||||
var pkBaseURL = (("https:" == document.location.protocol) ? "https://#{AppConfig[:piwik_url]}/" : "http://#{AppConfig[:piwik_url]}/");
|
||||
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
|
||||
:javascript
|
||||
try {
|
||||
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", #{AppConfig[:piwik_id]});
|
||||
piwikTracker.trackPageView();
|
||||
piwikTracker.enableLinkTracking();
|
||||
} catch( err ) {}
|
||||
|
||||
- if @person
|
||||
%link{:rel => "alternate", :href => "#{@person.public_url}.atom", :type => "application/atom+xml", :title => "#{t('.public_feed', :name => @person.name)}"}
|
||||
|
|
|
|||
|
|
@ -65,20 +65,3 @@
|
|||
|
||||
:javascript
|
||||
MBP.hideUrlBar();
|
||||
|
||||
-if AppConfig[:google_a_site]
|
||||
:javascript
|
||||
var _gaq=[["_setAccount","#{AppConfig[:google_a_site]}"],["_trackPageview"]];
|
||||
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;
|
||||
g.src=("https:"==location.protocol?"//ssl":"//www")+".google-analytics.com/ga.js";
|
||||
s.parentNode.insertBefore(g,s)}(document,"script"));
|
||||
|
||||
-if AppConfig[:piwik_id]
|
||||
:javascript
|
||||
var pkBaseURL = (("https:" == document.location.protocol) ? "https://#{AppConfig[:piwik_url]}/" : "http://#{AppConfig[:piwik_url]}/");
|
||||
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
|
||||
try {
|
||||
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", #{AppConfig[:piwik_id]});
|
||||
piwikTracker.trackPageView();
|
||||
piwikTracker.enableLinkTracking();
|
||||
} catch( err ) {}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,19 @@ Diaspora::Application.configure do
|
|||
# the I18n.default_locale when a translation can not be found)
|
||||
config.i18n.fallbacks = true
|
||||
config.threadsafe!
|
||||
|
||||
|
||||
require Rails.root + 'app/models/app_config'
|
||||
|
||||
if AppConfig[:google_a_site].present?
|
||||
config.gem 'rack-google-analytics', :lib => 'rack/google-analytics'
|
||||
config.middleware.use Rack::GoogleAnalytics, :tracker => AppConfig[:google_a_site]
|
||||
end
|
||||
|
||||
if AppConfig[:piwik_url].present?
|
||||
config.gem 'rack-piwik', :lib => 'rack/piwik'
|
||||
config.middleware.use Rack::Piwik, :piwik_url => AppConfig[:piwik_url], :piwik_id => AppConfig[:piwik_id]
|
||||
end
|
||||
end
|
||||
|
||||
# Sacrifice readability for a 10% performance boost
|
||||
|
|
|
|||
Loading…
Reference in a new issue