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
@@ -0,0 +1,83 @@
1
+ class Bootstrap
2
+ class Component
3
+ # generate bootstrap column layout
4
+ # @example
5
+ # layout container: true, fluid: true, class: "hidden" do
6
+ # row 6, 6, class: "unicorn" do
7
+ # column "horn",
8
+ # column "rainbow", class: "colorful"
9
+ # end
10
+ # end
11
+ # @example
12
+ # layout do
13
+ # row 3, 3, 4, 2, class: "unicorn" do
14
+ # [ "horn", "body", "tail", "rainbow"]
15
+ # end
16
+ # add_html "<span> some extra html</span>"
17
+ # row 6, 6, ["unicorn", "rainbow"], class: "horn"
18
+ # end
19
+ class Layout < Component
20
+ def render_content
21
+ content = instance_exec *@args, &@build_block
22
+ add_content content
23
+ opts = @args.first
24
+ return unless opts && opts.delete(:container)
25
+ content = @content.pop
26
+ @content = ["".html_safe]
27
+ container content, opts
28
+ end
29
+
30
+ add_div_method :container, nil do |opts, _extra_args|
31
+ prepend_class opts, opts.delete(:fluid) ? "container-fluid" : "container"
32
+ opts
33
+ end
34
+
35
+ # @param *args column widths, column content and html attributes
36
+ # @example
37
+ # row 6, 6, ["col one", "col two"], class: "count", id: "count"
38
+ # @example
39
+ # row md: 12, xs: 8, "single column content"
40
+ # @example
41
+ # row md: [1, 11], xs: [2, 10] do
42
+ # col "A"
43
+ # col "B"
44
+ # end
45
+ add_div_method :row, "row", content_processor: :column do |opts, extra_args|
46
+ cols_content = extra_args.pop if extra_args.last.is_a? Array
47
+ [opts, col_widths(extra_args, opts), cols_content].compact
48
+ end
49
+
50
+ # default column width type is for medium devices (col-md-)
51
+ add_div_method :column, nil do |opts, _extra_args|
52
+ @child_args.last.each do |medium, size|
53
+ prepend_class opts, "col-#{medium}-#{size.shift}"
54
+ end
55
+ opts
56
+ end
57
+
58
+ alias_method :col, :column
59
+
60
+ private
61
+
62
+ def standardize_row_args args
63
+ opts = args.last.is_a?(Hash) ? args.pop : {}
64
+ cols = (args.last.is_a?(Array) || args.last.is_a?(String)) &&
65
+ Array.wrap(args.pop)
66
+ [cols, opts, col_widths(args, opts)]
67
+ end
68
+
69
+ def col_widths args, opts
70
+ opts = args.pop if args.one? && args.last.is_a?(Hash)
71
+ if args.present?
72
+ raise Error, "bad argument" unless args.all? { |a| a.is_a? Fixnum }
73
+ { md: Array.wrap(args) }
74
+ else
75
+ [:lg, :xs, :sm, :md].each_with_object({}) do |k, cols_w|
76
+ next unless (widths = opts.delete(k))
77
+ cols_w[k] = Array.wrap widths
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,9 @@
1
+ class Bootstrap
2
+ class Component
3
+ class Panel < Component
4
+ add_div_method :panel, "panel panel-default"
5
+ add_div_method :heading, "panel-heading"
6
+ add_div_method :body, "panel-body"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,30 @@
1
+ class Bootstrap
2
+ module ComponentLoader
3
+ def load_components
4
+ components.each do |component|
5
+ require "component/#{component}"
6
+ include_component component
7
+ end
8
+ end
9
+
10
+ def include_component component
11
+ component_class = to_const component.camelcase
12
+ define_method component do |*args, &block|
13
+ component_class.render self, *args, &block
14
+ end
15
+ end
16
+
17
+ def components
18
+ path = File.expand_path "../component/*.rb", __FILE__
19
+ Dir.glob(path).map do |file|
20
+ File.basename file, ".rb"
21
+ end
22
+ end
23
+
24
+ def to_const name
25
+ self.class.const_get "::Bootstrap::Component::#{name.camelcase}"
26
+ end
27
+ end
28
+ end
29
+
30
+
@@ -0,0 +1,16 @@
1
+ class Bootstrap
2
+ module Delegate
3
+ def method_missing(method_name, *args, &block)
4
+ #return super unless @context.respond_to? method_name
5
+ if block_given?
6
+ @context.send(method_name, *args, &block)
7
+ else
8
+ @context.send(method_name, *args)
9
+ end
10
+ end
11
+
12
+ def respond_to_missing? method_name, _include_private=false
13
+ @context.respond_to? method_name
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require 'bootstrap'
2
+ module Bootstrapper
3
+ extend Bootstrap::ComponentLoader
4
+
5
+ def bootstrap
6
+ @bootstrap ||= ::Bootstrap.new(self)
7
+ end
8
+
9
+ def bs *args, &block
10
+ bootstrap.render *args, &block
11
+ end
12
+
13
+ components.each do |component|
14
+ delegate component, to: :bootstrap, prefix: :bs
15
+ end
16
+ end
@@ -3,7 +3,7 @@
3
3
  // --------------------------------------------------
4
4
 
5
5
 
6
- table {
6
+ table, .table {
7
7
  background-color: $table-bg;
8
8
  }
9
9
  caption {
@@ -12,7 +12,7 @@ caption {
12
12
  color: $text-muted;
13
13
  text-align: left;
14
14
  }
15
- th {
15
+ th, .th {
16
16
  text-align: left;
17
17
  }
18
18
 
@@ -26,10 +26,13 @@ th {
26
26
  // Cells
27
27
  > thead,
28
28
  > tbody,
29
- > tfoot {
30
- > tr {
31
- > th,
32
- > td {
29
+ > tfoot,
30
+ > .thead,
31
+ > .tbody,
32
+ > .tfoot {
33
+ > tr, > .tr {
34
+ > th, > .th
35
+ > td, > .td {
33
36
  padding: $table-cell-padding;
34
37
  line-height: $line-height-base;
35
38
  vertical-align: top;
@@ -38,23 +41,23 @@ th {
38
41
  }
39
42
  }
40
43
  // Bottom align for column headings
41
- > thead > tr > th {
44
+ > thead > tr > th, > .thead > .tr > .th {
42
45
  vertical-align: bottom;
43
46
  border-bottom: 2px solid $table-border-color;
44
47
  }
45
48
  // Remove top border from thead by default
46
49
  > caption + thead,
47
50
  > colgroup + thead,
48
- > thead:first-child {
49
- > tr:first-child {
50
- > th,
51
- > td {
51
+ > thead:first-child, > .thead:first-child {
52
+ > tr:first-child, > .tr:first-child {
53
+ > th, > .th,
54
+ > td, > .td {
52
55
  border-top: 0;
53
56
  }
54
57
  }
55
58
  }
56
59
  // Account for multiple tbody instances
57
- > tbody + tbody {
60
+ > tbody + tbody, > .tbody + .tbody {
58
61
  border-top: 2px solid $table-border-color;
59
62
  }
60
63
 
@@ -68,12 +71,12 @@ th {
68
71
  // Condensed table w/ half padding
69
72
 
70
73
  .table-condensed {
71
- > thead,
72
- > tbody,
73
- > tfoot {
74
- > tr {
75
- > th,
76
- > td {
74
+ > thead, > .thead,
75
+ > tbody, > .tbody,
76
+ > tfoot, > .tfoot {
77
+ > tr, > .tr {
78
+ > th, > .th
79
+ > td, > .td {
77
80
  padding: $table-condensed-cell-padding;
78
81
  }
79
82
  }
@@ -87,19 +90,19 @@ th {
87
90
 
88
91
  .table-bordered {
89
92
  border: 1px solid $table-border-color;
90
- > thead,
91
- > tbody,
92
- > tfoot {
93
- > tr {
94
- > th,
95
- > td {
93
+ > thead, > .thead,
94
+ > tbody, > .tbody,
95
+ > tfoot, > .tfoot {
96
+ > tr, > .tr {
97
+ > th, > .th,
98
+ > td, > .td {
96
99
  border: 1px solid $table-border-color;
97
100
  }
98
101
  }
99
102
  }
100
- > thead > tr {
101
- > th,
102
- > td {
103
+ > thead > tr, .thead > .tr {
104
+ > th, > .th,
105
+ > td, > .td {
103
106
  border-bottom-width: 2px;
104
107
  }
105
108
  }
@@ -111,7 +114,7 @@ th {
111
114
  // Default zebra-stripe styles (alternating gray and transparent backgrounds)
112
115
 
113
116
  .table-striped {
114
- > tbody > tr:nth-of-type(odd) {
117
+ > tbody > tr:nth-of-type(odd), > .tbody > .tr:nth-of-type(odd) {
115
118
  background-color: $table-bg-accent;
116
119
  }
117
120
  }
@@ -122,7 +125,7 @@ th {
122
125
  // Placed here since it has to come after the potential zebra striping
123
126
 
124
127
  .table-hover {
125
- > tbody > tr:hover {
128
+ > tbody > tr:hover, > .tbody > .tr:hover {
126
129
  background-color: $table-bg-hover;
127
130
  }
128
131
  }
@@ -132,14 +135,14 @@ th {
132
135
  //
133
136
  // Reset default table behavior
134
137
 
135
- table col[class*="col-"] {
138
+ table col[class*="col-"], .table col[class*="col-"] {
136
139
  position: static; // Prevent border hiding in Firefox and IE9-11 (see https://github.com/twbs/bootstrap/issues/11623)
137
140
  float: none;
138
141
  display: table-column;
139
142
  }
140
- table {
141
- td,
142
- th {
143
+ table, .table {
144
+ td, .td,
145
+ th, .th {
143
146
  &[class*="col-"] {
144
147
  position: static; // Prevent border hiding in Firefox and IE9-11 (see https://github.com/twbs/bootstrap/issues/11623)
145
148
  float: none;
@@ -184,12 +187,12 @@ table {
184
187
  margin-bottom: 0;
185
188
 
186
189
  // Ensure the content doesn't wrap
187
- > thead,
188
- > tbody,
189
- > tfoot {
190
- > tr {
191
- > th,
192
- > td {
190
+ > thead, > .thead,
191
+ > tbody, > .tbody,
192
+ > tfoot, > .tfoot {
193
+ > tr, > .tr {
194
+ > th, > .th
195
+ > td, > .td {
193
196
  white-space: nowrap;
194
197
  }
195
198
  }
@@ -201,16 +204,16 @@ table {
201
204
  border: 0;
202
205
 
203
206
  // Nuke the appropriate borders so that the parent can handle them
204
- > thead,
205
- > tbody,
206
- > tfoot {
207
- > tr {
208
- > th:first-child,
209
- > td:first-child {
207
+ > thead, > .thead,
208
+ > tbody, > .tbody,
209
+ > tfoot, > .tfoot {
210
+ > tr, > .tr {
211
+ > th:first-child, > .th:first-child,
212
+ > td:first-child, > .td:first-child {
210
213
  border-left: 0;
211
214
  }
212
- > th:last-child,
213
- > td:last-child {
215
+ > th:last-child, > .th:last-child,
216
+ > td:last-child, > .td:last-child {
214
217
  border-right: 0;
215
218
  }
216
219
  }
@@ -219,11 +222,11 @@ table {
219
222
  // Only nuke the last row's bottom-border in `tbody` and `tfoot` since
220
223
  // chances are there will be only one `tr` in a `thead` and that would
221
224
  // remove the border altogether.
222
- > tbody,
223
- > tfoot {
224
- > tr:last-child {
225
- > th,
226
- > td {
225
+ > tbody, > .tbody,
226
+ > tfoot, > .tfoot {
227
+ > tr:last-child, > .tr:last-child {
228
+ > th, > .th,
229
+ > td, > .td {
227
230
  border-bottom: 0;
228
231
  }
229
232
  }
@@ -3,25 +3,25 @@
3
3
  @mixin table-row-variant($state, $background) {
4
4
  // Exact selectors below required to override `.table-striped` and prevent
5
5
  // inheritance to nested tables.
6
- .table > thead > tr,
7
- .table > tbody > tr,
8
- .table > tfoot > tr {
9
- > td.#{$state},
10
- > th.#{$state},
11
- &.#{$state} > td,
12
- &.#{$state} > th {
6
+ .table > thead > tr, .table > .thead > .tr,
7
+ .table > tbody > tr, .table > .tbody > .tr,
8
+ .table > tfoot > tr, .table > .tfoot > .tr {
9
+ > td.#{$state}, > .td.#{$state},
10
+ > th.#{$state}, > .th.#{$state},
11
+ &.#{$state} > td, &.#{$state} > .td,
12
+ &.#{$state} > th, &.#{$state} > .th {
13
13
  background-color: $background;
14
14
  }
15
15
  }
16
16
 
17
17
  // Hover states for `.table-hover`
18
18
  // Note: this is not available for cells or rows within `thead` or `tfoot`.
19
- .table-hover > tbody > tr {
20
- > td.#{$state}:hover,
21
- > th.#{$state}:hover,
22
- &.#{$state}:hover > td,
19
+ .table-hover > tbody > tr, .table-hover > .tbody > .tr {
20
+ > td.#{$state}:hover, > .td.#{$state}:hover,
21
+ > th.#{$state}:hover, > .th.#{$state}:hover,
22
+ &.#{$state}:hover > td, &.#{$state}:hover > .td,
23
23
  &:hover > .#{$state},
24
- &.#{$state}:hover > th {
24
+ &.#{$state}:hover > th, &.#{$state}:hover > .th {
25
25
  background-color: darken($background, 5%);
26
26
  }
27
27
  }
@@ -63,6 +63,13 @@ form {
63
63
  }
64
64
 
65
65
 
66
+ .link-muted {
67
+ color: $gray-light;
68
+ &:hover {
69
+ color: inherit;
70
+ }
71
+ }
72
+
66
73
  /*-------- Special Pages --------*/
67
74
 
68
75
  /*-- sign in page --*/
@@ -277,3 +284,8 @@ body.mceContentBody {
277
284
  margin-left: 10px;
278
285
 
279
286
  }
287
+
288
+ /*-------- Help texts --------*/
289
+ .alert-info p:last-child {
290
+ margin-bottom: 0;
291
+ }
@@ -0,0 +1,63 @@
1
+ format :html do
2
+ def accordion_group list, collapse_id=card.cardname.safe_key, args={}
3
+ accordions = ""
4
+ index = 1
5
+ case list
6
+ when Array then accordions = list.join
7
+ when String then accordions = list
8
+ else
9
+ list.each_pair do |title, content|
10
+ accordions << accordion(title, content, "#{collapse_id}-#{index}")
11
+ index += 1
12
+ end
13
+ end
14
+ add_class args, "panel-group"
15
+
16
+ wrap_with :div, class: args[:class], id: "accordion-#{collapse_id}",
17
+ role: "tablist", "aria-multiselectable" => "true" do
18
+ accordions
19
+ end
20
+ end
21
+
22
+ def accordion title, content, collapse_id=card.cardname.safe_key
23
+ accordion_content =
24
+ case content
25
+ when Hash then accordion_group(content, collapse_id)
26
+ when Array then content.present? && list_group(content)
27
+ when String then content
28
+ end
29
+ <<-HTML.html_safe
30
+ <div class="panel panel-default">
31
+ #{accordion_panel(title, accordion_content, collapse_id)}
32
+ </div>
33
+ HTML
34
+ end
35
+
36
+ def accordion_panel title, body, collapse_id, panel_heading_link=false
37
+ if body
38
+ <<-HTML
39
+ <div class="panel-heading" role="tab" id="heading-#{collapse_id}">
40
+ <h4 class="panel-title">
41
+ <a data-toggle="collapse" data-parent="#accordion-#{collapse_id}" \
42
+ href="##{collapse_id}" aria-expanded="true" \
43
+ aria-controls="#{collapse_id}">
44
+ #{title}
45
+ </a>
46
+ </h4>
47
+ </div>
48
+ <div id="#{collapse_id}" class="panel-collapse collapse" \
49
+ role="tabpanel" aria-labelledby="heading-#{collapse_id}">
50
+ <div class="panel-body">
51
+ #{body}
52
+ </div>
53
+ </div>
54
+ HTML
55
+ else
56
+ <<-HTML
57
+ <li class="list-group-item">
58
+ <h4 class="panel-title">#{title}</h4>
59
+ </li>
60
+ HTML
61
+ end
62
+ end
63
+ end