]> git.openstreetmap.org Git - rails.git/commitdiff
Rework piwik configuration
authorTom Hughes <tom@compton.nu>
Sat, 24 Aug 2013 11:38:14 +0000 (12:38 +0100)
committerTom Hughes <tom@compton.nu>
Sat, 24 Aug 2013 11:54:51 +0000 (12:54 +0100)
app/assets/javascripts/osm.js.erb
app/assets/javascripts/piwik.js
app/controllers/user_controller.rb
app/views/layouts/site.html.erb
config/example.application.yml
config/initializers/piwik.rb [new file with mode: 0644]

index eb5ce64f310b178126b5885186e6032a809ef8a4..5c555a25ac9e37908bace402cf5673d95387d108 100644 (file)
@@ -1,7 +1,6 @@
 OSM = {
-<% if defined?(PIWIK_LOCATION) and defined?(PIWIK_SITE) %>
-  PIWIK_LOCATION:        <%= PIWIK_LOCATION.to_json %>,
-  PIWIK_SITE:            <%= PIWIK_SITE.to_json %>,
+<% if defined?(PIWIK) %>
+  PIWIK:                 <%= PIWIK.to_json %>,
 <% end %>
 
   MAX_REQUEST_AREA:      <%= MAX_REQUEST_AREA.to_json %>,
index d0443ae6d983ad9ee137f92eb66d8ed5cf15e3fe..d81a9ec630a97e2da3cf94c8152cb788a6ee1e17 100644 (file)
@@ -1,13 +1,13 @@
-if (OSM.PIWIK_LOCATION && OSM.PIWIK_SITE) {
+if (OSM.PIWIK) {
   $(document).ready(function () {
-    var base = document.location.protocol + "//" + OSM.PIWIK_LOCATION + "/";
+    var base = document.location.protocol + "//" + OSM.PIWIK.location + "/";
 
     $.ajax({
       url: base + "piwik.js",
       dataType: "script",
       cache: true,
       success: function () {
-        var piwikTracker = Piwik.getTracker(base + "piwik.php", OSM.PIWIK_SITE);
+        var piwikTracker = Piwik.getTracker(base + "piwik.php", OSM.PIWIK.site);
       
         piwikTracker.trackPageView();
         piwikTracker.enableLinkTracking();
index c3cd9fcf22f4cbf994555a00240895ffde9f3b52..a7822e47fd436188d703fe55493482d9649a92cb 100644 (file)
@@ -86,7 +86,7 @@ class UserController < ApplicationController
         @user.openid_url = nil if @user.openid_url and @user.openid_url.empty?
 
         if @user.save
-          flash[:piwik_goal] = PIWIK_SIGNUP_GOAL if defined?(PIWIK_SIGNUP_GOAL)
+          flash[:piwik_goal] = PIWIK["goals"]["signup"] if defined?(PIWIK)
 
           referer = welcome_path
 
index 12b5b82c5c358c9aa123e16c739b53fce0b61019..97bf062036dce8c615df6aed8fd29575fd8016a3 100644 (file)
         <%= yield %>
       </div>
     </div>
-    <% if defined?(PIWIK_LOCATION) and defined?(PIWIK_SITE) -%>
-    <noscript><p><img src="<%= request.protocol %><%= PIWIK_LOCATION %>/piwik.php?idsite=<%= PIWIK_SITE %>" style="border:0" alt="" /></p></noscript>
+    <% if defined?(PIWIK) -%>
+    <noscript><p><img src="<%= request.protocol %><%= PIWIK['location'] %>/piwik.php?idsite=<%= PIWIK['site'] %>" style="border:0" alt="" /></p></noscript>
     <% end -%>
   </body>
 </html>
index c6c15bb1d4003eb79409536b53ee19ea320ae499..d6a855ef5003b68fb343298bac7b60fd2a1faa73 100644 (file)
@@ -84,10 +84,6 @@ defaults: &defaults
   require_terms_seen: false
   # Whether to require users to agree to the CTs before editing
   require_terms_agreed: false
-  # Piwik details
-  #piwik_location: "piwik.openstreetmap.org"
-  #piwik_site: 1
-  #piwik_signup_goal: 1
 
 development:
   <<: *defaults
diff --git a/config/initializers/piwik.rb b/config/initializers/piwik.rb
new file mode 100644 (file)
index 0000000..1f054f7
--- /dev/null
@@ -0,0 +1,5 @@
+require "yaml"
+
+if File.exists?(piwik_file = File.expand_path("../../piwik.yml", __FILE__))
+  PIWIK = YAML.load_file(piwik_file)
+end