middleman-meta-tags 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE +21 -0
- data/README.md +23 -0
- data/lib/middleman-meta-tags/helpers.rb +24 -2
- data/lib/middleman-meta-tags/version.rb +1 -1
- metadata +5 -3
- data/LICENSE.txt +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 315f41669e5f4f22a78d163a99f104fed348b3f6
|
4
|
+
data.tar.gz: a2445224c7ccd61088e85d6919a7c361c6b6b606
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6e559fe8e507542b8dd7bfd0e4cdd68de568a95446d786e26694ebb4418fa1624190528a27e8baf172d92dab8b8eaec48c6ffed4b3f427be92d9f41090a607c
|
7
|
+
data.tar.gz: 8d26f130b0abb3669ddd08c0f28d7f70ff6070fa961a20b826dfdaf9c1bea32492df088aaa242d78f70b2edf79534b78e43dde544f0a79058313a03f140cf879
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
middleman-meta-tags
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2
|
data/CHANGELOG.md
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Baptiste Lecocq
|
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.
|
data/README.md
CHANGED
@@ -86,6 +86,7 @@ Then it looks the page meta data to attempt to display the following keys:
|
|
86
86
|
- MM `pull_image` => META `og:image`
|
87
87
|
- MM `site` => META `og:site_name`
|
88
88
|
- MM `title` => META `og:title`
|
89
|
+
- MM `host` => optional attribute for composing `pull_image` src with asset helper
|
89
90
|
|
90
91
|
In addition, if you want to customize meta tags by each page's frontmatter, you
|
91
92
|
can add `customize_by_frontmatter: true` in `data/site.yml`. The priority would
|
@@ -105,6 +106,28 @@ end
|
|
105
106
|
|
106
107
|
And add it to the layouts and views that you need.
|
107
108
|
|
109
|
+
### Pull images
|
110
|
+
|
111
|
+
For the `pull_image` to render for twitter metatags, a full url must be used:
|
112
|
+
|
113
|
+
```
|
114
|
+
pull_image: 'http://example.com/path/to/image.jpg'
|
115
|
+
```
|
116
|
+
|
117
|
+
If pointing to an image in your Middleman source, you can instead specify the
|
118
|
+
relative image path as you would with an asset helper provided you have also
|
119
|
+
configured the `host` in your `site.yml`. If your Middleman build activates
|
120
|
+
extensions like `:asset_hash`, the full, hashed URL will be generated in your
|
121
|
+
metatags.
|
122
|
+
|
123
|
+
```
|
124
|
+
# site.yml
|
125
|
+
host: http://example.com
|
126
|
+
|
127
|
+
# your article
|
128
|
+
pull_image 'page/to/image/jpg'
|
129
|
+
```
|
130
|
+
|
108
131
|
## Contributing
|
109
132
|
|
110
133
|
1. [Fork it](http://github.com/tiste/middleman-meta-tags/fork)
|
@@ -34,6 +34,7 @@ module Middleman
|
|
34
34
|
result << tag(:meta, name: :description, content: description) unless description.blank?
|
35
35
|
|
36
36
|
keywords = meta_tags.delete(:keywords)
|
37
|
+
keywords = keywords.join(', ') if keywords.is_a?(Array)
|
37
38
|
result << tag(:meta, name: :keywords, content: keywords) unless keywords.blank?
|
38
39
|
|
39
40
|
meta_tags.each do |name, content|
|
@@ -68,13 +69,13 @@ module Middleman
|
|
68
69
|
fall_through(site_data, 'twitter:card', 'twitter_card', 'summary_large_image')
|
69
70
|
fall_through(site_data, 'twitter:creator', 'twitter_author')
|
70
71
|
fall_through(site_data, 'twitter:description', 'description')
|
71
|
-
|
72
|
+
fall_through_image(site_data, 'twitter:image:src', 'pull_image')
|
72
73
|
fall_through(site_data, 'twitter:site', 'publisher_twitter')
|
73
74
|
fall_through(site_data, 'twitter:title', 'title')
|
74
75
|
|
75
76
|
# Open Graph
|
76
77
|
fall_through(site_data, 'og:description', 'description')
|
77
|
-
|
78
|
+
fall_through_image(site_data, 'og:image', 'pull_image')
|
78
79
|
fall_through(site_data, 'og:title', 'title')
|
79
80
|
end
|
80
81
|
|
@@ -86,10 +87,31 @@ module Middleman
|
|
86
87
|
(need_customized && current_page.data[key]) ||
|
87
88
|
site_data[key] ||
|
88
89
|
default
|
90
|
+
value = yield value if block_given?
|
89
91
|
set_meta_tags name => value unless value.blank?
|
90
92
|
value
|
91
93
|
end
|
92
94
|
|
95
|
+
def fall_through_image(*args)
|
96
|
+
fall_through(*args) do |path|
|
97
|
+
is_uri?(path) ? path : meta_tags_image_url(path)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def meta_tags_image_url(source)
|
102
|
+
meta_tags_host + image_path(source)
|
103
|
+
end
|
104
|
+
|
105
|
+
def meta_tags_host
|
106
|
+
(data['site'] || {})['host'] || ''
|
107
|
+
end
|
108
|
+
|
109
|
+
# borrowed from Rails 3
|
110
|
+
# http://apidock.com/rails/v3.2.8/ActionView/AssetPaths/is_uri%3F
|
111
|
+
def is_uri?(path)
|
112
|
+
path =~ %r{^[-a-z]+://|^(?:cid|data):|^//}
|
113
|
+
end
|
114
|
+
|
93
115
|
def full_title(meta_tags)
|
94
116
|
separator = meta_tags[:separator] || '|'
|
95
117
|
full_title = ''
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-meta-tags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Baptiste Lecocq
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|
@@ -60,9 +60,11 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
|
+
- ".ruby-gemset"
|
64
|
+
- ".ruby-version"
|
63
65
|
- CHANGELOG.md
|
64
66
|
- Gemfile
|
65
|
-
- LICENSE
|
67
|
+
- LICENSE
|
66
68
|
- README.md
|
67
69
|
- Rakefile
|
68
70
|
- lib/middleman-meta-tags.rb
|
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2014 Baptiste Lecocq
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|