turbolinks-analytics 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Heliom inc.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ Turbolinks::Analytics
2
+ =====================
3
+
4
+ Drop-in Analytics support for your Rails applications running with [Turbolinks](https://github.com/rails/turbolinks). Add your analytics scripts in your application layout like you would normally do. Make sure your analytics tool is [supported](#supported-services).
5
+
6
+
7
+ Installation
8
+ ------------
9
+
10
+ 1. Follow [Turbolinks installation guide](https://github.com/rails/turbolinks#installation).
11
+ 1. Add `gem 'turbolinks-analytics'` to your Gemfile.
12
+ 1. Run `bundle install`.
13
+ 1. Add `//= require turbolinks-analytics` to your Javascript manifest file.
14
+ 1. Restart your server.
15
+
16
+
17
+ Supported Services
18
+ ------------------
19
+
20
+ - [Google Analytics](http://www.google.com/analytics/)
21
+ - [Gauges](http://get.gaug.es)
@@ -0,0 +1,25 @@
1
+ if window.history?.pushState and window.history.replaceState
2
+ document.addEventListener 'page:change', (event) =>
3
+
4
+ # Google Analytics
5
+ if window._gaq != undefined
6
+ _gaq.push(['_trackPageview'])
7
+
8
+ # Gauges
9
+ @gaugesBaseScript ||= getGaugesBaseScript()
10
+ @gaugesCode ||= @gaugesBaseScript?.innerHTML
11
+
12
+ if @gaugesCode
13
+ gaugesTracker = document.getElementById('gauges-tracker')
14
+ gaugesTracker.parentNode.removeChild(gaugesTracker)
15
+
16
+ eval(@gaugesCode)
17
+
18
+ getGaugesBaseScript = ->
19
+ gaugesBaseScript = document.getElementById('gauges-base-script')
20
+
21
+ if !gaugesBaseScript
22
+ scripts = document.getElementsByTagName('script')
23
+ gaugesBaseScript = (s for s in scripts when s.innerHTML.indexOf('var _gauges') > -1)[0]
24
+
25
+ gaugesBaseScript
@@ -0,0 +1,4 @@
1
+ module Turbolinks::Analytics
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: turbolinks-analytics
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Etienne Lemay
9
+ - Rafael Blais Masson
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-10-23 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: turbolinks
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ description:
32
+ email: fellowship@heliom.ca
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - lib/assets/javascripts/turbolinks-analytics.js.coffee
38
+ - lib/turbolinks-analytics.rb
39
+ - README.md
40
+ - LICENSE
41
+ homepage:
42
+ licenses: []
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 1.8.23
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Add drop-in analytics support to Turbolinks
65
+ test_files: []