middleman-ogp 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06a47dbe1d43eadc2986af4ed48387c2549c313c
4
- data.tar.gz: 9e43b8b331044d136958eb88a96f9c64f4eff3f2
3
+ metadata.gz: ff26d501132ad5d6aff88ce5c3936b799bb8c6f8
4
+ data.tar.gz: 0c09e35c94c5490cfd23596718fa8d7241616d41
5
5
  SHA512:
6
- metadata.gz: 5ab7e36a2608652c10d909c049b3a2015e35996475ad229c989599b36c1f408e08674e7e0eb9ba8aee7e6f77993bac82d5a77d6d924424de237a4246912ab915
7
- data.tar.gz: 5728656b532f26049f2aa794098cc1af38e6df939a02d5f1b36c756067bac1026587dea1eab438c1ff66a430ecdf49d186ce575bd4a926b507e03a30b12215cd
6
+ metadata.gz: 35619f2a12782f18cc02b137fef74ebb93aab5bafe5ee6794708717349c0ef926e79d0ad52b3fc31e3d470863da5bd8ed3005a2a986f81e1078c0741770adb83
7
+ data.tar.gz: d2f2eb7474c5edc6533d48c95148cd1300c2810142cf04e29345d71868b3190e76b92433fe10e913f0e3060fbafb66960cc103f15a210b36bd1fe709bf14a1c9
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ Makefile
17
17
  .mm-pid-*
18
18
  *.gem
19
19
  .ruby-version
20
+ Gemfile
data/README.md CHANGED
@@ -20,10 +20,27 @@ activate :ogp do |ogp|
20
20
  og: data.ogp.og
21
21
  # from data/ogp/og.yml
22
22
  }
23
- og.base_url = 'http://mysite.tld/'
23
+ ogp.base_url = 'http://mysite.tld/'
24
24
  end
25
25
  ```
26
26
 
27
+ ### In your project's root directory
28
+
29
+ Create `data/ogp/fb.yml` and `data/ogp/og.yml` files.
30
+
31
+ Example:
32
+
33
+ ```yaml
34
+ image:
35
+ '': http://mydomain.tld/path/to/fbimage.png
36
+ secure_url: https://secure.mydomain.tld/path/to/fbimage.png
37
+ type: image/png
38
+ width: 400
39
+ height: 300
40
+ locale:
41
+ '': en_us
42
+ ```
43
+
27
44
  ### In your layout
28
45
 
29
46
  source/layout.slim
@@ -3,15 +3,9 @@ Feature: OpenGraph Protocol Tags with the "ogp_tags" helper method
3
3
  Scenario: Without page data
4
4
  Given the Server is running at "test-app"
5
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" />'
6
+ Then I should see '<meta content="5678" property="fb:app_id" />'
12
7
  Then I should see '<meta content="My Description" 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" />'
8
+ Then I should see '<meta content="https://images.mydomain.tld/path/to/og-site-image.png" property="og:image" />'
15
9
  Then I should see '<meta content="image/png" property="og:image:type" />'
16
10
  Then I should see '<meta content="400" property="og:image:width" />'
17
11
  Then I should see '<meta content="300" property="og:image:height" />'
@@ -24,15 +18,9 @@ Feature: OpenGraph Protocol Tags with the "ogp_tags" helper method
24
18
  Scenario: With page data
25
19
  Given the Server is running at "test-app"
26
20
  When I go to "/page.html"
27
- Then I should see '<meta content="This is my fixture Middleman article for Facebook." property="fb:description" />'
28
- Then I should see '<meta content="http://mydomain.tld/path/to/fb-article-image.png" property="fb:image" />'
29
- Then I should see '<meta content="https://secure.mydomain.tld/path/to/fb-article-image.png" property="fb:image:secure_url" />'
30
- Then I should see '<meta content="image/png" property="fb:image:type" />'
31
- Then I should see '<meta content="400" property="fb:image:width" />'
32
- Then I should see '<meta content="300" property="fb:image:height" />'
21
+ Then I should see '<meta content="1234" property="fb:app_id" />'
33
22
  Then I should see '<meta content="This is my fixture Middleman article." property="og:description" />'
34
- Then I should see '<meta content="http://mydomain.tld/path/to/og-article-image.png" property="og:image" />'
35
- Then I should see '<meta content="https://secure.mydomain.tld/path/to/og-article-image.png" property="og:image:secure_url" />'
23
+ Then I should see '<meta content="https://images.mydomain.tld/path/to/og-article-image.png" property="og:image" />'
36
24
  Then I should see '<meta content="image/png" property="og:image:type" />'
37
25
  Then I should see '<meta content="400" property="og:image:width" />'
38
26
  Then I should see '<meta content="300" property="og:image:height" />'
@@ -9,4 +9,5 @@ activate :ogp do |ogp|
9
9
  # from data/ogp/og.yml
10
10
  }
11
11
  ogp.base_url = 'http://myshop.foo.tld/'
12
+ ogp.image_base_url = 'https://images.mydomain.tld/path/'
12
13
  end
@@ -1,7 +1 @@
1
- description: 'This is my fixture Middleman site for Facebook.'
2
- image:
3
- '': http://mydomain.tld/path/to/fb-site-image.png
4
- secure_url: https://secure.mydomain.tld/path/to/fb-site-image.png
5
- type: image/png
6
- width: 400
7
- height: 300
1
+ app_id: 5678
@@ -1,7 +1,6 @@
1
1
  description: 'This is my fixture Middleman site for OpenGraph.'
2
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
3
+ '': to/og-site-image.png
5
4
  type: image/png
6
5
  width: 400
7
6
  height: 300
@@ -9,4 +8,4 @@ locale:
9
8
  '': en_us
10
9
  alternate:
11
10
  - ja_jp
12
- - zh_tw
11
+ - zh_tw
@@ -5,8 +5,7 @@ ogp:
5
5
  og:
6
6
  description: 'This is my fixture Middleman article for OpenGraph.'
7
7
  image:
8
- '': http://mydomain.tld/path/to/og-article-image.png
9
- secure_url: https://secure.mydomain.tld/path/to/og-article-image.png
8
+ '': to/og-article-image.png
10
9
  type: image/png
11
10
  width: 400
12
11
  height: 300
@@ -16,13 +15,7 @@ ogp:
16
15
  - ja_jp
17
16
  - zh_tw
18
17
  fb:
19
- description: 'This is my fixture Middleman article for Facebook.'
20
- image:
21
- '': http://mydomain.tld/path/to/fb-article-image.png
22
- secure_url: https://secure.mydomain.tld/path/to/fb-article-image.png
23
- type: image/png
24
- width: 400
25
- height: 300
18
+ app_id: 1234
26
19
  ---
27
20
 
28
21
  h1 Hello page
@@ -5,16 +5,18 @@ require 'middleman-core/extensions'
5
5
  module Middleman
6
6
  module OGP
7
7
  class OGPExtension < Extension
8
- option :namespaces, {}, 'Default namespaces'
9
- option :blog, false, 'Middleman Blog support'
10
- option :auto, %w{title url description}, 'Properties to automatically fill from page data.'
11
- option :base_url, nil, 'Base URL to generate permalink for og:url'
8
+ option :namespaces, {}, 'Default namespaces'
9
+ option :blog, false, 'Middleman Blog support'
10
+ option :auto, %w{title url description}, 'Properties to automatically fill from page data.'
11
+ option :base_url, nil, 'Base URL to generate permalink for og:url'
12
+ option :image_base_url, nil, 'Base URL to generate og:image'
12
13
 
13
14
  def after_configuration
14
15
  Middleman::OGP::Helper.namespaces = options[:namespaces] || {}
15
16
  Middleman::OGP::Helper.blog = options[:blog]
16
17
  Middleman::OGP::Helper.auto = options[:auto]
17
18
  Middleman::OGP::Helper.base_url = options[:base_url]
19
+ Middleman::OGP::Helper.image_base_url = options[:image_base_url]
18
20
  end
19
21
 
20
22
  helpers do
@@ -51,6 +53,7 @@ module Middleman
51
53
  Middleman::OGP::Helper.base_url
52
54
  opts[:og][:url] = URI.join(Middleman::OGP::Helper.base_url, URI.encode(current_resource.url))
53
55
  end
56
+
54
57
  Middleman::OGP::Helper.ogp_tags(opts) do|name, value|
55
58
  if block_given?
56
59
  block.call name, value
@@ -68,6 +71,7 @@ module Middleman
68
71
  mattr_accessor :blog
69
72
  mattr_accessor :auto
70
73
  mattr_accessor :base_url
74
+ mattr_accessor :image_base_url
71
75
 
72
76
  def self.ogp_tags(opts = {}, &block)
73
77
  opts ||= {}
@@ -120,7 +124,12 @@ module Middleman
120
124
  raise 'Unknown value'
121
125
  end
122
126
  else
123
- block.call [prefix].concat(key).join(':'), obj.to_s
127
+ name = [prefix].concat(key).join(':')
128
+ value = obj.to_s
129
+ if Middleman::OGP::Helper.image_base_url && name == 'og:image' && !%r{^https?://}.match(value)
130
+ value = URI.join(Middleman::OGP::Helper.image_base_url, URI.encode(value))
131
+ end
132
+ block.call name, value
124
133
  end
125
134
  end
126
135
  end
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module OGP
3
- VERSION = "1.1.0"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-ogp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Atsushi Nagase
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-08 00:00:00.000000000 Z
11
+ date: 2017-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.2'
27
27
  description: OpenGraph Protocol Helper for Middleman
@@ -31,8 +31,8 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - .gitignore
35
- - .travis.yml
34
+ - ".gitignore"
35
+ - ".travis.yml"
36
36
  - CHANGELOG.md
37
37
  - CONTRIBUTING.md
38
38
  - Gemfile.mm3
@@ -72,17 +72,17 @@ require_paths:
72
72
  - lib
73
73
  required_ruby_version: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - '>='
75
+ - - ">="
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  requirements: []
84
84
  rubyforge_project:
85
- rubygems_version: 2.0.14.1
85
+ rubygems_version: 2.6.13
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: OpenGraph Protocol Helper for Middleman