middleman-ogp 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +14 -0
- data/CHANGELOG.md +4 -0
- data/CONTRIBUTING.md +44 -0
- data/Gemfile +20 -0
- data/LICENSE.md +20 -0
- data/README.md +100 -0
- data/Rakefile +35 -0
- data/features/helper.feature +39 -0
- data/features/support/env.rb +5 -0
- data/fixtures/test-app/config.rb +11 -0
- data/fixtures/test-app/data/ogp/fb.yml +7 -0
- data/fixtures/test-app/data/ogp/og.yml +12 -0
- data/fixtures/test-app/source/index.html.slim +7 -0
- data/fixtures/test-app/source/layout.slim +10 -0
- data/fixtures/test-app/source/page.html.slim +29 -0
- data/lib/middleman-ogp.rb +7 -0
- data/lib/middleman-ogp/extension.rb +71 -0
- data/lib/middleman-ogp/middleman_extension.rb +2 -0
- data/lib/middleman-ogp/version.rb +5 -0
- data/middleman-ogp.gemspec +19 -0
- data/spec/helper_spec.rb +69 -0
- data/spec/spec_helper.rb +11 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c7a795f3654c7cc818de89ae7b305a490f35cf79
|
4
|
+
data.tar.gz: bea3e8661b877fcc400d3827f7bc151e7c768883
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cc0818834f813e104131b5227f5aa9e72c125954957b8d89b4aa0690e0259129472ac4b140668053d9e1296b1d19392e6dcb30e9548f9405ca62ba8427f0973d
|
7
|
+
data.tar.gz: c0f4ef61d865266300ac2bd746dc1229b1fe2dd6a0e4dfca73fef78404bfd3fa5be5c093dd046396147210f5383c4246fbdc2e451990a96a80a58eadeac59ada
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
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/ngs/middleman-ogp/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,20 @@
|
|
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-ogp.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", "~> 0.5.1"
|
15
|
+
gem "rspec"
|
16
|
+
|
17
|
+
gem "slim"
|
18
|
+
|
19
|
+
# Code Quality
|
20
|
+
gem "cane", :platforms => [:mri_19, :mri_20], :require => false
|
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 Atsushi Nagase
|
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,100 @@
|
|
1
|
+
Middleman-OGP
|
2
|
+
=============
|
3
|
+
|
4
|
+
`middleman-opg` is an extension for the [Middleman] static site generator that adds OpenGraph Protocol support.
|
5
|
+
|
6
|
+
|
7
|
+
Configuration
|
8
|
+
-------------
|
9
|
+
|
10
|
+
### In your `config.rb`
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
activate :ogp do |ogp|
|
14
|
+
#
|
15
|
+
# register namespace with default options
|
16
|
+
#
|
17
|
+
ogp.namespaces = {
|
18
|
+
fb: data.ogp.fb,
|
19
|
+
# from data/ogp/fb.yml
|
20
|
+
og: data.ogp.og
|
21
|
+
# from data/ogp/og.yml
|
22
|
+
}
|
23
|
+
end
|
24
|
+
```
|
25
|
+
|
26
|
+
### In your layout
|
27
|
+
|
28
|
+
source/layout.slim
|
29
|
+
|
30
|
+
```
|
31
|
+
html
|
32
|
+
head
|
33
|
+
meta charset="utf-8"
|
34
|
+
title= data.page.title
|
35
|
+
- ogp_tags do|name, value|
|
36
|
+
meta property=name content=value
|
37
|
+
|
38
|
+
body
|
39
|
+
.container
|
40
|
+
= yield
|
41
|
+
```
|
42
|
+
|
43
|
+
### In your page source
|
44
|
+
|
45
|
+
Page data overrides default options. (deep merge).
|
46
|
+
|
47
|
+
|
48
|
+
```markdown
|
49
|
+
---
|
50
|
+
ogp:
|
51
|
+
og:
|
52
|
+
description: 'This is my fixture Middleman site.'
|
53
|
+
image:
|
54
|
+
'': http://mydomain.tld/path/to/fbimage.png
|
55
|
+
secure_url: https://secure.mydomain.tld/path/to/fbimage.png
|
56
|
+
type: image/png
|
57
|
+
width: 400
|
58
|
+
height: 300
|
59
|
+
locale:
|
60
|
+
'': en_us
|
61
|
+
alternate:
|
62
|
+
- ja_jp
|
63
|
+
- zh_tw
|
64
|
+
fb:
|
65
|
+
description: 'This is my fixture Middleman site.'
|
66
|
+
image:
|
67
|
+
'': http://mydomain.tld/path/to/fbimage.png
|
68
|
+
secure_url: https://secure.mydomain.tld/path/to/fbimage.png
|
69
|
+
type: image/png
|
70
|
+
width: 400
|
71
|
+
height: 300
|
72
|
+
---
|
73
|
+
|
74
|
+
Hello
|
75
|
+
=====
|
76
|
+
|
77
|
+
This is the __content__
|
78
|
+
```
|
79
|
+
|
80
|
+
|
81
|
+
Build & Dependency Status
|
82
|
+
-------------------------
|
83
|
+
|
84
|
+
[![Gem Version](https://badge.fury.io/rb/middleman-ogp.png)][gem]
|
85
|
+
[![Build Status](https://travis-ci.org/ngs/middleman-ogp.png)][travis]
|
86
|
+
[![Dependency Status](https://gemnasium.com/ngs/middleman-ogp.png?travis)][gemnasium]
|
87
|
+
[![Code Quality](https://codeclimate.com/github/ngs/middleman-ogp.png)][codeclimate]
|
88
|
+
|
89
|
+
License
|
90
|
+
-------
|
91
|
+
|
92
|
+
Copyright (c) 2014 [Atsushi Nagase]. MIT Licensed, see [LICENSE] for details.
|
93
|
+
|
94
|
+
[middleman]: http://middlemanapp.com
|
95
|
+
[gem]: https://rubygems.org/gems/middleman-ogp
|
96
|
+
[travis]: http://travis-ci.org/ngs/middleman-ogp
|
97
|
+
[gemnasium]: https://gemnasium.com/ngs/middleman-ogp
|
98
|
+
[codeclimate]: https://codeclimate.com/github/ngs/middleman-ogp
|
99
|
+
[LICENSE]: https://github.com/ngs/middleman-ogp/blob/master/LICENSE.md
|
100
|
+
[Atsushi Nagase]: http://ngs.io/
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
8
|
+
|
9
|
+
Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
|
10
|
+
exempt_tags = ""
|
11
|
+
exempt_tags << "--tags ~@nojava " if RUBY_PLATFORM == "java"
|
12
|
+
t.cucumber_opts = "--color --tags ~@wip #{exempt_tags} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'rake/clean'
|
16
|
+
|
17
|
+
task :test => ["spec", "cucumber"]
|
18
|
+
|
19
|
+
begin
|
20
|
+
require 'cane/rake_task'
|
21
|
+
|
22
|
+
desc "Run cane to check quality metrics"
|
23
|
+
Cane::RakeTask.new(:quality) do |cane|
|
24
|
+
cane.no_style = true
|
25
|
+
cane.no_doc = true
|
26
|
+
cane.abc_glob = "lib/middleman-ogp/**/*.rb"
|
27
|
+
end
|
28
|
+
rescue LoadError
|
29
|
+
# warn "cane not available, quality task not provided."
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "Build HTML documentation"
|
33
|
+
task :doc do
|
34
|
+
sh 'bundle exec yard'
|
35
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Feature: OpenGraph Protocol Tags with the "ogp_tags" helper method
|
2
|
+
|
3
|
+
Scenario: Without page data
|
4
|
+
Given the Server is running at "test-app"
|
5
|
+
When I go to "/"
|
6
|
+
Then I should see '<meta content="This is my fixture Middleman site for Facebook." property="fb:description" />'
|
7
|
+
Then I should see '<meta content="http://mydomain.tld/path/to/fb-site-image.png" property="fb:image" />'
|
8
|
+
Then I should see '<meta content="https://secure.mydomain.tld/path/to/fb-site-image.png" property="fb:image:secure_url" />'
|
9
|
+
Then I should see '<meta content="image/png" property="fb:image:type" />'
|
10
|
+
Then I should see '<meta content="400" property="fb:image:width" />'
|
11
|
+
Then I should see '<meta content="300" property="fb:image:height" />'
|
12
|
+
Then I should see '<meta content="This is my fixture Middleman site for OpenGraph." property="og:description" />'
|
13
|
+
Then I should see '<meta content="http://mydomain.tld/path/to/og-site-image.png" property="og:image" />'
|
14
|
+
Then I should see '<meta content="https://secure.mydomain.tld/path/to/og-site-image.png" property="og:image:secure_url" />'
|
15
|
+
Then I should see '<meta content="image/png" property="og:image:type" />'
|
16
|
+
Then I should see '<meta content="400" property="og:image:width" />'
|
17
|
+
Then I should see '<meta content="300" property="og:image:height" />'
|
18
|
+
Then I should see '<meta content="en_us" property="og:locale" />'
|
19
|
+
Then I should see '<meta content="ja_jp" property="og:locale:alternate" />'
|
20
|
+
Then I should see '<meta content="zh_tw" property="og:locale:alternate" />'
|
21
|
+
|
22
|
+
Scenario: With page data
|
23
|
+
Given the Server is running at "test-app"
|
24
|
+
When I go to "/page.html"
|
25
|
+
Then I should see '<meta content="This is my fixture Middleman article for Facebook." property="fb:description" />'
|
26
|
+
Then I should see '<meta content="http://mydomain.tld/path/to/fb-article-image.png" property="fb:image" />'
|
27
|
+
Then I should see '<meta content="https://secure.mydomain.tld/path/to/fb-article-image.png" property="fb:image:secure_url" />'
|
28
|
+
Then I should see '<meta content="image/png" property="fb:image:type" />'
|
29
|
+
Then I should see '<meta content="400" property="fb:image:width" />'
|
30
|
+
Then I should see '<meta content="300" property="fb:image:height" />'
|
31
|
+
Then I should see '<meta content="This is my fixture Middleman article for OpenGraph." property="og:description" />'
|
32
|
+
Then I should see '<meta content="http://mydomain.tld/path/to/og-article-image.png" property="og:image" />'
|
33
|
+
Then I should see '<meta content="https://secure.mydomain.tld/path/to/og-article-image.png" property="og:image:secure_url" />'
|
34
|
+
Then I should see '<meta content="image/png" property="og:image:type" />'
|
35
|
+
Then I should see '<meta content="400" property="og:image:width" />'
|
36
|
+
Then I should see '<meta content="300" property="og:image:height" />'
|
37
|
+
Then I should see '<meta content="en_us" property="og:locale" />'
|
38
|
+
Then I should see '<meta content="ja_jp" property="og:locale:alternate" />'
|
39
|
+
Then I should see '<meta content="zh_tw" property="og:locale:alternate" />'
|
@@ -0,0 +1,12 @@
|
|
1
|
+
description: 'This is my fixture Middleman site for OpenGraph.'
|
2
|
+
image:
|
3
|
+
'': http://mydomain.tld/path/to/og-site-image.png
|
4
|
+
secure_url: https://secure.mydomain.tld/path/to/og-site-image.png
|
5
|
+
type: image/png
|
6
|
+
width: 400
|
7
|
+
height: 300
|
8
|
+
locale:
|
9
|
+
'': en_us
|
10
|
+
alternate:
|
11
|
+
- ja_jp
|
12
|
+
- zh_tw
|
@@ -0,0 +1,29 @@
|
|
1
|
+
---
|
2
|
+
title: Fixture page
|
3
|
+
ogp:
|
4
|
+
og:
|
5
|
+
description: 'This is my fixture Middleman article for OpenGraph.'
|
6
|
+
image:
|
7
|
+
'': http://mydomain.tld/path/to/og-article-image.png
|
8
|
+
secure_url: https://secure.mydomain.tld/path/to/og-article-image.png
|
9
|
+
type: image/png
|
10
|
+
width: 400
|
11
|
+
height: 300
|
12
|
+
locale:
|
13
|
+
'': en_us
|
14
|
+
alternate:
|
15
|
+
- ja_jp
|
16
|
+
- zh_tw
|
17
|
+
fb:
|
18
|
+
description: 'This is my fixture Middleman article for Facebook.'
|
19
|
+
image:
|
20
|
+
'': http://mydomain.tld/path/to/fb-article-image.png
|
21
|
+
secure_url: https://secure.mydomain.tld/path/to/fb-article-image.png
|
22
|
+
type: image/png
|
23
|
+
width: 400
|
24
|
+
height: 300
|
25
|
+
---
|
26
|
+
|
27
|
+
h1 Hello page
|
28
|
+
|
29
|
+
p This is page
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Middleman
|
2
|
+
module OGP
|
3
|
+
class OGPExtension < Extension
|
4
|
+
option :namespaces, {}, 'Default namespaces'
|
5
|
+
|
6
|
+
def after_configuration
|
7
|
+
Middleman::OGP::Helper.namespaces = options[:namespaces] || {}
|
8
|
+
end
|
9
|
+
|
10
|
+
helpers do
|
11
|
+
def ogp_tags(&block)
|
12
|
+
Middleman::OGP::Helper.ogp_tags(data.page.ogp) do|name, value|
|
13
|
+
if block_given?
|
14
|
+
block.call name, value
|
15
|
+
else
|
16
|
+
concat_content tag(:meta, name: name, property: value)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module Helper
|
24
|
+
include Padrino::Helpers::TagHelpers
|
25
|
+
mattr_accessor :namespaces
|
26
|
+
|
27
|
+
def self.ogp_tags(opts = {}, &block)
|
28
|
+
options = namespaces.respond_to?(:to_h) ? namespaces.to_h : namespaces || {}
|
29
|
+
options = options.deep_merge(opts || {}) {|k, old_value, new_value|
|
30
|
+
if old_value.is_a?(Hash)
|
31
|
+
if new_value.is_a? Hash
|
32
|
+
old_value.deep_merge new_value
|
33
|
+
else
|
34
|
+
old_value[''] = new_value
|
35
|
+
old_value
|
36
|
+
end
|
37
|
+
else
|
38
|
+
new_value
|
39
|
+
end
|
40
|
+
}.symbolize_keys
|
41
|
+
options.map{|k, v|
|
42
|
+
og_tag([], v, k, &block)
|
43
|
+
}.join("\n")
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.og_tag(key, obj = nil, prefix = 'og', &block)
|
47
|
+
case key
|
48
|
+
when String, Symbol
|
49
|
+
key = [key]
|
50
|
+
when Hash
|
51
|
+
prefix = obj if obj
|
52
|
+
obj = key
|
53
|
+
key = []
|
54
|
+
end
|
55
|
+
case obj
|
56
|
+
when Hash
|
57
|
+
obj.map{|k, v|
|
58
|
+
og_tag(k.to_s.empty? ? key.dup : (key.dup << k.to_sym) , v, prefix, &block)
|
59
|
+
}.join("\n")
|
60
|
+
when Array
|
61
|
+
obj.map{|v|
|
62
|
+
og_tag(key, v, prefix, &block)
|
63
|
+
}.join("\n")
|
64
|
+
else
|
65
|
+
block.call [prefix].concat(key).join(':'), obj.to_s
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "middleman-ogp/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "middleman-ogp"
|
7
|
+
s.version = Middleman::OGP::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Atsushi Nagase"]
|
10
|
+
s.email = ["a@ngs.io"]
|
11
|
+
s.homepage = "https://github.com/ngs/middleman-ogp"
|
12
|
+
s.summary = %q{OpenGraph Protocol Helper for Middleman}
|
13
|
+
s.description = %q{OpenGraph Protocol Helper 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,spec}/*`.split("\0")
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.add_runtime_dependency("middleman-core", ["~> 3.2"])
|
19
|
+
end
|
data/spec/helper_spec.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Middleman::OGP::Helper" do
|
4
|
+
subject {
|
5
|
+
Middleman::OGP::Helper.namespaces = namespaces
|
6
|
+
Middleman::OGP::Helper.ogp_tags(options) do|name, value|
|
7
|
+
%Q{<meta property="#{name}" content="#{value}" />}
|
8
|
+
end
|
9
|
+
}
|
10
|
+
describe "default namespace and options are nil" do
|
11
|
+
let(:namespaces) { nil }
|
12
|
+
let(:options) { nil }
|
13
|
+
it { subject.should eq '' }
|
14
|
+
end
|
15
|
+
context "with default namespaces" do
|
16
|
+
let(:namespaces) {
|
17
|
+
{
|
18
|
+
og: {
|
19
|
+
image: {
|
20
|
+
'' => 'http://mydomain.tld/mysite.png',
|
21
|
+
type: 'image/png',
|
22
|
+
'width' => 300,
|
23
|
+
'height' => 400
|
24
|
+
}
|
25
|
+
},
|
26
|
+
fb: {
|
27
|
+
description: 'foo'
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
describe "options is nil" do
|
32
|
+
let(:options) { nil }
|
33
|
+
it {
|
34
|
+
subject.should eq <<-EOF.unindent
|
35
|
+
<meta property="og:image" content="http://mydomain.tld/mysite.png" />
|
36
|
+
<meta property="og:image:type" content="image/png" />
|
37
|
+
<meta property="og:image:width" content="300" />
|
38
|
+
<meta property="og:image:height" content="400" />
|
39
|
+
<meta property="fb:description" content="foo" />
|
40
|
+
EOF
|
41
|
+
}
|
42
|
+
end
|
43
|
+
describe "options is presented" do
|
44
|
+
let(:options) {
|
45
|
+
{
|
46
|
+
og: {
|
47
|
+
image: 'http://mydomain.tld/myarticle.png'
|
48
|
+
},
|
49
|
+
fb: {
|
50
|
+
description: 'bar'
|
51
|
+
},
|
52
|
+
music: {
|
53
|
+
id: '123'
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
it {
|
58
|
+
subject.should eq <<-EOF.unindent
|
59
|
+
<meta property="og:image" content="http://mydomain.tld/myarticle.png" />
|
60
|
+
<meta property="og:image:type" content="image/png" />
|
61
|
+
<meta property="og:image:width" content="300" />
|
62
|
+
<meta property="og:image:height" content="400" />
|
63
|
+
<meta property="fb:description" content="bar" />
|
64
|
+
<meta property="music:id" content="123" />
|
65
|
+
EOF
|
66
|
+
}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
PROJECT_ROOT_PATH = File.dirname(File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-ogp')
|
5
|
+
require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-ogp/extension')
|
6
|
+
|
7
|
+
class String
|
8
|
+
def unindent
|
9
|
+
gsub(/^#{scan(/^\s*/).min_by{|l|l.length}}/, "").sub(/\n$/, '')
|
10
|
+
end
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: middleman-ogp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Atsushi Nagase
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-12 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: OpenGraph Protocol Helper for Middleman
|
28
|
+
email:
|
29
|
+
- a@ngs.io
|
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/helper.feature
|
43
|
+
- features/support/env.rb
|
44
|
+
- fixtures/test-app/config.rb
|
45
|
+
- fixtures/test-app/data/ogp/fb.yml
|
46
|
+
- fixtures/test-app/data/ogp/og.yml
|
47
|
+
- fixtures/test-app/source/index.html.slim
|
48
|
+
- fixtures/test-app/source/layout.slim
|
49
|
+
- fixtures/test-app/source/page.html.slim
|
50
|
+
- lib/middleman-ogp.rb
|
51
|
+
- lib/middleman-ogp/extension.rb
|
52
|
+
- lib/middleman-ogp/middleman_extension.rb
|
53
|
+
- lib/middleman-ogp/version.rb
|
54
|
+
- middleman-ogp.gemspec
|
55
|
+
- spec/helper_spec.rb
|
56
|
+
- spec/spec_helper.rb
|
57
|
+
homepage: https://github.com/ngs/middleman-ogp
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.0.14
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: OpenGraph Protocol Helper for Middleman
|
81
|
+
test_files:
|
82
|
+
- features/helper.feature
|
83
|
+
- features/support/env.rb
|
84
|
+
- fixtures/test-app/config.rb
|
85
|
+
- fixtures/test-app/data/ogp/fb.yml
|
86
|
+
- fixtures/test-app/data/ogp/og.yml
|
87
|
+
- fixtures/test-app/source/index.html.slim
|
88
|
+
- fixtures/test-app/source/layout.slim
|
89
|
+
- fixtures/test-app/source/page.html.slim
|
90
|
+
- spec/helper_spec.rb
|
91
|
+
- spec/spec_helper.rb
|
92
|
+
has_rdoc:
|