middleman-google-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/.gitignore +2 -0
- data/.rvmrc +1 -0
- data/Gemfile +17 -0
- data/LICENSE +22 -0
- data/README.md +62 -0
- data/Rakefile +14 -0
- data/lib/middleman-google-analytics.rb +12 -0
- data/lib/middleman-google-analytics/extension.rb +35 -0
- data/lib/middleman_extension.rb +1 -0
- data/middleman-google-analytics.gemspec +24 -0
- metadata +72 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use --create ruby-1.9.3-p374@middleman-google-analytics
|
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in middleman-google-analytics.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem "rake", "~> 0.9.2"
|
8
|
+
gem "rdoc", "~> 3.9"
|
9
|
+
gem "yard", "~> 0.8.0"
|
10
|
+
end
|
11
|
+
|
12
|
+
group :test do
|
13
|
+
gem "cucumber", "~> 1.2.0"
|
14
|
+
gem "fivemat"
|
15
|
+
gem "aruba", "~> 0.4.11"
|
16
|
+
gem "rspec", "~> 2.7"
|
17
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Jon Frisby
|
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 NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Middleman Google Analytics
|
2
|
+
|
3
|
+
Middleman-Google-Analytics is a [Middleman](https://github.com/middleman/middleman)
|
4
|
+
extension that generates Google Analytics tracking code, and keeps your config
|
5
|
+
in `config.rb`, where it belongs.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
If you already have a Middleman project:
|
10
|
+
|
11
|
+
Add `gem "middleman-google-analytics"` to your `Gemfile` then open up your `config.rb` and add:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
# Activate google-analytics extension
|
15
|
+
activate :google_analytics do |ga|
|
16
|
+
ga.tracking_id = 'UA-XXXXXXX-X'
|
17
|
+
end
|
18
|
+
```
|
19
|
+
|
20
|
+
Then, in your layout, after your footer, call `google_analytics_tag` and
|
21
|
+
include the results in the page. For example, in HAML:
|
22
|
+
|
23
|
+
```haml
|
24
|
+
= google_analytics_tag
|
25
|
+
```
|
26
|
+
|
27
|
+
Or ERB:
|
28
|
+
|
29
|
+
```erb
|
30
|
+
<%= google_analytics_tag %>
|
31
|
+
```
|
32
|
+
|
33
|
+
## Only Including Tracking Code in Builds
|
34
|
+
|
35
|
+
To include the tracking code only in builds, and not when running
|
36
|
+
`middleman server`, simply add environment-specific configurations in your
|
37
|
+
`config.rb`:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
configure :development do
|
41
|
+
activate :google_analytics do |ga|
|
42
|
+
ga.tracking_id = false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
configure :build do
|
47
|
+
activate :google_analytics do |ga|
|
48
|
+
ga.tracking_id = 'UA-XXXXXXX-X'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
53
|
+
## Usage
|
54
|
+
|
55
|
+
Once you've bundled you should be able to run middleman as normal, and have it
|
56
|
+
display the GA tracking code.
|
57
|
+
|
58
|
+
## License
|
59
|
+
|
60
|
+
Copyright (c) 2013 Jon Frisby
|
61
|
+
|
62
|
+
Licensed under the terms of the MIT X11 license. See LICENSE.
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
|
6
|
+
Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
|
7
|
+
t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'rake/clean'
|
11
|
+
|
12
|
+
task :test => ["cucumber"]
|
13
|
+
|
14
|
+
task :default => :test
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Require core library
|
2
|
+
require "middleman-core"
|
3
|
+
|
4
|
+
|
5
|
+
# Register extensions which can be activated
|
6
|
+
# Make sure we have the version of Middleman we expect
|
7
|
+
::Middleman::Extensions.register(:google_analytics) do
|
8
|
+
require 'middleman-google-analytics/extension'
|
9
|
+
|
10
|
+
# Return the extension module
|
11
|
+
::Middleman::GoogleAnalytics
|
12
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Middleman
|
2
|
+
module GoogleAnalytics
|
3
|
+
class Options < Struct.new(:tracking_id); end
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def options
|
7
|
+
@@options ||= {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def registered(app, options={})
|
11
|
+
@@options ||= Options.new(options)
|
12
|
+
yield @@options if block_given?
|
13
|
+
|
14
|
+
app.send :include, InstanceMethods
|
15
|
+
end
|
16
|
+
alias :included :registered
|
17
|
+
end
|
18
|
+
|
19
|
+
module InstanceMethods
|
20
|
+
def google_analytics_tag
|
21
|
+
tracking_id = ::Middleman::GoogleAnalytics.options.tracking_id
|
22
|
+
if(tracking_id)
|
23
|
+
return %Q{<script type="text/javascript">
|
24
|
+
//<![CDATA[
|
25
|
+
var _gaq=[['_setAccount','#{tracking_id}'],['_trackPageview']];
|
26
|
+
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
|
27
|
+
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
|
28
|
+
s.parentNode.insertBefore(g,s)}(document,'script'));
|
29
|
+
//]]>
|
30
|
+
</script>}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "middleman-google-analytics"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "middleman-google-analytics"
|
6
|
+
s.version = "0.0.1"
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Jon Frisby"]
|
9
|
+
s.email = ["jfrisby@mrjoy.com"]
|
10
|
+
s.homepage = "http://github.com/MrJoy/middleman-google-analytics"
|
11
|
+
s.summary = %q{A Middleman plugin for handling Google Analytics tracking code.}
|
12
|
+
# s.description = %q{A longer description of your extension}
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
# The version of middleman-core your extension depends on
|
20
|
+
s.add_runtime_dependency("middleman-core", [">= 3.0.6"])
|
21
|
+
|
22
|
+
# Additional dependencies
|
23
|
+
# s.add_runtime_dependency("gem-name", "gem-version")
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: middleman-google-analytics
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jon Frisby
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: middleman-core
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.0.6
|
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: 3.0.6
|
30
|
+
description:
|
31
|
+
email:
|
32
|
+
- jfrisby@mrjoy.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- .rvmrc
|
39
|
+
- Gemfile
|
40
|
+
- LICENSE
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- lib/middleman-google-analytics.rb
|
44
|
+
- lib/middleman-google-analytics/extension.rb
|
45
|
+
- lib/middleman_extension.rb
|
46
|
+
- middleman-google-analytics.gemspec
|
47
|
+
homepage: http://github.com/MrJoy/middleman-google-analytics
|
48
|
+
licenses: []
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.8.25
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: A Middleman plugin for handling Google Analytics tracking code.
|
71
|
+
test_files: []
|
72
|
+
has_rdoc:
|