scrivito_seo_page_extender 0.92.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -0
- data/app/helper/seo_page_extender_helper.rb +23 -0
- data/app/views/seo_page_extender/_meta_attribute.html.erb +2 -2
- data/lib/scrivito_seo_page_extender.rb +16 -0
- data/lib/scrivito_seo_page_extender/configuration.rb +8 -0
- data/lib/scrivito_seo_page_extender/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 123bcb2020a31ab95ef68e0d1e2821533c42a317
|
4
|
+
data.tar.gz: 06eeccd4f549acbd72ba9d67ba01115e5eab6abe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8afab6f73df6dce644d489f112fdba71079b8891bdd1dcf081f13f028f30579e82f7921dda34317a844e5f9c41cf8f9e1f5b064c96b109d48321ed2d7f44d88a
|
7
|
+
data.tar.gz: 832f12345e99094e31b874577ec9ba3877daa80eaafe1a9ade91e86fb5834aa048de9d95e240f001dec48f130c1268f1a0d4d5149fddb9a4f9875fdf629ed777
|
data/README.md
CHANGED
@@ -145,6 +145,30 @@ class MyObj < Obj
|
|
145
145
|
end
|
146
146
|
```
|
147
147
|
|
148
|
+
## Configuration
|
149
|
+
|
150
|
+
Add an initializer to activate automatic attribute mapping for titles and descriptions:
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
ScrivitoSeoPageExtender.configure do |config|
|
154
|
+
config.attribute_mapping = true
|
155
|
+
end
|
156
|
+
```
|
157
|
+
|
158
|
+
You can overwrite the default attribute mapping depending on your app in the obj.rb with:
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
def self.seo_attribute_mapping(obj)
|
162
|
+
{
|
163
|
+
og_title: obj.my_app_title,
|
164
|
+
og_description: obj.my_app_description
|
165
|
+
...
|
166
|
+
}
|
167
|
+
end
|
168
|
+
```
|
169
|
+
|
170
|
+
The key is an attribute from meta, open graph or twitter cards modules, the value is app specific. More detailed values like `obj.my_title || obj.title || 'Fallback title'` are possible.
|
171
|
+
|
148
172
|
## Customization
|
149
173
|
|
150
174
|
If you use the default details views provided in this gem, we recommend to activate [Scrivito Advanced Editors](https://github.com/Scrivito/scrivito_advanced_editors) to utilize the tabs used by this gem.
|
@@ -18,7 +18,20 @@ module SeoPageExtenderHelper
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
def seo_attribute_fallback(obj, attribute)
|
22
|
+
if seo_attribute_fallback?(obj, attribute)
|
23
|
+
seo_attribute_mapping(obj)[attribute]
|
24
|
+
else
|
25
|
+
obj.send(attribute.to_sym)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
21
29
|
private
|
30
|
+
def seo_attribute_fallback?(obj, attribute)
|
31
|
+
# config is true && attribute is not set && mapping exists
|
32
|
+
ScrivitoSeoPageExtender.configuration.attribute_mapping && !obj.send(attribute.to_sym).present? && (seo_attribute_mapping(obj)[attribute]).present?
|
33
|
+
end
|
34
|
+
|
22
35
|
def get_words_from_page(obj, attribute)
|
23
36
|
strip_tags(scrivito_tag(:span, obj, attribute).to_s).split(" ")
|
24
37
|
end
|
@@ -50,4 +63,14 @@ module SeoPageExtenderHelper
|
|
50
63
|
"a,able,about,across,after,all,almost,also,am,among,an,and,any,are,as,at,be,because,been,but,by,can,cannot,could,dear,did,do,does,either,else,ever,every,for,from,get,got,had,has,have,he,her,hers,him,his,how,however,i,if,in,into,is,it,its,just,least,let,like,likely,may,me,might,most,must,my,neither,no,nor,not,of,off,often,on,only,or,other,our,own,rather,said,say,says,she,should,since,so,some,than,that,the,their,them,then,there,these,they,this,tis,to,too,twas,us,wants,was,we,were,what,when,where,which,while,who,whom,why,will,with,would,yet,you,your".split(",")
|
51
64
|
end
|
52
65
|
end
|
66
|
+
|
67
|
+
def seo_attribute_mapping(obj)
|
68
|
+
return Obj.seo_attribute_mapping(obj) if Obj.respond_to?('seo_attribute_mapping')
|
69
|
+
{
|
70
|
+
og_title: obj.send(:title).presence,
|
71
|
+
og_description: obj.send(:meta_description).presence,
|
72
|
+
tc_title: obj.send(:title).presence,
|
73
|
+
tc_description: obj.send(:meta_description).presence
|
74
|
+
}
|
75
|
+
end
|
53
76
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
<% if @obj.respond_to?(attribute) &&
|
1
|
+
<% if @obj.respond_to?(attribute) && seo_attribute_fallback(@obj, attribute.to_sym).present? %>
|
2
2
|
<% if name[/image\d?$/] %>
|
3
3
|
<meta content="<%= scrivito_path(@obj[attribute]) %>" name="<%= name %>"/>
|
4
4
|
<% elsif name == 'audience' || name == 'robots' || name == 'keywords' %>
|
5
5
|
<meta content="<%= @obj.send(attribute).join(',') %>" name="<%= name %>"/>
|
6
6
|
<% else %>
|
7
|
-
<meta content="<%= @obj.
|
7
|
+
<meta content="<%= seo_attribute_fallback(@obj, attribute.to_sym) %>" name="<%= name %>"/>
|
8
8
|
<% end %>
|
9
9
|
<% end %>
|
@@ -1,4 +1,20 @@
|
|
1
1
|
require "scrivito_seo_page_extender/engine"
|
2
|
+
require "scrivito_seo_page_extender/configuration"
|
2
3
|
|
3
4
|
module ScrivitoSeoPageExtender
|
5
|
+
class << self
|
6
|
+
attr_writer :configuration
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.configuration
|
10
|
+
@configuration ||= Configuration.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.reset
|
14
|
+
@configuration = Configuration.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.configure
|
18
|
+
yield(configuration)
|
19
|
+
end
|
4
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scrivito_seo_page_extender
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scrivito
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: scrivito_sdk
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- app/views/seo_page_extender/open_graph/_profile.html.erb
|
65
65
|
- app/views/seo_page_extender/open_graph/_video.html.erb
|
66
66
|
- lib/scrivito_seo_page_extender.rb
|
67
|
+
- lib/scrivito_seo_page_extender/configuration.rb
|
67
68
|
- lib/scrivito_seo_page_extender/engine.rb
|
68
69
|
- lib/scrivito_seo_page_extender/version.rb
|
69
70
|
- lib/tasks/scrivito_seo_page_extender_tasks.rake
|