seorel 0.3.0 → 0.4.0
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/README.md +2 -0
- data/lib/generators/seorel/install_generator.rb +12 -4
- data/lib/generators/seorel/templates/globalize_migration.rb +13 -0
- data/lib/generators/seorel/templates/initializer.rb +29 -1
- data/lib/generators/seorel/templates/migration.rb +2 -2
- data/lib/seorel.rb +2 -0
- data/lib/seorel/configuration.rb +10 -7
- data/lib/seorel/controller/class_methods.rb +3 -1
- data/lib/seorel/controller/instance_methods.rb +3 -1
- data/lib/seorel/controller/params.rb +55 -49
- data/lib/seorel/engine.rb +2 -0
- data/lib/seorel/globalize.rb +17 -0
- data/lib/seorel/helper.rb +2 -0
- data/lib/seorel/helper/base.rb +6 -4
- data/lib/seorel/helper/generic.rb +11 -3
- data/lib/seorel/helper/manager.rb +3 -1
- data/lib/seorel/helper/open_graph.rb +9 -7
- data/lib/seorel/helper/twitter.rb +8 -6
- data/lib/seorel/model/base.rb +9 -2
- data/lib/seorel/model/class_methods.rb +2 -0
- data/lib/seorel/model/instance_methods.rb +13 -11
- data/lib/seorel/seorel.rb +7 -5
- data/lib/seorel/seorelify.rb +2 -0
- data/lib/seorel/version.rb +3 -1
- data/lib/tasks/seorel_tasks.rake +2 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c479f1d7dfaa791665b2a20d1a5ef1c2baa7f63
|
4
|
+
data.tar.gz: 2380c00e8e501060c1d35f989032d55e3bd6d381
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4dbcdcfb0364e06169211ca40126399386aba10ad4b873d8d9eacf781a1d3c11c64a23ee20116afe81200bd2c4bbc130f92b4a055a08fa7c212b93e8ce1ca82
|
7
|
+
data.tar.gz: d4aee49ecda37866939270ad873c169f44c94eeebfabe20abbf97614d5f4b5856f5a42b22f6a21d17183a91d3be53c3f2145611724e11b18bbe84fb56ed13133
|
data/README.md
CHANGED
@@ -41,6 +41,8 @@ Seorel.configure do |config|
|
|
41
41
|
# config.default_prepend_description = nil
|
42
42
|
# config.default_append_description = nil
|
43
43
|
|
44
|
+
config.default_keywords = 'RUBY ON RAILS,SEO,METATAGS'
|
45
|
+
|
44
46
|
config.default_image = 'http://www.example.com/share_image.png'
|
45
47
|
|
46
48
|
# config.store_seorel_if = :empty # Available values :empty | :changed
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'rails/generators'
|
2
|
-
require
|
2
|
+
require 'rails/generators/active_record'
|
3
3
|
|
4
4
|
module Seorel
|
5
5
|
# This generator adds a migration and aa configuration initializer
|
@@ -9,13 +9,21 @@ module Seorel
|
|
9
9
|
|
10
10
|
class_option :'skip-migration', type: :boolean, desc: "Don't generate a migration for the seorel table"
|
11
11
|
class_option :'skip-initializer', type: :boolean, desc: "Don't generate an initializer"
|
12
|
+
class_option :globalize, type: :boolean, desc: "Don't generate an initializer"
|
12
13
|
|
13
14
|
source_root File.expand_path('../templates', __FILE__)
|
14
15
|
|
15
16
|
# Copies the migration template to db/migrate.
|
16
|
-
def
|
17
|
+
def create_main_migration
|
17
18
|
return if options['skip-migration']
|
18
|
-
migration_template 'migration.rb', 'db/migrate/
|
19
|
+
migration_template 'migration.rb', 'db/migrate/create_seorel.rb'
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_globalize_migration
|
23
|
+
if options['globalize']
|
24
|
+
migration_template 'globalize_migration.rb',
|
25
|
+
'db/migrate/create_seorel_translations.rb'
|
26
|
+
end
|
19
27
|
end
|
20
28
|
|
21
29
|
def create_initializer
|
@@ -23,7 +31,7 @@ module Seorel
|
|
23
31
|
copy_file 'initializer.rb', 'config/initializers/seorel.rb'
|
24
32
|
end
|
25
33
|
|
26
|
-
def
|
34
|
+
def create_locale_file
|
27
35
|
copy_file 'seorel.en.yml', 'config/locales/seorel.en.yml'
|
28
36
|
end
|
29
37
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateSeorelTranslations < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
Seorel::Seorel.create_translation_table!({
|
4
|
+
title: :string,
|
5
|
+
description: :string,
|
6
|
+
image: :string
|
7
|
+
}, migrate_data: true)
|
8
|
+
end
|
9
|
+
|
10
|
+
def down
|
11
|
+
Seorel::Seorel.drop_translation_table!
|
12
|
+
end
|
13
|
+
end
|
@@ -1,21 +1,49 @@
|
|
1
|
-
#
|
1
|
+
# Decomment this line if you want to use Globalize to magage seo translations
|
2
|
+
# require 'seorel/globalize'
|
3
|
+
|
4
|
+
# Seorel configurations:
|
2
5
|
Seorel.configure do |config|
|
6
|
+
###
|
7
|
+
# Title meta tag configurations:
|
8
|
+
#
|
3
9
|
# config.default_prepend_title = nil
|
4
10
|
# config.default_title = nil
|
5
11
|
# config.default_append_title = nil
|
12
|
+
|
13
|
+
###
|
14
|
+
# Description meta tag configurations:
|
6
15
|
#
|
7
16
|
# config.default_prepend_description = nil
|
8
17
|
# config.default_description = nil
|
9
18
|
# config.default_append_description = nil
|
19
|
+
|
20
|
+
###
|
21
|
+
# Configure a default meta keywords:
|
22
|
+
#
|
23
|
+
# config.default_keywords = 'Ruby on Rails,Seorel,SEO'
|
24
|
+
|
25
|
+
###
|
26
|
+
# Configure a default share image:
|
10
27
|
#
|
11
28
|
# config.default_image = nil
|
29
|
+
|
30
|
+
###
|
31
|
+
# Choose when to save seorel meta tags:
|
32
|
+
# - `:empty` Store values only if title o description are empty
|
33
|
+
# - `:changed` Store values on every record save
|
12
34
|
#
|
13
35
|
# config.store_seorel_if = :empty # Available values :empty | :changed
|
14
36
|
|
37
|
+
###
|
38
|
+
# Add custom Open Graph meta tags:
|
39
|
+
#
|
15
40
|
# config.default_og_metas = {
|
16
41
|
# type: 'website'
|
17
42
|
# }
|
18
43
|
|
44
|
+
###
|
45
|
+
# Add custom Twitter card meta tags:
|
46
|
+
#
|
19
47
|
# config.default_twitter_metas = {
|
20
48
|
# card: 'summary_large_image'
|
21
49
|
# }
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class CreateSeorel < ActiveRecord::Migration[4.2]
|
2
2
|
def self.up
|
3
3
|
create_table :seorel_seorels do |t|
|
4
4
|
t.string :title
|
@@ -9,7 +9,7 @@ class CreateSeorelSeorels < ActiveRecord::Migration
|
|
9
9
|
t.timestamps
|
10
10
|
end
|
11
11
|
|
12
|
-
add_index :seorel_seorels, [
|
12
|
+
add_index :seorel_seorels, %i[seorelable_id seorelable_type]
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.down
|
data/lib/seorel.rb
CHANGED
data/lib/seorel/configuration.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# encoding: utf-8
|
3
|
+
|
2
4
|
require 'active_support/configurable'
|
3
5
|
|
4
6
|
module Seorel
|
@@ -11,6 +13,7 @@ module Seorel
|
|
11
13
|
config_accessor :default_prepend_description
|
12
14
|
config_accessor :default_description
|
13
15
|
config_accessor :default_append_description
|
16
|
+
config_accessor :default_keywords
|
14
17
|
config_accessor :default_image
|
15
18
|
config_accessor :store_seorel_if
|
16
19
|
config_accessor :default_og_metas
|
@@ -21,17 +24,19 @@ module Seorel
|
|
21
24
|
end
|
22
25
|
|
23
26
|
# define param_name writer (copied from AS::Configurable)
|
24
|
-
writer
|
27
|
+
writer = 'def param_name=(value); config.param_name = value; end'
|
28
|
+
line = __LINE__
|
25
29
|
singleton_class.class_eval writer, __FILE__, line
|
26
30
|
class_eval writer, __FILE__, line
|
27
31
|
|
28
32
|
def initialize_defaults
|
29
33
|
self.default_prepend_title = nil
|
30
34
|
self.default_title = nil
|
31
|
-
self.default_append_title
|
35
|
+
self.default_append_title = nil
|
32
36
|
self.default_prepend_description = nil
|
33
37
|
self.default_description = nil
|
34
|
-
self.default_append_description
|
38
|
+
self.default_append_description = nil
|
39
|
+
self.default_keywords = {}
|
35
40
|
self.default_image = nil
|
36
41
|
self.store_seorel_if = :empty
|
37
42
|
self.default_og_metas = {}
|
@@ -41,16 +46,14 @@ module Seorel
|
|
41
46
|
|
42
47
|
# Global settings for Seorel
|
43
48
|
def self.config
|
44
|
-
@config ||= ::Seorel::Configuration.new.tap
|
45
|
-
conf.initialize_defaults
|
46
|
-
end
|
49
|
+
@config ||= ::Seorel::Configuration.new.tap(&:initialize_defaults)
|
47
50
|
end
|
48
51
|
|
49
52
|
# Configures global settings for Seorel
|
50
53
|
# Seorel.configure do |config|
|
51
54
|
# config.default_default_title = 'Default website title'
|
52
55
|
# end
|
53
|
-
def self.configure
|
56
|
+
def self.configure
|
54
57
|
yield(config)
|
55
58
|
end
|
56
59
|
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# encoding: utf-8
|
3
|
+
|
2
4
|
module Seorel
|
3
5
|
module Controller
|
4
6
|
module ClassMethods
|
5
7
|
def add_seorel_meta(values = {})
|
6
|
-
class_name =
|
8
|
+
class_name = name
|
7
9
|
|
8
10
|
before_filter options do |controller|
|
9
11
|
controller.send :add_meta, values
|
@@ -1,4 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# encoding: utf-8
|
3
|
+
|
2
4
|
module Seorel
|
3
5
|
module Controller
|
4
6
|
module InstanceMethods
|
@@ -8,7 +10,7 @@ module Seorel
|
|
8
10
|
elsif obj.respond_to? :seorel
|
9
11
|
add_seorel_model obj
|
10
12
|
else
|
11
|
-
raise
|
13
|
+
raise 'Seorel `add_seorel_meta` invalid argument'
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
@@ -1,4 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# encoding: utf-8
|
3
|
+
|
2
4
|
require 'active_support/configurable'
|
3
5
|
|
4
6
|
module Seorel
|
@@ -16,20 +18,24 @@ module Seorel
|
|
16
18
|
|
17
19
|
def title
|
18
20
|
[
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
lookup_prepend_title,
|
22
|
+
base_title,
|
23
|
+
lookup_append_title
|
22
24
|
].compact.join.html_safe
|
23
25
|
end
|
24
26
|
|
25
27
|
def description
|
26
28
|
[
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
lookup_prepend_description,
|
30
|
+
base_description,
|
31
|
+
lookup_append_description
|
30
32
|
].compact.join.html_safe
|
31
33
|
end
|
32
34
|
|
35
|
+
def keywords
|
36
|
+
default_options.default_keywords
|
37
|
+
end
|
38
|
+
|
33
39
|
def image
|
34
40
|
config.image || default_options.default_image
|
35
41
|
end
|
@@ -44,63 +50,63 @@ module Seorel
|
|
44
50
|
|
45
51
|
protected
|
46
52
|
|
47
|
-
|
53
|
+
attr_reader :controller
|
48
54
|
|
49
|
-
|
50
|
-
|
51
|
-
|
55
|
+
def base_title
|
56
|
+
(config.title || lookup_title).html_safe
|
57
|
+
end
|
52
58
|
|
53
|
-
|
54
|
-
|
55
|
-
|
59
|
+
def base_description
|
60
|
+
(config.description || lookup_description).html_safe
|
61
|
+
end
|
56
62
|
|
57
|
-
|
58
|
-
|
59
|
-
|
63
|
+
def default_options
|
64
|
+
::Seorel.config
|
65
|
+
end
|
60
66
|
|
61
|
-
|
62
|
-
|
63
|
-
|
67
|
+
def lookup_i18n(key, default = nil)
|
68
|
+
I18n.t i18n_path(key), default: (default || '')
|
69
|
+
end
|
64
70
|
|
65
|
-
|
66
|
-
|
67
|
-
|
71
|
+
def lookup_prepend_title
|
72
|
+
lookup_i18n :prepend_title, default_options.default_prepend_title
|
73
|
+
end
|
68
74
|
|
69
|
-
|
70
|
-
|
71
|
-
|
75
|
+
def lookup_title
|
76
|
+
lookup_i18n :title, default_options.default_title
|
77
|
+
end
|
72
78
|
|
73
|
-
|
74
|
-
|
75
|
-
|
79
|
+
def lookup_append_title
|
80
|
+
lookup_i18n :append_title, default_options.default_append_title
|
81
|
+
end
|
76
82
|
|
77
|
-
|
78
|
-
|
79
|
-
|
83
|
+
def lookup_prepend_description
|
84
|
+
lookup_i18n :prepend_description, default_options.default_prepend_description
|
85
|
+
end
|
80
86
|
|
81
|
-
|
82
|
-
|
83
|
-
|
87
|
+
def lookup_description
|
88
|
+
lookup_i18n :description, default_options.default_description
|
89
|
+
end
|
84
90
|
|
85
|
-
|
86
|
-
|
87
|
-
|
91
|
+
def lookup_append_description
|
92
|
+
lookup_i18n :append_description, default_options.default_append_description
|
93
|
+
end
|
88
94
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
end
|
95
|
+
def controller_name
|
96
|
+
if controller
|
97
|
+
controller.class.name.underscore.gsub(/_controller$/, '')
|
98
|
+
else
|
99
|
+
'undefined'
|
95
100
|
end
|
101
|
+
end
|
96
102
|
|
97
|
-
|
98
|
-
|
99
|
-
|
103
|
+
def action_name
|
104
|
+
controller ? controller.action_name : 'undefined'
|
105
|
+
end
|
100
106
|
|
101
|
-
|
102
|
-
|
103
|
-
|
107
|
+
def i18n_path(key)
|
108
|
+
['seorel', controller_name, action_name, key].join('.')
|
109
|
+
end
|
104
110
|
end
|
105
111
|
end
|
106
112
|
end
|
data/lib/seorel/engine.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'globalize'
|
4
|
+
require 'seorel/seorel'
|
5
|
+
require 'active_support/concern'
|
6
|
+
|
7
|
+
module Seorel
|
8
|
+
module Globalize
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
included do
|
12
|
+
translates :title, :description, :image
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
Seorel::Seorel.include Seorel::Globalize
|
data/lib/seorel/helper.rb
CHANGED
data/lib/seorel/helper/base.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# encoding: utf-8
|
3
|
+
|
1
4
|
# require 'action_view/helpers/tag_helper/capture_helper'
|
2
5
|
# require 'action_view/helpers/tag_helper'
|
3
6
|
|
4
|
-
# encoding: utf-8
|
5
7
|
module Seorel
|
6
8
|
module Helper
|
7
9
|
class Base
|
@@ -20,10 +22,10 @@ module Seorel
|
|
20
22
|
ActionController::Base.helpers
|
21
23
|
end
|
22
24
|
|
23
|
-
|
25
|
+
alias h helpers
|
24
26
|
|
25
|
-
# def h.
|
26
|
-
# ActionView::Helpers::TagHelper.h.
|
27
|
+
# def h.tag(*args)
|
28
|
+
# ActionView::Helpers::TagHelper.h.tag(*args)
|
27
29
|
# end
|
28
30
|
|
29
31
|
def locale
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# encoding: utf-8
|
3
|
+
|
1
4
|
require 'seorel/helper/base'
|
2
5
|
|
3
|
-
# encoding: utf-8
|
4
6
|
module Seorel
|
5
7
|
module Helper
|
6
8
|
class Generic < Base
|
@@ -9,13 +11,19 @@ module Seorel
|
|
9
11
|
end
|
10
12
|
|
11
13
|
def description_tag
|
12
|
-
h.
|
14
|
+
h.tag :meta, name: 'description', content: params.description
|
15
|
+
end
|
16
|
+
|
17
|
+
def keywords_tag
|
18
|
+
return if params.keywords.blank?
|
19
|
+
h.tag :meta, name: 'keywords', content: params.keywords
|
13
20
|
end
|
14
21
|
|
15
22
|
def all
|
16
23
|
[
|
17
24
|
title_tag,
|
18
|
-
description_tag
|
25
|
+
description_tag,
|
26
|
+
keywords_tag
|
19
27
|
].compact
|
20
28
|
end
|
21
29
|
end
|
@@ -1,27 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# encoding: utf-8
|
3
|
+
|
1
4
|
require 'seorel/helper/base'
|
2
5
|
|
3
|
-
# encoding: utf-8
|
4
6
|
module Seorel
|
5
7
|
module Helper
|
6
8
|
class OpenGraph < Base
|
7
9
|
def title_tag
|
8
|
-
h.
|
10
|
+
h.tag :meta, property: 'og:title', content: title
|
9
11
|
end
|
10
12
|
|
11
13
|
def description_tag
|
12
|
-
h.
|
14
|
+
h.tag :meta, property: 'og:description', content: description
|
13
15
|
end
|
14
16
|
|
15
17
|
def locale_tag
|
16
|
-
h.
|
18
|
+
h.tag(:meta, property: 'og:locale', content: locale)
|
17
19
|
end
|
18
20
|
|
19
21
|
def image_tag
|
20
|
-
h.
|
22
|
+
h.tag(:meta, property: 'og:image', content: image_url) if image
|
21
23
|
end
|
22
24
|
|
23
25
|
def url_tag
|
24
|
-
h.
|
26
|
+
h.tag(:meta, property: 'og:url', content: request.url)
|
25
27
|
end
|
26
28
|
|
27
29
|
def custom_tags
|
@@ -43,7 +45,7 @@ module Seorel
|
|
43
45
|
protected
|
44
46
|
|
45
47
|
def custum_tag(key, value)
|
46
|
-
h.
|
48
|
+
h.tag(:meta, property: "og:#{key}", content: value)
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
@@ -1,23 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# encoding: utf-8
|
3
|
+
|
1
4
|
require 'seorel/helper/base'
|
2
5
|
|
3
|
-
# encoding: utf-8
|
4
6
|
module Seorel
|
5
7
|
module Helper
|
6
8
|
class Twitter < Base
|
7
9
|
def title_tag
|
8
|
-
h.
|
10
|
+
h.tag :meta, name: 'twitter:title', content: title
|
9
11
|
end
|
10
12
|
|
11
13
|
def description_tag
|
12
|
-
h.
|
14
|
+
h.tag :meta, name: 'twitter:description', content: description
|
13
15
|
end
|
14
16
|
|
15
17
|
def image_tag
|
16
|
-
h.
|
18
|
+
h.tag(:meta, name: 'twitter:image', content: image_url) if image
|
17
19
|
end
|
18
20
|
|
19
21
|
def url_tag
|
20
|
-
h.
|
22
|
+
h.tag(:meta, name: 'twitter:url', content: request.url)
|
21
23
|
end
|
22
24
|
|
23
25
|
def custom_tags
|
@@ -38,7 +40,7 @@ module Seorel
|
|
38
40
|
protected
|
39
41
|
|
40
42
|
def custum_tag(key, value)
|
41
|
-
h.
|
43
|
+
h.tag(:meta, name: "twitter:#{key}", content: value)
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end
|
data/lib/seorel/model/base.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# encoding: utf-8
|
3
|
+
|
2
4
|
module Seorel
|
3
5
|
module Model
|
4
6
|
module Base
|
@@ -18,11 +20,16 @@ module Seorel
|
|
18
20
|
class_variable_set '@@seorel_image_field', args[2]
|
19
21
|
end
|
20
22
|
|
21
|
-
has_one :seorel, as: :seorelable,
|
23
|
+
has_one :seorel, as: :seorelable,
|
24
|
+
dependent: :destroy,
|
25
|
+
class_name: 'Seorel::Seorel',
|
26
|
+
autosave: true,
|
27
|
+
inverse_of: :seorelable
|
28
|
+
|
22
29
|
accepts_nested_attributes_for :seorel, allow_destroy: true
|
23
30
|
|
24
31
|
delegate :title, :title?, :description, :description?, :image, :image?,
|
25
|
-
|
32
|
+
to: :seorel, prefix: :seo, allow_nil: true
|
26
33
|
|
27
34
|
before_save :set_seorel
|
28
35
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# encoding: utf-8
|
3
|
+
|
2
4
|
module Seorel
|
3
5
|
module Model
|
4
6
|
module InstanceMethods
|
5
7
|
def seorel?
|
6
|
-
|
8
|
+
try(:seorel).present?
|
7
9
|
end
|
8
10
|
|
9
11
|
def seorel_changed_mode?
|
@@ -11,37 +13,37 @@ module Seorel
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def should_update_seo_title?
|
14
|
-
|
16
|
+
seorel_changed_mode? || !seo_title?
|
15
17
|
end
|
16
18
|
|
17
19
|
def should_update_seo_description?
|
18
|
-
|
20
|
+
seorel_changed_mode? || !seo_description?
|
19
21
|
end
|
20
22
|
|
21
23
|
def should_update_seo_image?
|
22
|
-
|
24
|
+
seorel_changed_mode? || !seo_image?
|
23
25
|
end
|
24
26
|
|
25
27
|
def set_seorel
|
26
|
-
|
28
|
+
build_seorel unless seorel?
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
seorel.title = seorel_title_value if should_update_seo_title?
|
31
|
+
seorel.description = seorel_description_value if should_update_seo_description?
|
32
|
+
seorel.image = seorel_image_value if should_update_seo_image?
|
31
33
|
end
|
32
34
|
|
33
35
|
def seorel_title_value
|
34
|
-
raw_title = self.class.seorel_title_field &&
|
36
|
+
raw_title = self.class.seorel_title_field && send(self.class.seorel_title_field)
|
35
37
|
::ActionController::Base.helpers.strip_tags(raw_title.to_s).first(255)
|
36
38
|
end
|
37
39
|
|
38
40
|
def seorel_description_value
|
39
|
-
raw_description = self.class.seorel_description_field &&
|
41
|
+
raw_description = self.class.seorel_description_field && send(self.class.seorel_description_field)
|
40
42
|
::ActionController::Base.helpers.strip_tags(raw_description.to_s).first(255)
|
41
43
|
end
|
42
44
|
|
43
45
|
def seorel_image_value
|
44
|
-
raw_image = self.class.seorel_image_field &&
|
46
|
+
raw_image = self.class.seorel_image_field && send(self.class.seorel_image_field)
|
45
47
|
::ActionController::Base.helpers.strip_tags(raw_image.to_s)
|
46
48
|
end
|
47
49
|
|
data/lib/seorel/seorel.rb
CHANGED
@@ -1,23 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_record'
|
2
4
|
|
3
5
|
module Seorel
|
4
6
|
class Seorel < ::ActiveRecord::Base
|
5
|
-
belongs_to :seorelable, polymorphic: true, touch: true
|
7
|
+
belongs_to :seorelable, polymorphic: true, touch: true, inverse_of: :seorel
|
6
8
|
|
7
9
|
def title?
|
8
|
-
|
10
|
+
title.present?
|
9
11
|
end
|
10
12
|
|
11
13
|
def description?
|
12
|
-
|
14
|
+
description.present?
|
13
15
|
end
|
14
16
|
|
15
17
|
def image?
|
16
|
-
|
18
|
+
image.present?
|
17
19
|
end
|
18
20
|
|
19
21
|
def admin_label
|
20
|
-
I18n.t(
|
22
|
+
I18n.t('seorel.admin.label')
|
21
23
|
end
|
22
24
|
end
|
23
25
|
end
|
data/lib/seorel/seorelify.rb
CHANGED
data/lib/seorel/version.rb
CHANGED
data/lib/tasks/seorel_tasks.rake
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seorel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrea Dal Ponte
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- config/locales/en.seorel.yml
|
108
108
|
- config/locales/it.seorel.yml
|
109
109
|
- lib/generators/seorel/install_generator.rb
|
110
|
+
- lib/generators/seorel/templates/globalize_migration.rb
|
110
111
|
- lib/generators/seorel/templates/initializer.rb
|
111
112
|
- lib/generators/seorel/templates/migration.rb
|
112
113
|
- lib/generators/seorel/templates/seorel.en.yml
|
@@ -116,6 +117,7 @@ files:
|
|
116
117
|
- lib/seorel/controller/instance_methods.rb
|
117
118
|
- lib/seorel/controller/params.rb
|
118
119
|
- lib/seorel/engine.rb
|
120
|
+
- lib/seorel/globalize.rb
|
119
121
|
- lib/seorel/helper.rb
|
120
122
|
- lib/seorel/helper/base.rb
|
121
123
|
- lib/seorel/helper/generic.rb
|
@@ -149,9 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
151
|
version: '0'
|
150
152
|
requirements: []
|
151
153
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.
|
154
|
+
rubygems_version: 2.6.13
|
153
155
|
signing_key:
|
154
156
|
specification_version: 4
|
155
157
|
summary: Ruby on Rails SEO Metatags engine for ActiveRecord models
|
156
158
|
test_files: []
|
157
|
-
has_rdoc:
|