wco_models 3.1.0.167 → 3.1.0.169

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05367b8f0f5fd71ec10163a5b9015ee30e8d7ab8d9b44dfc85532e92b084e2be
4
- data.tar.gz: cd907b758d6867b0f414afa1d5f9c95b2893b4419f5480fd72039ac4b9cb1191
3
+ metadata.gz: 55d9ac4131e23711ece162eeb0d966ad0a0a1d674eeaff4914e9a8f8a04d8854
4
+ data.tar.gz: dd2312d66791bc3bb0bf644632acc6f9d37513a5331a226ea911ad2f7fa1f5e8
5
5
  SHA512:
6
- metadata.gz: ab4d63e88b4ebbf1167d8eae84603ac23a367d83e6f8f04e5624a8809dd3d31daaa8e138b3887be6d8d4b8988090b479c7de24c7cb5e8876170558677d85df68
7
- data.tar.gz: ae176db912dcd3a51c9da77564bba7ab2e3146e46b5b62b68e2ffb42b2b74bad9958e4a95df78c7df441e69c11451dd8bea3b975f77c61704b16a3a99be32386
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
@@ -77,7 +77,8 @@ class WcoEmail::ApplicationMailer < ActionMailer::Base
77
77
  mail( from: @ctx.from_email,
78
78
  to: @ctx.to_email,
79
79
  cc: @ctx.cc,
80
- bcc: "poxlovibb1@gmail.com",
80
+ ## 2024-07-30 I'm no longer sending these to google.
81
+ # bcc: "poxlovibb1@gmail.com",
81
82
  subject: rendered_subject,
82
83
  body: rendered_str,
83
84
  content_type: "text/html" )
@@ -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
 
@@ -221,11 +221,12 @@ class WcoEmail::MessageStub
221
221
  if config['skip_notification']
222
222
  ;
223
223
  else
224
- conv = WcoEmail::Conversation.find( conv.id )
225
- if conv.tags.include? Wco::Tag.inbox
226
- out = WcoEmail::ApplicationMailer.forwarder_notify( @message.id.to_s )
227
- Rails.env.production? ? out.deliver_later : out.deliver_now
228
- end
224
+ ## 2024-07-30 I'm no longer sending these to google.
225
+ # conv = WcoEmail::Conversation.find( conv.id )
226
+ # if conv.tags.include? Wco::Tag.inbox
227
+ # out = WcoEmail::ApplicationMailer.forwarder_notify( @message.id.to_s )
228
+ # Rails.env.production? ? out.deliver_later : out.deliver_now
229
+ # end
229
230
  end
230
231
 
231
232
  puts 'ok'
@@ -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.167
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
@@ -454,7 +455,6 @@ files:
454
455
  - app/helpers/wco/application_helper.rb
455
456
  - app/jobs/wco_hosting/certbot_job.rb
456
457
  - app/mailers/wco_email/application_mailer.rb
457
- - app/mailers/wco_email/application_mailer.rb-trash
458
458
  - app/models/ability.rb
459
459
  - app/models/ahoy/event.rb
460
460
  - app/models/ahoy/visit.rb
@@ -635,7 +635,9 @@ files:
635
635
  - app/views/wco/reports/show.haml
636
636
  - app/views/wco/sitemap_paths/_form.haml
637
637
  - app/views/wco/sitemap_paths/_index.haml
638
+ - app/views/wco/sitemap_paths/check.haml
638
639
  - app/views/wco/sitemap_paths/edit.haml
640
+ - app/views/wco/sitemap_paths/new.haml
639
641
  - app/views/wco/sites/_form.haml
640
642
  - app/views/wco/sites/_header.haml
641
643
  - app/views/wco/sites/check_sitemap.haml
@@ -1,18 +0,0 @@
1
- ## From: https://www.fileformat.info/info/unicode/char/a.htm
2
- ## From: https://stackoverflow.com/questions/7019034/utf-8-encoding-in-ruby-using-a-variable
3
- ## From: https://stackoverflow.com/questions/52654509/random-generate-a-valid-unicode-character-in-ruby
4
- ## latin
5
- # n1 = 0x192
6
- # n2 = 0x687
7
- ##
8
- ## weird punctuation
9
- # n1 = 0x133
10
- # n2 = 0x255
11
-
12
- # random_utf8 = Enumerator.new do |yielder|
13
- # loop do
14
- # yielder << ( rand(n2-n1)+n1 ).chr('UTF-8')
15
- # rescue RangeError
16
- # end
17
- # end
18
- # rendered_subject = "#{rendered_subject} #{ random_utf8.next }#{ random_utf8.next }"