wco_models 3.1.0.154 → 3.1.0.155

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: 8214f97a78a923e7696ac257e51c35e82735e5f49ee72fb5323897c263494eed
4
- data.tar.gz: 50a95c9ae5bc39baf0f5ed8c959b537219e6646accffd52f46577941c393835e
3
+ metadata.gz: 7087d1bed892c6923940fc6d1c8ba234ad9e9773e490e4bce6d92808625ad211
4
+ data.tar.gz: f88b3cb63acf8f2253156ec1fd45b53d1ff6e9d14886a19233142e7e026efc0d
5
5
  SHA512:
6
- metadata.gz: 2ee8c67d727e601dbf625f4309651d56611f147852e50091bb0f8144b4b25aa382a88268fce8475a975157a9fd01e97d8bc7bdc06c980dd02084fe47eb6683c9
7
- data.tar.gz: 7356863e168fc520d0dd7ba14a9a4e02bd4b77b97b92a00df164569f0136162446a843189495fde59eac51d804cae0a93adccfc99b2a292aca8c6af579cb3bc1
6
+ metadata.gz: da0b670caac9e737d49dbbf02633554617cd18c9abdc8def6dc8b65ad20e62038aa984e01f010bed84a2efa1b06b9e31db609acb418d9587b7681d071026813b
7
+ data.tar.gz: a828cddbe1e4662d249167c24ec8e5c0abf29beb1811deb3c780c10e013b148004884ea9a5fa30ac4756d823ab8bb26b712ea5ec64cc97587b95cb165fb94339
@@ -167,7 +167,7 @@ textarea.monospace {
167
167
  /* M */
168
168
 
169
169
  .maxwidth {
170
- width: 1000px;
170
+ max-width: 1000px; /* @TODO: this would be responsive by-breakpoint _vp_ 2024-04-23 */
171
171
  margin: auto;
172
172
  }
173
173
 
@@ -1,6 +1,13 @@
1
1
 
2
2
  class Wco::SitesController < Wco::ApplicationController
3
3
 
4
+ def check_sitemap
5
+ @site = Wco::Site.find params[:id]
6
+ authorize! :check_sitemap, @site
7
+ @site.check_sitemap
8
+ redirect_to request.referrer
9
+ end
10
+
4
11
  def create
5
12
  @site = Wco::Site.new params[:site].permit!
6
13
  authorize! :create, @site
@@ -41,6 +48,8 @@ class Wco::SitesController < Wco::ApplicationController
41
48
  def show
42
49
  @site = Wco::Site.find params[:id]
43
50
  authorize! :show, @site
51
+
52
+ @new_sitemap_path = Wco::SitemapPath.new( site_id: @site.id )
44
53
  end
45
54
 
46
55
  def update
@@ -29,13 +29,13 @@ class Wco::OfficeActionTemplate
29
29
  has_many :prev_ties, class_name: 'OfficeActionTemplateTie', inverse_of: :next_office_action_template
30
30
  accepts_nested_attributes_for :ties
31
31
 
32
+ has_and_belongs_to_many :email_filters, class_name: WcoEmail::EmailFilter
33
+
32
34
  def to_s
33
35
  "#{slug}"
34
36
  end
35
-
36
37
  def self.list
37
38
  [[nil,nil]] + all.map { |ttt| [ ttt.slug, ttt.id ] }
38
39
  end
39
-
40
40
  end
41
- OAT ||= Wco::OfficeActionTemplate
41
+ # OAT ||= Wco::OfficeActionTemplate
@@ -14,8 +14,11 @@ class Wco::Site
14
14
  [nil] + KINDS
15
15
  end
16
16
 
17
- has_many :publishers # , class_name: 'Wco::Publisher'
17
+
18
18
  has_many :headlines # , class_name: 'Wco::Newstitle'
19
+ has_many :logs, inverse_of: :obj
20
+ has_many :publishers # , class_name: 'Wco::Publisher'
21
+ has_many :sitemap_paths, class_name: 'Wco::SitemapPath'
19
22
  has_many :tags, class_name: 'Wco::Tag'
20
23
 
21
24
  field :slug
@@ -101,4 +104,112 @@ class Wco::Site
101
104
  puts "ok"
102
105
  end
103
106
 
107
+ def check_sitemap
108
+ results = []
109
+ total_count = 0
110
+ error_count = 0
111
+
112
+ sitemap_paths.each do |check|
113
+ total_count += 1
114
+
115
+ # puts "Checking #{check[:path]}:"
116
+ if check[:selector]
117
+ begin
118
+ body = HTTParty.get( "#{origin}#{check[:path]}" ).body
119
+ rescue OpenSSL::SSL::SSLError => err
120
+ results.push "NOT OK [ssl-exception] #{check[:path]}".red
121
+ logg "NOT OK [ssl-exception] #{check[:path]}"
122
+ check.update status: 'NOT OK'
123
+
124
+ next
125
+ end
126
+ doc = Nokogiri::HTML( body )
127
+ out = doc.search check[:selector]
128
+ if out.present?
129
+ results.push "OK #{check[:path]}"
130
+ logg "OK #{check[:path]}"
131
+ check.update status: 'OK'
132
+ else
133
+ results.push "NOT OK [selector-missing] #{check[:path]}".red
134
+ logg "NOT OK [selector-missing] #{check[:path]}"
135
+ check.update status: 'NOT OK'
136
+ error_count += 1
137
+ end
138
+
139
+ if check[:meta_description]
140
+ out = doc.search( 'head meta[name="description"]' )[0]['content']
141
+ if check[:meta_description] == out
142
+ results.push "OK #{check[:path]} meta_description"
143
+ logg "OK #{check[:path]} meta_description"
144
+ check.update status: 'OK'
145
+ else
146
+ results.push "NOT OK [meta-description-missing] #{check[:path]}".red
147
+ logg "NOT OK [meta-description-missing] #{check[:path]}"
148
+ check.update status: 'NOT OK'
149
+ error_count += 1
150
+ end
151
+ end
152
+
153
+ elsif check[:redirect_to]
154
+ out = HTTParty.get( "#{origin}#{check[:path]}", follow_redirects: false )
155
+ if( out.headers[:location] == check[:redirect_to] ||
156
+ out.headers[:location] == "#{origin}#{check[:redirect_to]}" )
157
+ results.push "OK #{check[:path]}"
158
+ logg "OK #{check[:path]}"
159
+ check.update status: 'OK'
160
+ else
161
+ results.push "NOT OK [redirect-missing] #{check[:path]}".red
162
+ logg "NOT OK [redirect-missing] #{check[:path]}"
163
+ check.update status: 'NOT OK'
164
+
165
+ puts!( out.response, 'response' ) if DEBUG
166
+ # puts!( out.body, 'body' ) if DEBUG
167
+
168
+ error_count += 1
169
+
170
+ puts "NOT OK #{check[:path]}".red
171
+ puts out.headers[:location]
172
+ puts check[:redirect_to]
173
+ end
174
+ else
175
+ results.push "SKIP #{check[:path]}"
176
+ logg "SKIP #{check[:path]}"
177
+ check.update status: 'SKIP'
178
+ end
179
+
180
+ if check[:selectors]
181
+ check[:selectors].each do |selector|
182
+ body = HTTParty.get( "#{origin}#{check[:path]}" ).body
183
+ doc = Nokogiri::HTML( body )
184
+ out = doc.search selector
185
+ if out.present?
186
+ results.push "OK #{check[:path]} selectors:#{selector}"
187
+ logg "OK #{check[:path]} selectors:#{selector}"
188
+ check.update status: 'OK'
189
+ else
190
+ results.push "NOT OK [selectors-missing:#{selector}] #{check[:path]}".red
191
+ logg "NOT OK [selectors-missing:#{selector}] #{check[:path]}"
192
+ check.update status: 'NOT OK'
193
+ error_count += 1
194
+ end
195
+ end
196
+ end
197
+
198
+ end
199
+
200
+ puts "Results:".green
201
+ results.each do |r|
202
+ puts r
203
+ end
204
+ puts "Total count: #{total_count}"
205
+ puts "Error count: #{error_count}"
206
+ end
207
+
208
+ def logg msg
209
+ Wco::Log.create!({
210
+ message: msg,
211
+ obj: self,
212
+ })
213
+ end
214
+
104
215
  end
@@ -0,0 +1,20 @@
1
+
2
+ class Wco::SitemapPath
3
+ include Mongoid::Document
4
+ include Mongoid::Timestamps
5
+ include Mongoid::Paranoia
6
+ store_in collection: 'wco_sitemap_paths'
7
+
8
+ belongs_to :site, class_name: 'Wco::Site'
9
+
10
+ field :path, type: String
11
+ validates :path, presence: true, uniqueness: { scope: :site }
12
+
13
+ field :redirect_to, type: String
14
+ field :selector, type: String
15
+ field :selectors, type: Array, default: []
16
+
17
+ field :status, type: String
18
+
19
+ end
20
+
@@ -10,6 +10,9 @@ class WcoEmail::EmailFilter
10
10
 
11
11
  PAGE_PARAM_NAME = :filters_page
12
12
 
13
+ FIELD_OPTS = [ :subject, :from, :to, :to_and_cc, :body, ]
14
+ MATCHTYPE_OPTS = [ :regex, :exact_insensitive, ]
15
+
13
16
  field :from_regex
14
17
  field :from_exact
15
18
  field :subject_regex
@@ -20,6 +23,10 @@ class WcoEmail::EmailFilter
20
23
  field :skip_from_regex
21
24
  field :skip_to_exact
22
25
 
26
+ has_many :email_filter_conditions
27
+ has_many :email_filter_skip_conditions, class_name: 'WcoEmail::EmailFilterCondition'
28
+ has_and_belongs_to_many :action_tmpls, class_name: 'Wco::OfficeActionTemplate'
29
+
23
30
  belongs_to :tag, class_name: 'Wco::Tag', inverse_of: :email_filters, optional: true
24
31
 
25
32
  KIND_AUTORESPOND_TMPL = 'autorespond-template'
@@ -36,6 +43,7 @@ class WcoEmail::EmailFilter
36
43
  KINDS = [ nil, KIND_AUTORESPOND_TMPL, KIND_AUTORESPOND_EACT, KIND_ADD_TAG, KIND_REMOVE_TAG, KIND_DESTROY_SCHS]
37
44
  field :kind
38
45
 
46
+
39
47
  belongs_to :email_template, class_name: 'WcoEmail::EmailTemplate', optional: true
40
48
  belongs_to :email_action_template, class_name: 'WcoEmail::EmailActionTemplate', optional: true
41
49
 
@@ -0,0 +1,17 @@
1
+
2
+ class WcoEmail::EmailFilterCondition
3
+ include Mongoid::Document
4
+ include Mongoid::Timestamps
5
+ include Mongoid::Paranoia
6
+ store_in collection: 'office_email_filter_conditions'
7
+
8
+ belongs_to :email_filter, inverse_of: :email_filter_conditions
9
+ belongs_to :email_filter_skip, inverse_of: :email_filter_skip_conditions
10
+
11
+ field :field
12
+ field :matchtype
13
+ field :value
14
+
15
+
16
+ end
17
+
@@ -29,7 +29,10 @@ class WcoEmail::Message
29
29
 
30
30
  field :read_at, type: DateTime
31
31
  index({ read_at: -1 })
32
- scope :unread, ->{ where( read_at: nil ) }
32
+ def self.unread
33
+ where( read_at: nil )
34
+ end
35
+ # scope :unread, ->() { where( read_at: nil ) }
33
36
 
34
37
  def part_html_sanitized
35
38
  doc = Nokogiri::HTML part_html
@@ -1,6 +1,9 @@
1
1
  !!!
2
2
  %html
3
3
  %head
4
+ %title #{@page_title} | Wco Core
5
+ %link{ :rel => 'icon', :href => "/favicon_#{ENV['RAILS_ENV']}.gif" }
6
+ %meta{ :name => :viewport, :content => 'width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=2' }
4
7
  %meta{content: "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}
5
8
  %title Wco Models
6
9
 
@@ -7,36 +7,39 @@
7
7
 
8
8
  %i.fa.fa-compress.collapse-expand#collapseHeaderModels
9
9
  Wco Suite
10
- .flex-row
11
- %ul
12
- %li= link_to 'ROOT', '/'
13
- - if defined? wco_email
14
- %li= link_to '/email', '/email'
15
- - if defined? wco_hosting
16
- %li= link_to '/hosting', '/hosting'
17
- - if defined? iro
18
- %li= link_to '/trading', '/trading'
19
-
20
- %ul
21
- %li= render '/wco/invoices/header'
22
- %li= render '/wco/products/header'
23
- %li= render '/wco/tags/header'
24
- %li= render '/wco/logs/header'
25
-
26
- %ul
27
- %li= render '/wco/leadsets/header'
28
- %li= render '/wco/leads/header'
29
- %li= render '/wco/office_action_templates/header'
30
- %li= render '/wco/office_actions/header'
31
- %li= render '/wco/profiles/header'
32
-
33
- %ul
34
- %li= render '/wco/sites/header'
35
- %li= render '/wco/headlines/header'
36
- %li= render '/wco/publishers/header'
37
- %li= render '/wco/galleries/header_mini'
38
- %li= render '/wco/reports/header'
39
- %li= render '/wco/videos/header'
10
+ .W
11
+
12
+ .d-flex.flex-wrap
13
+
14
+ %ul
15
+ %li= link_to 'ROOT', '/'
16
+ - if defined? wco_email
17
+ %li= link_to '/email', '/email'
18
+ - if defined? wco_hosting
19
+ %li= link_to '/hosting', '/hosting'
20
+ - if defined? iro
21
+ %li= link_to '/trading', '/trading'
22
+
23
+ %ul
24
+ %li= render '/wco/invoices/header'
25
+ %li= render '/wco/products/header'
26
+ %li= render '/wco/tags/menuitem'
27
+ %li= render '/wco/logs/header'
28
+
29
+ %ul
30
+ %li= render '/wco/leadsets/header'
31
+ %li= render '/wco/leads/header'
32
+ %li= render '/wco/office_action_templates/header'
33
+ %li= render '/wco/office_actions/header'
34
+ %li= render '/wco/profiles/header'
35
+
36
+ %ul
37
+ %li= render '/wco/sites/header'
38
+ %li= render '/wco/headlines/header'
39
+ %li= render '/wco/publishers/header'
40
+ %li= render '/wco/galleries/header_mini'
41
+ %li= render '/wco/reports/header'
42
+ %li= render '/wco/videos/header'
40
43
 
41
44
 
42
45
  .c
@@ -0,0 +1,18 @@
1
+
2
+ .sitemap-paths--form
3
+ = form_for spath do |f|
4
+ = hidden_field_tag :site_id, spath[:site_id] || params[:site_id]
5
+
6
+ .d-flex
7
+ .field
8
+ %label Path
9
+ = f.text_field :path
10
+ .field
11
+ %label redirect_to
12
+ = f.text_field :redirect_to
13
+ .field
14
+ %label selector
15
+ = f.text_field :selector
16
+
17
+ .actions
18
+ = f.submit 'Go'
@@ -0,0 +1,15 @@
1
+
2
+ .sitemap-paths--index
3
+ %table.bordered.data-table
4
+ %thead
5
+ %td Path
6
+ %td Redirect To
7
+ %td Selector
8
+ %td Status
9
+ %tbody
10
+ - spaths.each do |spath|
11
+ %tr
12
+ %td= spath.path
13
+ %td= spath.redirect_to
14
+ %td= spath.selector
15
+ %td= spath.status
@@ -1,8 +1,18 @@
1
1
 
2
- .sites-show.maxwidth
3
- .header
4
- %h5.title
5
- = @site
2
+ .sites-show.padded
3
+ .maxwidth
4
+ .header
5
+ %h5.title
6
+ = @site
6
7
 
7
- = render '/wco/tags/header'
8
- = render '/wco/tags/index', tags: @site.tags
8
+ = render '/wco/tags/header'
9
+ = render '/wco/tags/index', tags: @site.tags
10
+
11
+ %h5.d-flex
12
+ Sitemap Paths&nbsp;
13
+ = link_to '[+]', new_sitemap_path_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
@@ -1,7 +1,5 @@
1
1
 
2
- .d-flex
3
- = link_to "Tags (#{Wco::Tag.all.length})", wco.tags_path
4
- .inline-search
5
- = form_tag wco.tags_path, method: :get do
6
- = text_field_tag :q
7
- = link_to '[+]', wco.new_tag_path
2
+ .header
3
+ %h5.title
4
+ Tags (#{Wco::Tag.all.length})&nbsp;
5
+ = link_to '[+]', wco.new_tag_path
@@ -0,0 +1,9 @@
1
+
2
+ .d-flex
3
+ = link_to "Tags (#{Wco::Tag.all.length})", wco.tags_path
4
+ &nbsp;
5
+ .inline-search
6
+ = form_tag wco.tags_path, method: :get do
7
+ = text_field_tag :q
8
+ &nbsp;
9
+ = link_to '[+]', wco.new_tag_path
data/config/routes.rb CHANGED
@@ -54,7 +54,9 @@ Wco::Engine.routes.draw do
54
54
  get 'reports/deleted', to: 'reports#index', as: :deleted_reports, defaults: { deleted: true }
55
55
  resources :reports
56
56
 
57
+ post 'sites/:id/check_sitemap', to: 'sites#check_sitemap', as: :check_sitemap
57
58
  resources :sites
59
+ resources :sitemap_paths
58
60
  resources :subscriptions
59
61
 
60
62
  delete 'tags/remove/:id/from/:resource/:resource_id', to: 'tags#remove_from', as: :remove_tag_from
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.154
4
+ version: 3.1.0.155
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-04-13 00:00:00.000000000 Z
11
+ date: 2024-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -455,6 +455,7 @@ files:
455
455
  - app/models/wco/publisher.rb
456
456
  - app/models/wco/report.rb
457
457
  - app/models/wco/site.rb
458
+ - app/models/wco/sitemap_path.rb
458
459
  - app/models/wco/subscription.rb
459
460
  - app/models/wco/tag.rb
460
461
  - app/models/wco/utils.rb
@@ -466,6 +467,7 @@ files:
466
467
  - app/models/wco_email/email_action_template.rb
467
468
  - app/models/wco_email/email_action_template_tie.rb
468
469
  - app/models/wco_email/email_filter.rb
470
+ - app/models/wco_email/email_filter_condition.rb
469
471
  - app/models/wco_email/email_template.rb
470
472
  - app/models/wco_email/message.rb
471
473
  - app/models/wco_email/message_stub.rb
@@ -597,6 +599,8 @@ files:
597
599
  - app/views/wco/reports/index_table.haml
598
600
  - app/views/wco/reports/new.haml
599
601
  - app/views/wco/reports/show.haml
602
+ - app/views/wco/sitemap_paths/_form.haml
603
+ - app/views/wco/sitemap_paths/_index.haml
600
604
  - app/views/wco/sites/_form.haml
601
605
  - app/views/wco/sites/_header.haml
602
606
  - app/views/wco/sites/edit.haml
@@ -608,6 +612,7 @@ files:
608
612
  - app/views/wco/tags/_index.haml
609
613
  - app/views/wco/tags/_index_chips.haml
610
614
  - app/views/wco/tags/_list_chips.haml
615
+ - app/views/wco/tags/_menuitem.haml
611
616
  - app/views/wco/tags/edit.haml
612
617
  - app/views/wco/tags/index.haml
613
618
  - app/views/wco/tags/new.haml