wco_models 3.1.0.173 → 3.1.0.174
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/wco/utils.scss +3 -1
- data/app/controllers/wco/sitemap_paths_controller.rb +31 -0
- data/app/models/wco/sitemap_path.rb +41 -23
- data/app/views/wco/sitemap_paths/_form.haml +20 -12
- data/app/views/wco/sitemap_paths/_index.haml +3 -0
- data/app/views/wco/sitemap_paths/check.haml +12 -2
- data/config/routes.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3123e82f0b6b6c73467f25b805938849fec0eb0cdc83fabff9d0d4eb7636759e
|
4
|
+
data.tar.gz: 3f00797cf55c973a2fbc67d44c62d5b1fe9d2a8794b2a12f8c20b9a3674e681f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9291087081326216d314e00878343ec5b27e5aa45d4de1029ceadd02681926db68ce20188ccd91e107b9b247b1f58e47bc4c63ff17fb350a3bdf66ecdeb8bc93
|
7
|
+
data.tar.gz: e49aac91b44d0560f79f2bd9e402c2a833b8885eed54c9881d464396168ec68a9a4d93fd7ee0d2db5d8127b0605ba34614ff39e3f6919e1ae15bb93e593d0a3a
|
@@ -1,15 +1,25 @@
|
|
1
1
|
|
2
2
|
class Wco::SitemapPathsController < Wco::ApplicationController
|
3
3
|
|
4
|
+
before_action :fix_params, only: [ :create, :update ]
|
5
|
+
|
4
6
|
def check
|
5
7
|
@spath = Wco::SitemapPath.find params[:id]
|
6
8
|
authorize! :check, @spath
|
7
9
|
@spath.check
|
8
10
|
end
|
9
11
|
|
12
|
+
def clear
|
13
|
+
@spath = Wco::SitemapPath.find params[:id]
|
14
|
+
authorize! :clear, @spath
|
15
|
+
@spath.update_attributes({ results: [] })
|
16
|
+
redirect_to request.referrer || sites_path(@spath.site)
|
17
|
+
end
|
18
|
+
|
10
19
|
def create
|
11
20
|
authorize! :create, Wco::SitemapPath
|
12
21
|
@spath = Wco::SitemapPath.new params[:spath].permit!
|
22
|
+
|
13
23
|
if @spath.save
|
14
24
|
flash_notice 'Success.'
|
15
25
|
redirect_to wco.site_path(params[:spath][:site_id])
|
@@ -31,6 +41,14 @@ class Wco::SitemapPathsController < Wco::ApplicationController
|
|
31
41
|
authorize! :new, @spath
|
32
42
|
end
|
33
43
|
|
44
|
+
def show
|
45
|
+
@spath = Wco::SitemapPath.find params[:id]
|
46
|
+
@site = @spath.site
|
47
|
+
authorize! :show, @spath
|
48
|
+
render 'check'
|
49
|
+
end
|
50
|
+
|
51
|
+
|
34
52
|
def update
|
35
53
|
@spath = Wco::SitemapPath.find params[:id]
|
36
54
|
authorize! :update, @spath
|
@@ -45,6 +63,19 @@ class Wco::SitemapPathsController < Wco::ApplicationController
|
|
45
63
|
|
46
64
|
end
|
47
65
|
|
66
|
+
##
|
67
|
+
## private
|
68
|
+
##
|
69
|
+
private
|
70
|
+
|
71
|
+
def fix_params
|
72
|
+
if params[:spath][:selectors].present?
|
73
|
+
params[:spath][:selectors] = params[:spath][:selectors].split(',').strip
|
74
|
+
else
|
75
|
+
params[:spath][:selectors] = []
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
48
79
|
|
49
80
|
end
|
50
81
|
|
@@ -14,17 +14,20 @@ class Wco::SitemapPath
|
|
14
14
|
field :redirect_to, type: String
|
15
15
|
field :selector, type: String
|
16
16
|
field :selectors, type: Array, default: []
|
17
|
+
field :title, type: String
|
17
18
|
|
18
19
|
field :results, type: Array, default: []
|
19
20
|
field :status, type: String
|
20
21
|
|
21
22
|
def check
|
22
23
|
self.status = 'NOT_OK'
|
24
|
+
skip_rest = false
|
25
|
+
|
23
26
|
if self[:selector].present?
|
24
27
|
begin
|
25
28
|
body = HTTParty.get( "#{site.origin}#{self[:path]}" ).body
|
26
29
|
rescue OpenSSL::SSL::SSLError => err
|
27
|
-
results.push "NOT OK [ssl-exception] #{self[:path]}".red
|
30
|
+
results.push "NOT OK [ssl-exception] #{self[:path]}" # .red
|
28
31
|
return
|
29
32
|
end
|
30
33
|
doc = Nokogiri::HTML( body )
|
@@ -33,17 +36,7 @@ class Wco::SitemapPath
|
|
33
36
|
results.push "OK #{self[:path]}"
|
34
37
|
self.status = 'OK'
|
35
38
|
else
|
36
|
-
results.push "NOT OK [selector-missing] #{self[:path]}".red
|
37
|
-
end
|
38
|
-
|
39
|
-
if self[:meta_description]
|
40
|
-
out = doc.search( 'head meta[name="description"]' )[0]['content']
|
41
|
-
if self[:meta_description] == out
|
42
|
-
results.push "OK #{self[:path]} meta_description"
|
43
|
-
self.status = 'OK'
|
44
|
-
else
|
45
|
-
results.push "NOT OK [meta-description-missing] #{self[:path]}".red
|
46
|
-
end
|
39
|
+
results.push "NOT OK [selector-missing] #{self[:path]}" # .red
|
47
40
|
end
|
48
41
|
|
49
42
|
elsif self[:redirect_to].present?
|
@@ -53,33 +46,58 @@ class Wco::SitemapPath
|
|
53
46
|
results.push "OK #{self[:path]}"
|
54
47
|
self.status = 'OK'
|
55
48
|
else
|
56
|
-
results.push "NOT OK [redirect-missing] #{self[:path]}".red
|
49
|
+
results.push "NOT OK [redirect-missing] #{self[:path]}" # .red
|
57
50
|
|
58
51
|
puts!( out.response, 'response' ) if DEBUG
|
59
52
|
# puts!( out.body, 'body' ) if DEBUG
|
60
53
|
|
61
|
-
puts "NOT OK #{self[:path]}".red
|
54
|
+
puts "NOT OK #{self[:path]}" # .red
|
62
55
|
puts out.headers[:location]
|
63
56
|
puts self[:redirect_to]
|
64
57
|
end
|
58
|
+
skip_rest = true
|
65
59
|
else
|
66
60
|
results.push "SKIP #{self[:path]}"
|
67
61
|
self.status = 'OK'
|
62
|
+
skip_rest = true
|
68
63
|
end
|
69
64
|
|
70
|
-
if
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
out
|
75
|
-
|
76
|
-
|
77
|
-
self.status = '
|
65
|
+
if !skip_rest
|
66
|
+
|
67
|
+
if self[:meta_description].present?
|
68
|
+
out = doc.search( 'head meta[name="description"]' )[0]['content']
|
69
|
+
if out.include?( self[:meta_description] )
|
70
|
+
results.push "OK #{self[:path]} meta_description"
|
71
|
+
else
|
72
|
+
self.status = 'NOT_OK'
|
73
|
+
results.push "NOT OK [meta-description-no-contain] #{self[:path]}" # .red
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
if self[:selectors].present?
|
78
|
+
self[:selectors].each do |selector|
|
79
|
+
out = doc.search selector
|
80
|
+
if out.present?
|
81
|
+
results.push "OK #{self[:path]} selectors:#{selector}"
|
82
|
+
else
|
83
|
+
self.status = 'NOT_OK'
|
84
|
+
results.push "NOT OK [selectors-missing:#{selector}] #{self[:path]}" # .red
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
if self[:title].present?
|
90
|
+
out = doc.search( 'head title' )[0].text
|
91
|
+
if out.include?( self[:title] )
|
92
|
+
results.push "OK #{self[:path]} title"
|
78
93
|
else
|
79
|
-
|
94
|
+
self.status = 'NOT_OK'
|
95
|
+
results.push "NOT OK [title-no-contain] #{self[:path]}" # .red
|
80
96
|
end
|
81
97
|
end
|
98
|
+
|
82
99
|
end
|
100
|
+
|
83
101
|
self.save
|
84
102
|
end
|
85
103
|
|
@@ -8,16 +8,24 @@
|
|
8
8
|
= form_for spath, url: url, as: :spath do |f|
|
9
9
|
= hidden_field_tag 'spath[site_id]', spath[:site_id] || params[:site_id]
|
10
10
|
|
11
|
-
.d-flex
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
.
|
19
|
-
|
20
|
-
|
11
|
+
.field.d-flex
|
12
|
+
%label Path
|
13
|
+
= f.text_field :path, class: [ 'flex-grow' ]
|
14
|
+
.field.d-flex
|
15
|
+
%label redirect_to
|
16
|
+
= f.text_field :redirect_to, class: [ 'flex-grow' ]
|
17
|
+
%label selector
|
18
|
+
= f.text_field :selector, class: [ 'flex-grow' ]
|
19
|
+
%br
|
20
|
+
.field.d-flex
|
21
|
+
%label selectors (.a, .b , #c)
|
22
|
+
= f.text_field :selectors, value: spath.selectors.join(','), class: [ 'flex-grow' ]
|
23
|
+
.field.d-flex
|
24
|
+
%label meta_description
|
25
|
+
= f.text_field :meta_description, class: [ 'flex-grow' ]
|
26
|
+
.field.d-flex
|
27
|
+
%label title
|
28
|
+
= f.text_field :title, class: [ 'flex-grow' ]
|
21
29
|
|
22
|
-
|
23
|
-
|
30
|
+
.actions
|
31
|
+
= f.submit 'Go'
|
@@ -1,3 +1,13 @@
|
|
1
1
|
|
2
|
-
.
|
3
|
-
|
2
|
+
.sitemap-paths-check.maxwidth
|
3
|
+
|
4
|
+
.d-flex
|
5
|
+
= link_to 'Index', site_path(@spath.site)
|
6
|
+
%b.ml-3.mr-3= link_to @spath.path, spath_path(@spath)
|
7
|
+
= link_to '[~]', edit_spath_path(@spath)
|
8
|
+
= button_to 'clear', clear_spath_path(@spath), data: { confirm: 'Are you sure?' }
|
9
|
+
|
10
|
+
.spaths-check
|
11
|
+
%ul
|
12
|
+
- @spath.results.each do |pt|
|
13
|
+
%li= pt
|
data/config/routes.rb
CHANGED
@@ -62,7 +62,8 @@ Wco::Engine.routes.draw do
|
|
62
62
|
|
63
63
|
post 'sites/:id/check_sitemap', to: 'sites#check_sitemap', as: :check_sitemap
|
64
64
|
resources :sites
|
65
|
-
get
|
65
|
+
get 'sitemap_paths/:id/check', to: 'sitemap_paths#check', as: :check_spath
|
66
|
+
post 'sitemap_paths/:id/clear', to: 'sitemap_paths#clear', as: :clear_spath
|
66
67
|
resources :sitemap_paths, as: :spaths
|
67
68
|
resources :subscriptions
|
68
69
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wco_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.0.
|
4
|
+
version: 3.1.0.174
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Pudeyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ahoy_matey
|