para-seo_tools 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/app/components/seo_tools_skeleton_component.rb +4 -0
- data/app/controllers/{admin/para/seo_tools → para/seo_tools/admin}/skeleton_resources_controller.rb +3 -3
- data/app/models/para/seo_tools/page.rb +5 -1
- data/lib/para/seo_tools/engine.rb +0 -6
- data/lib/para/seo_tools/meta_tags/tags/image.rb +5 -2
- data/lib/para/seo_tools/routes.rb +1 -1
- data/lib/para/seo_tools/sitemap.rb +3 -3
- data/lib/para/seo_tools/skeleton/site.rb +40 -2
- data/lib/para/seo_tools/skeleton.rb +6 -16
- data/lib/para/seo_tools/version.rb +1 -1
- data/lib/para/seo_tools.rb +5 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a34f864ccd5b3365f87eff521544ce23fe555c6a
|
4
|
+
data.tar.gz: 98b4747257ce0acd81643e9c0b101e9706fbadb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf073b75a0b537fef122a1cec5614505b1e6e0ca0288f417a917bf68ffe015fd663de442fcde4fdda9d7de28791524e8be8acea01a5f9e0b098f318a5a9a9883
|
7
|
+
data.tar.gz: 6660839f153d03a48b1957aef6dc1118e8456957d3fc00e8fb729ad015ac921074eaa7c0633fdb6bd9bdd78505e39f5994dec455033bfe38e554150aad3683f3
|
data/.gitignore
CHANGED
@@ -7,7 +7,11 @@ module Para
|
|
7
7
|
validates_attachment :image, content_type: { content_type: /\Aimage\/.*\Z/ }
|
8
8
|
|
9
9
|
def meta_tag(name)
|
10
|
-
|
10
|
+
if (value = send(name).presence) && (meta = process(name, value)).present?
|
11
|
+
return meta
|
12
|
+
end
|
13
|
+
|
14
|
+
default(name)
|
11
15
|
end
|
12
16
|
|
13
17
|
def defaults
|
@@ -13,8 +13,11 @@ module Para
|
|
13
13
|
if url.start_with?('http://')
|
14
14
|
url
|
15
15
|
else
|
16
|
-
request = RequestStore.store[:'para.seo_tools.request']
|
17
|
-
|
16
|
+
if (request = RequestStore.store[:'para.seo_tools.request'])
|
17
|
+
URI.join(request.url, url).to_s
|
18
|
+
else
|
19
|
+
url
|
20
|
+
end
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
@@ -2,9 +2,9 @@ module Para
|
|
2
2
|
module SeoTools
|
3
3
|
class Sitemap
|
4
4
|
def self.build
|
5
|
-
::Sitemap::Generator.instance.load :
|
6
|
-
Para::SeoTools::
|
7
|
-
literal page.path
|
5
|
+
::Sitemap::Generator.instance.load host: Para::SeoTools.host do
|
6
|
+
Para::SeoTools::Page.find_each do |page|
|
7
|
+
literal page.path
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -3,15 +3,53 @@ module Para
|
|
3
3
|
module Skeleton
|
4
4
|
class Site
|
5
5
|
include Rails.application.routes.url_helpers
|
6
|
+
attr_reader :enable_logging
|
7
|
+
|
8
|
+
def initialize(options = {})
|
9
|
+
@enable_logging = options[:enable_logging]
|
10
|
+
end
|
6
11
|
|
7
12
|
def page(name, options = {} , &block)
|
8
|
-
|
9
|
-
|
13
|
+
Skeleton::Page.new(name, options).tap do |page|
|
14
|
+
pages << page
|
15
|
+
save if pages.length == max_pages_before_save
|
16
|
+
end
|
10
17
|
end
|
11
18
|
|
12
19
|
def pages
|
13
20
|
@pages ||= []
|
14
21
|
end
|
22
|
+
|
23
|
+
def save
|
24
|
+
log " * Saving #{ pages.length } generated pages ..."
|
25
|
+
|
26
|
+
ActiveRecord::Base.transaction do
|
27
|
+
pages.each do |page|
|
28
|
+
page.model.save!
|
29
|
+
saved_pages_ids << page.model.id
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
pages.clear
|
34
|
+
end
|
35
|
+
|
36
|
+
def saved_pages_ids
|
37
|
+
@saved_pages_ids ||= []
|
38
|
+
end
|
39
|
+
|
40
|
+
# Log messages when you're not in rails
|
41
|
+
#
|
42
|
+
def log(message)
|
43
|
+
Rails.logger.info(message) if enable_logging || !$0.end_with?('rails')
|
44
|
+
end
|
45
|
+
|
46
|
+
def max_pages_before_save
|
47
|
+
@max_pages_before_save ||= if (param = ENV['SEO_TOOLS_MAX_PAGES_BEFORE_SAVE']).present?
|
48
|
+
para.to_i
|
49
|
+
else
|
50
|
+
500
|
51
|
+
end
|
52
|
+
end
|
15
53
|
end
|
16
54
|
end
|
17
55
|
end
|
@@ -36,19 +36,13 @@ module Para
|
|
36
36
|
|
37
37
|
log " * Building app skeleton pages ..."
|
38
38
|
|
39
|
-
self.site = Skeleton::Site.new
|
39
|
+
self.site = Skeleton::Site.new(enable_logging: enable_logging)
|
40
40
|
# Evaluate the configuration block
|
41
41
|
site.instance_exec(&config)
|
42
42
|
|
43
|
-
# Save
|
43
|
+
# Save remaining pages and remove old pages
|
44
44
|
ActiveRecord::Base.transaction do
|
45
|
-
|
46
|
-
|
47
|
-
site.pages.each do |page|
|
48
|
-
page.model.save!
|
49
|
-
end
|
50
|
-
|
51
|
-
log " * Destroying old pages ..."
|
45
|
+
site.save
|
52
46
|
|
53
47
|
# Delete pages not in skeleton
|
54
48
|
destroy_deleted_pages!
|
@@ -60,13 +54,9 @@ module Para
|
|
60
54
|
end
|
61
55
|
|
62
56
|
def self.destroy_deleted_pages!
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
if (count = pages.count) > 0
|
67
|
-
log "Destroying #{ count } removed pages from Skeleton"
|
68
|
-
pages.destroy_all
|
69
|
-
end
|
57
|
+
pages = Para::SeoTools::Page.where.not(id: site.saved_pages_ids)
|
58
|
+
log " * Destroying old pages ..."
|
59
|
+
pages.delete_all
|
70
60
|
end
|
71
61
|
|
72
62
|
# Log messages when you're not in rails
|
data/lib/para/seo_tools.rb
CHANGED
@@ -17,7 +17,7 @@ module Para
|
|
17
17
|
autoload :MetaTaggableMacro
|
18
18
|
autoload :ViewHelpers
|
19
19
|
|
20
|
-
|
20
|
+
mattr_writer :host
|
21
21
|
@@host = ENV['APP_DOMAIN']
|
22
22
|
|
23
23
|
mattr_accessor :title_methods
|
@@ -39,5 +39,9 @@ module Para
|
|
39
39
|
def self.table_name_prefix
|
40
40
|
'seo_tools_'
|
41
41
|
end
|
42
|
+
|
43
|
+
def self.host
|
44
|
+
@@host.presence && @@host.match(/[^:]+/)[0]
|
45
|
+
end
|
42
46
|
end
|
43
47
|
end
|
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
|
+
version: 0.3.0
|
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-
|
11
|
+
date: 2016-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -102,7 +102,7 @@ files:
|
|
102
102
|
- app/.DS_Store
|
103
103
|
- app/components/seo_tools_skeleton_component.rb
|
104
104
|
- app/controllers/.DS_Store
|
105
|
-
- app/controllers/
|
105
|
+
- app/controllers/para/seo_tools/admin/skeleton_resources_controller.rb
|
106
106
|
- app/decorators/seo_tools_skeleton_component_decorator.rb
|
107
107
|
- app/helpers/para/seo_tools/admin/fields_helper.rb
|
108
108
|
- app/models/para/seo_tools/page.rb
|