card-mod-format 0.14.1 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/assets/script/decko/clicks_and_hovers.js.coffee +49 -0
  3. data/assets/script/decko/decko.js.coffee +32 -0
  4. data/assets/script/decko/decko_jquery.js.coffee +25 -0
  5. data/assets/script/decko/slot.js.coffee +150 -0
  6. data/assets/script/decko/slot_ready.js.coffee +11 -0
  7. data/assets/script/decko/slotter.js.coffee +208 -0
  8. data/assets/script/jquery/jquery-ui.min.js +13 -0
  9. data/assets/script/jquery/jquery.autosize.js +274 -0
  10. data/assets/script/jquery/jquery.ui.autocomplete.html.js +41 -0
  11. data/assets/script/manifest.yml +38 -0
  12. data/assets/style/common.scss +73 -0
  13. data/assets/style/logo_and_credit.scss +24 -0
  14. data/assets/style/menu.scss +43 -0
  15. data/assets/style/messaging.scss +59 -0
  16. data/assets/style/misc.scss +90 -0
  17. data/assets/style/open_and_closed.scss +68 -0
  18. data/data/files/credit_image.svg +59 -0
  19. data/data/files/mod_format_script_asset_output/file.js +66 -0
  20. data/data/real.yml +67 -0
  21. data/lib/card/format/html_format.rb +0 -2
  22. data/lib/card/mod/format.rb +4 -0
  23. data/lib/card/path.rb +20 -20
  24. data/set/all/base.rb +1 -11
  25. data/set/all/content.rb +3 -11
  26. data/set/all/csv.rb +22 -74
  27. data/set/all/data.rb +2 -2
  28. data/set/all/demo.rb +6 -2
  29. data/set/all/error.rb +1 -1
  30. data/set/all/html/error.rb +1 -1
  31. data/set/all/html/head.rb +22 -12
  32. data/set/all/html/header.rb +10 -40
  33. data/set/all/html/header_wrap.haml +3 -4
  34. data/set/all/html/labeled.haml +1 -1
  35. data/set/all/html/menu.rb +36 -12
  36. data/set/all/html/views.rb +8 -17
  37. data/set/all/html/wrap.rb +5 -4
  38. data/set/all/html.rb +2 -3
  39. data/set/all/json.rb +1 -5
  40. data/set/right/head.rb +1 -0
  41. data/set/type/cardtype.rb +4 -6
  42. data/set/type/json.rb +1 -1
  43. data/set/type/number.rb +1 -16
  44. data/vendor/jquery_file_upload/LICENSE.txt +20 -0
  45. data/vendor/jquery_file_upload/README.md +224 -0
  46. data/vendor/jquery_file_upload/SECURITY.md +227 -0
  47. data/vendor/jquery_file_upload/VULNERABILITIES.md +118 -0
  48. data/vendor/jquery_file_upload/cors/postmessage.html +85 -0
  49. data/vendor/jquery_file_upload/cors/result.html +26 -0
  50. data/vendor/jquery_file_upload/css/jquery.fileupload-noscript.css +22 -0
  51. data/vendor/jquery_file_upload/css/jquery.fileupload-ui-noscript.css +17 -0
  52. data/vendor/jquery_file_upload/css/jquery.fileupload-ui.css +68 -0
  53. data/vendor/jquery_file_upload/css/jquery.fileupload.css +36 -0
  54. data/vendor/jquery_file_upload/docker-compose.yml +55 -0
  55. data/vendor/jquery_file_upload/img/loading.gif +0 -0
  56. data/vendor/jquery_file_upload/img/progressbar.gif +0 -0
  57. data/vendor/jquery_file_upload/index.html +357 -0
  58. data/vendor/jquery_file_upload/js/cors/jquery.postmessage-transport.js +126 -0
  59. data/vendor/jquery_file_upload/js/cors/jquery.xdr-transport.js +97 -0
  60. data/vendor/jquery_file_upload/js/demo.js +75 -0
  61. data/vendor/jquery_file_upload/js/jquery.fileupload-audio.js +101 -0
  62. data/vendor/jquery_file_upload/js/jquery.fileupload-image.js +347 -0
  63. data/vendor/jquery_file_upload/js/jquery.fileupload-process.js +170 -0
  64. data/vendor/jquery_file_upload/js/jquery.fileupload-ui.js +759 -0
  65. data/vendor/jquery_file_upload/js/jquery.fileupload-validate.js +119 -0
  66. data/vendor/jquery_file_upload/js/jquery.fileupload-video.js +101 -0
  67. data/vendor/jquery_file_upload/js/jquery.fileupload.js +1604 -0
  68. data/vendor/jquery_file_upload/js/jquery.iframe-transport.js +227 -0
  69. data/vendor/jquery_file_upload/js/vendor/jquery.ui.widget.js +805 -0
  70. data/vendor/jquery_file_upload/package-lock.json +6853 -0
  71. data/vendor/jquery_file_upload/package.json +116 -0
  72. data/vendor/jquery_file_upload/server/gae-python/app.yaml +18 -0
  73. data/vendor/jquery_file_upload/server/gae-python/main.py +204 -0
  74. data/vendor/jquery_file_upload/server/gae-python/static/favicon.ico +0 -0
  75. data/vendor/jquery_file_upload/server/gae-python/static/robots.txt +2 -0
  76. data/vendor/jquery_file_upload/server/php/Dockerfile +44 -0
  77. data/vendor/jquery_file_upload/server/php/UploadHandler.php +1480 -0
  78. data/vendor/jquery_file_upload/server/php/index.php +15 -0
  79. data/vendor/jquery_file_upload/server/php/php.ini +5 -0
  80. data/vendor/jquery_file_upload/test/index.html +49 -0
  81. data/vendor/jquery_file_upload/test/unit.js +989 -0
  82. data/vendor/jquery_file_upload/test/vendor/chai.js +10854 -0
  83. data/vendor/jquery_file_upload/test/vendor/mocha.css +325 -0
  84. data/vendor/jquery_file_upload/test/vendor/mocha.js +18178 -0
  85. data/vendor/jquery_file_upload/wdio/LICENSE.txt +20 -0
  86. data/vendor/jquery_file_upload/wdio/assets/black+white-3x2.jpg +0 -0
  87. data/vendor/jquery_file_upload/wdio/assets/black+white-60x40.gif +0 -0
  88. data/vendor/jquery_file_upload/wdio/conf/chrome.js +40 -0
  89. data/vendor/jquery_file_upload/wdio/conf/firefox.js +25 -0
  90. data/vendor/jquery_file_upload/wdio/hooks/index.js +36 -0
  91. data/vendor/jquery_file_upload/wdio/test/pages/file-upload.js +79 -0
  92. data/vendor/jquery_file_upload/wdio/test/specs/01-file-upload.js +25 -0
  93. data/vendor/jquery_file_upload/wdio/wdio.conf.js +4 -0
  94. data/vendor/jquery_rails/CHANGELOG.md +359 -0
  95. data/vendor/jquery_rails/CONTRIBUTING.md +132 -0
  96. data/vendor/jquery_rails/Gemfile +22 -0
  97. data/vendor/jquery_rails/MIT-LICENSE +21 -0
  98. data/vendor/jquery_rails/README.md +75 -0
  99. data/vendor/jquery_rails/Rakefile +59 -0
  100. data/vendor/jquery_rails/VERSIONS.md +62 -0
  101. data/vendor/jquery_rails/jquery-rails.gemspec +26 -0
  102. data/vendor/jquery_rails/lib/jquery/assert_select.rb +149 -0
  103. data/vendor/jquery_rails/lib/jquery/rails/engine.rb +6 -0
  104. data/vendor/jquery_rails/lib/jquery/rails/version.rb +9 -0
  105. data/vendor/jquery_rails/lib/jquery/rails.rb +8 -0
  106. data/vendor/jquery_rails/lib/jquery-rails.rb +1 -0
  107. data/vendor/jquery_rails/test/assert_select_jquery_test.rb +85 -0
  108. data/vendor/jquery_rails/test/test_helper.rb +6 -0
  109. data/vendor/jquery_rails/vendor/assets/javascripts/jquery.js +11008 -0
  110. data/vendor/jquery_rails/vendor/assets/javascripts/jquery.min.js +5 -0
  111. data/vendor/jquery_rails/vendor/assets/javascripts/jquery.min.map +1 -0
  112. data/vendor/jquery_rails/vendor/assets/javascripts/jquery2.js +9814 -0
  113. data/vendor/jquery_rails/vendor/assets/javascripts/jquery2.min.js +4 -0
  114. data/vendor/jquery_rails/vendor/assets/javascripts/jquery2.min.map +1 -0
  115. data/vendor/jquery_rails/vendor/assets/javascripts/jquery3.js +10364 -0
  116. data/vendor/jquery_rails/vendor/assets/javascripts/jquery3.min.js +2 -0
  117. data/vendor/jquery_rails/vendor/assets/javascripts/jquery3.min.map +1 -0
  118. data/vendor/jquery_rails/vendor/assets/javascripts/jquery_ujs.js +555 -0
  119. metadata +104 -7
data/data/real.yml ADDED
@@ -0,0 +1,67 @@
1
+ ---
2
+
3
+
4
+ - :name: JSON
5
+ :type: :cardtype
6
+ :codename: json
7
+ - :name: RichText
8
+ :type: :cardtype
9
+ :codename: basic
10
+ :fields:
11
+ :description: "<p>Basic cards are for rich text, and are the default type for new cards.</p>"
12
+ - :name: Number
13
+ :type: :cardtype
14
+ :codename: number
15
+ :fields:
16
+ :description: "<p>Can contain only numerical values.</p>"
17
+ - :name: PlainText
18
+ :type: :cardtype
19
+ :codename: plain_text
20
+ :fields:
21
+ :description: "<p>PlainText cards are for unstyled text.</p>"
22
+ - :name: HTML
23
+ :type: :cardtype
24
+ :codename: html
25
+ :fields:
26
+ :description: "<p>These cards allow unrestricted HTML. [[http://decko.org/wagn/HTML|more]]</p>"
27
+ - :name: Toggle
28
+ :type: :cardtype
29
+ :codename: toggle
30
+ :fields:
31
+ :description: "<p>Toggles simply indicate yes or no. [[http://decko.org/wagn/Toggle|more]].</p>"
32
+ - :name: Phrase
33
+ :type: :cardtype
34
+ :codename: phrase
35
+ :fields:
36
+ :description: "<p>Phrase cards are for short unstyled text.</p>"
37
+ - :name: URI
38
+ :type: :cardtype
39
+ :codename: uri
40
+
41
+ - :name: "*head"
42
+ :type: :setting
43
+ :codename: head
44
+ :fields:
45
+ :self:
46
+ :fields:
47
+ :read: Anyone
48
+
49
+ - :name:
50
+ - :all
51
+ - :head
52
+ :content: "{{:head|core}}"
53
+
54
+ - :name: "*title"
55
+ :type: :phrase
56
+ :codename: title
57
+ :content: My Deck
58
+ - :name: "*credit"
59
+ :type: :html
60
+ :codename: credit
61
+ :content: |
62
+ {{+:image|core}}
63
+ <a href="http://decko.org">Decko v{{:version|core}}</a>
64
+ :fields:
65
+ :self:
66
+ :fields:
67
+ :read: Anyone
@@ -1,7 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- # # require "card/content/diff"
4
-
5
3
  class Card
6
4
  class Format
7
5
  # Main Format class for formatting card views in HTML
@@ -0,0 +1,4 @@
1
+ Cardio::Railtie.config.tap do |config|
2
+ config.default_html_view = :titled
3
+ config.rss_enabled = false
4
+ end
data/lib/card/path.rb CHANGED
@@ -16,22 +16,12 @@ class Card
16
16
 
17
17
  attr_reader :opts
18
18
 
19
- def action
20
- @action ||= opts.delete(:action)&.to_sym
21
- end
22
-
23
19
  def new_cardtype
24
- return unless new_cardtype?
25
-
26
- "#{action}/#{mark}#{query}"
27
- end
28
-
29
- def new_cardtype?
30
- return false unless action.in? %i[new type]
31
-
32
20
  # "new" and "type" are not really an action and are only
33
21
  # a valid value here for this path
34
- opts[:mark].present?
22
+ return unless action.in?(%i[new type]) && mark.present?
23
+
24
+ "#{action}/#{mark}#{query}"
35
25
  end
36
26
 
37
27
  def standard
@@ -40,7 +30,13 @@ class Card
40
30
  end
41
31
 
42
32
  def base
43
- explicit_action? ? action_base : mark
33
+ if action.in? %i[create update delete]
34
+ action_base
35
+ elsif mark.present? && view.present?
36
+ "#{mark}/#{view}"
37
+ else
38
+ mark
39
+ end
44
40
  end
45
41
 
46
42
  def action_base
@@ -48,8 +44,16 @@ class Card
48
44
  # the card/ prefix prevents interpreting action as cardname
49
45
  end
50
46
 
51
- def explicit_action?
52
- action.in? %i[create update delete]
47
+ def action
48
+ @action ||= opts.delete(:action)&.to_sym
49
+ end
50
+
51
+ def view
52
+ @view ||= opts.delete :view
53
+ end
54
+
55
+ def no_mark?
56
+ @no_mark ||= opts.delete :no_mark
53
57
  end
54
58
 
55
59
  def mark
@@ -67,10 +71,6 @@ class Card
67
71
  action == :create || no_mark?
68
72
  end
69
73
 
70
- def no_mark?
71
- @no_mark ||= opts.delete :no_mark
72
- end
73
-
74
74
  def extension
75
75
  extension = opts.delete :format
76
76
  extension ? ".#{extension}" : ""
data/set/all/base.rb CHANGED
@@ -94,9 +94,7 @@ format do
94
94
  end
95
95
 
96
96
  view :one_line_content, compact: true do
97
- with_nest_mode :compact do
98
- Card::Content.smart_truncate _render_core
99
- end
97
+ with_nest_mode(:compact) { truncate render_core }
100
98
  end
101
99
 
102
100
  view :labeled_content, unknown: :mini_unknown do
@@ -127,12 +125,4 @@ format do
127
125
  "#{card.name}: #{_render_labeled_content}"
128
126
  end
129
127
  view :closed, :labeled
130
-
131
- # SPECIAL VIEWS
132
-
133
- view :array, cache: :never do
134
- card.item_cards(limit: 0).map do |item_card|
135
- subformat(item_card)._render_core
136
- end.inspect
137
- end
138
128
  end
data/set/all/content.rb CHANGED
@@ -35,25 +35,17 @@ format do
35
35
 
36
36
  # TODO: move this into a nest once popovers are stub safe
37
37
  def label_description
38
- return unless (desc = card.field :description)
38
+ return unless (desc = card.fetch :description)
39
39
 
40
40
  desc.format.render_core
41
41
  end
42
42
 
43
43
  def raw_one_line_content
44
- cut_with_ellipsis render_raw
44
+ truncate strip_tags(render_raw), length: one_line_character_limit
45
45
  end
46
46
 
47
47
  def one_line_content
48
- Content.smart_truncate render_core
49
- end
50
-
51
- def cut_with_ellipsis text, limit=one_line_character_limit
52
- if text.size <= limit
53
- text
54
- else
55
- "#{text[0..(limit - 3)]}..."
56
- end
48
+ truncate strip_tags(render_core), length: one_line_character_limit
57
49
  end
58
50
 
59
51
  def one_line_character_limit
data/set/all/csv.rb CHANGED
@@ -1,94 +1,42 @@
1
1
  require "csv"
2
2
 
3
- format :csv do
4
- def default_nest_view
5
- :core
3
+ format :csv do
4
+ def show view, args
5
+ view ||= :titled
6
+ super view, args
6
7
  end
7
8
 
8
- def default_item_view
9
- depth.zero? ? :csv_row : :name
9
+ def nests
10
+ [["_self", { view: :name }], ["_self", { view: :type }]]
10
11
  end
11
12
 
12
- view :core do
13
- if (item_view_options[:view] == :name_with_fields) && focal?
14
- title_row("item name") + name_with_field_rows
15
- else
16
- super()
17
- end
18
- end
19
-
20
- view :csv_row do
21
- array = _render_raw.scan(/\{\{[^}]*\}\}/).map do |inc|
22
- process_content(inc).strip
23
- end
24
-
25
- CSV.generate_line(array).strip
26
- # strip is because search already joins with newlines
27
- end
28
-
29
- view :unknown do
30
- ""
31
- end
32
-
33
- view :name_with_fields do
34
- CSV.generate_line name_with_fields_row
35
- end
36
-
37
- def name_with_fields_row
38
- nested_field_names.each_with_object([card.name]) do |field_name, row|
39
- row << nest(field_name)
40
- end
41
- end
42
-
43
- def name_with_field_rows
44
- return [] unless row_card_names.present?
45
-
46
- row_card_names.map do |item_name|
47
- CSV.generate_line row_from_field_names(item_name, columns)
48
- end.join
49
- end
50
-
51
- def row_card_names
52
- @row_cards ||= card.item_names
13
+ def default_nest_view
14
+ :titled
53
15
  end
54
16
 
55
- def columns
56
- csv_structure_card.format.nested_field_names.map(&:tag)
17
+ def default_item_view
18
+ :name
57
19
  end
58
20
 
59
- def csv_structure_card
60
- card.rule_card(:csv_structure) || Card.fetch(row_card_names.first)
21
+ view :titled do
22
+ voo.items[:view] ||= :row
23
+ (render_header + render_core).map { |row| CSV.generate_line row }.join
61
24
  end
62
25
 
63
- def row_from_field_names parent_name, field_names, view=:core
64
- field_names.each_with_object([parent_name]) do |field, row|
65
- row << nest([parent_name, field], view: view)
66
- end
26
+ view :core do
27
+ item_cards.map { |item_card| nest item_card }
67
28
  end
68
29
 
69
- def title_row extra_titles=nil
70
- titles = column_titles extra_titles
71
- return "" unless titles.present?
72
-
73
- CSV.generate_line titles.map(&:upcase)
30
+ view :row do
31
+ nests.map { |nest_args| nest(*nest_args) }
74
32
  end
75
33
 
76
- def column_titles extra_titles=nil
77
- res = Array extra_titles
78
- card1 = Card.fetch card.item_names(limit: 1).first
79
- card1.nest_chunks.each do |chunk|
80
- res << column_title(chunk.options)
81
- end
82
- res.compact
34
+ # localize
35
+ view :header do
36
+ [%w[Name Type]]
83
37
  end
84
38
 
85
- def column_title opts
86
- if opts[:title]
87
- opts[:title]
88
- elsif %w[name link].member? opts[:view]
89
- opts[:view]
90
- else
91
- opts[:nest_name].to_name.tag
92
- end
39
+ view :unknown do
40
+ ""
93
41
  end
94
42
  end
data/set/all/data.rb CHANGED
@@ -7,10 +7,10 @@ def export_hash field_tags: []
7
7
  type: export_type,
8
8
  codename: codename,
9
9
  content: export_content,
10
- subfields: export_subfields(field_tags) }.compact_blank
10
+ fields: export_fields(field_tags) }.compact_blank
11
11
  end
12
12
 
13
- def export_subfields marks
13
+ def export_fields marks
14
14
  marks.each_with_object({}) do |mark, hash|
15
15
  hash[mark] = [name, mark].card&.export_content
16
16
  end.compact_blank
data/set/all/demo.rb CHANGED
@@ -6,11 +6,15 @@ format :html do
6
6
  end
7
7
 
8
8
  view :view_list do
9
- %i[bar box info_bar open closed titled labeled content content_panel].map do |v|
9
+ view_list.map do |v|
10
10
  wrap_with :p, [content_tag(:h3, v), render(v, show: :menu)]
11
11
  end.flatten.join ""
12
12
  end
13
13
 
14
+ def view_list
15
+ %i[content titled labeled bar box open closed content_panel]
16
+ end
17
+
14
18
  def demo_view
15
19
  Env.params[:demo_view] || :core
16
20
  end
@@ -31,6 +35,6 @@ format :html do
31
35
 
32
36
  def all_views
33
37
  Card::Set::Format::AbstractFormat::ViewDefinition
34
- .views.slice(*self.class.ancestors).values.map(&:keys).flatten.uniq
38
+ .views.slice(*self.class.ancestors).values.map(&:keys).flatten.uniq.sort
35
39
  end
36
40
  end
data/set/all/error.rb CHANGED
@@ -67,6 +67,6 @@ format :json do
67
67
  view :not_found, :errors
68
68
  view :bad_address do
69
69
  card.errors.add :address, super()
70
- render_error
70
+ render_errors
71
71
  end
72
72
  end
@@ -77,7 +77,7 @@ format :html do
77
77
  end
78
78
 
79
79
  def view_for_unknown setting_view
80
- main? && ok?(:create) ? :new : super
80
+ main? && voo.root? && ok?(:create) ? :new : super
81
81
  end
82
82
 
83
83
  def show_all_errors?
data/set/all/html/head.rb CHANGED
@@ -1,3 +1,9 @@
1
+ basket[:head_views] =
2
+ %i[page_title_tag meta_tags favicon_tag
3
+ head_stylesheet head_remote_stylesheets
4
+ universal_edit_button rss_links]
5
+ # TODO: the last two should be in mods
6
+
1
7
  format do
2
8
  view :page_title, unknown: true, perms: :none do
3
9
  title_parts = [Card::Rule.global_setting(:title)]
@@ -8,18 +14,10 @@ end
8
14
 
9
15
  format :html do
10
16
  view :head, unknown: true, perms: :none do
11
- views_in_head.map { |viewname| render viewname }.flatten.compact.join "\n"
17
+ basket[:head_views].map { |viewname| render viewname }.flatten.compact.join "\n"
12
18
  end
13
19
 
14
- def views_in_head
15
- %i[meta_tags page_title_tag favicon_tag head_stylesheet
16
- universal_edit_button rss_links]
17
- end
18
-
19
- # FIXME: tags not working with `template: :haml`
20
- view :meta_tags, unknown: true, perms: :none do
21
- haml :meta_tags
22
- end
20
+ view :meta_tags, unknown: true, perms: :none, template: :haml
23
21
 
24
22
  view :page_title_tag, unknown: true, perms: :none do
25
23
  content_tag(:title) { render :page_title }
@@ -29,7 +27,7 @@ format :html do
29
27
  nest :favicon, view: :link_tag
30
28
  end
31
29
 
32
- view :universal_edit_button, unknown: true, denial: :blank, perms: :update do
30
+ view :universal_edit_button, unknown: :blank, denial: :blank, perms: :update do
33
31
  return if card.new?
34
32
 
35
33
  tag "link", rel: "alternate", type: "application/x-wiki",
@@ -42,7 +40,11 @@ format :html do
42
40
  view :head_stylesheet, unknown: true, cache: :never, perms: :none do
43
41
  return unless (href = head_stylesheet_path)
44
42
 
45
- tag "link", href: href, media: "all", rel: "stylesheet", type: "text/css"
43
+ tag("link", href: href, media: "all", rel: "stylesheet", type: "text/css")
44
+ end
45
+
46
+ view :head_remote_stylesheets, unknown: true, cache: :never, perms: :none do
47
+ remote_style_tags
46
48
  end
47
49
 
48
50
  def param_or_rule_card setting
@@ -74,6 +76,14 @@ format :html do
74
76
  Card.config.rss_enabled && respond_to?(:rss_link_tag)
75
77
  end
76
78
 
79
+ def remote_style_tags
80
+ return unless (asset_card = Card[:style_mods])
81
+
82
+ asset_card.item_cards.map do |mod_style_card|
83
+ nest mod_style_card, view: :remote_include_tags
84
+ end.select(&:present?)
85
+ end
86
+
77
87
  def head_stylesheet_path
78
88
  debug_or_machine_path(
79
89
  :style,
@@ -3,59 +3,29 @@ TOGGLE_MAP = { close: %w[open open], open: %w[close closed] }.freeze
3
3
 
4
4
  format :html do
5
5
  view :header, perms: :none do
6
- main_header
6
+ header_wrap [render_header_title, render_menu]
7
7
  end
8
8
 
9
- def main_header
10
- header_wrap _render_header_title
11
- end
12
-
13
- def header_wrap content=nil
14
- haml :header_wrap, content: (block_given? ? yield : output(content))
9
+ def header_wrap header_parts
10
+ wrap_with :div, class: classy("d0-card-header") do
11
+ output Array.wrap(header_parts)
12
+ end
15
13
  end
16
14
 
17
15
  view :header_title, perms: :none do
18
- header_title_elements
16
+ wrap_with (voo.header || default_header), class: classy("d0-card-header-title") do
17
+ render_title
18
+ end
19
19
  end
20
20
 
21
- def header_title_elements
22
- voo.hide :title_toggle if show_view?(:icon_toggle, :hide)
23
- title_view = show_view?(:title_toggle, :hide) ? :title_toggle : :title
24
- [_render_icon_toggle(optional: :hide), _render(title_view)]
21
+ def default_header
22
+ main? ? :h1 : :h2
25
23
  end
26
24
 
27
25
  def show_draft_link?
28
26
  card.drafts.present? && @slot_view == :edit
29
27
  end
30
28
 
31
- view :title_toggle, perms: :none do
32
- content_toggle(_render_title(hide: :title_link))
33
- end
34
-
35
- view :icon_toggle, perms: :none do
36
- direction = @toggle_mode == :close ? :expand : :collapse_down
37
- content_toggle icon_tag(direction)
38
- end
39
-
40
- view :toggle, :icon_toggle # deprecated; use icon_toggle
41
-
42
- def content_toggle text=""
43
- return if text.nil?
44
-
45
- verb, adjective = toggle_verb_adjective
46
- link_to_view adjective, text, title: "#{verb} #{card.name}", # LOCALIZE
47
- class: "toggle-#{adjective} toggler nodblclick"
48
- end
49
-
50
- def toggle_view
51
- toggle_verb_adjective.last
52
- end
53
-
54
- def toggle_verb_adjective
55
- TOGGLE_MAP[@toggle_mode || :open] ||
56
- raise(Card::Error, "invalid toggle mode: #{@toggle_mode}")
57
- end
58
-
59
29
  def structure_editable?
60
30
  card.structure && card.template.ok?(:update)
61
31
  end
@@ -1,4 +1,3 @@
1
- %div{ class: [classy("d0-card-header")], href: path(view: toggle_view) }
2
- = _render_menu
3
- %div{ class: classy("d0-card-header-title") }
4
- = content
1
+ = render_menu
2
+ %div{ class: classy("d0-card-header-title") }
3
+ = title
@@ -1,4 +1,4 @@
1
- .label.col-4.text-right
1
+ .label.col-4.text-end
2
2
  = label
3
3
  .labeled-content.col-8
4
4
  = content
data/set/all/html/menu.rb CHANGED
@@ -1,11 +1,12 @@
1
1
  format :html do
2
2
  view :menu, denial: :blank, unknown: true do
3
- return "" if card.unknown?
4
-
3
+ return "" unless card.known?
4
+ # would be preferable to do this with unknown: :blank, but that fails with view
5
+ # caching on, because voo always thinks it's the root.
5
6
  wrap_with :div, class: "card-menu #{menu_link_classes}" do
6
7
  [render_help_link,
7
8
  menu_link,
8
- (voo.show?(:bridge_link) ? bridge_link(false) : nil)]
9
+ (voo.show?(:bridge_link) ? bridge_link(in_modal: false) : nil)]
9
10
  end
10
11
  end
11
12
 
@@ -35,6 +36,11 @@ format :html do
35
36
  edit_link edit_link_view
36
37
  end
37
38
 
39
+ view :edit_button do
40
+ view = voo.edit == :inline ? :edit_inline : :edit
41
+ link_to_view view, "Edit", class: "btn btn-sm btn-outline-primary me-2"
42
+ end
43
+
38
44
  def edit_link_view
39
45
  :edit
40
46
  end
@@ -47,13 +53,13 @@ format :html do
47
53
  bridge_link
48
54
  end
49
55
 
50
- def bridge_link in_modal=true
56
+ def bridge_link text: "", in_modal: true
51
57
  opts = { class: "bridge-link" }
52
58
  if in_modal
53
59
  # add_class opts, "close"
54
60
  opts["data-slotter-mode"] = "modal-replace"
55
61
  end
56
- link_to_view :bridge, material_icon(:more_horiz), opts
62
+ link_to_view :bridge, "#{bridge_icon} #{text}", opts
57
63
  end
58
64
 
59
65
  # no caching because help_text view doesn't cache, and we can't have a
@@ -70,7 +76,7 @@ format :html do
70
76
 
71
77
  def help_popover_opts text=nil, title=nil
72
78
  text ||= render_help_text
73
- opts = { "data-placement": :left, class: "help-link" }
79
+ opts = { "data-bs-placement": :left, class: "help-link" }
74
80
  popover_opts text, title, opts
75
81
  end
76
82
 
@@ -88,8 +94,18 @@ format :html do
88
94
  end.join Card::Name.joint
89
95
  end
90
96
 
91
- def full_page_link
92
- link_to_card full_page_card, full_page_icon, class: classy("full-page-link")
97
+ def full_page_link text: ""
98
+ link_to_card full_page_card, "#{full_page_icon} #{text}",
99
+ class: classy("full-page-link")
100
+ end
101
+
102
+ def modal_page_link text: ""
103
+ modal_link "#{modal_icon} #{text}",
104
+ path: { mark: card }, size: modal_page_size, class: "_modal-page-link"
105
+ end
106
+
107
+ def modal_page_size
108
+ :xl
93
109
  end
94
110
 
95
111
  def full_page_card
@@ -97,12 +113,12 @@ format :html do
97
113
  end
98
114
 
99
115
  def edit_in_bridge_link opts={}
100
- edit_link :bridge, opts
116
+ edit_link :bridge, *opts
101
117
  end
102
118
 
103
- def edit_link view=:edit, opts={}
104
- link_to_view view, opts.delete(:link_text) || menu_icon,
105
- edit_link_opts(modal: (opts[:modal] || :lg))
119
+ def edit_link view=:edit, link_text: nil, text: "", modal: nil
120
+ link_to_view view, link_text || "#{menu_icon} #{text}",
121
+ edit_link_opts(modal: (modal || :lg))
106
122
  end
107
123
 
108
124
  # @param modal [Symbol] modal size
@@ -126,4 +142,12 @@ format :html do
126
142
  def full_page_icon
127
143
  icon_tag :open_in_new
128
144
  end
145
+
146
+ def modal_icon
147
+ fa_icon :expand
148
+ end
149
+
150
+ def bridge_icon
151
+ fa_icon :box
152
+ end
129
153
  end