coprl 3.0.0.beta.1 → 3.0.0.beta.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +9 -15
  3. data/CHANGELOG.md +105 -13
  4. data/Gemfile +12 -1
  5. data/Gemfile.lock +105 -32
  6. data/README.md +10 -5
  7. data/app/demo/components/dialogs.pom +1 -1
  8. data/app/demo/components/nav/menu.pom +0 -1
  9. data/app/demo/components/snackbar.pom +9 -3
  10. data/app/demo/events/content_as_form.pom +3 -3
  11. data/app/demo/events/halted.pom +23 -0
  12. data/app/demo/events/nav/drawer.pom +1 -1
  13. data/app/demo/events/tagged_input.pom +2 -2
  14. data/app/demo/patterns/search_select.pom +1 -1
  15. data/app/demo/plugins/animate.pom +144 -0
  16. data/app/demo/plugins/cacheable.pom +64 -0
  17. data/app/demo/plugins/clipboard.pom +21 -0
  18. data/app/demo/plugins/color_picker.pom +17 -0
  19. data/app/demo/plugins/google_maps.pom +24 -0
  20. data/app/demo/plugins/iframe.pom +14 -0
  21. data/app/demo/plugins/image_crop.pom +1 -1
  22. data/app/demo/plugins/markup.pom +14 -0
  23. data/app/demo/plugins/nav/drawer.pom +1 -1
  24. data/app/demo/plugins/script.pom +17 -0
  25. data/app/demo/plugins/scroll_to.pom +22 -0
  26. data/app/demo/plugins/timer.pom +24 -0
  27. data/app/demo/shared/context_list.pom +1 -1
  28. data/config.ru +15 -1
  29. data/coprl.gemspec +2 -2
  30. data/lib/coprl/presenters/cli.rb +10 -0
  31. data/lib/coprl/presenters/dsl/components/actions/base.rb +5 -1
  32. data/lib/coprl/presenters/dsl/components/base.rb +6 -3
  33. data/lib/coprl/presenters/dsl/components/event.rb +6 -1
  34. data/lib/coprl/presenters/dsl/components/multi_select.rb +3 -3
  35. data/lib/coprl/presenters/dsl/components/table.rb +2 -2
  36. data/lib/coprl/presenters/generators/plugin.rb +21 -6
  37. data/lib/coprl/presenters/generators/templates/plugin/.github/workflows/semantic-release.yml +41 -0
  38. data/lib/coprl/presenters/generators/templates/plugin/.releaserc +15 -0
  39. data/lib/coprl/presenters/generators/templates/plugin/.ruby-version +1 -0
  40. data/lib/coprl/presenters/generators/templates/plugin/README.md.tt +34 -0
  41. data/lib/coprl/presenters/generators/templates/plugin/demo/plugin.pom.tt +15 -0
  42. data/lib/coprl/presenters/generators/templates/plugin/lib/coprl/presenters/plugins/components/actions/dsl.rb.tt +1 -1
  43. data/lib/coprl/presenters/generators/templates/plugin/lib/coprl/presenters/plugins/version.rb.tt +3 -0
  44. data/lib/coprl/presenters/generators/templates/plugin/presenter_plugin.gemspec.tt +8 -7
  45. data/lib/coprl/presenters/generators/templates/plugin/views/components/application/component.erb.tt +1 -1
  46. data/lib/coprl/presenters/settings.rb +1 -1
  47. data/lib/coprl/presenters/version.rb +1 -1
  48. data/lib/coprl/presenters/web_client/helpers/headers.rb +8 -6
  49. data/lib/coprl/presenters/web_client/helpers/rails.rb +1 -0
  50. data/lib/coprl/presenters/web_client/helpers/rails/template_helper.rb +10 -0
  51. data/lib/coprl/presenters/web_client/helpers/sinatra.rb +1 -0
  52. data/lib/coprl/presenters/web_client/helpers/sinatra/template_helper.rb +20 -0
  53. data/public/bundle.js +10 -4
  54. data/public/wc.js +10 -4
  55. data/rails-engine/app/controllers/coprl_controller.rb +20 -1
  56. data/rails-engine/app/views/layouts/coprl.html.erb +4 -4
  57. data/rails-engine/config/initializers/session.rb +8 -0
  58. data/rails-engine/config/routes.rb +2 -1
  59. data/views/mdc/assets/js/components/events/posts.js +10 -6
  60. data/views/mdc/body/{_preamble.erb → _wrapper.erb} +16 -5
  61. data/views/mdc/components/_card.erb +2 -2
  62. data/views/mdc/components/_checkbox.erb +1 -1
  63. data/views/mdc/components/_chip.erb +2 -2
  64. data/views/mdc/components/_content.erb +2 -2
  65. data/views/mdc/components/_datetime.erb +1 -1
  66. data/views/mdc/components/_dialog.erb +2 -2
  67. data/views/mdc/components/_form.erb +2 -2
  68. data/views/mdc/components/_grid.erb +2 -2
  69. data/views/mdc/components/_hidden_field.erb +1 -1
  70. data/views/mdc/components/_multi_select.erb +1 -1
  71. data/views/mdc/components/_number_field.erb +1 -1
  72. data/views/mdc/components/_radio_button.erb +1 -1
  73. data/views/mdc/components/_rich_text_area.erb +1 -1
  74. data/views/mdc/components/_select.erb +1 -1
  75. data/views/mdc/components/_slider.erb +2 -2
  76. data/views/mdc/components/_stepper.erb +4 -4
  77. data/views/mdc/components/_switch.erb +1 -1
  78. data/views/mdc/components/_text_area.erb +1 -1
  79. data/views/mdc/components/_text_field.erb +1 -1
  80. data/views/mdc/components/buttons/_image.erb +1 -1
  81. data/views/mdc/components/unordered_list/_list_item.erb +3 -3
  82. data/views/mdc/layout.erb +4 -4
  83. metadata +31 -17
  84. data/app/demo/components/google_maps.pom +0 -22
  85. data/app/demo/components/snackbar_attached.pom +0 -6
  86. data/lib/coprl/presenters/generators/templates/plugin/README.md +0 -253
  87. data/lib/coprl/presenters/plugins/google_maps.rb +0 -24
  88. data/lib/coprl/presenters/plugins/google_maps/google_map.erb +0 -10
  89. data/lib/coprl/presenters/plugins/google_maps/google_map.rb +0 -41
  90. data/views/mdc/body/_postamble.erb +0 -17
@@ -3,7 +3,7 @@
3
3
  type_class = comp.picker ? 'v-datetime' : 'v-date-text'
4
4
  %>
5
5
  <div id="<%= comp.id %>"
6
- <% if comp.tag %>data-input-tag="<%= comp.tag %>"<% end %>
6
+ <% if comp.input_tag %>data-input-tag="<%= comp.input_tag %>"<% end %>
7
7
  <% if comp.dirtyable %>data-dirtyable<% end %>
8
8
  class="v-input <%= type_class %> mdc-text-field mdc-text-field--outlined
9
9
  <%= 'mdc-text-field--with-trailing-icon' if comp.clear_icon %>
@@ -2,8 +2,8 @@
2
2
  dialog_action_buttons = Array(comp&.actions&.buttons)
3
3
  %>
4
4
  <div id="<%= comp.id %>"
5
- <% if comp.tag %>
6
- data-input-tag="<%= comp.tag %>"
5
+ <% if comp.input_tag %>
6
+ data-input-tag="<%= comp.input_tag %>"
7
7
  <% end %>
8
8
  class="v-dialog mdc-dialog"
9
9
  role="alertdialog"
@@ -1,6 +1,6 @@
1
1
  <form role="form"
2
- <% if comp.tag %>
3
- data-input-tag="<%= comp.tag %>"
2
+ <% if comp.input_tag %>
3
+ data-input-tag="<%= comp.input_tag %>"
4
4
  <% end %>
5
5
  id="<%= comp.id %>"
6
6
  class="v-form"
@@ -6,8 +6,8 @@
6
6
  @gutters.push comp.gutter.nil? ? @gutters.last : comp.gutter
7
7
  %>
8
8
  <div id="<%= comp.id %>"
9
- <% if comp.tag %>
10
- data-input-tag="<%= comp.tag %>"
9
+ <% if comp.input_tag %>
10
+ data-input-tag="<%= comp.input_tag %>"
11
11
  <% end %>
12
12
  class="v-grid mdc-layout-grid
13
13
  <%= _padding_classes_(comp.padding, @grid_nesting) %>
@@ -1,5 +1,5 @@
1
1
  <input class="v-input v-hidden-field"
2
2
  type="hidden"
3
- <% if comp.tag %>data-input-tag="<%= comp.tag %>"<% end %>
3
+ <% if comp.input_tag %>data-input-tag="<%= comp.input_tag %>"<% end %>
4
4
  <% if comp.dirtyable %>data-dirtyable<% end %>
5
5
  id="<%= comp.id %>" name="<%= comp.name %>" value="<%= comp.value %>"/>
@@ -2,7 +2,7 @@
2
2
  float_label = comp.options.select{|o| o.selected }.any?
3
3
  %>
4
4
  <div class="v-multi-select-container"
5
- <% if comp.tag %>data-input-tag="<%= comp.tag %>"<% end %>
5
+ <% if comp.input_tag %>data-input-tag="<%= comp.input_tag %>"<% end %>
6
6
  <% if comp.dirtyable %>data-dirtyable<% end %>>
7
7
  <div class="v-multi-select--options-list v-hidden">
8
8
  <% comp.options.each do |option| %>
@@ -4,7 +4,7 @@
4
4
  auto_complete = comp.auto_complete&.to_sym == :off ? 'extra-off' : comp.auto_complete
5
5
  %>
6
6
  <div id="<%= comp.id %>"
7
- <%= "data-input-tag='#{comp.tag}'" if comp.tag %>
7
+ <%= "data-input-tag='#{comp.input_tag}'" if comp.input_tag %>
8
8
  <%= 'data-dirtyable' if comp.dirtyable %>
9
9
  class="v-input v-text-field v-focusable mdc-text-field mdc-text-field--outlined
10
10
  <%= 'mdc-text-field--with-leading-icon' if leading_icon %>
@@ -1,6 +1,6 @@
1
1
  <div class="v-form-field mdc-form-field">
2
2
  <div id="<%= comp.id %>"
3
- <% if comp.tag %>data-input-tag="<%= comp.tag %>"<% end %>
3
+ <% if comp.input_tag %>data-input-tag="<%= comp.input_tag %>"<% end %>
4
4
  <% if comp.dirtyable %>data-dirtyable<% end %>
5
5
  class="v-radio mdc-radio v-input">
6
6
  <input class="mdc-radio__native-control"
@@ -1,6 +1,6 @@
1
1
  <div class="v-rich-text-area-container v-input"
2
2
  id="<%= comp.id %>"
3
- <% if comp.tag %>data-input-tag="<%= comp.tag %>"<% end %>
3
+ <% if comp.input_tag %>data-input-tag="<%= comp.input_tag %>"<% end %>
4
4
  <% if comp.dirtyable %>data-dirtyable<% end %>
5
5
  <% if comp.height %>data-initial-height="<%= comp.height %>"<% end %>
6
6
  <% if comp.resizable %>data-resizable<% end %>
@@ -4,7 +4,7 @@
4
4
  <div class="mdc-select v-select v-input
5
5
  <%= 'mdc-select--outlined' if comp.outlined %>
6
6
  <% if comp.disabled %>mdc-select--disabled<% end %>"
7
- <% if comp.tag %>data-input-tag="<%= comp.tag %>"<% end %>
7
+ <% if comp.input_tag %>data-input-tag="<%= comp.input_tag %>"<% end %>
8
8
  <% if comp.dirtyable %>data-dirtyable<% end %>
9
9
  <%= 'style="width: 100%;"' if comp.full_width %>>
10
10
  <%= partial "components/icon", :locals => {comp: comp.icon, class_name: 'mdc-select__icon', parent_id: "#{comp.id}-input", size_class: '', position: []} if comp.icon %>
@@ -1,6 +1,6 @@
1
1
  <div id="<%= comp.id %>"
2
- <% if comp.tag %>
3
- data-input-tag="<%= comp.tag %>"
2
+ <% if comp.input_tag %>
3
+ data-input-tag="<%= comp.input_tag %>"
4
4
  <% end %>
5
5
  class="v-slider v-input mdc-slider
6
6
  <%= 'mdc-slider--discrete' if comp.discrete %>
@@ -3,8 +3,8 @@
3
3
  %>
4
4
  <div class="v-errors">
5
5
  <ul id="<%= comp.id %>"
6
- <% if comp.tag %>
7
- data-input-tag="<%= comp.tag %>"
6
+ <% if comp.input_tag %>
7
+ data-input-tag="<%= comp.input_tag %>"
8
8
  <% end %>
9
9
  class="mdl-stepper v-stepper
10
10
  <%= ' mdl-stepper--horizontal' if horizontal %>
@@ -18,8 +18,8 @@
18
18
  <div id="<%= comp.id %>-content">
19
19
  <% for step in comp.steps %>
20
20
  <div id="<%= step.id %>-content"
21
- <% if step.tag %>
22
- data-input-tag="<%= step.tag %>"
21
+ <% if step.input_tag %>
22
+ data-input-tag="<%= step.input_tag %>"
23
23
  <% end %>
24
24
  class="v-content v-step__content v-step__content-<%= step.id %>
25
25
  <%= ' is-active' if step.selected %>
@@ -3,7 +3,7 @@
3
3
 
4
4
  <div class="v-form-field mdc-form-field">
5
5
  <div id="<%= comp.id %>"
6
- <% if comp.tag %>data-input-tag="<%= comp.tag %>"<% end %>
6
+ <% if comp.input_tag %>data-input-tag="<%= comp.input_tag %>"<% end %>
7
7
  <% if comp.dirtyable %>data-dirtyable<% end %>
8
8
  class="v-switch v-input mdc-switch
9
9
  <%= 'mdc-switch--disabled' if comp.disabled %>
@@ -1,6 +1,6 @@
1
1
  <div id="<%= comp.id %>" class="v-input v-text-field mdc-text-field mdc-text-field--textarea
2
2
  <% if comp.disabled %>mdc-text-field--disabled<% end %>"
3
- <% if comp.tag %>data-input-tag="<%= comp.tag %>"<% end %>
3
+ <% if comp.input_tag %>data-input-tag="<%= comp.input_tag %>"<% end %>
4
4
  <% if comp.dirtyable %>data-dirtyable<% end %>
5
5
  style="<%= 'width:100%' if comp.full_width %>">
6
6
  <textarea id="<%= comp.id %>-input"
@@ -5,7 +5,7 @@
5
5
  behavior = comp.behavior || 'text'
6
6
  %>
7
7
  <div id="<%= comp.id %>"
8
- <% if comp.tag %>data-input-tag="<%= comp.tag %>"<% end %>
8
+ <% if comp.input_tag %>data-input-tag="<%= comp.input_tag %>"<% end %>
9
9
  <% if comp.dirtyable %>data-dirtyable<% end %>
10
10
  class="v-input v-text-field v-focusable mdc-text-field mdc-text-field--outlined
11
11
  <%= 'mdc-text-field--with-leading-icon' if leading_icon %>
@@ -22,4 +22,4 @@
22
22
  <%= partial "components/icon", :locals => {comp: comp.icon, class_name: 'mdc-button__icon', position: [:right, :center]} if comp.icon %>
23
23
  </button>
24
24
  <%= partial "components/tooltip", :locals => {comp: comp.tooltip, parent_id: comp.id} if comp.tooltip %>
25
- <%= partial "components/menu", :locals => {comp: comp.menu, parent_id: comp.id} if comp.menus %>
25
+ <%= partial "components/menu", :locals => {comp: comp.menu, parent_id: comp.id} if comp.menu %>
@@ -1,7 +1,7 @@
1
1
  <li class="<%= 'icon-li' if list_item.icon %>">
2
- <%= erb :"components/unordered_list/icon", :locals => {:list_item => list_item} %>
2
+ <%= partial "components/unordered_list/icon", :locals => {:list_item => list_item} %>
3
3
  <%= expand_text(list_item.text&.text) %>
4
4
  <% if list_item.unordered_list %>
5
- <%= erb :"components/unordered_list", :locals => {:comp => list_item.unordered_list} %>
5
+ <%= partial "components/unordered_list", :locals => {:comp => list_item.unordered_list} %>
6
6
  <% end %>
7
- </li>
7
+ </li>
data/views/mdc/layout.erb CHANGED
@@ -7,12 +7,12 @@
7
7
  <title><%= @pom.page.title if @pom.page %></title>
8
8
  <meta name="description" content="">
9
9
  <meta name="viewport" content="width=device-width, initial-scale=1">
10
- <%= coprl_headers(@base_url, request, @pom) %>
10
+ <%= coprl_headers %>
11
11
  </head>
12
12
  <body class="mdc-typography">
13
- <%= partial "body/preamble", :locals => {pom:@pom} %>
14
- <%= yield %>
15
- <%= partial "body/postamble", :locals => {pom:@pom} %>
13
+ <% with_presenters_wrapper do %>
14
+ <%= yield %>
15
+ <% end %>
16
16
  <noscript><p>JavaScript must be enabled to continue.</p></noscript>
17
17
  </body>
18
18
  </html>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coprl
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta.1
4
+ version: 3.0.0.beta.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Russell Edens
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-02 00:00:00.000000000 Z
11
+ date: 2021-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ice_nine
@@ -267,33 +267,33 @@ dependencies:
267
267
  - !ruby/object:Gem::Version
268
268
  version: '3.0'
269
269
  - !ruby/object:Gem::Dependency
270
- name: gem-release
270
+ name: shotgun
271
271
  requirement: !ruby/object:Gem::Requirement
272
272
  requirements:
273
273
  - - "~>"
274
274
  - !ruby/object:Gem::Version
275
- version: '2.0'
275
+ version: '0.9'
276
276
  type: :development
277
277
  prerelease: false
278
278
  version_requirements: !ruby/object:Gem::Requirement
279
279
  requirements:
280
280
  - - "~>"
281
281
  - !ruby/object:Gem::Version
282
- version: '2.0'
282
+ version: '0.9'
283
283
  - !ruby/object:Gem::Dependency
284
- name: shotgun
284
+ name: timecop
285
285
  requirement: !ruby/object:Gem::Requirement
286
286
  requirements:
287
287
  - - "~>"
288
288
  - !ruby/object:Gem::Version
289
- version: '0.9'
289
+ version: 0.9.4
290
290
  type: :development
291
291
  prerelease: false
292
292
  version_requirements: !ruby/object:Gem::Requirement
293
293
  requirements:
294
294
  - - "~>"
295
295
  - !ruby/object:Gem::Version
296
- version: '0.9'
296
+ version: 0.9.4
297
297
  description:
298
298
  email:
299
299
  - 'rx@russelledens.net
@@ -340,7 +340,6 @@ files:
340
340
  - app/demo/components/fabs.pom
341
341
  - app/demo/components/file_inputs.pom
342
342
  - app/demo/components/footers.pom
343
- - app/demo/components/google_maps.pom
344
343
  - app/demo/components/headers.pom
345
344
  - app/demo/components/hidden_fields.pom
346
345
  - app/demo/components/icons.pom
@@ -360,7 +359,6 @@ files:
360
359
  - app/demo/components/selects.pom
361
360
  - app/demo/components/sliders.pom
362
361
  - app/demo/components/snackbar.pom
363
- - app/demo/components/snackbar_attached.pom
364
362
  - app/demo/components/steppers.pom
365
363
  - app/demo/components/tab_bars.pom
366
364
  - app/demo/components/tables.pom
@@ -391,6 +389,7 @@ files:
391
389
  - app/demo/events/content_as_form.pom
392
390
  - app/demo/events/field_level.pom
393
391
  - app/demo/events/form_level.pom
392
+ - app/demo/events/halted.pom
394
393
  - app/demo/events/nav/drawer.pom
395
394
  - app/demo/events/parallel.pom
396
395
  - app/demo/events/tagged_input.pom
@@ -405,10 +404,20 @@ files:
405
404
  - app/demo/patterns/drag_drop.pom
406
405
  - app/demo/patterns/floating_card.pom
407
406
  - app/demo/patterns/search_select.pom
407
+ - app/demo/plugins/animate.pom
408
+ - app/demo/plugins/cacheable.pom
408
409
  - app/demo/plugins/chart.pom
410
+ - app/demo/plugins/clipboard.pom
411
+ - app/demo/plugins/color_picker.pom
412
+ - app/demo/plugins/google_maps.pom
413
+ - app/demo/plugins/iframe.pom
409
414
  - app/demo/plugins/image_crop.pom
410
415
  - app/demo/plugins/index.pom
416
+ - app/demo/plugins/markup.pom
411
417
  - app/demo/plugins/nav/drawer.pom
418
+ - app/demo/plugins/script.pom
419
+ - app/demo/plugins/scroll_to.pom
420
+ - app/demo/plugins/timer.pom
412
421
  - app/demo/shared/code.pom
413
422
  - app/demo/shared/context_list.pom
414
423
  - app/demo/shared/debug.pom
@@ -558,16 +567,21 @@ files:
558
567
  - lib/coprl/presenters/errors/unprocessable.rb
559
568
  - lib/coprl/presenters/generators/inflectors.rb
560
569
  - lib/coprl/presenters/generators/plugin.rb
570
+ - lib/coprl/presenters/generators/templates/plugin/.github/workflows/semantic-release.yml
561
571
  - lib/coprl/presenters/generators/templates/plugin/.gitignore
572
+ - lib/coprl/presenters/generators/templates/plugin/.releaserc
573
+ - lib/coprl/presenters/generators/templates/plugin/.ruby-version
562
574
  - lib/coprl/presenters/generators/templates/plugin/Gemfile.tt
563
575
  - lib/coprl/presenters/generators/templates/plugin/LICENSE.txt.tt
564
- - lib/coprl/presenters/generators/templates/plugin/README.md
576
+ - lib/coprl/presenters/generators/templates/plugin/README.md.tt
577
+ - lib/coprl/presenters/generators/templates/plugin/demo/plugin.pom.tt
565
578
  - lib/coprl/presenters/generators/templates/plugin/lib/coprl/presenters/plugins/components/actions/action.rb.tt
566
579
  - lib/coprl/presenters/generators/templates/plugin/lib/coprl/presenters/plugins/components/actions/dsl.rb.tt
567
580
  - lib/coprl/presenters/generators/templates/plugin/lib/coprl/presenters/plugins/components/component.rb.tt
568
581
  - lib/coprl/presenters/generators/templates/plugin/lib/coprl/presenters/plugins/components/dsl.rb.tt
569
582
  - lib/coprl/presenters/generators/templates/plugin/lib/coprl/presenters/plugins/helpers/helper.rb.tt
570
583
  - lib/coprl/presenters/generators/templates/plugin/lib/coprl/presenters/plugins/plugin.rb.tt
584
+ - lib/coprl/presenters/generators/templates/plugin/lib/coprl/presenters/plugins/version.rb.tt
571
585
  - lib/coprl/presenters/generators/templates/plugin/lib/coprl/presenters/plugins/web_client/components/actions/data.rb.tt
572
586
  - lib/coprl/presenters/generators/templates/plugin/lib/coprl/presenters/plugins/web_client/components/render.rb.tt
573
587
  - lib/coprl/presenters/generators/templates/plugin/presenter_plugin.gemspec.tt
@@ -589,9 +603,6 @@ files:
589
603
  - lib/coprl/presenters/namespace.rb
590
604
  - lib/coprl/presenters/pluggable.rb
591
605
  - lib/coprl/presenters/plugins.rb
592
- - lib/coprl/presenters/plugins/google_maps.rb
593
- - lib/coprl/presenters/plugins/google_maps/google_map.erb
594
- - lib/coprl/presenters/plugins/google_maps/google_map.rb
595
606
  - lib/coprl/presenters/rails/engine.rb
596
607
  - lib/coprl/presenters/rails/railtie.rb
597
608
  - lib/coprl/presenters/registry.rb
@@ -623,6 +634,7 @@ files:
623
634
  - lib/coprl/presenters/web_client/helpers/rails/partials.rb
624
635
  - lib/coprl/presenters/web_client/helpers/rails/raw.rb
625
636
  - lib/coprl/presenters/web_client/helpers/rails/safe_markdown.rb
637
+ - lib/coprl/presenters/web_client/helpers/rails/template_helper.rb
626
638
  - lib/coprl/presenters/web_client/helpers/render_component.rb
627
639
  - lib/coprl/presenters/web_client/helpers/shared.rb
628
640
  - lib/coprl/presenters/web_client/helpers/sinatra.rb
@@ -631,6 +643,7 @@ files:
631
643
  - lib/coprl/presenters/web_client/helpers/sinatra/partials.rb
632
644
  - lib/coprl/presenters/web_client/helpers/sinatra/raw.rb
633
645
  - lib/coprl/presenters/web_client/helpers/sinatra/safe_markdown.rb
646
+ - lib/coprl/presenters/web_client/helpers/sinatra/template_helper.rb
634
647
  - lib/coprl/presenters/web_client/helpers/snake_to_camel.rb
635
648
  - lib/coprl/presenters/web_client/helpers/transform_hash.rb
636
649
  - lib/coprl/presenters/web_client/helpers/unique_id.rb
@@ -672,6 +685,7 @@ files:
672
685
  - rails-engine/app/views/layouts/coprl.html.erb
673
686
  - rails-engine/config.ru
674
687
  - rails-engine/config/initializers/presenters.rb
688
+ - rails-engine/config/initializers/session.rb
675
689
  - rails-engine/config/routes.rb
676
690
  - scripts/build.sh
677
691
  - views/mdc/.babelrc
@@ -802,9 +816,8 @@ files:
802
816
  - views/mdc/body/_footer.erb
803
817
  - views/mdc/body/_header.erb
804
818
  - views/mdc/body/_modal-drawer.erb
805
- - views/mdc/body/_postamble.erb
806
- - views/mdc/body/_preamble.erb
807
819
  - views/mdc/body/_snackbar.erb
820
+ - views/mdc/body/_wrapper.erb
808
821
  - views/mdc/body/drawer/_divider.erb
809
822
  - views/mdc/body/drawer/_item.erb
810
823
  - views/mdc/body/drawer/_label.erb
@@ -939,5 +952,6 @@ requirements: []
939
952
  rubygems_version: 3.1.4
940
953
  signing_key:
941
954
  specification_version: 4
942
- summary: COPRL Presenters Gem
955
+ summary: COmmon PResenter Language - A Ruby gem for joyfully writing modern user interfaces
956
+ in Rack and Rails.
943
957
  test_files: []
@@ -1,22 +0,0 @@
1
- require_relative '../helpers/indented_grid'
2
-
3
- Coprl::Presenters.define(:maps) do
4
- helpers Demo::Helpers::IndentedGrid
5
- attach :top_nav
6
- attach :component_drawer
7
- page_title 'Maps'
8
-
9
- indented_grid do
10
- subheading 'Static Maps'
11
-
12
- address = '125 Park Street, Traverse City, MI'
13
- google_map address: address, height: 300, width: 400 do
14
- event :click do
15
- loads "https://www.google.com/maps/place/#{address}"
16
- end
17
- end
18
-
19
- attach :code, file: __FILE__
20
- end
21
-
22
- end
@@ -1,6 +0,0 @@
1
-
2
- Coprl::Presenters.define(:snackbar_attached) do
3
- title 'In Attached'
4
- body 'This can be done in an attached presenter as well'
5
- snackbar 'Attached Snackbar Displayed!'
6
- end
@@ -1,253 +0,0 @@
1
- # Presenter Plugins
2
-
3
- Presenter plugins allows extension and modification of the DSL and WebClient.
4
- It is powerfully designed for adding additional components to the system, or to change the behavior/look feel/capabilities of existing components.
5
-
6
- ## Global Plugins
7
-
8
- Presenters have global plugins that are configured in the system. They are declared as a setting like so:
9
-
10
- Coprl::Presenters::Settings.configure do |config|
11
- config.presenters.plugins.push(:foo)
12
- end
13
-
14
- A global plugin is available to all presenters.
15
-
16
- ## Local Plugins
17
-
18
- A presenters can define that it uses a plugin like so:
19
-
20
- Coprl::Presenters.define(:index, namespace: :plugins) do
21
- plugin :foo
22
- end
23
-
24
- A local plugin is available only to the presenter that it is defined in.
25
-
26
-
27
- ## Creating Plugins
28
-
29
- The skeleton for a plugin starts with an empty module in a file stored in `coprl/presenters/plugins` somewhere in ruby's load path
30
- (typically in a gemfile or in the lib directory of an framework app, like Rails):
31
-
32
- module Coprl
33
- module Presenters
34
- module Plugins
35
- module Foo
36
- end
37
- end
38
- end
39
- end
40
-
41
- ## Extending the presenter DSL and POM
42
-
43
- ### Components
44
- If you want to add additional components to the presenters DSL, provide a `DSLComponents` module under the plugin module:
45
-
46
- module DSLComponents
47
- def foo(random_fact, **attributes, &block)
48
- self << Foo::Component.new(random_fact, parent: self, **attributes, &block)
49
- end
50
- end
51
-
52
- The above example will extend the dsl by adding the foo method that will add the Foo component to the
53
- presenter object model tree.
54
-
55
- A presenter component derives from `DSL::Components::Base` or if it needs to handle events `DSL::Components::EventBase`
56
-
57
- require 'coprl/presenters/dsl/components/base'
58
-
59
- module Coprl
60
- module Presenters
61
- module Plugins
62
- module Foo
63
- class Component < DSL::Components::Base
64
- def initialize(**attribs_, &block)
65
- super(type: :foo, **attribs_, &block)
66
- end
67
- end
68
- end
69
- end
70
- end
71
- end
72
-
73
- ### Helpers
74
-
75
- To add helpers to the POM define the module `DSLHelpers`
76
-
77
- module DSLHelpers
78
- def random_fact
79
- "http://en.wikipedia.org/wiki/Special:Randompage"
80
- end
81
- end
82
-
83
- ### Event Actions
84
- A plugin can extend the set of event actions that are available.
85
- When an event fires in the client, like mouse click, a set of actions are executed. A plugin can provide custom
86
- actions. This examnple adds a actionJs actionJs that can be bound to an event.
87
-
88
- module DSLEventActions
89
- def actionJs(text, **attributes, &block)
90
- self << Foo::Action.new(text: text, parent: self, **attributes, &block)
91
- end
92
- end
93
-
94
- Example actionJs class:
95
-
96
- require 'coprl/presenters/dsl/components/actions/base'
97
-
98
- module Coprl
99
- module Presenters
100
- module Plugins
101
- module Foo
102
- class Action < DSL::Components::Actions::Base
103
- def initialize(**attribs_, &block)
104
- super(type: :actionJs, **attribs_, &block)
105
- end
106
- end
107
- end
108
- end
109
- end
110
- end
111
-
112
-
113
- ## Adding a WebClient implementation
114
-
115
- A plugin that extends the DSL will give you a new custom POM (Presenter Object Model), but that alone won't get you very far.
116
- The POM describes the user interface, a client must implement each of the components.
117
- For the WebClient this means adding a template with HTML, CSS and Javascript.
118
-
119
- ### Component Templates
120
-
121
- To render your component you need to add the following to your plugin:
122
-
123
- module WebClientComponents
124
- def render_foo(comp,
125
- render:,
126
- components:,
127
- index:)
128
- view_dir = File.join(__dir__, 'foo')
129
- render.call :erb, :foo, views: view_dir,
130
- locals: {comp: comp,
131
- components: components, index: index}
132
- end
133
- end
134
-
135
- From you ERB you can call any of the other built in WebClient erb's. You can even replace built in component templates.
136
- The render object supports all the template types supported by Tilt/Sinatra (http://sinatrarb.com/intro.html)
137
-
138
- Example template:
139
-
140
- <iframe id="random_fact" src="<%= comp.random_fact %>" height=512 <%= erb :"components/event", :locals => {comp: comp, events: comp.events, parent_id: comp.id} %>></iframe>
141
-
142
-
143
- ### Event Action Data
144
-
145
- An actionJs from the Presenter Object Model (POM) is sent to a ruby method during template expansion.
146
- You are able to then setup any data that you want passed to your actionJs javascript method.
147
- It expects you will return an array with a type that matches your event actionJs presenter type. The rest is up to you.
148
-
149
-
150
- module WebClientActions
151
- def action_data_bar(actionJs, _parent_id, *)
152
- # Type, URL, Options, Params (passed into javascript event/actionJs classes)
153
- [actionJs.type, actionJs.url, actionJs.options.to_h, actionJs.attributes.to_h]
154
- end
155
- end
156
-
157
- Example Javascript method (typically rendered by a template triggered by the render_foo method above):
158
-
159
- <script>
160
- function actionJs(_options, params, _event) {
161
- // Reload iFrame: https://stackoverflow.com/questions/86428/what-s-the-best-way-to-reload-refresh-an-iframe
162
- document.getElementById('random_fact').src += '';
163
- return {actionJs: 'actionJs', content: {data: params.text}, statusCode: 200};
164
- }
165
- </script>
166
-
167
- Event actionJs WebClient methods must return a Javascript Object with the properties `actionJs`, `content` and `statusCode`.
168
-
169
-
170
- ## WebClient Javascript Interface
171
-
172
- When developing a plugin for the WebClient you may want to have your data submitted as part of another component container.
173
- The most familiar example is a Form. This requires that you bind your component to the DOM with a few methods.
174
- Not all plugins need to do this.
175
- It is only needed in the case of those components that add their data to an http post.
176
-
177
- The following components are Containers that will collect data from nested DOM elements using this lifecycle protocol.
178
- cards.js
179
- content.js
180
- dialogs.js
181
- file-inputs.js
182
- forms.js
183
- grid.js
184
- steppers.js
185
-
186
- Lifecycle Protocol:
187
-
188
- We call it it a protocol, because it defines a small number of DOM relationships to participate as an integrated component.
189
- Many frameworks require a common base class, this approach is very light by design.
190
-
191
- Container data in the WebClient is collected and submitted using the following sequence:
192
-
193
- In your element markup include the `v-input` class on an DOM element.
194
-
195
- You can see the container calling code here:
196
- https://github.com/rx/presenters/blob/master/views/mdc/assets/js/components/base-container.js
197
-
198
- If you add the v-plugin class to the DOM element along with a data-plugin-callback dataset that contains a string
199
- with the class name to proxy the plugin events to.
200
-
201
-
202
- Sample callback class:
203
-
204
- // Optional Javascript callback class. You typically need to define this when you have data to submit, or special
205
- // event handling to bind to.
206
- // To hook this up you need to provide the `v-plugin` class and
207
- // data-plugin-callback='RandomFacts' on the element.
208
- class RandomFacts {
209
- // passed the DOM element that has the .v-plugin class on it.
210
- constructor(element) {
211
- }
212
-
213
- // optional.
214
- // Called before the component is submitted via post/put. Allows the component to add its key/value pairs to the
215
- // submitted data.
216
- // If you provide this you need to add the v-input class to your DOM element to get called.
217
- // Containers iterate their elements that have the v-input class defined on them and invoke the prepareSubmit
218
- // function for each.
219
- prepareSubmit(params) {
220
- // params is a key,value pair. Add name/value like so:
221
- // params.push(['some_name', 'some_value']);
222
- }
223
-
224
- // optional.
225
- // Called whenever a container is about to be submitted, before prepareSubmit.
226
- // returns true on success
227
- // returns on failure return an error object that can be processed by VErrors:
228
- // { email: ["email must be filled", "email must be from your domain"] }
229
- // { page: ["must be filled"] }
230
- // Returning an error stops the submission.
231
- validate(formData) {
232
- return true;
233
- }
234
-
235
- // optional.
236
- // Clear's the control
237
- clear() {
238
- }
239
-
240
- // called to add an event listener to the component
241
- // this only needs to be defined if you need the event handler to be bound to the component
242
- // in a different manner. Here is the default implementation you get if you don't define this method:
243
- initEventListener(eventName, eventHandler) {
244
- if (typeof this.eventsHandler === 'undefined') {
245
- this.eventsHandler = {};
246
- }
247
- if (!this.eventsHandler[eventName]) {
248
- // Delegate to the component if possible
249
- this.eventsHandler[eventName] = eventHandler;
250
- this.element.addEventListener(eventName, eventHandler);
251
- }
252
- }
253
- }