scrivito_seo_page_extender 1.2.3 → 1.2.4

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: 0485fe86a66891c0b92217114d06944382f32f27
4
- data.tar.gz: 38d27823cf7f66f898b1688b3c28d06ec085dc7c
3
+ metadata.gz: 0105bcb9b2c5a5cd6b22daabc25c79d42fb0a33a
4
+ data.tar.gz: 581cde117affcdccd29d069166cdfb5f3a51a003
5
5
  SHA512:
6
- metadata.gz: 7df5b6363893ea9abcef3d82d33a2aa97b97bc1c6328560f2dcba86a0a450a9dd3bc0721ea48854e5c7b0a7bf88745e2e4758d69757e2b8db2be0cdaa16380bb
7
- data.tar.gz: e364531b187b1e9d857b3d8e4b863650ffcfe3f16a7b3f95a9f26a3adae50094d1def53e52ccf0cddea2cb8b4cd0daea00e71be6be12c7bd0a4ff09ea344ea88
6
+ metadata.gz: 3584bbcb4ed86ee94b656d30a478d9f77f95474d2325f87237e5263d90406b900d810ddb81ba7c99ec8524c955830e064eb9db6311f5610b83347818fc382df9
7
+ data.tar.gz: b804d98d32280e21becff068c4902df5e41c2541d28916867368fae140957e13b3e099287a3c3f3159d076cd693852e6a1eaa197606996a9b72a10bdc7ebf1d8
data/README.md CHANGED
@@ -164,6 +164,7 @@ def self.seo_attribute_mapping(obj)
164
164
  {
165
165
  og_title: obj.my_app_title,
166
166
  og_description: obj.my_app_description
167
+ og_image: Obj.where(:title, :equals, 'Logo').first
167
168
  ...
168
169
  }
169
170
  end
@@ -269,5 +270,4 @@ en:
269
270
  three_words: 'Three word phrases'
270
271
  two_words: 'Two word phrases'
271
272
  word: 'Word'
272
-
273
273
  ```
@@ -43,17 +43,5 @@ module OpenGraphExtender
43
43
  base.attribute :music_duration, :string
44
44
  base.attribute :music_musician, :stringlist
45
45
  base.attribute :music_song, :stringlist
46
-
47
- def image_width
48
- self.og_image.meta_data[:width]
49
- end
50
-
51
- def image_height
52
- self.og_image.meta_data[:height]
53
- end
54
-
55
- def image_type
56
- self.og_image.meta_data[:content_type]
57
- end
58
46
  end
59
47
  end
@@ -19,6 +19,7 @@ module SeoPageExtenderHelper
19
19
  end
20
20
 
21
21
  def seo_attribute_fallback(obj, attribute)
22
+ return unless obj.respond_to?(attribute)
22
23
  if seo_attribute_fallback?(obj, attribute)
23
24
  seo_attribute_mapping(obj)[attribute]
24
25
  else
@@ -26,10 +27,24 @@ module SeoPageExtenderHelper
26
27
  end
27
28
  end
28
29
 
30
+ def image_width(obj)
31
+ obj.meta_data[:width]
32
+ end
33
+
34
+ def image_height(obj)
35
+ obj.meta_data[:height]
36
+ end
37
+
38
+ def image_type(obj)
39
+ obj.binary_content_type
40
+ end
41
+
29
42
  private
30
43
  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?
44
+ # mapping is active && attribute is included to obj
45
+ if ScrivitoSeoPageExtender.configuration.attribute_mapping && obj.respond_to?(attribute)
46
+ !obj.send(attribute.to_sym).present? && (seo_attribute_mapping(obj)[attribute]).present?
47
+ end
33
48
  end
34
49
 
35
50
  def get_words_from_page(obj, attribute)
@@ -1,9 +1,11 @@
1
- <% if @obj.respond_to?(attribute) && seo_attribute_fallback(@obj, attribute.to_sym).present? %>
1
+ <% fallback = seo_attribute_fallback(@obj, attribute.to_sym) %>
2
+
3
+ <% if @obj.respond_to?(attribute) && fallback.present? %>
2
4
  <% if name[/image\d?$/] %>
3
- <meta content="<%= scrivito_path(@obj[attribute]) %>" name="<%= name %>"/>
5
+ <meta content="<%= scrivito_url(fallback) %>" name="<%= name %>"/>
4
6
  <% elsif name == 'audience' || name == 'robots' || name == 'keywords' %>
5
- <meta content="<%= @obj.send(attribute).join(',') %>" name="<%= name %>"/>
7
+ <meta content="<%= seo_attribute_fallback(@obj, attribute).join(',') %>" name="<%= name %>"/>
6
8
  <% else %>
7
- <meta content="<%= seo_attribute_fallback(@obj, attribute.to_sym) %>" name="<%= name %>"/>
9
+ <meta content="<%= fallback %>" name="<%= name %>"/>
8
10
  <% end %>
9
11
  <% end %>
@@ -1,10 +1,12 @@
1
- <% if @obj.respond_to?(attribute) && seo_attribute_fallback(@obj, attribute.to_sym).present? %>
1
+ <% fallback = seo_attribute_fallback(@obj, attribute.to_sym) %>
2
+
3
+ <% if @obj.respond_to?(attribute) && fallback.present? %>
2
4
  <% if attribute == 'og_image' %>
3
- <meta content="<%= scrivito_path(@obj[attribute]) %>" property="<%= name %>"/>
4
- <meta content="<%= @obj.image_type %>" property="og:image:type"/>
5
- <meta content="<%= @obj.image_width %>" property="og:image:width"/>
6
- <meta content="<%= @obj.image_height %>" property="og:image:height"/>
5
+ <meta content="<%= scrivito_url(fallback) %>" property="<%= name %>"/>
6
+ <meta content="<%= image_type(fallback) %>" property="og:image:type"/>
7
+ <meta content="<%= image_width(fallback) %>" property="og:image:width"/>
8
+ <meta content="<%= image_height(fallback) %>" property="og:image:height"/>
7
9
  <% else %>
8
- <meta content="<%= seo_attribute_fallback(@obj, attribute.to_sym) %>" property="<%= name %>"/>
10
+ <meta content="<%= fallback %>" property="<%= name %>"/>
9
11
  <% end %>
10
12
  <% end %>
@@ -1,5 +1,5 @@
1
- <% if @obj.respond_to?(attribute) && !@obj.send(attribute).blank? %>
2
- <% @obj[attribute].each do |obj| %>
1
+ <% if @obj.respond_to?(attribute) && seo_attribute_fallback(@obj, attribute).present? %>
2
+ <% seo_attribute_fallback(@obj, attribute).each do |obj| %>
3
3
  <% if !obj.is_a? String %>
4
4
  <meta content="<%= scrivito_path(obj) %>" property="<%= name %>"/>
5
5
  <% if obj.is_a? Image %>
@@ -1,5 +1,5 @@
1
- <% if(@obj.respond_to?(attribute) && !@obj.send(attribute).blank?) %>
2
- <meta content="<%= @obj.send(attribute).join(',') %>" name="robots" />
1
+ <% if(@obj.respond_to?(attribute) && seo_attribute_fallback(@obj, attribute).present?) %>
2
+ <meta content="<%= seo_attribute_fallback(@obj, attribute).join(',') %>" name="robots" />
3
3
  <% else %>
4
4
  <meta content="all" name="robots" />
5
5
  <% end %>
@@ -42,5 +42,5 @@
42
42
  <meta content="<%= canonical_link(@obj) %>" property="og:url"/>
43
43
 
44
44
  <% if Obj.respond_to? 'open_graph_site_name' %>
45
- <meta content="<%= Obj.open_graph_site_name %>" property="og:sitename"/>
45
+ <meta content="<%= Obj.open_graph_site_name %>" property="og:site_name"/>
46
46
  <% end %>
@@ -1,7 +1,7 @@
1
- <% if @obj.respond_to?(attribute) && !@obj.send(attribute).blank? %>
1
+ <% if @obj.respond_to?(attribute) && seo_attribute_fallback(@obj, attribute).present? %>
2
2
  <% if name[/image\d?$/] %>
3
- <meta content="<%= scrivito_path(@obj[attribute]) %>" name="<%= name %>"/>
3
+ <meta content="<%= scrivito_path(seo_attribute_fallback(@obj, attribute)) %>" name="<%= name %>"/>
4
4
  <% else %>
5
- <meta content="<%= @obj.send(attribute).tr("\u00a0", ' ').strip %>" property="<%= name %>"/>
5
+ <meta content="<%= seo_attribute_fallback(@obj, attribute).tr("\u00a0", ' ').strip %>" property="<%= name %>"/>
6
6
  <% end %>
7
7
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module ScrivitoSeoPageExtender
2
- VERSION = "1.2.3"
2
+ VERSION = "1.2.4"
3
3
  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: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scrivito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-30 00:00:00.000000000 Z
11
+ date: 2017-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: scrivito_sdk