para-seo_tools 0.4.2 → 0.4.3
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 +21 -0
- data/lib/para/seo_tools/controller.rb +2 -6
- data/lib/para/seo_tools/engine.rb +2 -1
- data/lib/para/seo_tools/helpers/page_helper.rb +72 -0
- data/lib/para/seo_tools/helpers/view_helper.rb +11 -0
- data/lib/para/seo_tools/helpers.rb +10 -0
- data/lib/para/seo_tools/sitemap_pinger.rb +0 -6
- data/lib/para/seo_tools/skeleton/job.rb +0 -6
- data/lib/para/seo_tools/version.rb +1 -1
- data/lib/para/seo_tools.rb +1 -1
- metadata +5 -3
- data/lib/para/seo_tools/view_helpers.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e220801b91af4f208d0699b1ad222e6da70a14a
|
4
|
+
data.tar.gz: 038f5d4d193c3dc4cf4b28d4952075e814e2c83c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5eae100d8ef70eb4cf1527b523a2390f0b0c797ba4c6a311dbcb20d12a592ea2f636148cc2913a6025aeca2633da888e43f926a0576a1ef461232850e96e38a
|
7
|
+
data.tar.gz: 2b4f5c397b6638653c7ddc7526aed32ff9b01b723540093fbcddc49d0abcad40024d65359f07aa5764af95afc72de32a17d24663f3b64e63dcbc7aa2f36ab726
|
data/README.md
CHANGED
@@ -196,6 +196,27 @@ Para::SeoTools::Skeleton.draw(scope: :locale) do
|
|
196
196
|
By using `I18n.with_locale`, we force the current locale in the block, and
|
197
197
|
SeoTools automatically assigns the locale to the page resource.
|
198
198
|
|
199
|
+
#### Scoping page fetching in request
|
200
|
+
|
201
|
+
When you add arbitrary scope your pages, you may want Seo Tools to use these
|
202
|
+
scopes when retrieving the page to fetch meta tags, at request time.
|
203
|
+
|
204
|
+
> **Note**: The following scopes are included in default page retrieval scoping
|
205
|
+
and need not to be overriden : `:locale`, `:subdomain` and `:domain`.
|
206
|
+
|
207
|
+
Override the `#seo_tools_scope_for(request)` method in the controllers that need
|
208
|
+
to apply these scope rules. This will be the ApplicationController in most
|
209
|
+
cases. The method should return a hash.
|
210
|
+
|
211
|
+
```
|
212
|
+
def seo_tools_scope_for(request)
|
213
|
+
super.tap do |hash|
|
214
|
+
# use `hash[:my_scope_name] = ...` here to fill or update the default scope
|
215
|
+
end
|
216
|
+
end
|
217
|
+
```
|
218
|
+
|
219
|
+
|
199
220
|
#### Lazy skeleton building.
|
200
221
|
|
201
222
|
On large applications, building the skeleton with all its pages at application
|
@@ -39,12 +39,8 @@ module Para
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def fetch_meta_tags_page
|
42
|
-
|
43
|
-
|
44
|
-
page_conditions = page_conditions.with_domain(request.domain) if Para::SeoTools.handle_domain
|
45
|
-
|
46
|
-
if (page = page_conditions.first)
|
47
|
-
set_meta_tags_from_page(page)
|
42
|
+
if current_seo_tools_page
|
43
|
+
set_meta_tags_from_page(current_seo_tools_page)
|
48
44
|
end
|
49
45
|
end
|
50
46
|
|
@@ -8,12 +8,13 @@ module Para
|
|
8
8
|
initializer 'para.seo_tools.include_controller_mixin' do
|
9
9
|
ActiveSupport.on_load(:action_controller) do
|
10
10
|
include Para::SeoTools::Controller
|
11
|
+
include Para::SeoTools::Helpers::PageHelper
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
14
15
|
initializer "para.seo_tools.include_view_helpers" do
|
15
16
|
ActiveSupport.on_load(:action_view) do
|
16
|
-
include Para::SeoTools::
|
17
|
+
include Para::SeoTools::Helpers::ViewHelper
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Para
|
2
|
+
module SeoTools
|
3
|
+
module Helpers
|
4
|
+
module PageHelper
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
# Allow module methods to be called from the view when the PageHelper
|
9
|
+
# module is included in a controller
|
10
|
+
if respond_to?(:helper_method)
|
11
|
+
helper_method :current_seo_tools_page,
|
12
|
+
:seo_tools_page_for,
|
13
|
+
:seo_tools_pages_for,
|
14
|
+
:seo_tools_scoped_sibling_for,
|
15
|
+
:seo_tools_scoped_siblings_for
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def current_seo_tools_page
|
20
|
+
RequestStore.store['para.seo_tools.current_seo_tools_page'] ||=
|
21
|
+
seo_tools_page_for({ path: request.path }.merge(seo_tools_scope_for(request)))
|
22
|
+
end
|
23
|
+
|
24
|
+
# Retrieve the first page that matches the given scope conditions
|
25
|
+
#
|
26
|
+
def seo_tools_page_for(scope_hash = {})
|
27
|
+
seo_tools_pages_for(scope_hash).first
|
28
|
+
end
|
29
|
+
|
30
|
+
# Find all the pages with the given scope conditions, merged with the
|
31
|
+
# current page ones.
|
32
|
+
#
|
33
|
+
def seo_tools_pages_for(scope_hash = {})
|
34
|
+
Para::SeoTools::Page.scope_with(scope_hash)
|
35
|
+
end
|
36
|
+
|
37
|
+
def seo_tools_scoped_sibling_for(*args)
|
38
|
+
seo_tools_scoped_siblings_for(*args).first
|
39
|
+
end
|
40
|
+
|
41
|
+
def seo_tools_scoped_siblings_for(path, scope_hash = {})
|
42
|
+
source_page = if Hash === path
|
43
|
+
scope_hash = path
|
44
|
+
current_seo_tools_page
|
45
|
+
else
|
46
|
+
Para::SeoTools::Page.find_by_path(path)
|
47
|
+
end
|
48
|
+
|
49
|
+
return Para::SeoTools::Page.none unless source_page
|
50
|
+
|
51
|
+
scope_hash = scope_hash.merge(seo_tools_scope_for(request))
|
52
|
+
source_page.siblings.scope_with(scope_hash)
|
53
|
+
end
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
57
|
+
# Return a simple scopes hash, letting the Page.scope_with method handle
|
58
|
+
# column and JSON field backed attributes
|
59
|
+
#
|
60
|
+
# This method is meant to be overriden in app controllers to scope
|
61
|
+
#
|
62
|
+
def seo_tools_scope_for(request)
|
63
|
+
{}.tap do |hash|
|
64
|
+
hash[:subdomain] = request.subdomain if Para::SeoTools.handle_subdomain
|
65
|
+
hash[:domain] = request.domain if Para::SeoTools.handle_domain
|
66
|
+
hash[:locale] = I18n.locale if I18n.available_locales.length > 1
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/para/seo_tools.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: para-seo_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valentin Ballestrino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -126,6 +126,9 @@ files:
|
|
126
126
|
- lib/para/seo_tools.rb
|
127
127
|
- lib/para/seo_tools/controller.rb
|
128
128
|
- lib/para/seo_tools/engine.rb
|
129
|
+
- lib/para/seo_tools/helpers.rb
|
130
|
+
- lib/para/seo_tools/helpers/page_helper.rb
|
131
|
+
- lib/para/seo_tools/helpers/view_helper.rb
|
129
132
|
- lib/para/seo_tools/meta_tags.rb
|
130
133
|
- lib/para/seo_tools/meta_tags/renderer.rb
|
131
134
|
- lib/para/seo_tools/meta_tags/store.rb
|
@@ -149,7 +152,6 @@ files:
|
|
149
152
|
- lib/para/seo_tools/skeleton/page_builder.rb
|
150
153
|
- lib/para/seo_tools/skeleton/site.rb
|
151
154
|
- lib/para/seo_tools/version.rb
|
152
|
-
- lib/para/seo_tools/view_helpers.rb
|
153
155
|
- lib/tasks/migration.rake
|
154
156
|
- lib/tasks/para_seo_tools_tasks.rake
|
155
157
|
- para-seo_tools.gemspec
|