seo_sensei 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/seo_sensei/attributes/image.rb +3 -3
- data/lib/seo_sensei/attributes/twitter.rb +6 -8
- data/lib/seo_sensei/controllers/helpers.rb +8 -8
- data/lib/seo_sensei/resource.rb +67 -0
- data/lib/seo_sensei/seo_attributes.rb +30 -0
- data/lib/seo_sensei/version.rb +1 -1
- data/lib/seo_sensei.rb +2 -1
- metadata +3 -2
- data/lib/seo_sensei/attributes/og.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 039b4d7451379832e9b2dde51b174b8161cea974f920b0dd04052721c84c6431
|
4
|
+
data.tar.gz: 40e9ed89593176b74804b78efc7faef877b5939f178d94dd4af8a7759c081f21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adeb0f223ca94b05663a02883c9f7b29086de23acfcb817f53adb2e994d3a20ff24cf7bb5a1d22164f32bdef5990354f3a416d5c9ef8b42747cca1f146654f4d
|
7
|
+
data.tar.gz: b37e1f5be403af45fa7d72cc364774f56712a40a8aed9357e5009efc098171d7730a9d50717cca482146154d012b864879e0c0aa0c2804dbcdbbeb0ea59cdced
|
@@ -4,12 +4,12 @@ module SeoSensei
|
|
4
4
|
module Attributes
|
5
5
|
module Image
|
6
6
|
def self.call(resource)
|
7
|
-
return {} unless resource.
|
7
|
+
return {} unless resource.use_image?
|
8
8
|
|
9
9
|
{
|
10
10
|
image: resource.seo_image_url,
|
11
|
-
"image:width" => resource.
|
12
|
-
"image:height" => resource.
|
11
|
+
"image:width" => resource.seo_image_width,
|
12
|
+
"image:height" => resource.seo_image_height
|
13
13
|
}
|
14
14
|
end
|
15
15
|
end
|
@@ -3,18 +3,16 @@
|
|
3
3
|
module SeoSensei
|
4
4
|
module Attributes
|
5
5
|
module Twitter
|
6
|
-
def self.call(
|
7
|
-
image_attributes = SeoSensei::Attributes::Image.call(resource)
|
8
|
-
|
6
|
+
def self.call(resource)
|
9
7
|
base_attributes = {
|
10
|
-
title:
|
11
|
-
description:
|
12
|
-
url: url
|
8
|
+
title: resource.title,
|
9
|
+
description: resource.description,
|
10
|
+
url: resource.url
|
13
11
|
}
|
14
12
|
|
15
|
-
|
13
|
+
if resource.use_image?
|
16
14
|
base_attributes.merge!(
|
17
|
-
image:
|
15
|
+
image: resource.seo_image_url,
|
18
16
|
card: 'summary_large_image'
|
19
17
|
)
|
20
18
|
end
|
@@ -10,7 +10,11 @@ module SeoSensei
|
|
10
10
|
before_action(options) do
|
11
11
|
resource_name = options.delete(:for) || controller_name
|
12
12
|
if (translated_seo = ::SeoSensei::Lookup.call(controller_name: resource_name, action_name: action_name))
|
13
|
-
|
13
|
+
attributes_service = ::SeoSensei::SeoAttributes.new(
|
14
|
+
translated_seo, nil, url_for(only_path: false)
|
15
|
+
)
|
16
|
+
|
17
|
+
set_meta_tags(attributes_service.call)
|
14
18
|
end
|
15
19
|
end
|
16
20
|
end
|
@@ -24,15 +28,11 @@ module SeoSensei
|
|
24
28
|
|
25
29
|
def seo_tags_with(resource)
|
26
30
|
if (translated_seo = ::SeoSensei::Lookup.call(controller_name: controller_name, action_name: action_name, resource: resource))
|
27
|
-
|
28
|
-
translated_seo, resource, url_for(:
|
29
|
-
)
|
30
|
-
|
31
|
-
twitter_attributes = ::SeoSensei::Attributes::Twitter.call(
|
32
|
-
translated_seo, resource, url_for(:only_path => false)
|
31
|
+
attributes_service = ::SeoSensei::SeoAttributes.new(
|
32
|
+
translated_seo, resource, url_for(only_path: false)
|
33
33
|
)
|
34
34
|
|
35
|
-
set_meta_tags(
|
35
|
+
set_meta_tags(attributes_service.call)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module SeoSensei
|
2
|
+
class Resource
|
3
|
+
def initialize(translation, obj, url)
|
4
|
+
@translation = translation
|
5
|
+
@obj = obj
|
6
|
+
@url = url
|
7
|
+
end
|
8
|
+
|
9
|
+
def url
|
10
|
+
@url
|
11
|
+
end
|
12
|
+
|
13
|
+
def title
|
14
|
+
@translation['title']
|
15
|
+
end
|
16
|
+
|
17
|
+
def description
|
18
|
+
@translation['description']
|
19
|
+
end
|
20
|
+
|
21
|
+
def keywords
|
22
|
+
@translation['keywords']
|
23
|
+
end
|
24
|
+
|
25
|
+
def use_image?
|
26
|
+
use_obj_image? || use_translation_image?
|
27
|
+
end
|
28
|
+
|
29
|
+
def seo_image_url
|
30
|
+
if use_obj_image?
|
31
|
+
@obj.seo_image_url
|
32
|
+
elsif use_translation_image?
|
33
|
+
@translation['seo_image_url']
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def seo_image_width
|
38
|
+
if use_obj_image?
|
39
|
+
@obj.seo_image_dimensions[:width].to_s
|
40
|
+
elsif use_translation_image?
|
41
|
+
@translation['seo_image_width']
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def seo_image_height
|
46
|
+
if use_obj_image?
|
47
|
+
@obj.seo_image_dimensions[:height].to_s
|
48
|
+
elsif use_translation_image?
|
49
|
+
@translation['seo_image_height']
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def use_obj_image?
|
56
|
+
!@obj.nil? &&
|
57
|
+
@obj.respond_to?(:use_seo_image?) &&
|
58
|
+
@obj.use_seo_image?
|
59
|
+
end
|
60
|
+
|
61
|
+
def use_translation_image?
|
62
|
+
!@translation['seo_image_url'].nil? &&
|
63
|
+
!@translation['seo_image_width'].nil? &&
|
64
|
+
!@translation['seo_image_height'].nil?
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module SeoSensei
|
2
|
+
class SeoAttributes
|
3
|
+
def initialize(translation, obj, url)
|
4
|
+
@translation = translation
|
5
|
+
@obj = obj
|
6
|
+
@url = url
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
attributes = {}
|
11
|
+
|
12
|
+
image_attributes = SeoSensei::Attributes::Image.call(resource)
|
13
|
+
twitter_attributes = SeoSensei::Attributes::Twitter.call(resource)
|
14
|
+
|
15
|
+
{
|
16
|
+
og: {
|
17
|
+
title: resource.title,
|
18
|
+
description: resource.description,
|
19
|
+
url: resource.url
|
20
|
+
}.merge(image_attributes)
|
21
|
+
}.merge(twitter_attributes)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def resource
|
27
|
+
@resource ||= SeoSensei::Resource.new(@translation, @obj, @url)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/seo_sensei/version.rb
CHANGED
data/lib/seo_sensei.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'meta-tags'
|
4
|
+
require 'seo_sensei/seo_attributes'
|
5
|
+
require 'seo_sensei/resource'
|
4
6
|
require 'seo_sensei/attributes/twitter'
|
5
|
-
require 'seo_sensei/attributes/og'
|
6
7
|
require 'seo_sensei/attributes/image'
|
7
8
|
require 'seo_sensei/lookup'
|
8
9
|
require 'seo_sensei/controllers/helpers'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seo_sensei
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paweł Dąbrowski
|
@@ -84,7 +84,6 @@ files:
|
|
84
84
|
- lib/generators/templates/seo_sensei.rb
|
85
85
|
- lib/seo_sensei.rb
|
86
86
|
- lib/seo_sensei/attributes/image.rb
|
87
|
-
- lib/seo_sensei/attributes/og.rb
|
88
87
|
- lib/seo_sensei/attributes/twitter.rb
|
89
88
|
- lib/seo_sensei/controllers/helpers.rb
|
90
89
|
- lib/seo_sensei/lookup.rb
|
@@ -94,6 +93,8 @@ files:
|
|
94
93
|
- lib/seo_sensei/lookups/translation_attributes.rb
|
95
94
|
- lib/seo_sensei/models/helpers.rb
|
96
95
|
- lib/seo_sensei/models/seo_tag.rb
|
96
|
+
- lib/seo_sensei/resource.rb
|
97
|
+
- lib/seo_sensei/seo_attributes.rb
|
97
98
|
- lib/seo_sensei/version.rb
|
98
99
|
homepage: http://github.com/rubyhero/seo_sensei
|
99
100
|
licenses:
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SeoSensei
|
4
|
-
module Attributes
|
5
|
-
module Og
|
6
|
-
def self.call(seo_translation, resource, url)
|
7
|
-
image_attributes = SeoSensei::Attributes::Image.call(resource)
|
8
|
-
|
9
|
-
base_attributes = {
|
10
|
-
title: seo_translation['title'],
|
11
|
-
description: seo_translation['description'],
|
12
|
-
url: url
|
13
|
-
}
|
14
|
-
|
15
|
-
{ og: base_attributes.merge(image_attributes) }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|