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
@@ -30,6 +30,6 @@ format :html do
30
30
  include Pointer::HtmlFormat
31
31
 
32
32
  def default_core_args args
33
- args[:item] = :name
33
+ args[:items] = { view: :name }
34
34
  end
35
35
  end
@@ -1,173 +1,194 @@
1
1
 
2
+ include_set Type::SearchType
3
+
2
4
  format :html do
3
- view :core do |args|
4
- _render args[:rule_view], args
5
- end
5
+ COMMON_RULE_SETTINGS =
6
+ [:create, :read, :update, :delete, :structure, :default, :style].freeze
6
7
 
7
- def default_core_args args
8
- args[:rule_view] ||= :common_rules
9
- args[:optional_set_label] ||= :show
10
- args[:optional_set_navbar] ||= :hide
11
- args[:optional_rule_navbar] ||= :show
8
+ view :core do |args|
9
+ voo.show :set_label, :rule_navbar
10
+ voo.hide :set_navbar
11
+ rule_view = args[:rule_view] || :common_rules
12
+ _render rule_view
12
13
  end
13
14
 
14
- def with_label_and_navbars args
15
+ def with_label_and_navbars selected_view
16
+ @selected_rule_navbar_view = selected_view
15
17
  wrap do
16
18
  [
17
- _optional_render(:set_label, args, :show),
18
- _optional_render(:rule_navbar, args, :hide),
19
- _optional_render(:set_navbar, args, :hide),
19
+ _optional_render_set_label,
20
+ _optional_render_rule_navbar,
21
+ _optional_render_set_navbar,
20
22
  yield
21
23
  ]
22
24
  end
23
25
  end
24
26
 
25
- view :all_rules do |args|
26
- with_label_and_navbars args.merge(selected_view: :all_rules) do
27
- rules_table card.visible_setting_codenames.sort, args
27
+ view :all_rules do
28
+ with_label_and_navbars :all_rules do
29
+ rules_table card.visible_setting_codenames.sort
28
30
  end
29
31
  end
30
32
 
31
- view :grouped_rules do |args|
32
- with_label_and_navbars args.merge(selected_view: :grouped_rules) do
33
- content_tag(:div, class: "panel-group",
34
- id: "accordion",
35
- role: "tablist",
36
- "aria-multiselectable" => "true") do
33
+ view :grouped_rules do
34
+ with_label_and_navbars :grouped_rules do
35
+ wrap_with :div, class: "panel-group", id: "accordion",
36
+ role: "tablist", "aria-multiselectable" => "true" do
37
37
  Card::Setting.groups.keys.map do |group_key|
38
- _optional_render(group_key, args, :show)
39
- end * "\n"
38
+ _optional_render group_key
39
+ end
40
40
  end
41
41
  end
42
42
  end
43
43
 
44
- view :recent_rules do |args|
45
- with_label_and_navbars args.merge(selected_view: :recent_rules) do
44
+ view :recent_rules do
45
+ with_label_and_navbars :recent_rules do
46
46
  recent_settings = Card[:recent_settings].item_cards.map(&:codename)
47
47
  settings = recent_settings.map(&:to_sym) & card.visible_setting_codenames
48
- rules_table settings, args
48
+ rules_table settings
49
49
  end
50
50
  end
51
51
 
52
- view :common_rules do |args|
53
- with_label_and_navbars args.merge(selected_view: :common_rules) do
54
- settings =
55
- card.visible_setting_codenames &
56
- [:create, :read, :update, :delete, :structure, :default, :style]
57
- rules_table settings, args
52
+ view :common_rules do
53
+ with_label_and_navbars :common_rules do
54
+ settings = card.visible_setting_codenames & COMMON_RULE_SETTINGS
55
+ # "&" = set intersection
56
+ rules_table settings
58
57
  end
59
58
  end
60
59
 
61
- view :field_related_rules do |args|
62
- with_label_and_navbars args.merge(selected_view: :field_related_rules) do
60
+ view :field_related_rules do
61
+ with_label_and_navbars :field_related_rules do
63
62
  field_settings = [:default, :help, :structure]
64
63
  if card.type_id == PointerID
64
+ # FIXME: should be done with override in pointer set module
65
65
  field_settings += [:input, :options, :options_label]
66
66
  end
67
- rules_table (card.visible_setting_codenames & field_settings), args
67
+ settings = card.visible_setting_codenames & field_settings
68
+ rules_table settings
68
69
  end
69
70
  end
70
71
 
71
- view :set_label do |_args|
72
- content_tag :h3, card.label, class: "set-label"
72
+ view :set_label do
73
+ wrap_with :h3, card.label, class: "set-label"
73
74
  end
74
75
 
75
76
  Card::Setting.groups.keys.each do |group_key|
76
- view group_key.to_sym do |args|
77
+ view group_key.to_sym do
77
78
  settings = card.visible_settings group_key
78
- if settings.present?
79
- group_name = Card::Setting.group_names[group_key] || group.to_s
80
- heading_id = "heading-#{group_key}"
81
- collapse_id = "collapse-#{card.cardname.safe_key}-#{group_key}"
82
- output [
83
- (content_tag :div, class: "panel panel-default" do
84
- content_tag :div, class: "panel-heading", role: "tab",
85
- id: heading_id do
86
- content_tag :h4, class: "panel-title" do
87
- content_tag :a, group_name,
88
- "data-toggle" => "collapse",
89
- "data-parent" => "#accordion",
90
- href: "##{collapse_id}",
91
- "aria-expanded" => "false",
92
- "aria-controls" => collapse_id
93
- end
94
- end
95
- end),
96
- (content_tag :div, id: collapse_id,
97
- class: "panel-collapse collapse",
98
- role: "tabpanel",
99
- "aria-labelledby" => heading_id do
100
- rules_table settings.map(&:codename), args
101
- end)
102
- ]
79
+ return unless settings.present?
80
+ group_panels group_key
81
+ end
82
+ end
83
+
84
+ def group_panels group_key
85
+ output [group_tab(group_key), group_tabpanel(group_key)]
86
+ end
87
+
88
+ def group_tab group_key
89
+ heading_id = "heading-#{group_key}"
90
+ wrap_with :div, class: "panel panel-default" do
91
+ wrap_with :div, class: "panel-heading", role: "tab", id: heading_id do
92
+ wrap_with :h4, class: "panel-title" do
93
+ group_collapse_link group_key
94
+ end
103
95
  end
104
96
  end
105
97
  end
106
98
 
107
- def rules_table settings, args={}
99
+ def group_collapse_link group_key
100
+ collapse_id = group_collapse_id group_key
101
+ group_name = Card::Setting.group_names[group_key] || group_key.to_s
102
+ link_to group_name,
103
+ href: "##{collapse_id}",
104
+ "data-toggle" => "collapse", "aria-expanded" => "false",
105
+ "data-parent" => "#accordion", "aria-controls" => collapse_id
106
+ end
107
+
108
+ def group_collapse_id group_key
109
+ "collapse-#{card.cardname.safe_key}-#{group_key}"
110
+ end
111
+
112
+ def group_tabpanel group_key
113
+ collapse_id = group_collapse_id group_key
114
+ heading_id = "heading-#{group_key}"
115
+ settings = card.visible_settings group_key
116
+ wrap_with :div, id: collapse_id, class: "panel-collapse collapse",
117
+ role: "tabpanel", "aria-labelledby" => heading_id do
118
+ rules_table settings.map(&:codename)
119
+ end
120
+ end
121
+
122
+ def rules_table settings
108
123
  wrap_with :table, class: "set-rules table" do
109
- [
110
- (content_tag(:tr, class: "rule-group") do
111
- wrap_each_with :th, %w(Trait Content Set), class: "rule-heading"
112
- end),
113
- (settings.map do |setting|
114
- if show_view? setting, args
115
- rule_card = card.fetch(trait: setting, new: {})
116
- nest(rule_card, view: :closed_rule).html_safe
117
- end
118
- end * "\n")
119
- ]
124
+ [rules_table_headings, rules_table_body(settings)]
125
+ end
126
+ end
127
+
128
+ def rules_table_headings
129
+ wrap_with :tr, class: "rule-group" do
130
+ wrap_each_with :th, %w(Trait Content Set), class: "rule-heading"
120
131
  end
121
132
  end
122
133
 
123
- view :editor do |_args|
134
+ def rules_table_body settings
135
+ settings.map do |setting|
136
+ next unless show_view? setting
137
+ rule_card = card.fetch trait: setting, new: {}
138
+ nest(rule_card, view: :closed_rule).html_safe
139
+ end * "\n"
140
+ end
141
+
142
+ view :editor do
124
143
  "Cannot currently edit Sets" # ENGLISH
125
144
  end
126
145
 
127
- view :template_link do |args|
128
- args.delete :style # why? comment needed
129
- wrap args do
130
- link = link_to_view :template_editor, args[:inc_syntax], class: "slotter"
131
- "{{#{link}}"
146
+ view :template_link, cache: :never do
147
+ wrap do
148
+ link = link_to_view :template_editor, parent.voo.nest_syntax,
149
+ class: "slotter"
150
+ "{{#{link}}}"
132
151
  end
133
152
  end
134
153
 
135
- view :template_closer do |_args|
154
+ view :template_closer do
136
155
  link_classes = "slotter glyphicon glyphicon-remove template-editor-close"
137
156
  link_to_view :template_link, "", class: link_classes
138
157
  end
139
158
 
140
- view :template_editor do |args|
141
- wrap args do
142
- %(
143
- <div class="template-editor-left">{{</div>
144
- <div class="template-editor-main">
145
- #{render_template_editor_frame args}
146
- </div>
147
- <div class="template-editor-right">}}</div>
148
- )
159
+ view :template_editor do
160
+ wrap do
161
+ [
162
+ wrap_with(:div, "{{", class: "template-editor-left"),
163
+ wrap_with(:div, class: "template-editor-main") do
164
+ render_template_editor_frame
165
+ end,
166
+ wrap_with(:div, "}}", class: "template-editor-right")
167
+ ]
149
168
  end
150
169
  end
151
170
 
152
- view :template_editor_frame do |args|
153
- frame no_slot: true, title: card.label, menu_hack: :template_closer do
154
- _render_core args.merge(hide: "set_label")
171
+ view :template_editor_frame do
172
+ voo.title = card.label
173
+ voo.hide :set_label
174
+ template_frame do
175
+ _render_core
155
176
  end
156
177
  end
157
178
 
158
- view :closed_content do |_args|
179
+ view :closed_content do
159
180
  ""
160
181
  end
161
182
 
162
183
  view :set_navbar do |args|
163
- id = "rule-navbar-#{card.cardname.safe_key}-#{args[:home_view]}"
184
+ id = "rule-navbar-#{card.cardname.safe_key}-#{voo.home_view}"
164
185
  related_sets = card.related_sets(true)
165
186
  return "" if related_sets.size <= 1
166
187
  navbar id, toggle: 'Rules<span class="caret"></span>', toggle_align: :left,
167
188
  class: "slotter toolbar", navbar_type: "inverse",
168
189
  collapsed_content: close_link(class: "pull-right visible-xs") do
169
190
  [
170
- content_tag(:span, "Set:", class: "navbar-text hidden-xs"),
191
+ wrap_with(:span, "Set:", class: "navbar-text hidden-xs"),
171
192
  (wrap_with :ul, class: "nav navbar-nav nav-pills" do
172
193
  related_sets.map do |name, label|
173
194
  slot_opts = { subheader: showname(name),
@@ -188,37 +209,44 @@ format :html do
188
209
  "<li role='presentation' #{"class='active'" if active}>#{content}</li>"
189
210
  end
190
211
 
191
- view :rule_navbar do |args|
192
- id = "rule-navbar-#{card.cardname.safe_key}-#{args[:home_view]}"
193
- args[:path_opts] = { slot: { show: :rule_navbar } }
194
- navbar id, toggle: 'Rules<span class="caret"></span>', toggle_align: :left,
195
- class: "slotter toolbar", navbar_type: "inverse",
196
- collapsed_content: close_link(class: "pull-right visible-xs") do
197
- [
198
- content_tag(:span, "Rules:", class: "navbar-text hidden-xs"),
199
- (wrap_with :ul, class: "nav navbar-nav nav-pills" do
200
- [
201
- (view_link_pill("field", :field_related_rules, args) if card.junction?),
202
- view_link_pill("common", :common_rules, args),
203
- view_link_pill("by group", :grouped_rules, args),
204
- view_link_pill("by name", :all_rules, args),
205
- (view_link_pill("recent", :recent_rules, args) if recently_edited_settings?)
206
- ]
207
- end)
208
- ]
212
+ view :rule_navbar do
213
+ navbar "rule-navbar-#{card.cardname.safe_key}-#{voo.home_view}",
214
+ toggle: 'Rules<span class="caret"></span>', toggle_align: :left,
215
+ class: "slotter toolbar", navbar_type: "inverse",
216
+ collapsed_content: close_link(class: "pull-right visible-xs") do
217
+ [rule_navbar_heading, rule_navbar_content]
209
218
  end
210
219
  end
211
220
 
212
- def view_link_pill name, view, args
213
- selected_view = args[:selected_view] || @slot_view || args[:home_view]
221
+ def rule_navbar_heading
222
+ wrap_with :span, "Rules:", class: "navbar-text hidden-xs"
223
+ end
224
+
225
+ def rule_navbar_pills
226
+ pills = [["common", :common_rules],
227
+ ["by group", :grouped_rules],
228
+ ["by name", :all_rules]]
229
+ pills.unshift ["field", :field_related_rules] if card.junction?
230
+ pills.push ["recent", :recent_rules] if recently_edited_settings?
231
+ pills
232
+ end
233
+
234
+ def rule_navbar_content
235
+ wrap_with :ul, class: "nav navbar-nav nav-pills" do
236
+ rule_navbar_pills.map do |label, symbol|
237
+ view_link_pill label, symbol
238
+ end
239
+ end
240
+ end
241
+
242
+ def view_link_pill name, view
243
+ selected_view = @selected_rule_navbar_view || @slot_view || voo.home_view
214
244
  link = link_to_view view, name, class: "slotter", role: "pill",
215
- path: args[:path_opts]
245
+ path: { slot: { show: :rule_navbar } }
216
246
  li_pill link, selected_view == view
217
247
  end
218
248
  end
219
249
 
220
- include Card::Set::Type::SearchType
221
-
222
250
  def followed_by? user_id=nil
223
251
  all_members_followed_by? user_id
224
252
  end
@@ -256,6 +284,13 @@ def label
256
284
  end
257
285
  end
258
286
 
287
+ def uncapitalized_label
288
+ label = label.to_s
289
+ return label unless label[0]
290
+ label[0] = label[0].downcase
291
+ label
292
+ end
293
+
259
294
  def follow_label
260
295
  if (klass = subclass_for_set)
261
296
  klass.follow_label cardname.left
@@ -276,17 +311,6 @@ def follow_rule_name user=nil
276
311
  end
277
312
  end
278
313
 
279
- # def to_following_item_name args
280
- # left_part = follow_rule_name( args[:user] )
281
- # option = args[:option] || if (rule_card = Card.fetch(left_part))
282
- # rule_card.content
283
- # else
284
- # Card[:nothing].name
285
- # end
286
- #
287
- # "#{left_part}+#{option}"
288
- # end
289
-
290
314
  def all_user_ids_with_rule_for setting_code
291
315
  Card.all_user_ids_with_rule_for self, setting_code
292
316
  end
@@ -7,6 +7,6 @@ view :core do |_args|
7
7
  end
8
8
  end
9
9
 
10
- view :editor do |_args|
10
+ view :editor do
11
11
  check_box :content
12
12
  end
@@ -1,11 +1,11 @@
1
1
  format do
2
2
  include Phrase::Format
3
3
 
4
- view :core do |args|
5
- link_to_resource _render_raw(args), render_title(args)
4
+ view :core do
5
+ link_to_resource _render_raw, render_title
6
6
  end
7
7
 
8
- view :url_link do |args|
9
- link_to_resource _render_raw(args)
8
+ view :url_link do
9
+ link_to_resource _render_raw
10
10
  end
11
11
  end
@@ -1,9 +1,9 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- describe Card::Content::Chunk::Include, "Inclusion" do
3
+ describe Card::Content::Chunk::Nest, "Inclusion" do
4
4
  context "syntax parsing" do
5
5
  before do
6
- @class = Card::Content::Chunk::Include
6
+ @class = Card::Content::Chunk::Nest
7
7
  end
8
8
 
9
9
  let :instance do
@@ -18,25 +18,28 @@ describe Card::Content::Chunk::Include, "Inclusion" do
18
18
  it "handles visible comments" do
19
19
  expect(render_content("{{# now you see me}}"))
20
20
  .to eq("<!-- # now you see me -->")
21
+ end
22
+
23
+ it "handles weird characters in nest comments" do
21
24
  expect(render_content("{{# -->}}")).to eq("<!-- # --&gt; -->")
22
25
  end
23
26
 
24
27
  it "handles empty nests" do
25
28
  @chunk = "{{ }}"
26
29
  expect(name).to eq("")
27
- expect(options[:inc_syntax]).to eq(" ")
30
+ expect(options[:nest_syntax]).to eq(" ")
28
31
  end
29
32
 
30
33
  it "handles empty nests with pipe" do
31
34
  @chunk = "{{|}}"
32
35
  expect(name).to eq("")
33
- expect(options[:inc_syntax]).to eq("|")
36
+ expect(options[:nest_syntax]).to eq("|")
34
37
  end
35
38
 
36
39
  it "handles no pipes" do
37
40
  @chunk = "{{toy}}"
38
41
  expect(name).to eq("toy")
39
- expect(options[:inc_name]).to eq("toy")
42
+ expect(options[:nest_name]).to eq("toy")
40
43
  expect(options.key?(:view)).to eq(false)
41
44
  end
42
45
 
@@ -58,7 +61,7 @@ describe Card::Content::Chunk::Include, "Inclusion" do
58
61
 
59
62
  it "handles single pipe" do
60
63
  @chunk = "{{toy|view:link;hide:me}}"
61
- expect(options[:inc_name]).to eq("toy")
64
+ expect(options[:nest_name]).to eq("toy")
62
65
  expect(options[:view]).to eq("link")
63
66
  expect(options[:hide]).to eq("me")
64
67
  expect(options.key?(:items)).to eq(false)
@@ -66,7 +69,7 @@ describe Card::Content::Chunk::Include, "Inclusion" do
66
69
 
67
70
  it "handles multiple pipes" do
68
71
  @chunk = "{{box|open|closed}}"
69
- expect(options[:inc_name]).to eq("box")
72
+ expect(options[:nest_name]).to eq("box")
70
73
  expect(options[:view]).to eq("open")
71
74
  expect(options[:items][:view]).to eq("closed")
72
75
  expect(options[:items].key?(:items)).to eq(false)
@@ -74,14 +77,14 @@ describe Card::Content::Chunk::Include, "Inclusion" do
74
77
 
75
78
  it "handles multiple pipes with blank lists" do
76
79
  @chunk = "{{box||closed}}"
77
- expect(options[:inc_name]).to eq("box")
80
+ expect(options[:nest_name]).to eq("box")
78
81
  expect(options[:view]).to eq(nil)
79
82
  expect(options[:items][:view]).to eq("closed")
80
83
  end
81
84
 
82
85
  it "treats :item as view of next level" do
83
86
  @chunk = "{{toy|link;item:name}}"
84
- expect(options[:inc_name]).to eq("toy")
87
+ expect(options[:nest_name]).to eq("toy")
85
88
  expect(options[:view]).to eq("link")
86
89
  expect(options[:items][:view]).to eq("name")
87
90
  end
@@ -165,7 +168,7 @@ describe Card::Content::Chunk::Include, "Inclusion" do
165
168
  it "handles structured cards" do
166
169
  create!("age")
167
170
  Card["*template"]
168
- specialtype = Card.create type_code: "Cardtype", name: "SpecialType"
171
+ specialtype = Card.create type_code: :cardtype, name: "SpecialType"
169
172
  specialtype_template = specialtype.fetch(trait: :type, new: {})
170
173
  .fetch(trait: :structure, new: {})
171
174
  specialtype_template.content = "{{#{Card::Name.joint}age}}"
@@ -178,26 +181,5 @@ describe Card::Content::Chunk::Include, "Inclusion" do
178
181
  expect(wooga_age.format.render_core).to eq("39")
179
182
  expect(wooga_age.includers.map(&:name)).to eq(["Wooga"])
180
183
  end
181
-
182
- it "handles shading" do
183
- create! "Alpha", "Pooey"
184
- create! "Beta", "{{Alpha|shade:off}}"
185
- r = create!("Bee", "{{Alpha|shade:off}}").format.render_core
186
- assert_view_select r, 'div[style~="shade:off;"]' do
187
- assert_select "div[class~=card-content]", "Pooey"
188
- end
189
- r = create!("Cee", "{{Alpha| shade: off }}").format.render_core
190
- assert_view_select r, 'div[style~="shade:off;"]' do
191
- assert_select "div[class~=card-content]", "Pooey"
192
- end
193
- r = create!("Dee", "{{Alpha| shade:off }}").format.render_core
194
- assert_view_select r, 'div[style~="shade:off;"]' do
195
- assert_select 'div[class~="card-content"]', "Pooey"
196
- end
197
- r = create!("Eee", "{{Alpha| shade:on }}").format.render_core
198
- assert_view_select r, 'div[style~="shade:on;"]' do
199
- assert_select 'div[class~="card-content"]', "Pooey"
200
- end
201
- end
202
184
  end
203
185
  end