wheelhouse-google-analytics 1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ Google Analytics Plugin for Wheelhouse CMS
2
+ ==========================================
3
+
4
+ This gem allows the Google Analytics tracking code to be easily added to your theme templates.
5
+
6
+ It has a number of benefits over statically adding the tracking code directly in your theme layout:
7
+
8
+ - The tracking code can be easily changed by an Administrator within the Site Options
9
+ - The tracking code is only added in production mode
10
+ - The tracking code is not added when previewing pages in the admin
11
+
12
+ Installation & Usage
13
+ --------------------
14
+
15
+ **1. Add `wheelhouse-google-analytics` to your Gemfile:**
16
+
17
+ gem "wheelhouse-google-analytics"
18
+
19
+ Then run `bundle install`.
20
+
21
+ **2. Include the helper in your layout, just before the closing `</body>` tag:**
22
+
23
+ <%= google_analytics %>
24
+ </body>
25
+
26
+ **3. Set the tracking code within _Configuration_ -> _Site Options_.**
@@ -0,0 +1,3 @@
1
+ Wheelhouse::Site.class_eval do
2
+ property :google_analytics_code, String
3
+ end
@@ -0,0 +1,19 @@
1
+ module GoogleAnalytics::AnalyticsHelper
2
+ TRACKING_CODE = <<-EOJS
3
+ var _gaq = _gaq || [];
4
+ _gaq.push(['_setAccount', '{{CODE}}']);
5
+ _gaq.push(['_trackPageview']);
6
+
7
+ (function() {
8
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
9
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
10
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
11
+ })();
12
+ EOJS
13
+
14
+ def google_analytics
15
+ if Rails.env.production? && site.google_analytics_code? && !controller.env['wheelhouse.preview']
16
+ javascript_tag(TRACKING_CODE.sub("{{CODE}}", site.google_analytics_code))
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ = field :google_analytics_code do
2
+ = form.text_field :google_analytics_code, :placeholder => "UA-XXXXXXXX-X"
3
+
@@ -0,0 +1,5 @@
1
+ en:
2
+ resource:
3
+ attributes:
4
+ wheelhouse/site:
5
+ google_analytics_code: Google Analytics Tracking Code
@@ -0,0 +1,7 @@
1
+ require 'wheelhouse'
2
+
3
+ module GoogleAnalytics
4
+ class Plugin < Wheelhouse::Plugin
5
+ hook(:"site-options.primary", "google_analytics/site_options")
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wheelhouse-google-analytics
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sam Pohlenz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: wheelhouse
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
30
+ description: Integrates Google Analytics into your Wheelhouse CMS site.
31
+ email: info@wheelhousecms.com
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - app/extensions/wheelhouse/site.rb
37
+ - app/helpers/google_analytics/analytics_helper.rb
38
+ - app/views/google_analytics/_site_options.html.haml
39
+ - config/locales/en.yml
40
+ - lib/wheelhouse-google-analytics.rb
41
+ - README.md
42
+ homepage: https://www.wheelhousecms.com/
43
+ licenses: []
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 1.8.7
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: 1.3.6
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 1.8.24
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Wheelhouse CMS Google Analytics plugin
66
+ test_files: []
67
+ has_rdoc: