nesta-plugin-gtm 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/README.md +21 -0
- data/Rakefile +58 -0
- data/lib/nesta-plugin-gtm.rb +3 -0
- data/lib/nesta-plugin-gtm/init.rb +24 -0
- data/lib/nesta-plugin-gtm/version.rb +7 -0
- data/nesta-plugin-gtm.gemspec +28 -0
- data/views/gtmbody.haml +6 -0
- data/views/gtmheader.haml +9 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4eac750b5b1b31b092b3b916bada98fa67e4d29f
|
4
|
+
data.tar.gz: a0e8bc190d7346fc99a870d5b7ef38fc4585444f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6f1b9690a4afeafa21f1a42397b61471eb26a798fc2579a8ccfb394d02996f5d4a224678be488eb166728d68efd84587f7f9e47a488cf2bcba1ffac388205990
|
7
|
+
data.tar.gz: f805cffdb6357f230c771f698d4d958ef9e35c410713a5f200bf5b3d8d8661c99828180d59cc784a8ee2294a004d816a5eab382991bb12bd7243a4f46e785756
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
README
|
2
|
+
======
|
3
|
+
|
4
|
+
TODO: Explain what your plugin is for
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
To use this plugin just add it to your Nesta project's `Gemfile` and
|
10
|
+
then install it with Bundler:
|
11
|
+
|
12
|
+
```
|
13
|
+
$ echo 'gem "nesta-plugin-gtm"' >> Gemfile
|
14
|
+
$ bundle
|
15
|
+
$ cp [nesta_path]/views ./
|
16
|
+
$ cp [nesta-plugin-gtm_path]/views/*.* ./views/
|
17
|
+
|
18
|
+
```
|
19
|
+
|
20
|
+
|
21
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
def version
|
2
|
+
version_file = File.join(File.dirname(__FILE__), "lib", name, "version.rb")
|
3
|
+
contents = File.read(version_file)
|
4
|
+
contents.match(/VERSION = ['"]([0-9a-z.-]+)['"].*$/)
|
5
|
+
$1
|
6
|
+
end
|
7
|
+
|
8
|
+
def name
|
9
|
+
"nesta-plugin-gtm"
|
10
|
+
end
|
11
|
+
|
12
|
+
def built_gem_path
|
13
|
+
gem_packages = File.join(File.dirname(__FILE__), "pkg", "#{name}-*.gem")
|
14
|
+
Dir[gem_packages].sort_by { |file| File.mtime(file) }.last
|
15
|
+
end
|
16
|
+
|
17
|
+
def already_tagged?
|
18
|
+
`git tag`.split(/\n/).include?("v#{version}")
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Build #{name}-#{version}.gem into the pkg directory."
|
22
|
+
task 'build' do
|
23
|
+
`gem build -V #{File.join(File.dirname(__FILE__), "#{name}.gemspec")}`
|
24
|
+
FileUtils.mkdir_p(File.join(File.dirname(__FILE__), "pkg"))
|
25
|
+
gem = Dir[File.join(File.dirname(__FILE__), "#{name}-*.gem")].sort_by{|f| File.mtime(f)}.last
|
26
|
+
FileUtils.mv(gem, 'pkg')
|
27
|
+
puts "#{name} #{version} built to #{built_gem_path}."
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Build and install #{name}-#{version}.gem into system gems."
|
31
|
+
task 'install' => 'build' do
|
32
|
+
`gem install '#{built_gem_path}' --local`
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Create tag v#{version} and build and push #{name}-#{version}.gem to Rubygems\n" \
|
36
|
+
"To prevent publishing in Rubygems use `gem_push=no rake release`"
|
37
|
+
task 'release' => ['build', 'release:guard_clean',
|
38
|
+
'release:source_control_push', 'release:rubygem_push'] do
|
39
|
+
end
|
40
|
+
|
41
|
+
task 'release:guard_clean' do
|
42
|
+
if !system("git diff --exit-code") || !system("git diff-index --quiet --cached HEAD")
|
43
|
+
puts "There are files that need to be committed first."
|
44
|
+
exit(1)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
task 'release:source_control_push' do
|
49
|
+
unless already_tagged?
|
50
|
+
system "git tag -a -m 'Version #{version}' v#{version}"
|
51
|
+
system 'git push'
|
52
|
+
system 'git push --tags'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
task 'release:rubygem_push' do
|
57
|
+
system "gem push #{built_gem_path}"
|
58
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Nesta
|
2
|
+
module Plugin
|
3
|
+
module Gtm
|
4
|
+
module Helpers
|
5
|
+
# If your plugin needs any helper methods, add them here...
|
6
|
+
extend View::Helpers
|
7
|
+
|
8
|
+
def set_common_variables
|
9
|
+
super
|
10
|
+
set_from_config(:google_tag_manager_id)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class App
|
17
|
+
helpers Nesta::Plugin::Gtm::Helpers
|
18
|
+
end
|
19
|
+
|
20
|
+
Config.class_eval do
|
21
|
+
@settings += %w[google_tag_manager_id]
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "nesta-plugin-gtm/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "nesta-plugin-gtm"
|
8
|
+
spec.version = Nesta::Plugin::Gtm::VERSION
|
9
|
+
spec.authors = ["violake"]
|
10
|
+
spec.email = ["violake@foxmail.com"]
|
11
|
+
spec.homepage = ""
|
12
|
+
spec.summary = %q{add google tag manager to all pages}
|
13
|
+
spec.description = %q{my first nesta plugin}
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.rubyforge_project = "nesta-plugin-gtm"
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0")
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
# specify any dependencies here; for example:
|
24
|
+
# spec.add_development_dependency "rspec"
|
25
|
+
# spec.add_runtime_dependency "rest-client"
|
26
|
+
spec.add_dependency("nesta", ">= 0.9.11")
|
27
|
+
spec.add_development_dependency("rake")
|
28
|
+
end
|
data/views/gtmbody.haml
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
- if @google_tag_manager_id
|
2
|
+
:plain
|
3
|
+
<!-- Google Tag Manager (noscript) -->
|
4
|
+
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=#{@google_tag_manager_id}"
|
5
|
+
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
6
|
+
<!-- End Google Tag Manager (noscript) -->
|
@@ -0,0 +1,9 @@
|
|
1
|
+
- if @google_tag_manager_id
|
2
|
+
:plain
|
3
|
+
<!-- Google Tag Manager -->
|
4
|
+
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
5
|
+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
6
|
+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
7
|
+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
8
|
+
})(window,document,'script','dataLayer','#{@google_tag_manager_id}');</script>
|
9
|
+
<!-- End Google Tag Manager -->
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nesta-plugin-gtm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- violake
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nesta
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.11
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.11
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: my first nesta plugin
|
42
|
+
email:
|
43
|
+
- violake@foxmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- lib/nesta-plugin-gtm.rb
|
53
|
+
- lib/nesta-plugin-gtm/init.rb
|
54
|
+
- lib/nesta-plugin-gtm/version.rb
|
55
|
+
- nesta-plugin-gtm.gemspec
|
56
|
+
- views/gtmbody.haml
|
57
|
+
- views/gtmheader.haml
|
58
|
+
homepage: ''
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project: nesta-plugin-gtm
|
78
|
+
rubygems_version: 2.5.1
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: add google tag manager to all pages
|
82
|
+
test_files: []
|