wco_models 3.1.0.168 → 3.1.0.169

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39a1b5be41ae4ca454da67541e42674f6159bd51688022cc6646fee183d172b0
4
- data.tar.gz: 1a9662e0814a685f277910c80fb48839f4fdb11f188fcfae0aa484d08f100920
3
+ metadata.gz: 55d9ac4131e23711ece162eeb0d966ad0a0a1d674eeaff4914e9a8f8a04d8854
4
+ data.tar.gz: dd2312d66791bc3bb0bf644632acc6f9d37513a5331a226ea911ad2f7fa1f5e8
5
5
  SHA512:
6
- metadata.gz: 432bff7bf6f0ad15331348e2580262c1b745452b3a68f6b1dbcfea1a86a3e5b35d609fe9ef2b7ce38a01cdadb6d11dbcbb1559599c0abc1b69b9127b7a5b53f5
7
- data.tar.gz: cf3d4c3d3f3443b4ca2295c8344561c1127c4d3ad8cd52bb106a8159f946dd05dca8121b08ffc7dcdaafb2c9f908cd70af940af79cf4cc99f8c996141d181d36
6
+ metadata.gz: e886165a18d09abcc2798f081803c2fb645d0c664e152e5511b496a534b58b8c9ae8977aa64c2c728c2bda233546bb3a82418cdf25b731768060f2d6e87b9dc5
7
+ data.tar.gz: 88921f8da539770fd3698a7a98be6eff4f8043b8d4513d495f1a55a9b44763124221e939c98f8583a36a51d4b40541b7c71aaa090c626dc2a62e44ef96852d92
@@ -0,0 +1,4 @@
1
+
2
+ .Sitemaps {
3
+ border: 1px solid red;
4
+ }
@@ -74,7 +74,6 @@ textarea.monospace {
74
74
  padding: 0.6em;
75
75
  }
76
76
 
77
-
78
77
  /* D */
79
78
 
80
79
  .descr {
@@ -1,11 +1,36 @@
1
1
 
2
2
  class Wco::SitemapPathsController < Wco::ApplicationController
3
3
 
4
+ def check
5
+ @spath = Wco::SitemapPath.find params[:id]
6
+ authorize! :check, @spath
7
+ @spath.check
8
+ end
9
+
10
+ def create
11
+ authorize! :create, Wco::SitemapPath
12
+ @spath = Wco::SitemapPath.new params[:spath].permit!
13
+ if @spath.save
14
+ flash_notice 'Success.'
15
+ redirect_to wco.site_path(params[:spath][:site_id])
16
+ else
17
+ flash_alert "Could not save spath: #{@spath.errors.full_messages}"
18
+ render 'new'
19
+ end
20
+ end
21
+
4
22
  def edit
5
23
  @spath = Wco::SitemapPath.find params[:id]
24
+ @site = @spath.site
6
25
  authorize! :edit, @spath
7
26
  end
8
27
 
28
+ def new
29
+ @site = Wco::Site.find( params[:site_id] )
30
+ @spath = Wco::SitemapPath.new site: @site
31
+ authorize! :new, @spath
32
+ end
33
+
9
34
  def update
10
35
  @spath = Wco::SitemapPath.find params[:id]
11
36
  authorize! :update, @spath
@@ -31,8 +31,11 @@ class Wco::Site
31
31
  field :username
32
32
  field :password
33
33
 
34
+ default_scope ->{ order_by( slug: :asc ) }
35
+
34
36
  def to_s
35
- origin
37
+ slug
38
+ # origin
36
39
  end
37
40
 
38
41
  def self.list
@@ -10,11 +10,78 @@ class Wco::SitemapPath
10
10
  field :path, type: String
11
11
  validates :path, presence: true, uniqueness: { scope: :site }
12
12
 
13
+ field :meta_description, type: String
13
14
  field :redirect_to, type: String
14
15
  field :selector, type: String
15
16
  field :selectors, type: Array, default: []
16
17
 
17
- field :status, type: String
18
+ field :results, type: Array, default: []
19
+ field :status, type: String
20
+
21
+ def check
22
+ self.status = 'NOT_OK'
23
+ if self[:selector]
24
+ begin
25
+ body = HTTParty.get( "#{site.origin}#{self[:path]}" ).body
26
+ rescue OpenSSL::SSL::SSLError => err
27
+ results.push "NOT OK [ssl-exception] #{self[:path]}".red
28
+ return
29
+ end
30
+ doc = Nokogiri::HTML( body )
31
+ out = doc.search self[:selector]
32
+ if out.present?
33
+ results.push "OK #{self[:path]}"
34
+ self.status = 'OK'
35
+ 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
47
+ end
48
+
49
+ elsif self[:redirect_to]
50
+ out = HTTParty.get( "#{origin}#{self[:path]}", follow_redirects: false )
51
+ if( out.headers[:location] == self[:redirect_to] ||
52
+ out.headers[:location] == "#{origin}#{self[:redirect_to]}" )
53
+ results.push "OK #{self[:path]}"
54
+ self.status = 'OK'
55
+ else
56
+ results.push "NOT OK [redirect-missing] #{self[:path]}".red
57
+
58
+ puts!( out.response, 'response' ) if DEBUG
59
+ # puts!( out.body, 'body' ) if DEBUG
60
+
61
+ puts "NOT OK #{self[:path]}".red
62
+ puts out.headers[:location]
63
+ puts self[:redirect_to]
64
+ end
65
+ else
66
+ results.push "SKIP #{self[:path]}"
67
+ self.status = 'OK'
68
+ end
69
+
70
+ if self[:selectors].present?
71
+ self[:selectors].each do |selector|
72
+ body = HTTParty.get( "#{origin}#{self[:path]}" ).body
73
+ doc = Nokogiri::HTML( body )
74
+ out = doc.search selector
75
+ if out.present?
76
+ results.push "OK #{self[:path]} selectors:#{selector}"
77
+ self.status = 'OK'
78
+ else
79
+ results.push "NOT OK [selectors-missing:#{selector}] #{self[:path]}".red
80
+ end
81
+ end
82
+ end
83
+ self.save
84
+ end
18
85
 
19
86
  end
20
87
 
@@ -5,8 +5,8 @@
5
5
  - url = spath_path(spath)
6
6
 
7
7
  .sitemap-paths--form
8
- = form_for spath, url: url do |f|
9
- = hidden_field_tag :site_id, spath[:site_id] || params[:site_id]
8
+ = form_for spath, url: url, as: :spath do |f|
9
+ = hidden_field_tag 'spath[site_id]', spath[:site_id] || params[:site_id]
10
10
 
11
11
  .d-flex
12
12
  .field
@@ -11,7 +11,8 @@
11
11
  %tr
12
12
  %td
13
13
  = link_to '[~]', edit_spath_path(spath)
14
- = spath.path
14
+ .d-inline-block= button_to 'check', check_spath_path(spath), method: :get
15
+ = link_to "#{@site.origin}#{spath.path}","#{@site.origin}#{spath.path}", target: :_blank
15
16
  - if spath.redirect_to
16
17
  %div
17
18
  \-> &nbsp;
@@ -0,0 +1,3 @@
1
+
2
+ .spaths-check
3
+ = @spath.results.inspect
@@ -1,5 +1,6 @@
1
1
 
2
2
  .sitemap-paths-edit.maxwidth
3
3
  .header
4
- %h3.title Edit spath
4
+ %h3.title
5
+ Edit Spath for `#{link_to @site, site_path(@site)}`
5
6
  = render 'form', spath: @spath
@@ -0,0 +1,7 @@
1
+
2
+ .spaths-new.maxwidth
3
+ .header
4
+ %h3.title
5
+ New Spath for `#{link_to @site, site_path(@site)}`
6
+
7
+ = render 'form', spath: @spath
@@ -5,14 +5,18 @@
5
5
  %h5.title
6
6
  = @site
7
7
 
8
- = render '/wco/tags/header'
9
- = render '/wco/tags/index', tags: @site.tags
8
+ .row
9
+ .Sitemaps.col-md-9
10
10
 
11
- %h5.d-flex
12
- Sitemap Paths &nbsp;
13
- = link_to '[+]', new_spath_path( site_id: @site.id )
14
- &nbsp;
15
- = button_to 'check', check_sitemap_path( site: @site ), data: { confirm: 'Are you sure?' }
16
- = render '/wco/sitemap_paths/form', spath: @new_sitemap_path
17
- -# %hr
18
- = render '/wco/sitemap_paths/index', spaths: @site.sitemap_paths
11
+ %h5.d-flex
12
+ Sitemap Paths &nbsp;
13
+ = link_to '[+]', new_spath_path( site_id: @site.id )
14
+ &nbsp;
15
+ = button_to 'check', check_sitemap_path( site: @site ), data: { confirm: 'Are you sure?' }
16
+
17
+ -# %hr
18
+ = render '/wco/sitemap_paths/index', spaths: @site.sitemap_paths
19
+
20
+ .col-md-3
21
+ = render '/wco/tags/header'
22
+ = render '/wco/tags/index', tags: @site.tags
data/config/routes.rb CHANGED
@@ -62,6 +62,7 @@ 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 'sitemap_paths/:id/check', to: 'sitemap_paths#check', as: :check_spath
65
66
  resources :sitemap_paths, as: :spaths
66
67
  resources :subscriptions
67
68
 
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.168
4
+ version: 3.1.0.169
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-07-31 00:00:00.000000000 Z
11
+ date: 2024-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ahoy_matey
@@ -424,6 +424,7 @@ files:
424
424
  - app/assets/stylesheets/wco/office_action_templates.scss
425
425
  - app/assets/stylesheets/wco/pagination.scss
426
426
  - app/assets/stylesheets/wco/photos.scss
427
+ - app/assets/stylesheets/wco/sitemaps.scss
427
428
  - app/assets/stylesheets/wco/utils.scss
428
429
  - app/assets/stylesheets/wco/videos.scss
429
430
  - app/controllers/wco/api/leads_controller.rb
@@ -634,7 +635,9 @@ files:
634
635
  - app/views/wco/reports/show.haml
635
636
  - app/views/wco/sitemap_paths/_form.haml
636
637
  - app/views/wco/sitemap_paths/_index.haml
638
+ - app/views/wco/sitemap_paths/check.haml
637
639
  - app/views/wco/sitemap_paths/edit.haml
640
+ - app/views/wco/sitemap_paths/new.haml
638
641
  - app/views/wco/sites/_form.haml
639
642
  - app/views/wco/sites/_header.haml
640
643
  - app/views/wco/sites/check_sitemap.haml