wco_models 3.5.0.14 → 3.5.0.15

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: 103f90272ca93030e271c4e5c9dcea36ca99ce3dae9b4018e982c7908f07d037
4
- data.tar.gz: 8cbf3f2aa9780392745ee8eeac3b9b1883bbfa138801e81deef72d715cbf746d
3
+ metadata.gz: ef064fe9a8253b0ff674d511bae665d9d058244a2d9891529f26c8536fb1b713
4
+ data.tar.gz: 82ff728b550b678038b6f7baf11e6a7c8513330cf7fe924b72d4dd08b9bf56e5
5
5
  SHA512:
6
- metadata.gz: bae0cf58f5d69f501c3d5b69c36a95621726c41dcda58de23625376e6fb27cf15f1893b1bac8c8005e2539d8906866c32260c5738ae35104f57d7c8b4f07b828
7
- data.tar.gz: 728f9be425b96c1d1ae00d772301f341081e0424d7d4b5a899fafbeec017f23427d57a85825209eca439998e82d9c280d3a08c4e2b7e1d74a41f1bb96a1d3a9d
6
+ metadata.gz: e040a226b9dc8d6fdda4df02f606dd664d74d67fd518506da0adfa4b73f1417f0fc4c449e14b3f0042119449577006203d2a235d2e97a10125af727a59d7855e
7
+ data.tar.gz: ef71554379a09d2ffb41fac9e5c14ccb581562d3efa143f6c3474f69002c2af9e5f742396e99db5ea2589ba6b73db16c842442359398cc01a68d2e4e92666b21
@@ -47,6 +47,14 @@ class Wco::PublishersController < Wco::ApplicationController
47
47
  @galleries_list = Wco::Gallery.list
48
48
  end
49
49
 
50
+ def show
51
+ @publisher = Wco::Publisher.find params[:id]
52
+ authorize! :show, @publisher
53
+
54
+ @publisher.props = JSON.parse @publisher.default_props
55
+ @publisher.prep_do_run
56
+ end
57
+
50
58
  def update
51
59
  @publisher = Wco::Publisher.find params[:id]
52
60
  authorize! :update, @publisher
@@ -12,7 +12,7 @@ class Wco::Publisher
12
12
  include Wco::PublisherD10
13
13
  store_in collection: 'wco_publishers'
14
14
 
15
- attr_accessor :output_str
15
+ attr_accessor :output_str, :tmpl, :body
16
16
 
17
17
  field :slug
18
18
  validates :slug, presence: true, uniqueness: true
@@ -32,16 +32,17 @@ class Wco::Publisher
32
32
  has_and_belongs_to_many :tags
33
33
 
34
34
  attr_accessor :props
35
+ field :default_props, default: '{}'
35
36
 
36
- def do_run
37
- @publisher = publisher = self
38
-
39
- @site = publisher.site
40
- @headers = {}
41
- @ctx = OpenStruct.new
37
+ def prep_do_run
38
+ @publisher = self
39
+ @site = @publisher.site
40
+ @headers = {}
41
+ @ctx = OpenStruct.new
42
+ @props = @publisher.props
42
43
 
43
- puts! publisher.context_eval, 'context_eval'
44
- eval( publisher.context_eval )
44
+ puts! @publisher.context_eval, 'context_eval'
45
+ eval( @publisher.context_eval )
45
46
  puts! @ctx, '@ctx'
46
47
 
47
48
  if @abort
@@ -49,7 +50,7 @@ class Wco::Publisher
49
50
  return false
50
51
  end
51
52
 
52
- tmpl = ERB.new publisher.post_body_tmpl
53
+ tmpl = ERB.new @publisher.post_body_tmpl
53
54
  tmpl = tmpl.result(binding)
54
55
  loop do
55
56
  ## remove ,,
@@ -58,12 +59,18 @@ class Wco::Publisher
58
59
  break if cleaned == tmpl
59
60
  tmpl = cleaned
60
61
  end
62
+ self.tmpl = tmpl
61
63
 
62
- body = JSON.parse tmpl
63
- puts! body, 'body'
64
+ @body = JSON.parse tmpl
65
+ self.body = @body
66
+ puts! @body, '@body'
67
+ end
68
+
69
+ def do_run
70
+ prep_do_run()
64
71
 
65
72
  out = Wco::HTTParty.post( "#{@site.origin}#{post_path}", {
66
- body: body.to_json,
73
+ body: @body.to_json,
67
74
  headers: @headers,
68
75
  basic_auth: { username: @site.username, password: @site.password },
69
76
  debug_output: $stdout,
@@ -87,7 +94,7 @@ class Wco::Publisher
87
94
  eval( after_eval )
88
95
  end
89
96
 
90
- publisher.output_str = out
97
+ @publisher.output_str = out
91
98
  return true
92
99
  end
93
100
 
@@ -75,7 +75,7 @@ class Wco::Tag
75
75
 
76
76
  def to_s
77
77
  if site
78
- "#{slug}@#{site}"
78
+ "#{site} :: #{slug}"
79
79
  else
80
80
  slug
81
81
  end
@@ -38,5 +38,9 @@
38
38
  %label Tags (#{publisher.tags.length}):
39
39
  = f.select :tag_ids, options_for_select(@tags_list, selected: publisher.tag_ids), {}, { multiple: true, class: 'select2' }
40
40
 
41
+ .field
42
+ %label default props
43
+ = f.text_area :default_props, class: 'monospace'
44
+
41
45
  .actions
42
46
  = f.submit
@@ -12,7 +12,7 @@
12
12
  %tr
13
13
  %th &nbsp;
14
14
  %th
15
- slug
15
+ Publisher
16
16
  %th
17
17
  site
18
18
  %th
@@ -24,8 +24,9 @@
24
24
  = button_to 'x', wco.publisher_path(item), method: :delete, data: { confirm: 'Are you sure?' }
25
25
  = link_to '[~]', wco.edit_publisher_path(item)
26
26
  %td
27
- -# = link_to item.slug, publisher_path(item)
28
- = item.slug
27
+ = link_to item.slug, publisher_path(item)
28
+ %br
29
+ .gray.mini= item.id.to_s
29
30
  %td
30
31
  = link_to '[~]', edit_site_path(item.site)
31
32
  -# = link_to item.site.origin, site_path(item.site)
@@ -34,5 +35,5 @@
34
35
  .Card
35
36
  = form_for item, url: wco.run_publisher_path( item ), method: :post do |f|
36
37
  %label props
37
- = f.text_field :props, value: '{}', class: 'w-400px'
38
+ = f.text_field :props, value: item.default_props, class: 'w-400px'
38
39
  = f.submit 'run', data: { confirm: 'Are you sure?' }
@@ -0,0 +1,23 @@
1
+
2
+ .publishers-show.fixed-container
3
+ .header
4
+ %h5.title
5
+ = @publisher
6
+ = link_to '[~]', edit_publisher_path(@publisher)
7
+
8
+
9
+ %h5 context_eval
10
+ .descr
11
+ %code
12
+ %pre= @publisher.context_eval
13
+
14
+ %h5 self.tmpl
15
+ .descr
16
+ %code
17
+ %pre= @publisher.tmpl
18
+
19
+ %h5 self.body
20
+ = @publisher.body
21
+
22
+
23
+
@@ -8,7 +8,7 @@
8
8
  .Chip{ data: { tag: { id: tag.id.to_s } } }
9
9
  - unless config[:skip_checkbox]
10
10
  = check_box_tag 'tag_ids[]', tag.id
11
- = link_to tag.slug, wco.tag_path( tag )
11
+ = link_to tag.to_s, wco.tag_path( tag )
12
12
  - if defined? resource
13
13
  .mini.d-inline-block= button_to 'x', wco.remove_tag_from_path(id: tag.id, resource: resource.class, resource_id: resource.id, ), method: 'delete', data: { confirm: 'Are you sure?' }
14
14
 
@@ -4,7 +4,7 @@
4
4
  %li
5
5
  = link_to '[~]', wco.edit_tag_path(node[:tag][:id])
6
6
  = button_to 'x', wco.tag_path(node[:tag][:id]), method: :delete, data: { confirm: 'Are you sure?' }, form_class: 'd-inline-block'
7
- = link_to node[:tag].slug, wco.tag_path(node[:tag][:id])
7
+ = link_to node[:tag].to_s, wco.tag_path(node[:tag][:id])
8
8
 
9
9
  - if node[:sons].present?
10
10
  = render 'wco/tags/index_tree', nodes: node[:sons]
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.14
4
+ version: 3.5.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev
@@ -754,6 +754,7 @@ files:
754
754
  - app/views/wco/publishers/edit.haml
755
755
  - app/views/wco/publishers/index.haml
756
756
  - app/views/wco/publishers/new.haml
757
+ - app/views/wco/publishers/show.haml
757
758
  - app/views/wco/reports/_form.haml
758
759
  - app/views/wco/reports/_header.haml
759
760
  - app/views/wco/reports/_index.haml