card 1.19.6 → 1.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (298) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/card.gemspec +8 -7
  4. data/config/initializers/01_core_extensions/array.rb +4 -0
  5. data/config/initializers/01_core_extensions/persistent_identifiers.rb +12 -0
  6. data/config/initializers/02_patches/better_errors.rb +56 -0
  7. data/config/initializers/core_extensions.rb +13 -18
  8. data/config/initializers/patches.rb +8 -0
  9. data/config/locales/de.yml +0 -2
  10. data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +22 -12
  11. data/db/migrate_core_cards/20161102202156_tweak_recaptcha_setting_cards.rb +17 -0
  12. data/db/migrate_core_cards/20161103154836_update_keys.rb +46 -0
  13. data/lib/card.rb +1 -8
  14. data/lib/card/act_manager.rb +4 -0
  15. data/lib/card/auth/permissions.rb +5 -3
  16. data/lib/card/cache.rb +1 -20
  17. data/lib/card/cache/persistent.rb +6 -0
  18. data/lib/card/content/chunk.rb +4 -3
  19. data/lib/card/content/diff.rb +2 -2
  20. data/lib/card/content/diff/result.rb +11 -0
  21. data/lib/card/env/success.rb +4 -0
  22. data/lib/card/error.rb +2 -0
  23. data/lib/card/format.rb +14 -17
  24. data/lib/card/format/content.rb +16 -8
  25. data/lib/card/format/error.rb +3 -5
  26. data/lib/card/format/names.rb +22 -16
  27. data/lib/card/format/nest.rb +67 -61
  28. data/lib/card/format/nest/fetch.rb +40 -33
  29. data/lib/card/format/nest/main.rb +39 -19
  30. data/lib/card/format/nest/subformat.rb +3 -16
  31. data/lib/card/format/nest/view.rb +23 -32
  32. data/lib/card/format/permission.rb +49 -34
  33. data/lib/card/format/registration.rb +12 -6
  34. data/lib/card/format/render.rb +62 -73
  35. data/lib/card/migration.rb +14 -10
  36. data/lib/card/migration/import.rb +20 -19
  37. data/lib/card/migration/import/import_data.rb +50 -59
  38. data/lib/card/migration/import/import_data/card_attributes.rb +56 -0
  39. data/lib/card/migration/import/import_data/card_content.rb +33 -0
  40. data/lib/card/migration/import/merger.rb +47 -0
  41. data/lib/card/mod/loader.rb +4 -4
  42. data/lib/card/model/save_helper.rb +49 -10
  43. data/lib/card/name.rb +16 -52
  44. data/lib/card/name/fields_and_traits.rb +67 -0
  45. data/lib/card/name/variants.rb +17 -0
  46. data/lib/card/query.rb +6 -2
  47. data/lib/card/query/attributes.rb +1 -1
  48. data/lib/card/query/interpretation.rb +3 -3
  49. data/lib/card/set/event.rb +2 -1
  50. data/lib/card/set/format.rb +18 -7
  51. data/lib/card/set_pattern.rb +17 -13
  52. data/lib/card/tasks/card.rake +1 -1
  53. data/lib/card/view.rb +55 -0
  54. data/lib/card/view/cache.rb +90 -0
  55. data/lib/card/view/fetch.rb +109 -0
  56. data/lib/card/view/options.rb +164 -0
  57. data/lib/card/view/stub.rb +30 -0
  58. data/lib/card/view/visibility.rb +95 -0
  59. data/lib/cardio.rb +3 -2
  60. data/lib/cardio/schema.rb +21 -8
  61. data/lib/generators/card.rb +16 -2
  62. data/lib/generators/card/format/format_generator.rb +10 -9
  63. data/lib/generators/card/migration/migration_generator.rb +10 -5
  64. data/lib/generators/card/set/USAGE +1 -1
  65. data/lib/generators/card/set/set_generator.rb +11 -9
  66. data/mod/account/set/right/account.rb +38 -40
  67. data/mod/account/set/right/token.rb +2 -1
  68. data/mod/account/set/self/account_links.rb +34 -54
  69. data/mod/account/set/self/signin.rb +107 -93
  70. data/mod/account/set/type/signup.rb +33 -32
  71. data/mod/account/set/type/user.rb +28 -21
  72. data/mod/account/spec/set/all/account_spec.rb +9 -9
  73. data/mod/account/spec/set/right/account_spec.rb +23 -14
  74. data/mod/account/spec/set/right/email_spec.rb +6 -6
  75. data/mod/account/spec/set/right/password_spec.rb +4 -4
  76. data/mod/account/spec/set/right/token_spec.rb +3 -3
  77. data/mod/account/spec/set/self/account_links_spec.rb +3 -3
  78. data/mod/account/spec/set/self/signin_spec.rb +2 -2
  79. data/mod/account/spec/set/type/signup_spec.rb +7 -8
  80. data/mod/ace_editor/set/abstract/ace_editor.rb +1 -4
  81. data/mod/admin/set/self/admin.rb +2 -2
  82. data/mod/admin/set/self/admin_info.rb +1 -1
  83. data/mod/admin/set/self/recaptcha_private_key.rb +3 -0
  84. data/mod/admin/set/self/recaptcha_proxy.rb +3 -0
  85. data/mod/admin/set/self/recaptcha_public_key.rb +3 -0
  86. data/mod/admin/set/self/trash.rb +4 -4
  87. data/mod/admin/spec/set/self/admin_spec.rb +4 -4
  88. data/mod/admin/spec/set/self/version_spec.rb +1 -1
  89. data/mod/basic_formats/set/all/all_css.rb +3 -3
  90. data/mod/basic_formats/set/all/all_csv.rb +6 -6
  91. data/mod/basic_formats/set/all/all_js.rb +4 -0
  92. data/mod/basic_formats/set/all/base.rb +40 -62
  93. data/mod/basic_formats/set/all/json.rb +34 -39
  94. data/mod/basic_formats/set/all/rss.rb +6 -6
  95. data/mod/basic_formats/set/all/text.rb +3 -2
  96. data/mod/basic_formats/set/self/01_head/javascript.rb +2 -2
  97. data/mod/basic_formats/set/self/head.rb +6 -10
  98. data/mod/basic_formats/spec/set/all/all_css_spec.rb +1 -1
  99. data/mod/basic_formats/spec/set/all/all_csv_spec.rb +1 -1
  100. data/mod/basic_formats/spec/set/all/base_spec.rb +8 -5
  101. data/mod/basic_formats/spec/set/all/json_spec.rb +2 -2
  102. data/mod/basic_formats/spec/set/all/rss_spec.rb +4 -4
  103. data/mod/basic_types/set/type/plain_text.rb +3 -5
  104. data/mod/basic_types/spec/set/type/plain_text_spec.rb +2 -2
  105. data/mod/bootstrap/lib/bootstrap.rb +16 -0
  106. data/mod/bootstrap/lib/bootstrap/basic_tags.rb +26 -0
  107. data/mod/bootstrap/lib/bootstrap/component.rb +133 -0
  108. data/mod/bootstrap/lib/bootstrap/component/form.rb +31 -0
  109. data/mod/bootstrap/lib/bootstrap/component/horizontal_form.rb +38 -0
  110. data/mod/bootstrap/lib/bootstrap/component/layout.rb +83 -0
  111. data/mod/bootstrap/lib/bootstrap/component/panel.rb +9 -0
  112. data/mod/bootstrap/lib/bootstrap/component_loader.rb +30 -0
  113. data/mod/bootstrap/lib/bootstrap/delegate.rb +16 -0
  114. data/mod/bootstrap/lib/bootstrapper.rb +16 -0
  115. data/mod/bootstrap/lib/stylesheets/bootstrap/_tables.scss +55 -52
  116. data/mod/bootstrap/lib/stylesheets/bootstrap/mixins/_table-row.scss +12 -12
  117. data/mod/bootstrap/lib/stylesheets/bootstrap_cards.scss +12 -0
  118. data/mod/bootstrap/set/all/bootstrap/accordion.rb +63 -0
  119. data/mod/bootstrap/set/all/bootstrap/helper.rb +7 -140
  120. data/mod/bootstrap/set/all/bootstrap/navbar.rb +74 -0
  121. data/mod/bootstrap/set/all/bootstrap/table.rb +76 -46
  122. data/mod/bootstrap/set/all/bootstrap/tabs.rb +58 -23
  123. data/mod/bootstrap/set/all/bootstrap/wrapper.rb +14 -8
  124. data/mod/bootstrap/set/all/rich_bootstrap.rb +5 -3
  125. data/mod/bootstrap/spec/set/all/bootstrap/bootstrap_builder_spec.rb +31 -0
  126. data/mod/bootstrap/spec/set/all/bootstrap/bootstrap_spec.rb +20 -0
  127. data/mod/bootstrap/spec/set/all/bootstrap/form_spec.rb +59 -1
  128. data/mod/bootstrap/spec/set/all/bootstrap/layout_spec.rb +104 -15
  129. data/mod/carrierwave/set/abstract/attachment.rb +4 -3
  130. data/mod/carrierwave/set/abstract/attachment/paths.rb +1 -1
  131. data/mod/carrierwave/set/abstract/attachment/storage_type.rb +5 -11
  132. data/mod/carrierwave/set/type/file.rb +39 -32
  133. data/mod/carrierwave/set/type/image.rb +59 -34
  134. data/mod/carrierwave/spec/set/type/image_spec.rb +3 -3
  135. data/mod/core/chunk/link.rb +5 -0
  136. data/mod/core/chunk/{include.rb → nest.rb} +8 -29
  137. data/mod/core/chunk/reference.rb +5 -6
  138. data/mod/core/chunk/view_stub.rb +42 -0
  139. data/mod/core/format/html_format.rb +23 -26
  140. data/mod/core/set/abstract/code_file.rb +1 -1
  141. data/mod/core/set/all/actify.rb +1 -1
  142. data/mod/core/set/all/active_card.rb +0 -1
  143. data/mod/core/set/all/{tracked_attributes.rb → assign_attributes.rb} +55 -24
  144. data/mod/core/set/all/collection.rb +136 -122
  145. data/mod/core/set/all/content.rb +8 -0
  146. data/mod/core/set/all/event.rb +5 -2
  147. data/mod/core/set/all/export.rb +7 -7
  148. data/mod/core/set/all/fetch.rb +90 -26
  149. data/mod/core/set/all/initialize.rb +17 -6
  150. data/mod/core/set/all/name.rb +2 -3
  151. data/mod/core/set/all/permissions.rb +19 -11
  152. data/mod/core/set/all/states.rb +12 -2
  153. data/mod/core/set/all/trash.rb +1 -1
  154. data/mod/core/set/all/type.rb +2 -0
  155. data/mod/core/set/all/utils.rb +4 -3
  156. data/mod/core/spec/chunk/literal_spec.rb +2 -2
  157. data/mod/core/spec/chunk/uri_spec.rb +17 -17
  158. data/mod/core/spec/format/html_format_spec.rb +11 -13
  159. data/mod/core/spec/set/all/attribute_tracking_spec.rb +2 -2
  160. data/mod/core/spec/set/all/collection_spec.rb +21 -24
  161. data/mod/core/spec/set/all/content_spec.rb +1 -1
  162. data/mod/core/spec/set/all/export_spec.rb +3 -3
  163. data/mod/core/spec/set/all/fetch_spec.rb +5 -5
  164. data/mod/core/spec/set/all/initialize_spec.rb +4 -4
  165. data/mod/core/spec/set/all/name_spec.rb +6 -6
  166. data/mod/core/spec/set/all/permissions_spec.rb +10 -10
  167. data/mod/core/spec/set/all/references_spec.rb +1 -1
  168. data/mod/core/spec/set/all/rules2_spec.rb +24 -24
  169. data/mod/core/spec/set/all/rules_spec.rb +1 -1
  170. data/mod/core/spec/set/all/templating_spec.rb +8 -8
  171. data/mod/core/spec/set/all/tracked_attributes_spec.rb +6 -6
  172. data/mod/core/spec/set/all/type_spec.rb +5 -5
  173. data/mod/developer/spec/set/all/event_viz_spec.rb +1 -1
  174. data/mod/developer/spec/set/right/debug_spec.rb +1 -1
  175. data/mod/email/set/all/email_html.rb +2 -2
  176. data/mod/email/set/all/notify.rb +8 -3
  177. data/mod/email/set/right/bcc.rb +3 -3
  178. data/mod/email/set/right/follow.rb +5 -5
  179. data/mod/email/set/right/following.rb +1 -1
  180. data/mod/email/set/self/follow_defaults.rb +27 -16
  181. data/mod/email/set/type/email_template.rb +1 -1
  182. data/mod/email/set/type_plus_right/user/follow.rb +10 -9
  183. data/mod/history/lib/card/act.rb +4 -0
  184. data/mod/history/lib/card/act/act_renderer.rb +194 -0
  185. data/mod/history/lib/card/act/act_renderer/absolute_act_renderer.rb +25 -0
  186. data/mod/history/lib/card/act/act_renderer/relative_act_renderer.rb +41 -0
  187. data/mod/history/lib/card/action.rb +1 -0
  188. data/mod/history/lib/card/action/action_renderer.rb +92 -0
  189. data/mod/history/lib/card/action/differ.rb +6 -1
  190. data/mod/history/set/all/act_view.rb +64 -0
  191. data/mod/history/set/all/action_view.rb +65 -0
  192. data/mod/history/set/all/content_history.rb +44 -37
  193. data/mod/history/set/all/history.rb +49 -263
  194. data/mod/machines/lib/stylesheets/style_cards.scss +30 -115
  195. data/mod/machines/set/abstract/script.rb +42 -7
  196. data/mod/machines/set/right/machine_input.rb +4 -0
  197. data/mod/machines/set/type/coffee_script.rb +8 -22
  198. data/mod/machines/set/type/css.rb +2 -2
  199. data/mod/machines/set/type/java_script.rb +4 -24
  200. data/mod/machines/set/type/scss.rb +1 -1
  201. data/mod/machines/spec/set/type/css_spec.rb +1 -1
  202. data/mod/machines/spec/set/type/scss_spec.rb +3 -3
  203. data/mod/machines/spec/set/type/skin_spec.rb +7 -7
  204. data/mod/pointer/set/abstract/01_pointer.rb +44 -46
  205. data/mod/pointer/set/abstract/01_pointer/edit.rb +13 -13
  206. data/mod/pointer/set/right/options.rb +4 -0
  207. data/mod/pointer/spec/set/type/pointer_spec.rb +7 -7
  208. data/mod/prosemirror_editor/set/abstract/prosemirror_editor.rb +3 -3
  209. data/mod/settings/set/abstract/permission.rb +25 -18
  210. data/mod/settings/set/right/add_help.rb +3 -3
  211. data/mod/settings/set/right/structure.rb +10 -16
  212. data/mod/settings/spec/set/right/comment_spec.rb +3 -3
  213. data/mod/settings/spec/set/right/create_spec.rb +1 -1
  214. data/mod/settings/spec/set/right/style_spec.rb +1 -1
  215. data/mod/settings/spec/set/type/setting_spec.rb +1 -1
  216. data/mod/solid_cache/set/abstract/solid_cache.rb +4 -4
  217. data/mod/solid_cache/set/right/solid_cache.rb +9 -10
  218. data/mod/standard/set/abstract/01_search_params.rb +41 -0
  219. data/mod/standard/set/abstract/search.rb +132 -0
  220. data/mod/standard/set/abstract/search/paging.rb +81 -0
  221. data/mod/standard/set/abstract/search/paging/paging_links.rb +90 -0
  222. data/mod/standard/set/abstract/wql_search.rb +67 -0
  223. data/mod/standard/set/all/error.rb +89 -82
  224. data/mod/standard/set/all/links.rb +1 -1
  225. data/mod/standard/set/all/rich_html/content.rb +125 -141
  226. data/mod/standard/set/all/rich_html/editing.rb +115 -178
  227. data/mod/standard/set/all/rich_html/form.rb +111 -131
  228. data/mod/standard/set/all/rich_html/header.rb +57 -39
  229. data/mod/standard/set/all/rich_html/menu.rb +94 -94
  230. data/mod/standard/set/all/rich_html/modal.rb +5 -10
  231. data/mod/standard/set/all/rich_html/new.rb +103 -0
  232. data/mod/standard/set/all/rich_html/toolbar.rb +54 -74
  233. data/mod/standard/set/all/rich_html/wrapper.rb +111 -138
  234. data/mod/standard/set/rstar/rules.rb +27 -38
  235. data/mod/standard/set/rstar/rules_editor.rb +298 -277
  236. data/mod/standard/set/self/navbox.rb +20 -15
  237. data/mod/standard/set/self/recent.rb +25 -17
  238. data/mod/standard/set/self/search.rb +25 -4
  239. data/mod/standard/set/type/cardtype.rb +11 -9
  240. data/mod/standard/set/type/date.rb +1 -1
  241. data/mod/standard/set/type/number.rb +1 -1
  242. data/mod/standard/set/type/phrase.rb +1 -1
  243. data/mod/standard/set/type/search_type.rb +17 -282
  244. data/mod/standard/set/type/session.rb +1 -1
  245. data/mod/standard/set/type/set.rb +155 -131
  246. data/mod/standard/set/type/toggle.rb +1 -1
  247. data/mod/standard/set/type/uri.rb +4 -4
  248. data/mod/standard/spec/chunk/include_spec.rb +13 -31
  249. data/mod/standard/spec/chunk/link_spec.rb +1 -1
  250. data/mod/standard/spec/set/all/error_spec.rb +1 -1
  251. data/mod/standard/spec/set/all/history_spec.rb +2 -2
  252. data/mod/standard/spec/set/all/rich_html/form_spec.rb +4 -4
  253. data/mod/standard/spec/set/all/rich_html/toolbar_spec.rb +22 -0
  254. data/mod/standard/spec/set/all/rich_html/wrapper_spec.rb +3 -2
  255. data/mod/standard/spec/set/right/when_created_spec.rb +1 -1
  256. data/mod/standard/spec/set/right/when_last_edited_spec.rb +1 -1
  257. data/mod/standard/spec/set/rstar/rules_spec.rb +2 -3
  258. data/mod/standard/spec/set/self/head_spec.rb +2 -2
  259. data/mod/standard/spec/set/self/navbox_spec.rb +1 -1
  260. data/mod/standard/spec/set/self/now_spec.rb +1 -1
  261. data/mod/standard/spec/set/type/date_spec.rb +1 -1
  262. data/mod/standard/spec/set/type/email_template_spec.rb +1 -1
  263. data/mod/standard/spec/set/type/layout_type_spec.rb +1 -1
  264. data/mod/standard/spec/set/type/number_spec.rb +1 -1
  265. data/mod/standard/spec/set/type/phrase_spec.rb +1 -1
  266. data/mod/standard/spec/set/type/search_type_spec.rb +2 -2
  267. data/mod/standard/spec/set/type/set_spec.rb +2 -2
  268. data/mod/standard/spec/set/type/toggle_spec.rb +2 -2
  269. data/mod/standard/spec/set/type/uri_spec.rb +3 -1
  270. data/mod/tinymce_editor/set/abstract/tinymce_editor.rb +1 -1
  271. data/spec/config/initializers/core_extensions_spec.rb +40 -10
  272. data/spec/lib/card/auth_spec.rb +8 -8
  273. data/spec/lib/card/cache_spec.rb +3 -3
  274. data/spec/lib/card/chunk_spec.rb +4 -4
  275. data/spec/lib/card/codename_spec.rb +2 -2
  276. data/spec/lib/card/content_spec.rb +23 -23
  277. data/spec/lib/card/diff_spec.rb +1 -1
  278. data/spec/lib/card/format_spec.rb +19 -24
  279. data/spec/lib/card/loader_spec.rb +4 -4
  280. data/spec/lib/card/name_spec.rb +16 -16
  281. data/spec/lib/card/query_spec.rb +80 -80
  282. data/spec/lib/card/reference_spec.rb +5 -5
  283. data/spec/lib/card/set_spec.rb +6 -6
  284. data/spec/lib/card/subcards_spec.rb +14 -0
  285. data/spec/lib/card/view_cache_spec.rb +5 -5
  286. data/spec/models/card/cardtype_spec.rb +15 -15
  287. data/spec/models/card/create_spec.rb +2 -2
  288. data/spec/models/card/trash_spec.rb +24 -24
  289. data/spec/models/card/type_transition_spec.rb +8 -8
  290. data/spec/models/card/validation_spec.rb +5 -5
  291. data/spec/models/card_spec.rb +14 -14
  292. data/spec/spec_helper.rb +6 -2
  293. data/spec/support/card_spec_helper.rb +21 -11
  294. data/spec/support/helper/card_helper.rb +11 -4
  295. metadata +73 -15
  296. data/lib/card/cache/view_cache.rb +0 -103
  297. data/mod/bootstrap/set/all/bootstrap/layout.rb +0 -58
  298. data/mod/core/set/all/view_cache.rb +0 -9
@@ -5,7 +5,7 @@ format :html do
5
5
  opts[:href] = path opts.delete(:path)
6
6
  text = raw(text || opts[:href])
7
7
  interpret_data_opts_to_link_to opts
8
- content_tag :a, text, opts
8
+ wrap_with :a, text, opts
9
9
  end
10
10
 
11
11
  def interpret_data_opts_to_link_to opts
@@ -2,117 +2,110 @@ def show_comment_box_in_related?
2
2
  false
3
3
  end
4
4
 
5
+ def help_rule_card
6
+ setting = new_card? ? [:add_help, { fallback: :help }] : :help
7
+ help_card = rule_card(*setting)
8
+ help_card if help_card && help_card.ok?(:read)
9
+ end
10
+
5
11
  format :html do
6
12
  def show view, args
7
- if show_layout?
8
- args[:view] = view if view
9
- @main_opts = args
10
- render :layout
11
- else
12
- view ||= args[:home_view] || :open
13
- @nest_opts = (args[:items] || {}).clone
14
- render view, args
15
- end
13
+ send "show_#{show_layout? ? :with : :without}_layout", view, args
16
14
  end
17
15
 
18
16
  def show_layout?
19
17
  !Env.ajax? || params[:layout]
20
18
  end
21
19
 
22
- view :layout, perms: :none do |args|
23
- output [
24
- process_content(get_layout_content, content_opts:
25
- { chunk_list: :references }),
26
- _render_modal_slot(args)
27
- ]
20
+ def show_with_layout view, args
21
+ args[:view] = view if view
22
+ @main = false
23
+ @main_opts = args
24
+ render :layout, title: params[:layout]
25
+ # FIXME: using title because it's a standard view option. hack!
28
26
  end
29
27
 
30
- view :content do |args|
31
- wrap args.reverse_merge(slot_class: "card-content") do
32
- [
33
- _optional_render(:menu, args, :hide),
34
- _render_core(args)
35
- ]
36
- end
28
+ def show_without_layout view, args
29
+ @main = true if params[:is_main] || args[:main]
30
+ view ||= args[:home_view] || :open
31
+ render view, args
32
+ end
33
+
34
+ view :layout, perms: :none do
35
+ layout = process_content get_layout_content(voo.title),
36
+ content_opts: { chunk_list: :references }
37
+ output [layout, _render_modal_slot]
38
+ end
39
+
40
+ view :content do
41
+ class_up "card-slot", "card-content"
42
+ voo.hide :menu
43
+ wrap { [_optional_render_menu, _render_core] }
37
44
  end
38
45
 
39
- view :content_panel do |args|
40
- wrap args.reverse_merge(slot_class: "card-content panel panel-default") do
46
+ view :content_panel do
47
+ class_up "card-slot", "card-content panel panel-default"
48
+ voo.hide :menu
49
+ wrap do
41
50
  wrap_with :div, class: "panel-body" do
42
- [
43
- _optional_render(:menu, args, :hide),
44
- _render_core(args)
45
- ].join("\n")
51
+ [_optional_render_menu, _render_core]
46
52
  end
47
53
  end
48
54
  end
49
55
 
50
- view :titled, tags: :comment do |args|
51
- wrap args do
56
+ view :titled, tags: :comment do
57
+ @content_body = true
58
+ wrap do
52
59
  [
53
- _optional_render(:menu, args),
54
- _render_header(args),
55
- wrap_body(content: true) { _render_core args },
56
- optional_render(:comment_box, args)
60
+ _optional_render_menu,
61
+ _render_header,
62
+ wrap_body { _render_core },
63
+ optional_render_comment_box
57
64
  ]
58
65
  end
59
66
  end
60
67
 
61
- view :labeled do |args|
62
- wrap args do
68
+ view :labeled do
69
+ class_up "card-body", "closed-content"
70
+ @content_body = true
71
+ wrap do
63
72
  [
64
- _optional_render(:menu, args),
65
- "<label>#{_render_title args}</label>",
66
- wrap_body(body_class: "closed-content", content: true) do
67
- _render_closed_content args
73
+ _optional_render_menu,
74
+ wrap_with(:label, _render_title),
75
+ wrap_body do
76
+ _render_closed_content
68
77
  end
69
78
  ]
70
79
  end
71
80
  end
72
81
 
73
- view :title do |args|
74
- title = fancy_title args[:title], args[:title_class]
75
- title =
76
- _optional_render(:title_editable, args, :hide) ||
77
- _optional_render(:title_link, args.merge(title_ready: title), :hide) ||
78
- title
82
+ view :title do
83
+ title = fancy_title super()
84
+ if show_view? :title_link, :hide
85
+ title = _render_title_link title_ready: title
86
+ end
79
87
  add_name_context
80
88
  title
81
89
  end
82
90
 
83
91
  view :title_link do |args|
84
- title_text = args[:title_ready] || showname(args[:title])
92
+ title_text = args[:title_ready] || showname(voo.title)
85
93
  link_to_card card.cardname, title_text
86
94
  end
87
95
 
88
96
  view :type_info do
89
- link = link_to_card card.type_name, nil, class: "navbar-link"
90
- %(<span class="type-info pull-right">#{link}</span>).html_safe
91
- end
92
-
93
- view :title_editable do |args|
94
- links = card.cardname.parts.map { |name| link_to_card name }
95
- res = links.shift
96
- links.each_with_index do |link, index|
97
- name = card.cardname.parts[0..index + 1].join "+"
98
- res += link_to_card name, glyphicon("plus", "header-icon")
99
- res += link
97
+ return unless show_view?(:toolbar, :hide) && card.type_code != :basic
98
+ wrap_with :span, class: "type-info pull-right" do
99
+ link_to_card card.type_name, nil, class: "navbar-link"
100
100
  end
101
- res += " "
102
- res.concat link_to_view(
103
- :edit_name, glyphicon("edit", "header-icon"),
104
- class: "slotter", "data-toggle" => "tooltip", title: "edit name"
105
- )
106
- res.concat _optional_render(:type_link, args, :show)
107
101
  end
108
102
 
109
- view :open, tags: :comment do |args|
110
- args[:optional_toggle] ||= main? ? :hide : :show
111
- frame args.merge(content: true) do
112
- [
113
- _render_open_content(args),
114
- optional_render(:comment_box, args)
115
- ]
103
+ view :open, tags: :comment do
104
+ voo.show! :toolbar if toolbar_pinned?
105
+ voo.viz :toggle, (main? ? :hide : :show)
106
+ @content_body = true
107
+ frame do
108
+ [_render_open_content, optional_render_comment_box]
116
109
  end
117
110
  end
118
111
 
@@ -125,26 +118,22 @@ format :html do
125
118
  link_to_card card.type_card, nil, class: klasses
126
119
  end
127
120
 
128
- view :closed do |args|
129
- frame args.reverse_merge(
130
- content: true,
131
- body_class: "closed-content",
132
- toggle_mode: :close,
133
- optional_toggle: :show,
134
- optional_toolbar: :hide
135
- ) do
136
- _optional_render :closed_content, args
137
- end
121
+ view :closed do
122
+ voo.show :toggle
123
+ voo.hide! :toolbar
124
+ class_up "card-body", "closed-content"
125
+ @content_body = true
126
+ @toggle_mode = :close
127
+ frame { _optional_render :closed_content }
138
128
  end
139
129
 
140
- view :change do |args|
141
- args[:optional_title_link] = :show
142
- wrap args do
143
- [
144
- _optional_render(:title, args),
145
- _optional_render(:menu, args, :hide),
146
- _optional_render(:last_action, args)
147
- ]
130
+ view :change do
131
+ voo.show :title_link
132
+ voo.hide :menu
133
+ wrap do
134
+ [_optional_render_title,
135
+ _optional_render_menu,
136
+ _optional_render_last_action]
148
137
  end
149
138
  end
150
139
 
@@ -157,60 +146,51 @@ format :html do
157
146
  Card.fetch(set_name)
158
147
  end
159
148
 
149
+ # subheader = with_name_context(card.name) do
150
+ # subformat(rcard)._render_title(args)
151
+ # end
152
+
160
153
  view :related do |args|
161
- if args[:related_card]
162
- frame args.merge(optional_toolbar: :show) do
163
- nest(args[:related_card], args[:related_args])
164
- end
154
+ related_card, options = related_card_and_options args
155
+ return unless related_card
156
+ voo.show :toolbar, :menu, :help
157
+ frame do
158
+ voo.hide :header, :toggle
159
+ nest related_card, options
165
160
  end
166
161
  end
167
162
 
168
- def default_related_args args
169
- rparams = args[:related] || params[:related]
170
- return unless rparams
171
- rcard = rparams[:card] || begin
172
- rcardname = rparams[:name].to_name.to_absolute_name(card.cardname)
173
- Card.fetch rcardname, new: {}
174
- end
163
+ def related_card_and_options args
164
+ options = (args[:related] || params[:related]).symbolize_keys
165
+ return unless options
166
+ related_card = related_card_from_options options
167
+ options[:view] ||= :open
168
+ options[:show] ||= []
169
+ options[:show] << :comment_box if related_card.show_comment_box_in_related?
170
+ [related_card, options]
171
+ end
175
172
 
176
- subheader = with_name_context(card.name) do
177
- subformat(rcard)._render_title(args)
178
- end
179
- add_name_context card.name
180
- nest_args = (rparams[:slot] || {}).deep_symbolize_keys.reverse_merge(
181
- view: (rparams[:view] || :open),
182
- optional_header: :hide,
183
- optional_menu: :show,
184
- subheader: subheader,
185
- optional_toggle: :hide,
186
- optional_help: :show,
187
- parent: card,
188
- subframe: true,
189
- subslot: true
190
- )
191
- if rcard.show_comment_box_in_related?
192
- nest_args[:optional_comment_box] = :show
193
- end
194
- args[:related_args] = nest_args
195
- args[:related_card] = rcard
196
- end
197
-
198
- view :help, tags: :unknown_ok do |args|
199
- text = args[:help_text] || begin
200
- setting = card.new_card? ? [:add_help, { fallback: :help }] : :help
201
- help_card = card.rule_card(*setting)
202
- if help_card && help_card.ok?(:read)
203
- with_nest_mode :normal do
204
- raw_help_content = _render_raw args.merge(structure: help_card.name)
205
- process_content raw_help_content, content_opts:
206
- { chunk_list: :references }
207
- # render help card with current card's format
208
- # so current card's context is used in help card nests
209
- end
210
- end
173
+ def related_card_from_options options
174
+ related_card = options.delete :card
175
+ return related_card if related_card
176
+ related_name = options.delete(:name).to_name.to_absolute_name card.cardname
177
+ Card.fetch related_name, new: {}
178
+ end
179
+
180
+ view :help, tags: :unknown_ok do
181
+ help_text = voo.help || rule_based_help
182
+ return "" unless help_text.present?
183
+ wrap_with :div, help_text, class: classy("help-text")
184
+ end
185
+
186
+ def rule_based_help
187
+ return "" unless (rule_card = card.help_rule_card)
188
+ with_nest_mode :normal do
189
+ process_content _render_raw(structure: rule_card.name),
190
+ content_opts: { chunk_list: :references }
191
+ # render help card with current card's format
192
+ # so current card's context is used in help card nests
211
193
  end
212
- klass = [args[:help_class], "help-text"].compact * " "
213
- %(<div class="#{klass}">#{raw text}</div>) if text
214
194
  end
215
195
 
216
196
  view :last_action do
@@ -236,9 +216,13 @@ format :html do
236
216
 
237
217
  private
238
218
 
239
- def fancy_title title=nil, title_class=nil
240
- klasses = ["card-title", title_class].compact * " "
241
- title = showname(title).to_name.parts.join %(<span class="joint">+</span>)
242
- raw %(<span class="#{klasses}">#{title}</span>)
219
+ def fancy_title title=nil
220
+ wrap_with :span, class: classy("card-title") do
221
+ showname(title).to_name.parts.join fancy_joint
222
+ end
223
+ end
224
+
225
+ def fancy_joint
226
+ wrap_with :span, "+", classy("joint")
243
227
  end
244
228
  end
@@ -1,240 +1,177 @@
1
1
  format :html do
2
2
  ###---( TOP_LEVEL (used by menu) NEW / EDIT VIEWS )
3
-
4
- view :new, perms: :create, tags: :unknown_ok do |args|
5
- frame_and_form :create, args, "main-success" => "REDIRECT" do
3
+ view :edit, perms: :update, tags: :unknown_ok, cache: :never do
4
+ voo.show :toolbar, :help
5
+ frame_and_form :update do
6
6
  [
7
- _optional_render(:name_formgroup, args),
8
- _optional_render(:type_formgroup, args),
9
- _optional_render(:content_formgroup, args),
10
- _optional_render(:button_formgroup, args)
7
+ edit_view_hidden,
8
+ _optional_render_content_formgroup,
9
+ _optional_render_edit_buttons
11
10
  ]
12
11
  end
13
12
  end
14
13
 
15
- def default_new_args args
16
- hidden = args[:hidden] ||= {}
17
- hidden[:success] ||= card.rule(:thanks) || "_self"
18
- hidden[:card] ||= {}
19
-
20
- args[:optional_help] ||= :show
21
-
22
- default_new_args_for_name_field_or_title args
23
- default_new_args_for_type_field args
24
- default_new_args_buttons args
14
+ def edit_view_hidden
15
+ # for override
25
16
  end
26
17
 
27
- def default_new_args_for_name_field_or_title args
28
- hidden = args[:hidden]
29
- if !params[:name_prompt] && !card.cardname.blank?
30
- # name is ready and will show up in title
31
- hidden[:card][:name] ||= card.name
32
- else
33
- args[:title] ||= generic_new_card_title
34
- # FIXME: - overrides nest args
35
- unless card.rule_card :autoname
36
- # prompt for name
37
- hidden[:name_prompt] = true unless hidden.key? :name_prompt
38
- args[:optional_name_formgroup] ||= :show
39
- end
18
+ view :edit_buttons do
19
+ button_formgroup do
20
+ [standard_submit_button, standard_cancel_button]
40
21
  end
41
- args[:optional_name_formgroup] ||= :hide
42
22
  end
43
23
 
44
- def generic_new_card_title
45
- if card.type_id == Card.default_type_id
46
- "New"
47
- else
48
- "New #{card.type_name}"
49
- end
24
+ def standard_submit_button
25
+ submit_button class: "submit-button"
50
26
  end
51
27
 
52
- def default_new_args_for_type_field args
53
- if show_type_formgroup?(args)
54
- args[:optional_type_formgroup] = :show
55
- else
56
- args[:hidden][:card][:type_id] ||= card.type_id
57
- args[:optional_type_formgroup] = :hide
58
- end
28
+ def standard_cancel_button href=nil
29
+ href ||= path
30
+ cancel_button class: "cancel-button", href: href
59
31
  end
60
32
 
61
- def show_type_formgroup? args
62
- !params[:type] && !args[:type] &&
63
- (main? || card.simple? || card.is_template?) &&
64
- Card.new(type_id: card.type_id).ok?(:create)
33
+ view :edit_name, perms: :update do
34
+ voo.show :toolbar
35
+ frame_and_form({ action: :update, id: card.id },
36
+ "main-success" => "REDIRECT") do
37
+ [hidden_edit_name_fields,
38
+ _optional_render_name_formgroup,
39
+ rename_confirmation_alert,
40
+ edit_name_buttons]
41
+ end
65
42
  end
66
43
 
67
- def default_new_args_buttons args
68
- cancel_path = !main? && path(view: :missing)
69
- args[:buttons] ||= [
70
- submit_button(class: "create-submit-button"),
71
- cancel_button(class: "create-cancel-button", href: cancel_path)
72
- ].join "\n"
44
+ def hidden_edit_name_fields
45
+ hidden_tags success: "_self",
46
+ old_name: card.name,
47
+ card: { update_referers: false }
73
48
  end
74
49
 
75
- view :edit, perms: :update, tags: :unknown_ok do |args|
76
- frame_and_form :update, args.reverse_merge(optional_toolbar: :show) do
77
- [
78
- _optional_render(:content_formgroup, args),
79
- _optional_render(:button_formgroup, args)
80
- ]
50
+ def edit_name_buttons
51
+ button_formgroup do
52
+ [rename_and_update_button, rename_button, standard_cancel_button]
81
53
  end
82
54
  end
83
55
 
84
- def default_edit_args args
85
- args[:optional_help] ||= :show
86
- args[:optional_toolbar] ||= :show
87
-
88
- args[:buttons] ||= %(
89
- #{submit_button class: 'submit-button'}
90
- #{cancel_button href: (args[:cancel_path] || path),
91
- class: 'cancel-button',
92
- 'data-slot-selector' => args[:cancel_slot_selector]}
93
- )
56
+ def rename_and_update_button
57
+ submit_button text: "Rename and Update", disable_with: "Renaming",
58
+ class: "renamer-updater"
94
59
  end
95
60
 
96
- view :edit_name, perms: :update do |args|
97
- frame_and_form(
98
- { action: :update, id: card.id }, args, "main-success" => "REDIRECT"
99
- ) do
100
- [
101
- _render_name_formgroup(args),
102
- _optional_render(:confirm_rename, args),
103
- _optional_render(:button_formgroup, args)
104
- ]
105
- end
61
+ def rename_button
62
+ button_tag "Rename", data: { disable_with: "Renaming" }, class: "renamer"
106
63
  end
107
64
 
108
- view :confirm_rename do |args|
109
- referers = args[:referers]
110
- descendants = card.descendants
65
+ def rename_confirmation_alert
111
66
  msg = "<h5>Are you sure you want to rename <em>#{card.name}</em>?</h5>"
112
- if referers.any? || descendants.any?
113
- msg << rename_info(referers, descendants)
114
- end
67
+ msg << rename_effects_and_options
115
68
  alert("warning") { msg }
116
69
  end
117
70
 
118
- def rename_info referers, descendants
119
- effects = []
120
- options = ""
121
- if descendants.any? # FIXME: count, don't instantiate
122
- effects << "automatically alter #{descendants.size} related name(s)."
123
- end
124
- if referers.any? # FIXME: count, don't instantiate
125
- count = referers.size
126
- refs = count == 1 ? "reference" : "references"
127
- effects << "affect at least #{count} #{refs} to \"#{card.name}\""
128
- options = "You may choose to <em>update or ignore</em> the referers."
129
- end
130
- effects = effects.map { |effect| "<li>#{effect}</li>" }.join("")
131
- "<h6>This change will...</h6><ul>#{effects}</ul><p>#{options}</p>"
132
- end
133
-
134
- def default_edit_name_args args
135
- referers = args[:referers] = card.family_referers
136
- args[:hidden] ||= {}
137
- args[:hidden].reverse_merge!(
138
- success: "_self",
139
- old_name: card.name,
140
- referers: referers.size, # FIXME: count, don't instantiate
141
- card: { update_referers: false }
142
- )
143
- args[:optional_toolbar] ||= :show
144
- args[:buttons] = default_rename_buttons
71
+ def rename_effects_and_options
72
+ descendant_effect = rename_descendant_effect
73
+ referer_effect, referer_option = rename_referer_effect_and_option
74
+ effects = [descendant_effect, referer_effect].compact
75
+ return "" if effects.empty?
76
+ format_rename_effects_and_options effects, referer_option
145
77
  end
146
78
 
147
- def default_rename_buttons
148
- [submit_button(text: "Rename and Update",
149
- disable_with: "Renaming",
150
- class: "renamer-updater"),
151
- button_tag("Rename", data: { disable_with: "Renaming" }, class: "renamer"),
152
- cancel_button(href: path)].join "\n"
79
+ def format_rename_effects_and_options effects, referer_option
80
+ effects = effects.map { |effect| "<li>#{effect}</li>" }.join
81
+ info = %(<h6>This change will...</h6>)
82
+ info += %(<ul>#{effects}</ul>)
83
+ info += %(<p>#{referer_option}</p>) if referer_option
84
+ info
153
85
  end
154
86
 
155
- view :edit_type, perms: :update do |args|
156
- frame_and_form :update, args do
157
- # 'main-success'=>'REDIRECT: _self', # adding this back in would make
158
- # main cards redirect on cardtype changes
87
+ def rename_descendant_effect
88
+ descendants = card.descendants
89
+ return unless descendants.any? # FIXME: count, don't instantiate
90
+ "automatically alter #{descendants.size} related name(s)."
91
+ end
92
+
93
+ def rename_referer_effect_and_option
94
+ referers = card.family_referers
95
+ return unless referers.any? # FIXME: count, don't instantiate
96
+ count = referers.size
97
+ refs = count == 1 ? "reference" : "references"
98
+ effect = "affect at least #{count} #{refs} to \"#{card.name}\""
99
+ effect += hidden_field_tag(:referers, count)
100
+ option = "You may choose to <em>update or ignore</em> the referers."
101
+ [effect, option]
102
+ end
103
+
104
+ view :edit_type, cache: :never, perms: :update do
105
+ voo.show :toolbar
106
+ frame_and_form :update do
159
107
  [
160
- _render_type_formgroup(args),
161
- optional_render(:button_formgroup, args)
108
+ hidden_edit_type_fields,
109
+ _render_type_formgroup,
110
+ edit_type_buttons
162
111
  ]
163
112
  end
164
113
  end
165
114
 
166
- def default_edit_type_args args
167
- args[:variety] = :edit # YUCK!
168
- args[:optional_toolbar] ||= :show
169
- args[:hidden] ||= { success: { view: :edit } }
170
- args[:buttons] = [
171
- submit_button, cancel_button(href: path(view: :edit))
172
- ].join "\n"
173
- end
174
-
175
- view :edit_rules, tags: :unknown_ok do |args|
176
- view = args[:rule_view] || :common_rules
177
- slot_args =
178
- {
179
- rule_view: view,
180
- optional_set_navbar: :show,
181
- optional_set_label: :hide,
182
- optional_rule_navbar: :hide
183
- }
184
- _render_related args.merge(
185
- related: { card: current_set_card, view: :open, slot: slot_args }
186
- )
115
+ def hidden_edit_type_fields
116
+ hidden_field_tag "success[view]", "edit"
187
117
  end
188
118
 
189
- def default_edit_rules_args args
190
- args[:optional_toolbar] ||= :show
119
+ def edit_type_buttons
120
+ cancel_path = path view: :edit
121
+ button_formgroup do
122
+ [standard_submit_button, standard_cancel_button(cancel_path)]
123
+ end
191
124
  end
192
125
 
193
- # for backwards compatibility
194
- view :options, view: :edit_rules, mod: All::RichHtml::Editing::HtmlFormat
126
+ view :edit_rules, cache: :never, tags: :unknown_ok do |args|
127
+ voo.show :set_navbar, :toolbar
128
+ voo.hide :set_label, :rule_navbar
195
129
 
196
- view :edit_structure do |args|
197
- slot_args =
198
- {
199
- cancel_slot_selector: ".card-slot.related-view",
200
- cancel_path: card.format.path(view: :edit),
201
- optional_edit_toolbar: :hide,
202
- hidden: { success: { view: :open, "slot[subframe]" => true } }
130
+ _render_related args.merge(
131
+ related: {
132
+ card: current_set_card,
133
+ view: :open,
134
+ slot: { rule_view: (args[:rule_view] || :common_rules) }
203
135
  }
204
- render_related args.merge(
205
- related: { card: card.structure, view: :edit, slot: slot_args }
206
136
  )
207
137
  end
208
138
 
209
- def default_edit_structure_args args
210
- args[:optional_toolbar] ||= :show
139
+ view :edit_structure, cache: :never do |args|
140
+ voo.show :toolbar
141
+ render_related args.merge(
142
+ related: {
143
+ card: card.structure,
144
+ view: :edit
145
+ }
146
+ # FIXME: this stuff:
147
+ # slot: {
148
+ # cancel_slot_selector: ".card-slot.related-view",
149
+ # cancel_path: card.format.path(view: :edit), hide: :edit_toolbar,
150
+ # hidden: { success: { view: :open, "slot[subframe]" => true } }
151
+ # }
152
+ # }
153
+ )
211
154
  end
212
155
 
213
- view :edit_nests do |args|
214
- frame args do
156
+ view :edit_nests, cache: :never do
157
+ voo.show :toolbar
158
+ frame do
215
159
  with_nest_mode :edit do
216
- process_nested_fields optional_toolbar: :hide
160
+ process_nested_fields hide: :toolbar
217
161
  end
218
162
  end
219
163
  end
220
- def default_edit_nests_args args
221
- args[:optional_toolbar] ||= :show
222
- end
223
164
 
224
- view :edit_nest_rules do |args|
165
+ view :edit_nest_rules, cache: :never do |args|
166
+ voo.show :toolbar
225
167
  view = args[:rule_view] || :field_related_rules
226
- frame args do
168
+ frame do
227
169
  # with_nest_mode :edit do
228
- nested_fields(args).map do |chunk|
229
- nest Card.fetch("#{chunk.referee_name}+*self"),
230
- view: :titled, title: chunk.referee_name, rule_view: view,
231
- optional_set_label: :hide,
232
- optional_rule_navbar: :show
170
+ nested_fields.map do |name, _options|
171
+ nest Card.fetch(name.to_name.trait(:self)),
172
+ view: :titled, title: name, rule_view: view,
173
+ hide: :set_label, show: :rule_navbar
233
174
  end
234
175
  end
235
176
  end
236
-
237
- def default_edit_nest_rules_args args
238
- args[:optional_toolbar] ||= :show
239
- end
240
177
  end