wco_models 3.4.0.9 → 3.4.0.10

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: 931abf0936b81ddba99ba3723e7d3a138009e6dcc735effc1655113d57ebde03
4
- data.tar.gz: 6ae127b731884b1d1c58a017c455158f8b07d23d6ec56ed3afcb70818a7faa9e
3
+ metadata.gz: 4f5abb5827947d4171ccd787261016dd83ab76eb8df606961e3fbd639771ae4b
4
+ data.tar.gz: 24b8d1da5e414a442bcf05c9cb8b85d7440a431b2335584f4dc564c7370a1390
5
5
  SHA512:
6
- metadata.gz: ccdadbdf9e7984ace44cf61ee7d6a0568181c55b98201903ff900233476eea4079f2dcadae689408d7494f47338e1bf1a76a9df40cfb546c6cdefec85dc04c6a
7
- data.tar.gz: a9662923a67361ad564cd9512a2617555b657974cd50127365cf0b8c47e3438caa013dba020e4b91cafd7f5d610a9cfa513c4fc865714aa6009847f8b0b1e99a
6
+ metadata.gz: 5230158058f314c630b0085006c91bec6211fbbbe5559ab88f3ce5021d9667acee3116085291cd8802ad51c49871be20000216d1d8545fcab59724624997a20f
7
+ data.tar.gz: 5d526a2d4bdaf7ecf50d5492e4a028f76f2a376219de38991d814e2de32026e80323a3f64ab0f2203d07a846b9fd20e7bfdf0d117c8cb49471a946fa4af394c5
@@ -7,12 +7,13 @@ class Wco::SitemapPathsController < Wco::ApplicationController
7
7
  @spath = Wco::SitemapPath.find params[:id]
8
8
  authorize! :check, @spath
9
9
  @spath.check
10
+ redirect_to wco.spath_path(@spath)
10
11
  end
11
12
 
12
13
  def clear
13
14
  @spath = Wco::SitemapPath.find params[:id]
14
15
  authorize! :clear, @spath
15
- @spath.update_attributes({ results: [] })
16
+ @spath.logs.destroy_all
16
17
  redirect_to request.referrer || sites_path(@spath.site)
17
18
  end
18
19
 
@@ -29,6 +30,18 @@ class Wco::SitemapPathsController < Wco::ApplicationController
29
30
  end
30
31
  end
31
32
 
33
+ def destroy
34
+ @spath = Wco::SitemapPath.find params[:id]
35
+ site_id = @spath.site_id
36
+ authorize! :destroy, @spath
37
+ if @spath.destroy
38
+ flash_notice 'ok'
39
+ else
40
+ flash_alert 'No luck.'
41
+ end
42
+ redirect_to request.referrer || sites_path(site_id)
43
+ end
44
+
32
45
  def edit
33
46
  @spath = Wco::SitemapPath.find params[:id]
34
47
  @site = @spath.site
@@ -45,7 +58,6 @@ class Wco::SitemapPathsController < Wco::ApplicationController
45
58
  @spath = Wco::SitemapPath.find params[:id]
46
59
  @site = @spath.site
47
60
  authorize! :show, @spath
48
- render 'check'
49
61
  end
50
62
 
51
63
 
@@ -0,0 +1,50 @@
1
+
2
+ ##
3
+ ## this doesn't work and was never tested or used.
4
+ ## 2026-11-14
5
+ ##
6
+ class Wco::PublisherD10 < Wco::Publisher
7
+
8
+ def self.context_eval
9
+
10
+ @headers['Content-Type'] = 'application/vnd.api+json'
11
+ @headers['Authorization'] = "Basic base64(#{@site.username}:#{@site.password})"
12
+
13
+ @report = Wco::Report.find @props[:report_id]
14
+
15
+ tags = @publisher.tags.where( site: @site )
16
+ @tags_data = tags.map do |tag|
17
+ { "type": "taxonomy_term--tags", "id": tag.external_id.to_s }
18
+ end.to_json
19
+ puts! @tags_data, '@tags_data'
20
+
21
+ @field_image_thumb_data = ""
22
+ if false || @report.image_thumb
23
+ image_url ||= @report.image_thumb.photo.url(:thumb)
24
+
25
+ uri = URI(image_url)
26
+ image_data = Net::HTTP.get(uri)
27
+ credentials = Base64.strict_encode64("#{@site.username}:#{@site.password}")
28
+
29
+ puts! 'Saving an image...'
30
+ response = HTTParty.post(
31
+ "#{@site.origin}/jsonapi/node/article/field_image_thumb",
32
+ headers: {
33
+ 'Content-Type' => 'application/octet-stream',
34
+ 'Accept' => 'application/vnd.api+json',
35
+ 'Content-Disposition' => 'file; filename="thumbnail.jpg"',
36
+ 'Authorization' => "Basic #{credentials}",
37
+ },
38
+ body: image_data
39
+ )
40
+ puts! response, 'response'
41
+ field_image_thumb_id = response['data']['id']
42
+ @field_image_thumb_data =<<~AOL
43
+ "field_image_thumb": { "data": { "type": "file--file", "id": "#{field_image_thumb_id}" } },
44
+ AOL
45
+ puts! @field_image_thumb_data, '@field_image_thumb_data'
46
+ end
47
+
48
+ end
49
+
50
+ end
@@ -15,9 +15,15 @@ class Wco::SitemapPath
15
15
  field :selectors, type: Array, default: []
16
16
  field :title, type: String
17
17
 
18
- field :results, type: Array, default: []
18
+
19
19
  field :status, type: String
20
20
 
21
+ # field :results, type: Array, default: []
22
+ has_many :logs, inverse_of: :obj
23
+ def results
24
+ logs.map { |log| "#{log.message} [on #{log.created_at.to_s[0...10]}]" }
25
+ end
26
+
21
27
  def check
22
28
  self.status = 'NOT_OK'
23
29
  skip_rest = false
@@ -26,26 +32,26 @@ class Wco::SitemapPath
26
32
  begin
27
33
  body = HTTParty.get( "#{site.origin}#{self[:path]}" ).body
28
34
  rescue OpenSSL::SSL::SSLError => err
29
- results.push "NOT OK [ssl-exception] #{self[:path]}" # .red
35
+ log = Wco::Log.create obj: self, message: "NOT OK [ssl-exception] #{self[:path]}" # .red
30
36
  return
31
37
  end
32
38
  doc = Nokogiri::HTML( body )
33
39
  out = doc.search self[:selector]
34
40
  if out.present?
35
- results.push "OK #{self[:path]}"
41
+ log = Wco::Log.create obj: self, message: "OK #{self[:path]}"
36
42
  self.status = 'OK'
37
43
  else
38
- results.push "NOT OK [selector-missing] #{self[:path]}" # .red
44
+ log = Wco::Log.create obj: self, message: "NOT OK [selector-missing] #{self[:path]}" # .red
39
45
  end
40
46
 
41
47
  elsif self[:redirect_to].present?
42
48
  out = HTTParty.get( "#{site.origin}#{self[:path]}", follow_redirects: false )
43
49
  if( out.headers[:location] == self[:redirect_to] ||
44
50
  out.headers[:location] == "#{site.origin}#{self[:redirect_to]}" )
45
- results.push "OK #{self[:path]}"
51
+ log = Wco::Log.create obj: self, message: "OK #{self[:path]}"
46
52
  self.status = 'OK'
47
53
  else
48
- results.push "NOT OK [redirect-missing] #{self[:path]}" # .red
54
+ log = Wco::Log.create obj: self, message: "NOT OK [redirect-missing] #{self[:path]}" # .red
49
55
 
50
56
  puts!( out.response, 'response' ) if DEBUG
51
57
  # puts!( out.body, 'body' ) if DEBUG
@@ -56,7 +62,7 @@ class Wco::SitemapPath
56
62
  end
57
63
  skip_rest = true
58
64
  else
59
- results.push "SKIP #{self[:path]}"
65
+ log = Wco::Log.create obj: self, message: "SKIP #{self[:path]}"
60
66
  self.status = 'OK'
61
67
  skip_rest = true
62
68
  end
@@ -66,10 +72,10 @@ class Wco::SitemapPath
66
72
  if self[:meta_description].present?
67
73
  out = doc.search( 'head meta[name="description"]' )[0]['content']
68
74
  if out.include?( self[:meta_description] )
69
- results.push "OK #{self[:path]} meta_description"
75
+ log = Wco::Log.create obj: self, message: "OK #{self[:path]} meta_description"
70
76
  else
71
77
  self.status = 'NOT_OK'
72
- results.push "NOT OK [meta-description-no-contain] #{self[:path]}" # .red
78
+ log = Wco::Log.create obj: self, message: "NOT OK [meta-description-no-contain] #{self[:path]}" # .red
73
79
  end
74
80
  end
75
81
 
@@ -77,10 +83,10 @@ class Wco::SitemapPath
77
83
  self[:selectors].each do |selector|
78
84
  out = doc.search selector
79
85
  if out.present?
80
- results.push "OK #{self[:path]} selectors:#{selector}"
86
+ log = Wco::Log.create obj: self, message: "OK #{self[:path]} selectors:#{selector}"
81
87
  else
82
88
  self.status = 'NOT_OK'
83
- results.push "NOT OK [selectors-missing:#{selector}] #{self[:path]}" # .red
89
+ log = Wco::Log.create obj: self, message: "NOT OK [selectors-missing:#{selector}] #{self[:path]}" # .red
84
90
  end
85
91
  end
86
92
  end
@@ -88,10 +94,10 @@ class Wco::SitemapPath
88
94
  if self[:title].present?
89
95
  out = doc.search( 'head title' )[0].text
90
96
  if out.include?( self[:title] )
91
- results.push "OK #{self[:path]} title"
97
+ log = Wco::Log.create obj: self, message: "OK #{self[:path]} title"
92
98
  else
93
99
  self.status = 'NOT_OK'
94
- results.push "NOT OK [title-no-contain] #{self[:path]}" # .red
100
+ log = Wco::Log.create obj: self, message: "NOT OK [title-no-contain] #{self[:path]}" # .red
95
101
  end
96
102
  end
97
103
 
@@ -11,6 +11,7 @@
11
11
  %tr
12
12
  %td
13
13
  = link_to '[~]', edit_spath_path(spath)
14
+ .d-inline-block= button_to 'X', spath_path(spath), method: :delete, data: { confirm: 'Are you sure?' }
14
15
  .d-inline-block= button_to 'check', check_spath_path(spath), method: :get
15
16
  = link_to "#{@site.origin}#{spath.path}","#{@site.origin}#{spath.path}", target: :_blank
16
17
  - if spath.redirect_to
@@ -0,0 +1,14 @@
1
+
2
+ .sitemap-paths-show.maxwidth
3
+
4
+ .d-flex
5
+ = link_to '[back to Site]', 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 'check', check_spath_path(@spath), data: { confirm: 'Are you sure?' }
9
+ = button_to 'clear', clear_spath_path(@spath), data: { confirm: 'Are you sure?' }
10
+
11
+ .spaths-check
12
+ %ul
13
+ - @spath.results.each do |result|
14
+ %li= result
@@ -9,7 +9,7 @@
9
9
  .Sitemaps.col-md-9
10
10
 
11
11
  %h5.d-flex
12
- Sitemap Paths &nbsp;
12
+ Sitemap Paths (#{@site.sitemap_paths.length})&nbsp;
13
13
  = link_to '[+]', new_spath_path( site_id: @site.id )
14
14
  &nbsp;
15
15
  = button_to 'check', check_sitemap_path( site: @site ), data: { confirm: 'Are you sure?' }
data/config/routes.rb CHANGED
@@ -128,8 +128,8 @@ Wco::Engine.routes.draw do
128
128
 
129
129
  post 'sites/:id/check_sitemap', to: 'sites#check_sitemap', as: :check_sitemap
130
130
  resources :sites
131
- get 'sitemap_paths/:id/check', to: 'sitemap_paths#check', as: :check_spath
132
- post 'sitemap_paths/:id/clear', to: 'sitemap_paths#clear', as: :clear_spath
131
+ match 'sitemap_paths/:id/check', to: 'sitemap_paths#check', as: :check_spath, via: [ :get, :post ]
132
+ post 'sitemap_paths/:id/clear', to: 'sitemap_paths#clear', as: :clear_spath
133
133
  resources :sitemap_paths, as: :spaths
134
134
  resources :subscriptions
135
135
 
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.4.0.9
4
+ version: 3.4.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-12 00:00:00.000000000 Z
11
+ date: 2026-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -541,6 +541,7 @@ files:
541
541
  - app/models/wco/product.rb
542
542
  - app/models/wco/profile.rb
543
543
  - app/models/wco/publisher.rb
544
+ - app/models/wco/publisher_d10.rb
544
545
  - app/models/wco/report.rb
545
546
  - app/models/wco/setting.rb
546
547
  - app/models/wco/site.rb
@@ -762,9 +763,10 @@ files:
762
763
  - app/views/wco/reports/show.haml
763
764
  - app/views/wco/sitemap_paths/_form.haml
764
765
  - app/views/wco/sitemap_paths/_index.haml
765
- - app/views/wco/sitemap_paths/check.haml
766
+ - app/views/wco/sitemap_paths/check.haml-trash
766
767
  - app/views/wco/sitemap_paths/edit.haml
767
768
  - app/views/wco/sitemap_paths/new.haml
769
+ - app/views/wco/sitemap_paths/show.haml
768
770
  - app/views/wco/sites/_form.haml
769
771
  - app/views/wco/sites/_header.haml
770
772
  - app/views/wco/sites/check_sitemap.haml