wco_models 3.5.0.10 → 3.5.0.12

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: 862a406eb4a6d40a4ec5e6459976979c588c2b0bd6da3bd2c04130f79a3d39ea
4
- data.tar.gz: 28554991c346b364cd4aa08f57c3edca728d1e25d6bdd9845fa34c98bf584f91
3
+ metadata.gz: 4099dbffe17a810767e219038668b3c78619a7455b3fd43ab2dcacb2a4c6c3b5
4
+ data.tar.gz: f05f916c3aa8dc345128c8f8a80e84ee257e9f59083d273e3f40573368856c79
5
5
  SHA512:
6
- metadata.gz: 916751f803a76ed9f3b5102071a535e21d0500ef29dc62dac7808f8e5b305c8c085934b89d94310d677598b56c31361f7f2aa02f6638cbf951bc5f7a0aa97aa8
7
- data.tar.gz: 235e2890a18f7bca79d75f8610baa342ef7d26ebe2187dd3446138e6739e0793cc6807329edde4a178ce953e2f490b5923b13938b3e7ca4fddb16f7b68d2bd2e
6
+ metadata.gz: 39c61c813f34021638e31ea31dcbc1bf4b544eed924135572e337a000dc7773a9d186ad2b3ac59844038c5db52bfef8c47cc39f203a807dbc8a23a6629ee23d0
7
+ data.tar.gz: 7979d233ef199c5beeb8e051581becc0995b77721d3c27e4fd2284eea9f5bf15f56a36077c94caa95a309b8e72b549e45374e24ddfe4e3069fc1e6f54d5df1ed
@@ -16,7 +16,7 @@ class Wco::PublishersController < Wco::ApplicationController
16
16
  @publisher = Wco::Publisher.find params[:id]
17
17
  authorize! :do_run, @publisher
18
18
 
19
- @publisher.props = OpenStruct.new( JSON.parse params[:props] )
19
+ @publisher.props = OpenStruct.new( JSON.parse params[:publisher][:props] || params[:props] )
20
20
  flag = @publisher.do_run
21
21
  if !flag
22
22
  flash_alert @publisher.errors
@@ -24,7 +24,8 @@ class Wco::PublishersController < Wco::ApplicationController
24
24
  flash_notice "#do_run_any Probably ok"
25
25
  end
26
26
 
27
- redirect_to request.referrer || { action: 'index' }
27
+ @publishers = Wco::Publisher.all
28
+ render 'index'
28
29
  end
29
30
 
30
31
  def edit
@@ -9,8 +9,11 @@ end
9
9
  class Wco::Publisher
10
10
  include Mongoid::Document
11
11
  include Mongoid::Timestamps
12
+ include Wco::PublisherD10
12
13
  store_in collection: 'wco_publishers'
13
14
 
15
+ attr_accessor :output_str
16
+
14
17
  field :slug
15
18
  validates :slug, presence: true, uniqueness: true
16
19
 
@@ -75,6 +78,7 @@ class Wco::Publisher
75
78
  eval( after_eval )
76
79
  end
77
80
 
81
+ publisher.output_str = out
78
82
  return true
79
83
  end
80
84
 
@@ -87,31 +91,3 @@ class Wco::Publisher
87
91
  [[nil,nil]] + all.map { |p| [p, p.id] }
88
92
  end
89
93
  end
90
-
91
- =begin
92
-
93
- curl --include \
94
- --request POST \
95
- --user admin:<>, \
96
- --header 'Content-type: application/hal+json' \
97
- http://pi.local/node?_format=hal_json \
98
- --data-binary '{
99
- "_links": {
100
- "type":{"href":"http://pi.local/rest/type/node/article"}
101
- },
102
- "title":[{"value":"Node +++ 123 bac +++" }],
103
- "body":[{"value": "<b>hello, wor</b>ld!", "format": "full_html" }],
104
- "type":[{"target_id":"article"}],
105
- "status": [{"value": 1}],
106
- "_embedded": {
107
- "http://pi.local/rest/relation/node/article/field_issue": [
108
- { "uuid": [{ "value": "56229a95-d675-43e1-99b1-f9e11b5579c5" }] }
109
- ],
110
- "http://pi.local/rest/relation/node/article/field_tags": [
111
- { "uuid": [{ "value": "45646a7d-1a16-42e8-b758-f6e1c8d976f7" }] },
112
- { "uuid": [{ "value": "834e34e2-05ae-498d-b876-453798872ce1" }] }
113
- ]
114
- }
115
- }'
116
-
117
- =end
@@ -1,10 +1,60 @@
1
1
 
2
2
  ##
3
- ## this doesn't work and was never tested or used.
4
3
  ## 2026-11-14
5
4
  ##
6
- class Wco::PublisherD10 < Wco::Publisher
5
+ module Wco::PublisherD10
7
6
 
7
+ def field_tags_data
8
+ publisher = self
9
+
10
+ tags = publisher.tags.where( site: publisher.site )
11
+ return "" if !tags.present?
12
+
13
+ out = tags.map do |tag|
14
+ { "type": "taxonomy_term--tags", "id": tag.external_id.to_s }
15
+ end
16
+
17
+ out =<<~AOL
18
+ "field_tags": { "data": <%= out %> }
19
+ AOL
20
+ end
21
+
22
+ def field_image_thumb_data photo=nil
23
+ return '' if !photo
24
+
25
+ out =<<~AOL
26
+ "field_image_thumb": { "data": { "type": "file--file", "id": "#{save_image(photo)}" } },
27
+ AOL
28
+ end
29
+
30
+ ## this works, if file_entity is not present in d10.
31
+ def save_image image
32
+ publisher = self
33
+ # image = Wco::Photo.all.last
34
+
35
+ site = publisher.site
36
+ image_url = image.photo.url(:thumb)
37
+
38
+ uri = URI(image_url)
39
+ image_data = Net::HTTP.get(uri)
40
+ credentials = Base64.strict_encode64("#{site.username}:#{site.password}")
41
+
42
+ puts! 'Saving an image...'
43
+ response = HTTParty.post(
44
+ "#{site.origin}/jsonapi/node/article/field_image_thumb",
45
+ headers: {
46
+ 'Content-Type' => 'application/octet-stream',
47
+ 'Accept' => 'application/vnd.api+json',
48
+ 'Content-Disposition' => 'file; filename="thumbnail.jpg"',
49
+ 'Authorization' => "Basic #{credentials}",
50
+ },
51
+ body: image_data
52
+ )
53
+ puts! response, 'response'
54
+ field_image_thumb_id = response['data']['id']
55
+ end
56
+
57
+ ## this doesn't work and was never tested or used.
8
58
  def self.context_eval
9
59
 
10
60
  @headers['Content-Type'] = 'application/vnd.api+json'
@@ -142,6 +142,12 @@ class Wco::Site
142
142
  return { total_count: @total_count, error_count: @error_count, results: @results }
143
143
  end
144
144
 
145
+ def basic_credentials
146
+ site = self
147
+ credentials = Base64.strict_encode64("#{site.username}:#{site.password}")
148
+ "Basic #{credentials}"
149
+ end
150
+
145
151
  def logg msg
146
152
  Wco::Log.create!({
147
153
  message: msg,
@@ -1,4 +1,8 @@
1
1
 
2
+ .a
3
+ .b
4
+ = @publisher.output_str rescue nil
5
+
2
6
  .publishers-index.maxwidth
3
7
  %h5
4
8
  Publishers
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wco_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.0.10
4
+ version: 3.5.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev