middleman-piwik 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0ae00062f9ed70a7306aed9b3772656ec2881dbe
4
+ data.tar.gz: 53f4273cd2500bfcd647ced867c2965ddac5037f
5
+ SHA512:
6
+ metadata.gz: 35cc140b3695c9c4067ab66418605dcd62bc20270dfdead858a689a432a08d75f2a5cc1f9324e71bc52ece9a971e848cee5be2d2728650fcf3f30d96fddf04ee
7
+ data.tar.gz: 54ea82894ff7ccf5cf6b37774092fa346de2fc4ba1eff1cece91a5bfaf9d16d6e344352bd8101dc624046c4a5dac393bea2972514d10103ad6721c540f2341f2
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ Gemfile.lock
2
+ pkg
3
+ .*.swp
4
+ tmp
5
+ .yardoc
6
+ doc
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+ - 2.1.0
5
+ - jruby-19mode
6
+
7
+ script: "bundle exec rake test"
8
+
9
+ env: TEST=true
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ 0.1
2
+ ---
3
+
4
+ * Initial release
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,44 @@
1
+ # Contributing
2
+ In the spirit of [free software][free-sw], **everyone** is encouraged to help
3
+ improve this project.
4
+
5
+ [free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
6
+
7
+ Here are some ways *you* can contribute:
8
+
9
+ * by using alpha, beta, and prerelease versions
10
+ * by reporting bugs
11
+ * by suggesting new features
12
+ * by writing or editing documentation
13
+ * by writing specifications
14
+ * by writing code (**no patch is too small**: fix typos, add comments, clean up
15
+ inconsistent whitespace)
16
+ * by refactoring code
17
+ * by closing [issues][]
18
+ * by reviewing patches
19
+
20
+ [issues]: https://github.com/middleman/middleman-syntax/issues
21
+
22
+ ## Submitting an Issue
23
+ We use the [GitHub issue tracker][issues] to track bugs and features. Before
24
+ submitting a bug report or feature request, check to make sure it hasn't
25
+ already been submitted. When submitting a bug report, please include a [Gist][]
26
+ that includes a stack trace and any details that may be necessary to reproduce
27
+ the bug, including your gem version, Ruby version, and operating system.
28
+ Ideally, a bug report should include a pull request with failing specs.
29
+
30
+ [gist]: https://gist.github.com/
31
+
32
+ ## Submitting a Pull Request
33
+ 1. [Fork the repository.][fork]
34
+ 2. [Create a topic branch.][branch]
35
+ 3. Add specs for your unimplemented feature or bug fix.
36
+ 4. Run `bundle exec rake test`. If your specs pass, return to step 3.
37
+ 5. Implement your feature or bug fix.
38
+ 6. Run `bundle exec rake test`. If your specs fail, return to step 5.
39
+ 7. Add, commit, and push your changes.
40
+ 8. [Submit a pull request.][pr]
41
+
42
+ [fork]: http://help.github.com/fork-a-repo/
43
+ [branch]: http://learn.github.com/p/branching.html
44
+ [pr]: http://help.github.com/send-pull-requests/
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "middleman-core", :github => "middleman/middleman", :branch => 'v3-stable'
4
+
5
+ # Specify your gem's dependencies in middleman-syntax.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 10.1.0", :require => false
9
+ gem "yard", "~> 0.8.0", :require => false
10
+
11
+ # Test tools
12
+ gem "cucumber", "~> 1.3.1"
13
+ gem "fivemat"
14
+ gem "aruba"
15
+
16
+ # Code Quality
17
+ gem "cane", :platforms => [:mri_19, :mri_20], :require => false
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Michael Scherer
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Middleman-Piwik
2
+
3
+ `middleman-piwik` is an extension for the [Middleman](http://middlemanapp.com/) static site generator that ease the use of the [Piwik](http://piwik.org/) web analytics platform.
4
+
5
+ ## Installation
6
+
7
+ Just add `gem "middleman-piwik"` to your existing Gemfile and run `bundle install`.
8
+
9
+ ## Configuration
10
+
11
+ ```ruby
12
+ activate :piwik do |p|
13
+ p.id = 1
14
+ p.domain = 'piwik.example.net'
15
+ end
16
+ ```
17
+
18
+ id is the id of the site, as given by piwik. Usually, it start at 1.
19
+
20
+ domain is the domain name of the piwik server.
21
+
22
+ ## Helper
23
+
24
+ The extension adds 3 new helper to Middleman to add the proper javascript and img in your website
25
+
26
+ ```erb
27
+ <%= insert_piwik_tracker %>
28
+ ```
29
+
30
+ The one that should be almost always be used is `insert_piwik_tracker`, which will try to insert the regular javascript code and a img tag as a fallback.
31
+
32
+ The 2 others `insert_piwik_tracker_js` and `insert_piwik_tracker_img` will add only the javascript tracker or the img one.
data/Rakefile ADDED
@@ -0,0 +1,32 @@
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
+ exempt_tags = ""
8
+ exempt_tags << "--tags ~@nojava " if RUBY_PLATFORM == "java"
9
+ t.cucumber_opts = "--color --tags ~@wip #{exempt_tags} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
10
+ end
11
+
12
+ require 'rake/clean'
13
+
14
+ task :test => ["cucumber"]
15
+
16
+ begin
17
+ require 'cane/rake_task'
18
+
19
+ desc "Run cane to check quality metrics"
20
+ Cane::RakeTask.new(:quality) do |cane|
21
+ cane.no_style = true
22
+ cane.no_doc = true
23
+ cane.abc_glob = "lib/middleman-piwik/**/*.rb"
24
+ end
25
+ rescue LoadError
26
+ # warn "cane not available, quality task not provided."
27
+ end
28
+
29
+ desc "Build HTML documentation"
30
+ task :doc do
31
+ sh 'bundle exec yard'
32
+ end
@@ -0,0 +1,44 @@
1
+ Feature: Piwik helpers for js and img.
2
+
3
+ Scenario: Helpers works
4
+ Given a fixture app "test-app"
5
+ And a file named "config.rb" with:
6
+ """
7
+ activate :piwik do |f|
8
+ f.id = 3
9
+ f.domain = 'piwik.example.com'
10
+ end
11
+ """
12
+ Given the Server is running at "test-app"
13
+ When I go to "/piwik_both.html"
14
+ Then I should see "piwik.example.com/piwik.php?idsite=3"
15
+ Then I should see "setSiteId"
16
+ Then I should see "noscript"
17
+
18
+ Scenario: Helper for img work
19
+ Given a fixture app "test-app"
20
+ And a file named "config.rb" with:
21
+ """
22
+ activate :piwik do |f|
23
+ f.id = 4
24
+ f.domain = 'piwik_img.example.com'
25
+ end
26
+ """
27
+ Given the Server is running at "test-app"
28
+ When I go to "/piwik_img.html"
29
+ Then I should see "piwik_img.example.com/piwik.php?idsite=4"
30
+ Then I should not see "noscript"
31
+
32
+ Scenario: Helper for js work
33
+ Given a fixture app "test-app"
34
+ And a file named "config.rb" with:
35
+ """
36
+ activate :piwik do |f|
37
+ f.id = 5
38
+ f.domain = 'piwik_js.example.com'
39
+ end
40
+ """
41
+ Given the Server is running at "test-app"
42
+ When I go to "/piwik_js.html"
43
+ Then I should not see "noscript"
44
+ Then I should see 'setSiteId'
@@ -0,0 +1,6 @@
1
+ PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
+ ENV['TEST'] = 'true'
3
+ require "middleman-core"
4
+ require "middleman-core/step_definitions"
5
+ require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-piwik')
6
+
@@ -0,0 +1,4 @@
1
+ activate :piwik do |f|
2
+ f.id = 3
3
+ f.domain = 'piwik.example.com'
4
+ end
@@ -0,0 +1,2 @@
1
+ <h1>Tracker with image and js
2
+ <%= insert_piwik_tracker %>
@@ -0,0 +1,2 @@
1
+ <h1>Tracker with image
2
+ <%= insert_piwik_tracker_img %>
@@ -0,0 +1,2 @@
1
+ <h1>Tracker with js
2
+ <%= insert_piwik_tracker_js %>
@@ -0,0 +1,40 @@
1
+ module Middleman
2
+ module Piwik
3
+ class PiwikExtension < Extension
4
+ option :id, 1, 'Piwik site id'
5
+ option :domain, 'piwik.example.org', 'Piwik domain'
6
+
7
+ def after_configuration
8
+ app.set :piwik_domain, options.domain
9
+ app.set :piwik_id, options.id
10
+ end
11
+
12
+ helpers do
13
+ def insert_piwik_tracker_img
14
+ "<p><img src=\"https://#{piwik_domain}/piwik.php?idsite=#{piwik_id}\" style=\"border:0;\" alt=\"\" /></p>"
15
+ end
16
+
17
+ def insert_piwik_tracker_js
18
+ <<END
19
+ <script type="test/javascript">
20
+ var _paq = _paq || [];
21
+ _paq.push(['trackPageView']);
22
+ _paq.push(['enableLinkTracking']);
23
+ (function() {
24
+ var u=(("https:" == document.location.protocol) ? "https" : "http") + "://#{piwik_domain}/";
25
+ _paq.push(['setTrackerUrl', u+'piwik.php']);
26
+ _paq.push(['setSiteId', #{piwik_id}]);
27
+ var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
28
+ g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
29
+ })();
30
+ </script>
31
+ END
32
+ end
33
+
34
+ def insert_piwik_tracker
35
+ insert_piwik_tracker_js + "<noscript>" + insert_piwik_tracker_img + "</noscript>"
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1 @@
1
+ require 'middleman-piwik'
@@ -0,0 +1,5 @@
1
+ module Middleman
2
+ module Piwik
3
+ VERSION = "0.1"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "middleman-core"
2
+ require "middleman-piwik/version"
3
+
4
+ ::Middleman::Extensions.register(:piwik) do
5
+ require "middleman-piwik/extension"
6
+ ::Middleman::Piwik::PiwikExtension
7
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "middleman-piwik/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "middleman-piwik"
7
+ s.version = Middleman::Piwik::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Michael Scherer"]
10
+ s.email = ["mscherer@redhat.com"]
11
+ s.homepage = "https://github.com/mscherer/middleman-piwik"
12
+ s.summary = %q{Piwik tracker integration for Middleman}
13
+ s.description = %q{Piwik tracker integration for Middleman}
14
+ s.license = "MIT"
15
+ s.files = `git ls-files -z`.split("\0")
16
+ s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0")
17
+ s.require_paths = ["lib"]
18
+ s.add_runtime_dependency("middleman-core", ["~> 3.2"])
19
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-piwik
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Michael Scherer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: middleman-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ description: Piwik tracker integration for Middleman
28
+ email:
29
+ - mscherer@redhat.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - .gitignore
35
+ - .travis.yml
36
+ - CHANGELOG.md
37
+ - CONTRIBUTING.md
38
+ - Gemfile
39
+ - LICENSE.md
40
+ - README.md
41
+ - Rakefile
42
+ - features/piwik_helpers.feature
43
+ - features/support/env.rb
44
+ - fixtures/test-app/config.rb
45
+ - fixtures/test-app/source/piwik_both.html.erb
46
+ - fixtures/test-app/source/piwik_img.html.erb
47
+ - fixtures/test-app/source/piwik_js.html.erb
48
+ - lib/middleman-piwik.rb
49
+ - lib/middleman-piwik/extension.rb
50
+ - lib/middleman-piwik/middleman_extension.rb
51
+ - lib/middleman-piwik/version.rb
52
+ - middleman-piwik.gemspec
53
+ homepage: https://github.com/mscherer/middleman-piwik
54
+ licenses:
55
+ - MIT
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 2.1.11
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Piwik tracker integration for Middleman
77
+ test_files:
78
+ - features/piwik_helpers.feature
79
+ - features/support/env.rb
80
+ - fixtures/test-app/config.rb
81
+ - fixtures/test-app/source/piwik_both.html.erb
82
+ - fixtures/test-app/source/piwik_img.html.erb
83
+ - fixtures/test-app/source/piwik_js.html.erb
84
+ has_rdoc: