middleman-facebook-pixel 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 92e9f098043a89c9e81060856e1fc159de5a197b
4
+ data.tar.gz: 9854bc585d19353d940405c5bae721f94d649c0e
5
+ SHA512:
6
+ metadata.gz: 32b28a8f9291b346b94df145a967a6ee4f1e4b58df1985f6594424cdaec6c33a6bd1fe6c1a9f45fa32cb937b72f0e5bd37c8dd0376082eab5a26674677c4dc80
7
+ data.tar.gz: 978b951e01c765bbd04dd66840c048df4e3cbf87492563bede026038c8bd16b24163525822807282f8bdd66356d9aedda4b3e8e7403b7d40ac496e9ca119efe7
@@ -0,0 +1,6 @@
1
+ Gemfile.lock
2
+ .ruby-version
3
+ *.gem
4
+
5
+ /pkg
6
+ /tmp
@@ -0,0 +1,24 @@
1
+ language: ruby
2
+ sudo: false
3
+ cache: bundler
4
+ before_script:
5
+ - bundle update
6
+
7
+ rvm:
8
+ - ruby-head
9
+ - 2.2
10
+ - 2.1
11
+ - 2.0
12
+
13
+ os:
14
+ - linux
15
+ # - osx
16
+
17
+ matrix:
18
+ fast_finish: true
19
+ allow_failures:
20
+ - rvm: ruby-head
21
+
22
+ script: bundle exec rake test
23
+
24
+ env: TEST=true
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'middleman-core', '~> 3.4.1'
4
+
5
+ gemspec
6
+
7
+ group :development do
8
+ gem 'rake'
9
+ gem 'rdoc'
10
+ gem 'yard'
11
+ end
12
+
13
+ group :test do
14
+ gem 'cucumber'
15
+ gem 'aruba'
16
+ gem 'rspec'
17
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Kairat Jenishev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,52 @@
1
+ # middleman-facebook-pixel [![Build Status](https://travis-ci.org/xcopy/middleman-facebook-pixel.svg?branch=master)](https://travis-ci.org/xcopy/middleman-facebook-pixel)
2
+
3
+ **middleman-facebook-pixel** is a [Middleman](http://middlemanapp.com) extension that generates Facebook Pixel code, and keeps your config in `config.rb`, where it belongs.
4
+
5
+
6
+ ## Installation
7
+
8
+ Specify the dependency in your project's `Gemfile`:
9
+
10
+ ```ruby
11
+ gem 'middleman-facebook-pixel'
12
+ ```
13
+
14
+ Activate the Facebook Pixel extension in your project's `config.rb`:
15
+
16
+ ```ruby
17
+ # ...
18
+ activate :facebook_pixel, id: 1234567890
19
+ # ...
20
+ ```
21
+
22
+ In your layout, in `<head>` section, call `facebook_pixel` helper:
23
+
24
+ **Haml:**
25
+
26
+ ```haml
27
+ # Facebook Pixel
28
+ = facebook_pixel
29
+ ```
30
+
31
+ **ERB:**
32
+
33
+ ```erb
34
+ # Facebook Pixel
35
+ <%= facebook_pixel %>
36
+ ```
37
+
38
+ That's it!
39
+
40
+ ## Contributing
41
+
42
+ 1. Fork it
43
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
44
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
45
+ 4. Push to the branch (`git push origin my-new-feature`)
46
+ 5. Create a new Pull Request
47
+
48
+ ## License
49
+
50
+ Copyright (c) 2016 Kairat Jenishev. See [LICENSE](./LICENSE) for details.
51
+
52
+ Inspired by [middleman-google-analytics](https://github.com/danielbayerlein/middleman-google-analytics)
@@ -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'
8
+ end
9
+
10
+ require 'rake/clean'
11
+
12
+ task test: ['cucumber']
13
+
14
+ task default: :test
@@ -0,0 +1,19 @@
1
+ Feature: Facebook Pixel
2
+ Scenario: Basic
3
+ Given the Server is running at "basic"
4
+ When I go to "/index.html"
5
+ Then I should see:
6
+ """
7
+ <!-- Facebook Pixel Code -->
8
+ <script>
9
+ !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
10
+ n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
11
+ n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
12
+ t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
13
+ document,'script','https://connect.facebook.net/en_US/fbevents.js');
14
+ fbq('init', '1234567890000000');
15
+ fbq('track', 'PageView');
16
+ </script>
17
+ <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1234567890000000&ev=PageView&noscript=1"/></noscript>
18
+ <!-- End Facebook Pixel Code -->
19
+ """
@@ -0,0 +1,4 @@
1
+ PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
+ require 'middleman-core'
3
+ require 'middleman-core/step_definitions'
4
+ require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-facebook-pixel')
@@ -0,0 +1 @@
1
+ activate :facebook_pixel, id: 1234567890000000
@@ -0,0 +1 @@
1
+ <%= facebook_pixel %>
@@ -0,0 +1,6 @@
1
+ require 'middleman-core'
2
+
3
+ ::Middleman::Extensions.register(:facebook_pixel) do
4
+ require 'middleman-facebook-pixel/extension'
5
+ ::Middleman::FacebookPixelExtension
6
+ end
@@ -0,0 +1,11 @@
1
+ require 'middleman-facebook-pixel/helpers'
2
+
3
+ module Middleman
4
+ class FacebookPixelExtension < Extension
5
+ option :id, nil, 'Facebook Pixel ID'
6
+
7
+ helpers do
8
+ include ::Middleman::FacebookPixel::Helpers
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ <!-- Facebook Pixel Code -->
2
+ <script>
3
+ !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
4
+ n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
5
+ n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
6
+ t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
7
+ document,'script','https://connect.facebook.net/en_US/fbevents.js');
8
+ fbq('init', '<%= @options.id %>');
9
+ fbq('track', 'PageView');
10
+ </script>
11
+ <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=<%= @options.id %>&ev=PageView&noscript=1"/></noscript>
12
+ <!-- End Facebook Pixel Code -->
@@ -0,0 +1,20 @@
1
+ require 'erubis'
2
+
3
+ module Middleman
4
+ module FacebookPixel
5
+ module Helpers
6
+ def facebook_pixel
7
+ # get configuration options
8
+ options = extensions[:facebook_pixel].options
9
+ # path to Facebook Pixel template
10
+ path = File.join(File.dirname(__FILE__), 'facebook-pixel.html.erb')
11
+ # set template context
12
+ context = {options: options}
13
+ # init ERB engine
14
+ erb = Erubis::FastEruby.new(File.read(path))
15
+ # return compiled HTML
16
+ erb.evaluate(context)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ module Middleman
2
+ module FacebookPixel
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'middleman-facebook-pixel/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'middleman-facebook-pixel'
7
+ s.version = Middleman::FacebookPixel::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.author = 'Kairat Jenishev'
10
+ s.email = 'kairat.jenishev@gmail.com'
11
+ s.homepage = 'https://github.com/xcopy/middleman-facebook-pixel'
12
+ s.summary = 'A Middleman plugin for handling Facebook Pixel code'
13
+ s.description = '"middleman-facebook-pixel" is a Middleman extension that generates Facebook Pixel code, and keeps your config in config.rb, where it belongs'
14
+
15
+ s.license = 'MIT'
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = []
20
+ s.require_paths = ['lib']
21
+
22
+ s.required_ruby_version = '>= 2.0'
23
+ # The version of middleman-core your extension depends on
24
+ s.add_runtime_dependency 'middleman-core', '~> 3.4'
25
+ # Additional dependencies
26
+ s.add_runtime_dependency 'erubis', '~> 2.7'
27
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-facebook-pixel
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kairat Jenishev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-20 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.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '3.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: erubis
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '2.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '2.7'
41
+ description: '"middleman-facebook-pixel" is a Middleman extension that generates Facebook
42
+ Pixel code, and keeps your config in config.rb, where it belongs'
43
+ email: kairat.jenishev@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - .travis.yml
50
+ - Gemfile
51
+ - LICENSE
52
+ - README.md
53
+ - Rakefile
54
+ - features/basic.feature
55
+ - features/support/env.rb
56
+ - fixtures/basic/config.rb
57
+ - fixtures/basic/source/index.html.erb
58
+ - lib/middleman-facebook-pixel.rb
59
+ - lib/middleman-facebook-pixel/extension.rb
60
+ - lib/middleman-facebook-pixel/facebook-pixel.html.erb
61
+ - lib/middleman-facebook-pixel/helpers.rb
62
+ - lib/middleman-facebook-pixel/version.rb
63
+ - middleman-facebook-pixel.gemspec
64
+ homepage: https://github.com/xcopy/middleman-facebook-pixel
65
+ licenses:
66
+ - MIT
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '2.0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.4.8
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: A Middleman plugin for handling Facebook Pixel code
88
+ test_files: []