card-mod-layout 0.11.2 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4f8bee4588b5b82610fc77cd6f6649806169bd492bafad3164a626b4d443e41
4
- data.tar.gz: 306fe76d6d25ceb7379bdec8a3773d24cc0f3d6f2204c6b0a366f03cc8620291
3
+ metadata.gz: 9aebbcb41a5e7d109b07b38006e366d18e82873032e0e0032c87fabaaa324144
4
+ data.tar.gz: 15e513bbbb39276828cd20a8cf5ca21893d43bd92c9fa9a5be09aafcab2bd97c
5
5
  SHA512:
6
- metadata.gz: fa1752d2bcec2f88058c7af2b5c91bb614e636dc0ff2658fe899302b3538692753579a33e0eb30fad6eb4ef02db3841566df29f8fde42c1eda089c0fa45921cf
7
- data.tar.gz: ad4a39de93feff90538471d8b8f01e8e0d3bac2dff248b6a9d1bb1386b18ab9ad50f2b429fe0f7755d18ea9e2fc526812853a1a312c63ee99dea62c55134e30f
6
+ metadata.gz: 0caf1aae59a7c90349ebffd38aba724a6c7b2fd73df58681eff1019546b2f7f86ceb28ef764a654f64b2725fbb3764c0243079283963c3831c830dd2babca98c
7
+ data.tar.gz: 9260c99fcd0fdc641bc1cd5e58f032ca5a867ba0f54cf2d8cfb36c1d180e9ffb5e8e072ea1603129012efef2ddb608e6dbf596e76f6669bd64e117d2461552f9
data/lib/card/layout.rb CHANGED
@@ -7,18 +7,18 @@ class Card
7
7
 
8
8
  def layout_class layout
9
9
  if layout.respond_to? :call
10
- Card::Layout::ProcLayout
10
+ ProcLayout
11
11
  elsif card_layout? layout
12
- Card::Layout::CardLayout
12
+ CardLayout
13
13
  elsif code_layout? layout
14
- Card::Layout::CodeLayout
14
+ CodeLayout
15
15
  else
16
- Card::Layout::UnknownLayout
16
+ UnknownLayout
17
17
  end
18
18
  end
19
19
 
20
20
  def card_layout? name
21
- Card.fetch_type_id(name).in? [Card::LayoutTypeID, Card::HtmlID, Card::BasicID]
21
+ Card.fetch_type_id(name).in? [LayoutTypeID, HtmlID, BasicID]
22
22
  rescue ArgumentError, Card::Error::CodenameNotFound => _e
23
23
  false
24
24
  end
@@ -40,6 +40,7 @@ class Card
40
40
 
41
41
  def layout_key name
42
42
  return name if name.is_a? Symbol
43
+
43
44
  name.to_name.key.to_sym
44
45
  end
45
46
 
@@ -1,18 +1,18 @@
1
1
  class Card
2
2
  class Layout
3
3
  class UnknownLayout < Layout
4
+ delegate :t, to: Cardio
5
+
4
6
  def render
5
7
  @format.output [header, text]
6
8
  end
7
9
 
8
10
  def header
9
- @format.content_tag :h1, @format.tr(:unknown_layout,
10
- scope: "card-mod-format", name: @layout)
11
+ @format.content_tag :h1, t(:layout_unknown_layout, name: @layout)
11
12
  end
12
13
 
13
14
  def text
14
- @format.tr(:available_layouts, scope: "card-mod-format",
15
- available_layouts: self.class.built_in_layouts)
15
+ t :layout_available_layouts, available_layouts: self.class.built_in_layouts
16
16
  end
17
17
  end
18
18
  end
@@ -17,9 +17,7 @@ format :html do
17
17
  Auth.current_roles.size > 1
18
18
  end
19
19
 
20
- def role_items
21
- Auth.current_roles.map do |role_name|
22
- yield role_name
23
- end
20
+ def role_items &block
21
+ Auth.current_roles.map(&block)
24
22
  end
25
23
  end
data/set/all/modal.rb CHANGED
@@ -14,6 +14,7 @@ format :html do
14
14
  def normalize_modal_option key, opts
15
15
  val = opts[key]
16
16
  return render("modal_#{key}") unless val
17
+
17
18
  cast_model_option val
18
19
  end
19
20
 
data/set/all/overlay.rb CHANGED
@@ -59,8 +59,7 @@ format :html do
59
59
  end
60
60
 
61
61
  def overlay_delete_button
62
- opts = { no_success: true }.merge OVERLAY_CLOSE_OPTS
63
- delete_button opts
62
+ delete_button OVERLAY_CLOSE_OPTS.merge(success: {})
64
63
  end
65
64
 
66
65
  def overlay_save_and_close_button
@@ -80,25 +79,23 @@ format :html do
80
79
  header_wrap [title, _render_overlay_menu]
81
80
  end
82
81
 
83
- def overlay_frame slot=true, header=render_overlay_header, slot_opts=nil
82
+ def overlay_frame slot=true, header=render_overlay_header, slot_opts=nil, &block
84
83
  slot_opts ||= {}
85
84
  overlay_framer slot, header, slot_opts do
86
- wrap_body { yield }
85
+ wrap_body(&block)
87
86
  end
88
87
  end
89
88
 
90
- def haml_overlay_frame slot=true, header=render_overlay_header
89
+ def haml_overlay_frame slot=true, header=render_overlay_header, &block
91
90
  overlay_framer slot, header, {} do
92
- haml_wrap_body { yield }
91
+ haml_wrap_body(&block)
93
92
  end
94
93
  end
95
94
 
96
95
  private
97
96
 
98
- def overlay_framer slot, header, slot_opts
97
+ def overlay_framer slot, header, slot_opts, &block
99
98
  class_up "card-slot", "_overlay"
100
- with_frame slot, header, slot_opts do
101
- yield
102
- end
99
+ with_frame slot, header, slot_opts, &block
103
100
  end
104
101
  end
@@ -14,13 +14,6 @@ format :html do
14
14
  end
15
15
  end
16
16
 
17
- def main_render_args view, args
18
- args[:view] = view if view
19
- args[:main] = true
20
- args[:main_view] = true
21
- args
22
- end
23
-
24
17
  def page_layout
25
18
  params[:layout] || layout_name_from_rule || :default
26
19
  end
@@ -33,28 +26,43 @@ format :html do
33
26
  render! view, view_opts.reverse_merge(args)
34
27
  end
35
28
 
36
- def render_outside_of_layout view, args
37
- body = render_with_layout(nil, page_layout, {})
38
- modal = render!(view, args)
39
- if body.include?("</body>")
40
- # a bit hacky
41
- # the problem is that the body tag has to be in the layout
42
- # so that you can add layout css classes like <body class="right-sidebar">
43
- body.sub!("</body>", "#{modal}</body>")
44
- else
45
- body += modal
46
- end
47
- body
48
- end
49
-
50
29
  def show_layout?
51
30
  !Env.ajax? || params[:layout]
52
31
  end
53
32
 
54
33
  def explicit_modal_wrapper? view
55
- return unless view_setting(:wrap, view)
34
+ return unless (wrap_view = view_setting :wrap, view)
35
+
36
+ (wrapper_names(wrap_view) & %i[modal bridge]).any?
37
+ end
38
+
39
+ private
40
+
41
+ def main_render_args view, args
42
+ args[:view] = view if view
43
+ args[:main] = true
44
+ args[:main_view] = true
45
+ args
46
+ end
47
+
48
+ def layout_name_from_rule
49
+ card.rule_card(:layout)&.try :item_name
50
+ end
51
+
52
+ def render_outside_of_layout view, args
53
+ body = render_with_layout nil, page_layout, {}
54
+ body_with_modal body, render!(view, args)
55
+ end
56
56
 
57
- wrapper_names(view_setting(:wrap, view)).any? { |n| n == :modal || n == :bridge }
57
+ def body_with_modal body, modal
58
+ if body.include? "</body>"
59
+ # a bit hacky
60
+ # the problem is that the body tag has to be in the layout
61
+ # so that you can add layout css classes like <body class="right-sidebar">
62
+ body.sub "</body>", "#{modal}</body>"
63
+ else
64
+ body + modal
65
+ end
58
66
  end
59
67
 
60
68
  def wrapper_names wrappers
@@ -65,12 +73,6 @@ format :html do
65
73
  end
66
74
  end
67
75
 
68
- def layout_name_from_rule
69
- card.rule_card(:layout)&.try :item_name
70
- end
71
-
72
- private
73
-
74
76
  def wrapper_names_from_array wrapper_array
75
77
  wrapper_array.map { |w| w.is_a?(Array) ? w.first : w }
76
78
  end
data/set/all/tabs.rb CHANGED
@@ -21,6 +21,7 @@ format :html do
21
21
  path: nest_path(name, tab_options).html_safe
22
22
  }
23
23
  return unless tabs[:active].empty?
24
+
24
25
  tabs[:active] = { name: name, content: nest(name, tab_options) }
25
26
  end
26
27
 
data/set/right/head.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require "coderay"
2
+
1
3
  def ok_to_read
2
4
  true
3
5
  end
@@ -24,9 +24,9 @@ format :html do
24
24
  end
25
25
  end
26
26
 
27
- def self.link_options opts={}
27
+ def self.link_options opts={}, &block
28
28
  options = { denial: :blank, cache: :never }.merge opts
29
- options[:perms] = ->(r) { yield r } if block_given?
29
+ options[:perms] = block if block_given?
30
30
  options.clone
31
31
  end
32
32
 
@@ -80,7 +80,7 @@ format :html do
80
80
  end
81
81
 
82
82
  def account_link_text purpose
83
- voo.title || tr(purpose, scope: "card-mod-account")
83
+ voo.title || t("account_#{purpose}")
84
84
  end
85
85
 
86
86
  def nav_link_class type
data/set/self/foot.rb CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  def content
3
2
  "<!-- *foot is deprecated. please remove from layout -->"
4
3
  end
data/set/self/head.rb CHANGED
@@ -9,7 +9,7 @@ format :html do
9
9
  view :core, cache: :never do
10
10
  escape_in_main do
11
11
  nest root.card, view: :head
12
- # note that the head tag for each card is different
12
+ # NOTE: that the head tag for each card is different
13
13
  # (different title, different style rules, etc)
14
14
  # so we don't cache the core of *head, but we _do_ cache some
15
15
  # views within each head (see all/head.rb)
@@ -1,5 +1,7 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
+ require "coderay"
4
+
3
5
  include_set Type::Html
4
6
 
5
7
  event :update_layout_registry, :finalize, on: :update do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: card-mod-layout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan McCutchen
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-03-15 00:00:00.000000000 Z
13
+ date: 2021-07-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: card
@@ -18,42 +18,42 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.101.2
21
+ version: 1.102.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 1.101.2
28
+ version: 1.102.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: card-mod-account
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - '='
34
34
  - !ruby/object:Gem::Version
35
- version: 0.11.2
35
+ version: 0.12.0
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - '='
41
41
  - !ruby/object:Gem::Version
42
- version: 0.11.2
42
+ version: 0.12.0
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: card-mod-session
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - '='
48
48
  - !ruby/object:Gem::Version
49
- version: 0.11.2
49
+ version: 0.12.0
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - '='
55
55
  - !ruby/object:Gem::Version
56
- version: 0.11.2
56
+ version: 0.12.0
57
57
  description: ''
58
58
  email:
59
59
  - info@decko.org
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
- rubygems_version: 3.0.3
118
+ rubygems_version: 3.2.15
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: decko layouts