rack-piwik 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -19,8 +19,8 @@ Simple Rack middleware to help injecting the Piwik tracking code into the footer
19
19
 
20
20
  #### Rails
21
21
 
22
- ## environment.rb:
23
- config.gem 'rack-piwik', :lib => 'rack/piwik
22
+ ## application.rb:
23
+ config.gem 'rack-piwik', :lib => 'rack/piwik'
24
24
  config.middleware.use Rack::Piwik, :piwik_url => '<url of your piwik site here>', :piwik_id => '<your piwik id here>'
25
25
 
26
26
  ## Thread Safety
data/lib/rack/piwik.rb CHANGED
@@ -8,6 +8,7 @@ module Rack
8
8
 
9
9
  def initialize(app, options = {})
10
10
  raise ArgumentError, "piwik_url must be present" unless options[:piwik_url] and !options[:piwik_url].empty?
11
+ raise ArgumentError, "piwik_id must be present" unless options[:piwik_id] and !options[:piwik_id].empty?
11
12
  @app, @options = app, DEFAULT.merge(options)
12
13
  end
13
14
 
@@ -28,7 +29,7 @@ module Rack
28
29
  def inject(response)
29
30
  file = 'async'
30
31
  @template ||= ::ERB.new ::File.read ::File.expand_path("../templates/#{file}.erb",__FILE__)
31
- response.gsub(%r{</head>}, @template.result(binding) + "</head>")
32
+ response.gsub(%r{</body>}, @template.result(binding) + "</body>")
32
33
  end
33
34
  end
34
35
  end
@@ -1,12 +1,21 @@
1
1
  <!-- Piwik -->
2
2
  <script type="text/javascript">
3
- var pkBaseURL = (("https:" == document.location.protocol) ? "https://<%= @options[:piwik_url]%>/" : "http://<%= @options[:piwik_url]%>/");
4
- document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
3
+ var pkBaseURL = (("https:" == document.location.protocol) ? "https://<%= @options[:piwik_url]%>/" : "http://<%= @options[:piwik_url]%>/");
4
+ document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
5
5
  </script><script type="text/javascript">
6
6
  try {
7
- var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", <%= @options[:piwik_id]%>);
8
- piwikTracker.trackPageView();
9
- piwikTracker.enableLinkTracking();
7
+ var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", <%= @options[:piwik_id]%>);
8
+
9
+ <%# If this is a 404 page, provide additional information to Piwik %>
10
+ <% if @status.equal?(404) %>
11
+ piwikTracker.setDocumentTitle('404/URL = ' +
12
+ String(document.location.pathname + document.location.search).replace(/\//g,"%2f") +
13
+ '/From = ' + String(document.referrer).replace(/\//g,"%2f"));
14
+ <% end %>
15
+
16
+ piwikTracker.trackPageView();
17
+ piwikTracker.enableLinkTracking();
10
18
  } catch( err ) {}
11
19
  </script>
20
+ <noscript><img src="http://<%= @options[:piwik_url]%>/piwik.php?idsite=<%= @options[:piwik_id]%>" alt="" /></noscript>
12
21
  <!-- End Piwik Code -->
metadata CHANGED
@@ -1,70 +1,52 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rack-piwik
3
- version: !ruby/object:Gem::Version
4
- hash: 31
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 2
10
- version: 0.1.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Maxwell Salzberg
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-01-05 00:00:00 Z
12
+ date: 2012-07-21 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
- description: Simple Rack middleware for implementing piwik Analytics racking in your Ruby-Rack based project.
22
- email:
14
+ description: Simple Rack middleware for implementing piwik Analytics racking in your
15
+ Ruby-Rack based project.
16
+ email:
23
17
  - maxwell@joindiaspora.com
24
18
  executables: []
25
-
26
19
  extensions: []
27
-
28
20
  extra_rdoc_files: []
29
-
30
- files:
21
+ files:
31
22
  - lib/rack/piwik.rb
32
23
  - lib/rack/templates/async.erb
33
24
  - README.md
34
25
  - LICENSE
35
- homepage: https://github.com/leehambley/rack-google-analytics
26
+ homepage: https://github.com/maxwell/rack-piwik
36
27
  licenses: []
37
-
38
28
  post_install_message:
39
29
  rdoc_options: []
40
-
41
- require_paths:
30
+ require_paths:
42
31
  - lib
43
- required_ruby_version: !ruby/object:Gem::Requirement
32
+ required_ruby_version: !ruby/object:Gem::Requirement
44
33
  none: false
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- hash: 3
49
- segments:
50
- - 0
51
- version: "0"
52
- required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
39
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
61
44
  requirements: []
62
-
63
45
  rubyforge_project:
64
- rubygems_version: 1.8.12
46
+ rubygems_version: 1.8.17
65
47
  signing_key:
66
48
  specification_version: 3
67
- summary: Rack middleware to inject the Piwik tracking code into outgoing responses. Adapted from rack-google-analytics
49
+ summary: Rack middleware to inject the Piwik tracking code into outgoing responses.
50
+ Adapted from rack-google-analytics
68
51
  test_files: []
69
-
70
52
  has_rdoc: