card 1.96.8 → 1.97.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (488) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/config/initializers/01_core_extensions/hash.rb +7 -7
  4. data/config/initializers/01_core_extensions/object.rb +8 -4
  5. data/config/initializers/02_patches/kaminari.rb +0 -6
  6. data/config/locales/de.yml +7 -4
  7. data/config/locales/en.yml +46 -39
  8. data/db/migrate/20110511221913_require_earlier_migrations.rb +1 -0
  9. data/db/migrate/20120105203350_require_1_8_migrations.rb +1 -0
  10. data/db/migrate/20190116170824_add_left_key_to_card_virtuals.rb +11 -0
  11. data/db/migrate/20190131223248_add_codename_index.rb +9 -0
  12. data/db/migrate_core_cards/20120611203506_rails_inflection_updates.rb +8 -2
  13. data/db/migrate_core_cards/20180712042655_head_rule.rb +14 -0
  14. data/db/migrate_core_cards/20180905061536_migrate_layouts.rb +64 -0
  15. data/db/migrate_core_cards/20190125125150_add_script_rules_card.rb +9 -0
  16. data/db/migrate_core_cards/20190204195039_add_rule_card.rb +7 -0
  17. data/db/migrate_core_cards/data/decko_logo.svg +59 -0
  18. data/db/schema.rb +3 -2
  19. data/db/seed/new/card_actions.yml +1506 -1458
  20. data/db/seed/new/card_acts.yml +2 -2
  21. data/db/seed/new/card_references.yml +633 -633
  22. data/db/seed/new/cards.yml +1802 -1634
  23. data/db/seed/new/schema_migrations.yml +4 -0
  24. data/db/seed/new/schema_migrations_core_cards.yml +28 -2
  25. data/db/seed/test/fixtures/card_actions.yml +2485 -2533
  26. data/db/seed/test/fixtures/card_acts.yml +520 -460
  27. data/db/seed/test/fixtures/card_changes.yml +66 -66
  28. data/db/seed/test/fixtures/card_references.yml +1533 -1407
  29. data/db/seed/test/fixtures/cards.yml +3392 -2945
  30. data/db/seed/test/fixtures/schema_migrations.yml +4 -0
  31. data/db/seed/test/fixtures/schema_migrations_core_cards.yml +28 -2
  32. data/db/seed/test/seed.rb +33 -1
  33. data/db/version.txt +1 -1
  34. data/db/version_core_cards.txt +1 -1
  35. data/lib/card.rb +1 -0
  36. data/lib/card/act_manager.rb +6 -2
  37. data/lib/card/act_manager/stage.rb +5 -5
  38. data/lib/card/act_manager/stage_director.rb +11 -7
  39. data/lib/card/act_manager/stage_director/phases.rb +4 -8
  40. data/lib/card/auth.rb +1 -0
  41. data/lib/card/auth/current.rb +1 -1
  42. data/lib/card/auth/permissions.rb +1 -0
  43. data/lib/card/auth/proxy.rb +1 -0
  44. data/lib/card/cache.rb +10 -9
  45. data/lib/card/cache/persistent.rb +2 -1
  46. data/lib/card/cache/prepopulate.rb +1 -0
  47. data/lib/card/cache/temporary.rb +1 -0
  48. data/lib/card/codename.rb +11 -6
  49. data/lib/card/content/chunk.rb +24 -9
  50. data/lib/card/content/clean.rb +4 -2
  51. data/lib/card/content/diff.rb +4 -4
  52. data/lib/card/content/diff/lcs.rb +1 -3
  53. data/lib/card/content/diff/processor.rb +2 -0
  54. data/lib/card/content/diff/result.rb +3 -0
  55. data/lib/card/content/parser.rb +2 -1
  56. data/lib/card/content/truncate.rb +4 -1
  57. data/lib/card/dirty.rb +3 -2
  58. data/lib/card/env.rb +11 -2
  59. data/lib/card/env/location_history.rb +3 -1
  60. data/lib/card/env/success.rb +3 -1
  61. data/lib/card/error.rb +42 -8
  62. data/lib/card/format.rb +22 -9
  63. data/lib/card/format/content.rb +10 -2
  64. data/lib/card/format/context_names.rb +4 -2
  65. data/lib/card/format/error.rb +1 -1
  66. data/lib/card/format/nest.rb +4 -3
  67. data/lib/card/format/nesting.rb +2 -0
  68. data/lib/card/format/nesting/main.rb +11 -5
  69. data/lib/card/format/nesting/mode.rb +1 -0
  70. data/lib/card/format/nesting/subformat.rb +12 -0
  71. data/lib/card/format/permission.rb +3 -0
  72. data/lib/card/format/registration.rb +7 -3
  73. data/lib/card/format/render.rb +73 -17
  74. data/lib/card/mailer.rb +2 -1
  75. data/lib/card/mark.rb +2 -2
  76. data/lib/card/migration.rb +115 -113
  77. data/lib/card/migration/core.rb +1 -0
  78. data/lib/card/migration/deck_structure.rb +1 -0
  79. data/lib/card/migration/import.rb +1 -1
  80. data/lib/card/migration/import/import_data.rb +6 -3
  81. data/lib/card/migration/import/import_data/card_attributes.rb +56 -54
  82. data/lib/card/migration/import/import_data/card_content.rb +0 -1
  83. data/lib/card/mod.rb +4 -1
  84. data/lib/card/mod/dirs.rb +11 -2
  85. data/lib/card/mod/load_strategy.rb +4 -4
  86. data/lib/card/mod/load_strategy/set_binding_magic.rb +9 -5
  87. data/lib/card/mod/load_strategy/set_tmp_files.rb +1 -1
  88. data/lib/card/mod/load_strategy/tmp_files.rb +1 -0
  89. data/lib/card/mod/loader.rb +8 -9
  90. data/lib/card/mod/loader/set_loader.rb +4 -4
  91. data/lib/card/mod/loader/set_pattern_loader.rb +2 -2
  92. data/lib/card/mod/module_template.rb +12 -12
  93. data/lib/card/model/save_helper.rb +13 -4
  94. data/lib/card/name.rb +3 -2
  95. data/lib/card/name/name_variants.rb +3 -3
  96. data/lib/card/query.rb +19 -12
  97. data/lib/card/query/abstract_query/query_helper.rb +2 -0
  98. data/lib/card/query/card_query.rb +1 -0
  99. data/lib/card/query/card_query/conjunctions.rb +2 -0
  100. data/lib/card/query/card_query/interpretation.rb +2 -7
  101. data/lib/card/query/card_query/match_attributes.rb +1 -0
  102. data/lib/card/query/card_query/reference_attributes.rb +4 -4
  103. data/lib/card/query/card_query/run.rb +1 -0
  104. data/lib/card/query/card_query/sorting.rb +1 -0
  105. data/lib/card/query/clause.rb +14 -12
  106. data/lib/card/query/join.rb +4 -2
  107. data/lib/card/query/reference_query.rb +1 -0
  108. data/lib/card/query/sql_statement.rb +4 -8
  109. data/lib/card/query/sql_statement/joins.rb +1 -0
  110. data/lib/card/query/sql_statement/order.rb +7 -6
  111. data/lib/card/query/sql_statement/where.rb +3 -1
  112. data/lib/card/query/value.rb +1 -0
  113. data/lib/card/reference.rb +1 -0
  114. data/lib/card/set/advanced_api.rb +2 -2
  115. data/lib/card/set/code_nest.rb +15 -0
  116. data/lib/card/set/event.rb +4 -3
  117. data/lib/card/set/event/callbacks.rb +1 -0
  118. data/lib/card/set/event/delayed_event.rb +7 -6
  119. data/lib/card/set/event/options.rb +5 -1
  120. data/lib/card/set/format.rb +21 -0
  121. data/lib/card/set/format/abstract_format.rb +15 -6
  122. data/lib/card/set/format/haml_views.rb +1 -1
  123. data/lib/card/set/format/wrapper.rb +89 -0
  124. data/lib/card/set/helpers.rb +5 -0
  125. data/lib/card/set/i18n_scanner.rb +5 -4
  126. data/lib/card/set/i18n_scope.rb +10 -10
  127. data/lib/card/set/inheritance.rb +3 -0
  128. data/lib/card/set/loader.rb +1 -0
  129. data/lib/card/set/required_field.rb +74 -0
  130. data/lib/card/set/trait.rb +6 -0
  131. data/lib/card/set_pattern.rb +8 -4
  132. data/lib/card/subcards.rb +9 -1
  133. data/lib/card/subcards/add.rb +1 -3
  134. data/lib/card/subcards/remove.rb +2 -0
  135. data/lib/card/tasks/card.rake +2 -0
  136. data/lib/card/tasks/card/create.rake +2 -1
  137. data/lib/card/tasks/card/file_card_creator.rb +1 -1
  138. data/lib/card/tasks/card/file_card_creator/abstract_file_card/migration_file.rb +1 -0
  139. data/lib/card/tasks/card/migrate.rake +3 -3
  140. data/lib/card/version.rb +6 -4
  141. data/lib/card/view.rb +15 -2
  142. data/lib/card/view/cache.rb +12 -12
  143. data/lib/card/view/cache_action.rb +11 -14
  144. data/lib/card/view/classy.rb +168 -0
  145. data/lib/card/view/layout.rb +14 -0
  146. data/lib/card/view/options.rb +12 -8
  147. data/lib/card/view/options/key_lists.rb +4 -4
  148. data/lib/card/view/options/voo_api.rb +46 -9
  149. data/lib/card/view/stub.rb +2 -2
  150. data/lib/card/view/visibility.rb +4 -5
  151. data/lib/card/view/wrapper.rb +28 -0
  152. data/lib/cardio.rb +2 -1
  153. data/mod/Modfile +2 -0
  154. data/mod/account/set/right/account.rb +4 -6
  155. data/mod/account/set/right/password.rb +2 -2
  156. data/mod/account/set/self/signin.rb +16 -9
  157. data/mod/account/set/type/signup.rb +1 -1
  158. data/mod/account/spec/set/right/password_spec.rb +26 -19
  159. data/mod/account/spec/set/type/signup_spec.rb +1 -1
  160. data/mod/basic_formats/set/self/head.rb +4 -0
  161. data/mod/bootstrap/lib/javascript/script_load_select2.js.coffee +2 -0
  162. data/mod/bootstrap/lib/stylesheets/style_bootstrap_cards.scss +76 -21
  163. data/mod/bootstrap/lib/stylesheets/style_select2_bootstrap.scss +24 -6
  164. data/mod/bootstrap/set/abstract/bootswatch_theme/html_views.rb +2 -1
  165. data/mod/bootstrap/set/type/customized_bootswatch_skin/core.haml +2 -2
  166. data/mod/bootstrap/set/type/customized_bootswatch_skin/html_views.rb +14 -14
  167. data/mod/bootstrap/set/type_plus_right/customized_bootswatch_skin/colors.rb +4 -0
  168. data/mod/bootstrap/set/type_plus_right/customized_bootswatch_skin/colors/core.haml +10 -0
  169. data/mod/carrierwave/lib/carrier_wave/file_card_uploader.rb +2 -2
  170. data/mod/carrierwave/set/abstract/attachment.rb +1 -1
  171. data/mod/carrierwave/set/type/file.rb +4 -0
  172. data/mod/carrierwave/set/type/image.rb +13 -0
  173. data/mod/carrierwave/spec/lib/carrier_wave/file_card_uploader_spec.rb +2 -2
  174. data/mod/carrierwave/spec/set/type/file_spec.rb +4 -4
  175. data/mod/carrierwave/spec/set/type/image_spec.rb +6 -6
  176. data/mod/core/chunk/nest.rb +9 -1
  177. data/mod/core/format/html_format.rb +9 -45
  178. data/mod/core/layout/blank.html +5 -5
  179. data/mod/core/layout/default.html +10 -8
  180. data/mod/core/layout/noside.html +6 -9
  181. data/mod/core/layout/pre.html +1 -2
  182. data/mod/core/layout/simple.html +1 -5
  183. data/mod/core/set/abstract/code_file.rb +1 -1
  184. data/mod/core/set/all/cache.rb +0 -2
  185. data/mod/core/set/all/codename.rb +2 -0
  186. data/mod/core/set/all/collection.rb +3 -1
  187. data/mod/core/set/all/event_conditions.rb +36 -4
  188. data/mod/core/set/all/export.rb +1 -10
  189. data/mod/core/set/all/haml.rb +3 -2
  190. data/mod/core/set/all/layouts.rb +34 -0
  191. data/mod/core/set/all/name_events.rb +1 -1
  192. data/mod/core/set/all/pattern.rb +6 -11
  193. data/mod/core/set/all/subcards.rb +4 -0
  194. data/mod/core/set/all/utils.rb +21 -1
  195. data/mod/core/set_pattern/07_type_plus_right.rb +1 -1
  196. data/mod/core/set_pattern/08_rule.rb +17 -0
  197. data/mod/core/set_pattern/{08_self.rb → 09_self.rb} +0 -0
  198. data/mod/core/spec/format/html_format_spec.rb +6 -99
  199. data/mod/core/spec/set/all/codename_spec.rb +1 -1
  200. data/mod/core/spec/set/all/collection_spec.rb +9 -5
  201. data/mod/core/spec/set/all/event_conditions_spec.rb +91 -0
  202. data/mod/core/spec/set/all/pattern_spec.rb +17 -10
  203. data/mod/developer/spec/set/right/debug_spec.rb +1 -1
  204. data/mod/edit/set/all/bridge.rb +61 -0
  205. data/mod/edit/set/all/bridge/bridge.haml +6 -0
  206. data/mod/edit/set/all/bridge/follow_section.rb +37 -0
  207. data/mod/edit/set/all/bridge/tab_views.rb +75 -0
  208. data/mod/edit/set/all/bridge/tab_visibility.rb +51 -0
  209. data/mod/edit/set/all/edit_content.rb +58 -0
  210. data/mod/edit/set/all/edit_in_place.rb +58 -0
  211. data/mod/edit/set/all/edit_name.rb +87 -0
  212. data/mod/edit/set/all/edit_type.rb +28 -0
  213. data/mod/edit/set/all/editing.rb +79 -0
  214. data/mod/{standard/set/all/rich_html → edit/set/all}/editor.rb +1 -0
  215. data/mod/{standard/set/all/rich_html → edit/set/all}/form.rb +17 -10
  216. data/mod/edit/set/all/form_buttons.rb +52 -0
  217. data/mod/{standard/set/all/rich_html → edit/set/all}/form_elements.rb +2 -1
  218. data/mod/{standard/set/all/rich_html → edit/set/all}/formgroup.rb +3 -1
  219. data/mod/{standard/set/all/rich_html → edit/set/all}/new.rb +0 -2
  220. data/mod/edit/set/all/toolbar.rb +8 -0
  221. data/mod/edit/spec/set/all/bridge/tab_views_spec.rb +14 -0
  222. data/mod/{standard/spec/set/all/rich_html/editing_spec.rb → edit/spec/set/all/bridge_spec.rb} +1 -1
  223. data/mod/edit/spec/set/all/editing_spec.rb +15 -0
  224. data/mod/{standard/spec/set/all/rich_html → edit/spec/set/all}/form_elements_spec.rb +10 -8
  225. data/mod/edit/spec/set/all/form_spec.rb +50 -0
  226. data/mod/follow/lib/card/follower_stash.rb +5 -0
  227. data/mod/follow/set/abstract/follow_option.rb +0 -1
  228. data/mod/follow/set/all/follow/follow_link.rb +42 -54
  229. data/mod/follow/set/all/follow/follow_link_views.rb +29 -0
  230. data/mod/follow/set/all/follow/followed_by.rb +3 -0
  231. data/mod/follow/set/all/follow/follower_ids.rb +5 -0
  232. data/mod/follow/set/all/follow/start_follow_link.rb +11 -0
  233. data/mod/follow/set/all/follow/stop_follow_link.rb +12 -0
  234. data/mod/follow/set/all/notify.rb +4 -0
  235. data/mod/follow/set/all/notify/base_views.rb +11 -0
  236. data/mod/follow/set/right/account.rb +2 -1
  237. data/mod/follow/set/right/follow.rb +4 -0
  238. data/mod/follow/set/right/follow/follow_status.haml +2 -2
  239. data/mod/follow/set/right/followers.rb +1 -0
  240. data/mod/follow/set/right/following.rb +2 -3
  241. data/mod/follow/set/self/follow_defaults.rb +17 -16
  242. data/mod/follow/set/type/set.rb +2 -0
  243. data/mod/follow/set/type/user.rb +1 -0
  244. data/mod/follow/set/type_plus_right/user/follow.rb +1 -0
  245. data/mod/follow/set/type_plus_right/user/follow/follow_editor.haml +4 -1
  246. data/mod/follow/set/type_plus_right/user/follow/follow_editor_helper.rb +6 -0
  247. data/mod/follow/spec/set/all/follow/follow_link_views_spec.rb +27 -0
  248. data/mod/follow/spec/set/all/follow/start_follow_link_spec.rb +11 -0
  249. data/mod/follow/spec/set/all/follow/stop_follow_link_spec.rb +13 -0
  250. data/mod/follow/spec/set/all/follow_spec.rb +13 -9
  251. data/mod/follow/spec/set/all/notify_spec.rb +4 -3
  252. data/mod/follow/spec/set/right/account_spec.rb +29 -31
  253. data/mod/follow/spec/set/right/following_spec.rb +2 -8
  254. data/mod/history/lib/card/act.rb +9 -7
  255. data/mod/history/lib/card/act/act_renderer.rb +12 -9
  256. data/mod/history/lib/card/act/act_renderer/absolute_act_renderer.rb +2 -2
  257. data/mod/history/lib/card/act/act_renderer/bridge_act_renderer.rb +53 -0
  258. data/mod/history/lib/card/act/act_renderer/relative_act_renderer.rb +3 -0
  259. data/mod/history/lib/card/action.rb +9 -4
  260. data/mod/history/lib/card/action/action_renderer.rb +5 -3
  261. data/mod/history/lib/card/action/differ.rb +3 -0
  262. data/mod/history/set/all/history.rb +2 -1
  263. data/mod/history/set/all/history/act_listing.rb +11 -8
  264. data/mod/history/set/all/history/actions.rb +11 -2
  265. data/mod/history/set/all/history/events.rb +0 -1
  266. data/mod/history/set/all/history/last.rb +2 -1
  267. data/mod/history/set/all/history/revision.rb +1 -0
  268. data/mod/history/set/all/history/selected.rb +1 -1
  269. data/mod/history/set/all/history/views.rb +0 -1
  270. data/mod/history/set/all/history_bridge.rb +66 -0
  271. data/mod/item/set/all/bar.haml +1 -3
  272. data/mod/item/set/all/bar.rb +39 -21
  273. data/mod/item/set/all/box.haml +1 -0
  274. data/mod/item/set/all/box.rb +13 -3
  275. data/mod/item/set/all/expanded_bar.haml +4 -6
  276. data/mod/machines/file/all_script_machine_output/file.js +37380 -65
  277. data/mod/machines/file/all_style_machine_output/file.css +2 -2
  278. data/mod/machines/file/script_html5shiv_printshiv_machine_output/file.js +1 -1
  279. data/mod/machines/lib/javascript/decko.js.coffee +2 -17
  280. data/mod/machines/lib/javascript/decko_bridge.js.coffee +28 -0
  281. data/mod/machines/lib/javascript/decko_components.js.coffee +21 -0
  282. data/mod/machines/lib/javascript/decko_filter.js.coffee +3 -1
  283. data/mod/machines/lib/javascript/decko_mod.js.coffee +7 -64
  284. data/mod/machines/lib/javascript/decko_modal.js.coffee +108 -0
  285. data/mod/machines/lib/javascript/decko_navbox.js.coffee +2 -0
  286. data/mod/machines/lib/javascript/decko_overlay.js.coffee +42 -0
  287. data/mod/machines/lib/javascript/decko_recaptcha.js.coffee +9 -1
  288. data/mod/machines/lib/javascript/decko_slot.js.coffee +46 -50
  289. data/mod/machines/lib/javascript/decko_slotter.js.coffee +204 -63
  290. data/mod/machines/lib/javascript/script_card_menu.js.coffee +3 -3
  291. data/mod/machines/lib/stylesheets/style_cards.scss +234 -107
  292. data/mod/machines/set/abstract/machine.rb +4 -3
  293. data/mod/machines/set/self/script_slot.rb +2 -2
  294. data/mod/machines/set/type/css.rb +8 -1
  295. data/mod/machines/set/type/skin.rb +1 -1
  296. data/mod/machines/spec/set/type/coffeescript_spec.rb +3 -3
  297. data/mod/pointer/set/abstract/00_paging_params.rb +2 -0
  298. data/mod/pointer/set/abstract/01_paging.rb +12 -6
  299. data/mod/pointer/set/abstract/02_pointer/html_views.rb +25 -0
  300. data/mod/pointer/set/abstract/02_pointer/html_views/filter.rb +20 -4
  301. data/mod/pointer/set/abstract/02_pointer/html_views/filter/filter_items.haml +1 -6
  302. data/mod/pointer/set/abstract/02_pointer/html_views/filter/filtered_list_input.haml +4 -13
  303. data/mod/pointer/set/type/pointer.rb +9 -0
  304. data/mod/pointer/spec/set/abstract/pointer/events_spec.rb +6 -0
  305. data/mod/rules/lib/javascript/script_rules.js.coffee +23 -0
  306. data/mod/rules/set/rstar/rule_user.rb +8 -0
  307. data/mod/rules/set/rule/bridge_rules_editor.rb +32 -0
  308. data/mod/rules/set/rule/editor.rb +144 -0
  309. data/mod/rules/set/rule/rule_form.rb +57 -0
  310. data/mod/rules/set/rule/rule_form/buttons.rb +44 -0
  311. data/mod/rules/set/rule/rule_form/form_elements.rb +52 -0
  312. data/mod/rules/set/rule/rule_form/rule_form.haml +20 -0
  313. data/mod/rules/set/rule/rule_form/rule_set_radio.rb +86 -0
  314. data/mod/rules/set/rule/rule_form/set_selection.rb +46 -0
  315. data/mod/{standard/set/rstar → rules/set/rule}/rules.rb +5 -9
  316. data/mod/rules/set/rule/table.rb +27 -0
  317. data/mod/rules/set/rule/table_row.rb +62 -0
  318. data/mod/rules/set/self/script_rules.rb +3 -0
  319. data/mod/{standard → rules}/set/type/set.rb +8 -10
  320. data/mod/rules/set/type/set/html_views.rb +72 -0
  321. data/mod/{standard → rules}/set/type/set/html_views/group_panel.haml +0 -0
  322. data/mod/rules/set/type/set/html_views/rules_bridge.rb +129 -0
  323. data/mod/rules/set/type/set/html_views/rules_table.haml +11 -0
  324. data/mod/{standard → rules}/set/type/set/html_views/template.rb +3 -7
  325. data/mod/{standard → rules}/set/type/set/html_views/template/template_editor.haml +0 -0
  326. data/mod/rules/spec/set/rule/editor_spec.rb +9 -0
  327. data/mod/rules/spec/set/rule/table_row_spec.rb +9 -0
  328. data/mod/rules/spec/set/rule/table_spec.rb +15 -0
  329. data/mod/rules/spec/set/type/set/html_views_spec.rb +22 -0
  330. data/mod/{standard → rules}/spec/set/type/set_spec.rb +18 -18
  331. data/mod/search/set/abstract/00_filter_helper.rb +15 -7
  332. data/mod/search/set/abstract/01_filter_form_helper.rb +1 -0
  333. data/mod/search/set/abstract/02_search_params.rb +7 -5
  334. data/mod/search/set/abstract/03_filter.rb +3 -2
  335. data/mod/search/set/abstract/04_right_filter_form.rb +1 -2
  336. data/mod/search/set/abstract/search.rb +1 -1
  337. data/mod/search/set/abstract/search/views.rb +2 -0
  338. data/mod/search/set/abstract/wql_search.rb +6 -0
  339. data/mod/search/set/self/navbox.rb +1 -1
  340. data/mod/search/set/self/search.rb +2 -2
  341. data/mod/settings/lib/card/setting.rb +6 -1
  342. data/mod/settings/set/right/help.rb +4 -0
  343. data/mod/settings/set/right/read.rb +14 -4
  344. data/mod/settings/set/right/structure.rb +3 -0
  345. data/mod/settings/set/right/style.rb +2 -1
  346. data/mod/settings/set/self/create.rb +2 -1
  347. data/mod/settings/set/self/default.rb +2 -1
  348. data/mod/settings/set/self/delete.rb +2 -1
  349. data/mod/settings/set/self/head.rb +2 -0
  350. data/mod/settings/set/self/help.rb +2 -1
  351. data/mod/settings/set/self/input.rb +1 -1
  352. data/mod/settings/set/self/read.rb +2 -1
  353. data/mod/settings/set/self/structure.rb +2 -1
  354. data/mod/settings/set/self/thanks.rb +2 -1
  355. data/mod/settings/set/self/update.rb +2 -1
  356. data/mod/settings/set/type/setting.rb +1 -1
  357. data/mod/solid_cache/set/abstract/solid_cache.rb +2 -2
  358. data/mod/standard/file/logo/image-original.svg +59 -0
  359. data/mod/standard/lib/card/layout.rb +79 -0
  360. data/mod/standard/lib/card/layout/card_layout.rb +44 -0
  361. data/mod/standard/lib/card/layout/code_layout.rb +9 -0
  362. data/mod/standard/lib/card/layout/proc_layout.rb +9 -0
  363. data/mod/standard/lib/card/layout/unknown_layout.rb +20 -0
  364. data/mod/standard/set/all/links.rb +5 -20
  365. data/mod/standard/set/all/rich_html.rb +4 -0
  366. data/mod/standard/set/all/rich_html/alert.rb +23 -0
  367. data/mod/standard/set/all/rich_html/content.rb +26 -100
  368. data/mod/standard/set/all/rich_html/error.rb +27 -3
  369. data/mod/standard/set/all/rich_html/error/debug_server_error.haml +1015 -0
  370. data/mod/standard/set/all/rich_html/frame.rb +10 -54
  371. data/mod/standard/set/all/rich_html/header.rb +25 -15
  372. data/mod/standard/set/all/rich_html/header/header_wrap.haml +2 -1
  373. data/mod/standard/set/all/rich_html/html_views/help.rb +18 -0
  374. data/mod/standard/set/all/rich_html/html_views/info.rb +59 -0
  375. data/mod/standard/set/all/rich_html/html_views/size.rb +17 -0
  376. data/mod/standard/set/all/rich_html/menu.rb +44 -146
  377. data/mod/standard/set/all/rich_html/modal.rb +99 -24
  378. data/mod/standard/set/all/rich_html/modal/modal_dialog.haml +12 -0
  379. data/mod/standard/set/all/rich_html/overlay.rb +57 -13
  380. data/mod/standard/set/all/rich_html/process_layout.rb +91 -0
  381. data/mod/standard/set/all/rich_html/show.rb +37 -0
  382. data/mod/standard/set/all/rich_html/wrapper.rb +47 -10
  383. data/mod/standard/set/right/head.rb +11 -0
  384. data/mod/standard/set/type/cardtype.rb +1 -1
  385. data/mod/standard/set/type/listed_by.rb +3 -3
  386. data/mod/standard/spec/set/all/email_html_format_spec.rb +17 -0
  387. data/mod/standard/spec/set/all/links_spec.rb +1 -22
  388. data/mod/standard/spec/set/all/rich_html/overlay_spec.rb +18 -0
  389. data/mod/standard/spec/set/all/rich_html/process_layout/explicit_modal_wrapper_spec.rb +29 -0
  390. data/mod/standard/spec/set/all/rich_html/process_layout_spec.rb +110 -0
  391. data/mod/standard/spec/set/all/rich_html/show_spec.rb +9 -0
  392. data/mod/standard/spec/set/all/rich_html/wrapper_spec.rb +17 -24
  393. data/mod/standard/spec/set/type/email_template/email_config_spec.rb +9 -5
  394. data/mod/standard/spec/set/type/layout_type_spec.rb +6 -0
  395. data/mod/standard/spec/set/type/search_type_spec.rb +1 -1
  396. data/mod/tinymce_editor/db/migrate_core_cards/20190306172623_update_tinymce_config_to_v5.rb +23 -0
  397. data/mod/tinymce_editor/lib/javascript/script_tinymce.js +9 -2
  398. data/mod/tinymce_editor/lib/javascript/script_tinymce_config.js.coffee +3 -2
  399. data/mod/tinymce_editor/public/assets/tinymce/jquery.tinymce.min.js +92 -1
  400. data/mod/tinymce_editor/public/assets/tinymce/plugins/advlist/plugin.min.js +9 -1
  401. data/mod/tinymce_editor/public/assets/tinymce/plugins/anchor/plugin.min.js +9 -1
  402. data/mod/tinymce_editor/public/assets/tinymce/plugins/autolink/plugin.min.js +9 -1
  403. data/mod/tinymce_editor/public/assets/tinymce/plugins/autoresize/plugin.min.js +9 -1
  404. data/mod/tinymce_editor/public/assets/tinymce/plugins/autosave/plugin.min.js +9 -1
  405. data/mod/tinymce_editor/public/assets/tinymce/plugins/bbcode/plugin.min.js +9 -1
  406. data/mod/tinymce_editor/public/assets/tinymce/plugins/charmap/plugin.min.js +9 -1
  407. data/mod/tinymce_editor/public/assets/tinymce/plugins/code/plugin.min.js +9 -1
  408. data/mod/tinymce_editor/public/assets/tinymce/plugins/codesample/plugin.min.js +9 -1
  409. data/mod/tinymce_editor/public/assets/tinymce/plugins/colorpicker/plugin.min.js +9 -1
  410. data/mod/tinymce_editor/public/assets/tinymce/plugins/contextmenu/plugin.min.js +9 -1
  411. data/mod/tinymce_editor/public/assets/tinymce/plugins/directionality/plugin.min.js +9 -1
  412. data/mod/tinymce_editor/public/assets/tinymce/plugins/emoticons/js/emojis.js +9015 -0
  413. data/mod/tinymce_editor/public/assets/tinymce/plugins/emoticons/js/emojis.min.js +2 -0
  414. data/mod/tinymce_editor/public/assets/tinymce/plugins/emoticons/plugin.min.js +9 -1
  415. data/mod/tinymce_editor/public/assets/tinymce/plugins/fullpage/plugin.min.js +9 -1
  416. data/mod/tinymce_editor/public/assets/tinymce/plugins/fullscreen/plugin.min.js +9 -1
  417. data/mod/tinymce_editor/public/assets/tinymce/plugins/help/plugin.min.js +9 -1
  418. data/mod/tinymce_editor/public/assets/tinymce/plugins/hr/plugin.min.js +9 -1
  419. data/mod/tinymce_editor/public/assets/tinymce/plugins/image/plugin.min.js +9 -1
  420. data/mod/tinymce_editor/public/assets/tinymce/plugins/imagetools/plugin.min.js +9 -1
  421. data/mod/tinymce_editor/public/assets/tinymce/plugins/importcss/plugin.min.js +9 -1
  422. data/mod/tinymce_editor/public/assets/tinymce/plugins/insertdatetime/plugin.min.js +9 -1
  423. data/mod/tinymce_editor/public/assets/tinymce/plugins/legacyoutput/plugin.min.js +9 -1
  424. data/mod/tinymce_editor/public/assets/tinymce/plugins/link/plugin.min.js +9 -1
  425. data/mod/tinymce_editor/public/assets/tinymce/plugins/lists/plugin.min.js +9 -1
  426. data/mod/tinymce_editor/public/assets/tinymce/plugins/media/plugin.min.js +9 -1
  427. data/mod/tinymce_editor/public/assets/tinymce/plugins/nonbreaking/plugin.min.js +9 -1
  428. data/mod/tinymce_editor/public/assets/tinymce/plugins/noneditable/plugin.min.js +9 -1
  429. data/mod/tinymce_editor/public/assets/tinymce/plugins/pagebreak/plugin.min.js +9 -1
  430. data/mod/tinymce_editor/public/assets/tinymce/plugins/paste/plugin.min.js +9 -1
  431. data/mod/tinymce_editor/public/assets/tinymce/plugins/preview/plugin.min.js +9 -1
  432. data/mod/tinymce_editor/public/assets/tinymce/plugins/print/plugin.min.js +9 -1
  433. data/mod/tinymce_editor/public/assets/tinymce/plugins/quickbars/plugin.min.js +9 -0
  434. data/mod/tinymce_editor/public/assets/tinymce/plugins/save/plugin.min.js +9 -1
  435. data/mod/tinymce_editor/public/assets/tinymce/plugins/searchreplace/plugin.min.js +9 -1
  436. data/mod/tinymce_editor/public/assets/tinymce/plugins/spellchecker/plugin.min.js +9 -1
  437. data/mod/tinymce_editor/public/assets/tinymce/plugins/tabfocus/plugin.min.js +9 -1
  438. data/mod/tinymce_editor/public/assets/tinymce/plugins/table/plugin.min.js +9 -1
  439. data/mod/tinymce_editor/public/assets/tinymce/plugins/template/plugin.min.js +9 -1
  440. data/mod/tinymce_editor/public/assets/tinymce/plugins/textcolor/plugin.min.js +9 -1
  441. data/mod/tinymce_editor/public/assets/tinymce/plugins/textpattern/plugin.min.js +9 -1
  442. data/mod/tinymce_editor/public/assets/tinymce/plugins/toc/plugin.min.js +9 -1
  443. data/mod/tinymce_editor/public/assets/tinymce/plugins/visualblocks/plugin.min.js +9 -1
  444. data/mod/tinymce_editor/public/assets/tinymce/plugins/visualchars/plugin.min.js +9 -1
  445. data/mod/tinymce_editor/public/assets/tinymce/plugins/wordcount/plugin.min.js +9 -1
  446. data/mod/tinymce_editor/public/assets/tinymce/skins/content/default/content.min.css +7 -0
  447. data/mod/tinymce_editor/public/assets/tinymce/skins/content/document/content.min.css +7 -0
  448. data/mod/tinymce_editor/public/assets/tinymce/skins/content/writer/content.min.css +7 -0
  449. data/mod/tinymce_editor/public/assets/tinymce/skins/ui/oxide-dark/content.inline.min.css +7 -0
  450. data/mod/tinymce_editor/public/assets/tinymce/skins/ui/oxide-dark/content.min.css +7 -0
  451. data/mod/tinymce_editor/public/assets/tinymce/skins/ui/oxide-dark/skin.min.css +7 -0
  452. data/mod/tinymce_editor/public/assets/tinymce/skins/ui/oxide/content.inline.min.css +7 -0
  453. data/mod/tinymce_editor/public/assets/tinymce/skins/ui/oxide/content.min.css +7 -0
  454. data/mod/tinymce_editor/public/assets/tinymce/skins/ui/oxide/content.mobile.min.css +1 -0
  455. data/mod/tinymce_editor/public/assets/tinymce/skins/ui/oxide/fonts/tinymce-mobile.woff +0 -0
  456. data/mod/tinymce_editor/public/assets/tinymce/skins/ui/oxide/skin.min.css +7 -0
  457. data/mod/tinymce_editor/public/assets/tinymce/skins/ui/oxide/skin.mobile.min.css +1 -0
  458. data/mod/tinymce_editor/public/assets/tinymce/themes/mobile/theme.min.js +9 -1
  459. data/mod/tinymce_editor/public/assets/tinymce/themes/silver/theme.min.js +9 -0
  460. data/mod/tinymce_editor/public/assets/tinymce/tinymce.min.js +9 -2
  461. data/mod/utility/spec/set/abstract/media_spec.rb +6 -6
  462. data/mod/virtual/lib/card/virtual.rb +17 -2
  463. data/mod/virtual/set/abstract/virtual_cache.rb +1 -1
  464. data/mod/virtual/spec/set/lib/card/virtual_spec.rb +1 -1
  465. metadata +121 -42
  466. data/mod/core/layout/modal.html +0 -9
  467. data/mod/core/layout/simple_modal.html +0 -3
  468. data/mod/follow/spec/set/all/follow/follow_link_spec.rb +0 -7
  469. data/mod/standard/file/logo/image-icon.png +0 -0
  470. data/mod/standard/file/logo/image-large.png +0 -0
  471. data/mod/standard/file/logo/image-medium.png +0 -0
  472. data/mod/standard/file/logo/image-original.png +0 -0
  473. data/mod/standard/file/logo/image-small.png +0 -0
  474. data/mod/standard/set/abstract/toolbar_split_button.rb +0 -22
  475. data/mod/standard/set/all/rich_html/classy.rb +0 -37
  476. data/mod/standard/set/all/rich_html/editing.rb +0 -176
  477. data/mod/standard/set/all/rich_html/related.rb +0 -30
  478. data/mod/standard/set/all/rich_html/toolbar.rb +0 -264
  479. data/mod/standard/set/rstar/rules_editor.rb +0 -371
  480. data/mod/standard/set/self/activity_toolbar_button.rb +0 -14
  481. data/mod/standard/set/self/rules_toolbar_button.rb +0 -44
  482. data/mod/standard/set/type/set/html_views.rb +0 -155
  483. data/mod/standard/set/type/set/html_views/rules_table.haml +0 -9
  484. data/mod/standard/spec/set/all/rich_html/form_spec.rb +0 -47
  485. data/mod/standard/spec/set/all/rich_html/toolbar_spec.rb +0 -25
  486. data/mod/standard/spec/set/rstar/rules_spec.rb +0 -26
  487. data/mod/standard/spec/set/self/activity_toolbar_button_spec.rb +0 -22
  488. data/mod/standard/spec/set/type/set/html_views_spec.rb +0 -10
@@ -0,0 +1,9 @@
1
+ class Card
2
+ class Layout
3
+ class CodeLayout < Layout
4
+ def render
5
+ @format.send Card::Set::Format.layout_method_name(@layout)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class Card
2
+ class Layout
3
+ class ProcLayout < Layout
4
+ def render
5
+ @layout.call
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,20 @@
1
+ class Card
2
+ class Layout
3
+ class UnknownLayout < Layout
4
+ SCOPE = "mod.core.format.html_format".freeze
5
+
6
+ def render
7
+ @format.output [header, text]
8
+ end
9
+
10
+ def header
11
+ @format.content_tag(:h1, @format.tr(:unknown_layout, scope: SCOPE, name: @layout))
12
+ end
13
+
14
+ def text
15
+ @format.tr(:available_layouts, scope: SCOPE,
16
+ available_layouts: self.class.built_in_layouts)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -34,15 +34,6 @@ format do
34
34
  link_to text, opts
35
35
  end
36
36
 
37
- # link to the "related" view (handles many card menu items)
38
- # @param field_cardish [Integer, Symbol, String, Card] identify the related field
39
- # @param text [String]
40
- # @param opts [Hash]
41
- def link_to_related field_cardish, text=nil, opts={}
42
- opts.bury :path, :slot, :items, :nest_name, "+#{Card::Name[field_cardish]}"
43
- link_to_view :related, text, opts
44
- end
45
-
46
37
  # a "resource" is essentially a reference to something that
47
38
  # decko doesn't recognize to be a card. Can be a remote url,
48
39
  # a local url (that decko hasn't parsed) or a local path.
@@ -54,15 +45,14 @@ format do
54
45
  link_to text, opts.merge(path: resource)
55
46
  end
56
47
 
57
- # smart_link_to is wrapper method for #link_to, #link_to_card, #link_to_view,
58
- # #link_to_resource, and #link_to_related. If the opts argument contains
59
- # :view, :related, :card, or :resource, it will use the respective method to
60
- # render a link.
48
+ # smart_link_to is wrapper method for #link_to, #link_to_card, #link_to_view, and
49
+ # #link_to_resource. If the opts argument contains :view, :related, :card, or
50
+ # :resource, it will use the respective method to render a link.
61
51
  #
62
52
  # This is usually most useful when writing views that generate many different
63
53
  # kinds of links.
64
54
  def smart_link_to text, opts={}
65
- if (linktype = %i[view related card resource].find { |key| opts[key] })
55
+ if (linktype = %i[view card resource].find { |key| opts[key] })
66
56
  send "link_to_#{linktype}", opts.delete(linktype), text, opts
67
57
  else
68
58
  send :link_to, text, opts
@@ -119,6 +109,7 @@ format :html do
119
109
  # in HTML, #link_to_view defaults to a remote link with rel="nofollow".
120
110
  def link_to_view view, text=nil, opts={}
121
111
  opts.reverse_merge! remote: true, rel: "nofollow"
112
+ add_class opts, "slotter"
122
113
  super view, (text || view), opts
123
114
  end
124
115
 
@@ -130,12 +121,6 @@ format :html do
130
121
  super
131
122
  end
132
123
 
133
- # in HTML, #link_to_related defaults to using the field name as text
134
- def link_to_related field_cardish, text=nil, opts={}
135
- name = Card::Name[field_cardish]
136
- super name, (text || name), opts
137
- end
138
-
139
124
  private
140
125
 
141
126
  def add_known_or_wanted_class opts, name
@@ -0,0 +1,4 @@
1
+ format :html do
2
+ delegate :class_up, :class_down, :with_class_up, :without_upped_class, :classy,
3
+ to: :voo
4
+ end
@@ -0,0 +1,23 @@
1
+ format :html do
2
+ # alert_types: 'success', 'info', 'warning', 'danger'
3
+ def alert alert_type, dismissable=false, disappear=false, args={}
4
+ add_class args, alert_classes(alert_type, dismissable, disappear)
5
+ wrap_with :div, args.merge(role: "alert") do
6
+ [(alert_close_button if dismissable), output(yield)]
7
+ end
8
+ end
9
+
10
+ def alert_classes alert_type, dismissable, disappear
11
+ classes = ["alert", "alert-#{alert_type}"]
12
+ classes << "alert-dismissible " if dismissable
13
+ classes << "_disappear" if disappear
14
+ classy classes
15
+ end
16
+
17
+ def alert_close_button
18
+ wrap_with :button, type: "button", "data-dismiss": "alert",
19
+ class: "close", "aria-label": "Close" do
20
+ wrap_with :span, "&times;", "aria-hidden" => true
21
+ end
22
+ end
23
+ end
@@ -5,37 +5,10 @@ end
5
5
  def help_rule_card
6
6
  setting = new_card? ? [:add_help, { fallback: :help }] : :help
7
7
  help_card = rule_card(*setting)
8
- help_card if help_card && help_card.ok?(:read)
8
+ help_card if help_card&.ok?(:read)
9
9
  end
10
10
 
11
11
  format :html do
12
- def show view, args
13
- send "show_#{show_layout? ? :with : :without}_layout", view, args
14
- end
15
-
16
- def show_layout?
17
- !Env.ajax? || params[:layout]
18
- end
19
-
20
- def show_with_layout view, args
21
- args[:view] = view if view
22
- @main = false
23
- @main_opts = args
24
- render! :layout, layout: params[:layout]
25
- # FIXME: using title because it's a standard view option. hack!
26
- end
27
-
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, cache: :never do
35
- layout = process_content get_layout_content(voo.layout), chunk_list: :references
36
- output [layout, modal_slot]
37
- end
38
-
39
12
  def prepare_content_slot
40
13
  class_up "card-slot", "d0-card-content"
41
14
  voo.hide :menu
@@ -47,6 +20,10 @@ format :html do
47
20
  wrap { [_render_menu, _render_core] }
48
21
  end
49
22
 
23
+ view :short_content, wrap: { div: { class: "text-muted" } } do
24
+ short_content
25
+ end
26
+
50
27
  before(:content_with_title) { prepare_content_slot }
51
28
 
52
29
  view :content_with_title do
@@ -57,7 +34,7 @@ format :html do
57
34
 
58
35
  before :content_panel do
59
36
  prepare_content_slot
60
- class_up "card-slot", "card", true
37
+ class_up "card-slot", "card"
61
38
  end
62
39
 
63
40
  view :content_panel do
@@ -72,7 +49,6 @@ format :html do
72
49
  @content_body = true
73
50
  wrap do
74
51
  [
75
- _render_menu,
76
52
  _render_header,
77
53
  wrap_body { _render_titled_content },
78
54
  render_comment_box
@@ -80,16 +56,11 @@ format :html do
80
56
  end
81
57
  end
82
58
 
83
- # view :property do
84
- # voo.title ||= card.name.right
85
- # render_labeled
86
- # end
87
-
88
59
  view :labeled, tags: :unknown_ok do
89
60
  @content_body = true
61
+ voo.edit = :content_modal
90
62
  wrap(true, class: "row") do
91
- [_render_menu,
92
- labeled(render_title, wrap_body { render_labeled_content })]
63
+ labeled(render_title, wrap_body { "#{render_menu}#{render_labeled_content}" } )
93
64
  end
94
65
  end
95
66
 
@@ -97,89 +68,44 @@ format :html do
97
68
  haml :labeled, label: label, content: content
98
69
  end
99
70
 
100
- view :type_info do
101
- return unless show_view?(:toolbar, :hide) && card.type_code != :basic
102
- wrap_with :span, class: "type-info float-right" do
103
- link_to_card card.type_name, nil, class: "navbar-link"
104
- end
105
- end
106
-
107
71
  view :open, tags: :comment do
108
- voo.show! :toolbar if toolbar_pinned?
109
- voo.viz :toggle, (main? ? :hide : :show)
72
+ voo.viz :toggle, :hide # (main? ? :hide : :show)
73
+ @toggle_mode = :open
110
74
  @content_body = true
111
75
  frame do
112
76
  [_render_open_content, render_comment_box]
113
77
  end
114
78
  end
115
79
 
116
- view :type do
117
- link_to_card card.type_card, nil, class: "cardtype"
118
- end
119
-
120
80
  view :closed do
121
81
  with_nest_mode :closed do
122
- voo.show :toggle
123
- voo.hide! :toolbar
82
+ voo.show :header_toggle
83
+ voo.hide! :toggle
84
+ voo.hide! :closed_content
124
85
  class_up "d0-card-body", "closed-content"
125
- @content_body = true
86
+ @content_body = false
126
87
  @toggle_mode = :close
127
- frame { _render :closed_content }
128
- end
129
- end
130
-
131
- view :change do
132
- voo.show :title_link
133
- voo.hide :menu
134
- wrap do
135
- [_render_title,
136
- _render_menu,
137
- _render_last_action]
88
+ frame
138
89
  end
139
90
  end
140
91
 
141
92
  def current_set_card
142
93
  set_name = params[:current_set]
143
- if card.known? && card.type_id == Card::CardtypeID
144
- set_name ||= "#{card.name}+*type"
145
- end
94
+ set_name ||= "#{card.name}+*type" if card.known? && card.type_id == Card::CardtypeID
146
95
  set_name ||= "#{card.name}+*self"
147
96
  Card.fetch(set_name)
148
97
  end
149
98
 
150
- view :help, tags: :unknown_ok, cache: :never do
151
- help_text = voo.help || rule_based_help
152
- return "" unless help_text.present?
153
- wrap_with :div, help_text, class: classy("help-text")
154
- end
155
-
156
- def rule_based_help
157
- return "" unless (rule_card = card.help_rule_card)
158
- with_nest_mode :normal do
159
- process_content rule_card.content, chunk_list: :references
160
- # render help card with current card's format
161
- # so current card's context is used in help card nests
99
+ def short_content
100
+ content = render_core
101
+ if content.blank?
102
+ "empty"
103
+ elsif content.size <= 5
104
+ content
105
+ elsif content.count("\n") < 2
106
+ "#{content.size} characters"
107
+ else
108
+ "#{content.count("\n") + 1} lines"
162
109
  end
163
110
  end
164
-
165
- view :last_action do
166
- act = card.last_act
167
- return unless act
168
- action = act.action_on card.id
169
- return unless action
170
- action_verb =
171
- case action.action_type
172
- when :create then "added"
173
- when :delete then "deleted"
174
- else
175
- link_to_view :history, "edited", class: "last-edited", rel: "nofollow"
176
- end
177
-
178
- %(
179
- <span class="last-update">
180
- #{action_verb} #{_render_acted_at} ago by
181
- #{subformat(card.last_actor)._render_link}
182
- </span>
183
- )
184
- end
185
111
  end
@@ -1,6 +1,12 @@
1
1
  format :html do
2
2
  view :server_error, template: :haml
3
3
 
4
+ view :debug_server_error, wrap: { modal: { size: :full } } do
5
+ error_page = BetterErrors::ErrorPage.new Card::Error.current,
6
+ "PATH_INFO" => request.env["REQUEST_URI"]
7
+ haml :debug_server_error, {}, error_page
8
+ end
9
+
4
10
  view :message, perms: :none, tags: :unknown_ok do
5
11
  frame { params[:message] }
6
12
  end
@@ -17,7 +23,7 @@ format :html do
17
23
 
18
24
  def missing_link text
19
25
  path_opts = voo.type ? { card: { type: voo.type } } : {}
20
- link_to_view :new, text, path: path_opts, class: "slotter missing-link"
26
+ link_to_view :new, text, path: path_opts, class: "missing-link"
21
27
  end
22
28
 
23
29
  view :closed_missing, perms: :none do
@@ -42,11 +48,11 @@ format :html do
42
48
 
43
49
  view :errors, perms: :none do
44
50
  return if card.errors.empty?
51
+
45
52
  voo.title = card.name.blank? ? "Problems" : tr(:problems_name, cardname: card.name)
46
53
  voo.hide! :menu
47
- class_up "d0-card-frame", "card card-warning card-inverse"
48
54
  class_up "alert", "card-error-msg"
49
- frame { standard_errors }
55
+ standard_errors voo.title
50
56
  end
51
57
 
52
58
  view :not_found do
@@ -72,6 +78,7 @@ format :html do
72
78
  def commentable? view
73
79
  return false unless self.class.tagged(view, :comment) &&
74
80
  show_view?(:comment_box, :hide)
81
+
75
82
  ok? :comment
76
83
  end
77
84
 
@@ -106,6 +113,21 @@ format :html do
106
113
  wrap_with(:span, title: error_message(exception)) { cardname }
107
114
  end
108
115
 
116
+ def standard_errors heading=nil
117
+ alert "warning", true do
118
+ [
119
+ (wrap_with(:h4, heading, class: "alert-heading") if heading),
120
+ error_messages.join("<hr>")
121
+ ]
122
+ end
123
+ end
124
+
125
+ def error_messages
126
+ card.errors.map do |attrib, msg|
127
+ attrib == :abort ? h(msg) : standard_error_message(attrib, msg)
128
+ end
129
+ end
130
+
109
131
  def standard_error_message attribute, message
110
132
  "<div><strong>#{h attribute.to_s.upcase}:</strong> #{h message}</div>"
111
133
  end
@@ -120,6 +142,7 @@ format :html do
120
142
 
121
143
  def sign_in_or_up_links to_task
122
144
  return if Auth.signed_in?
145
+
123
146
  links = [signin_link, signup_link].compact.join " #{tr :or} "
124
147
  wrap_with(:div) do
125
148
  [tr(:please), links, to_task].join(" ") + "."
@@ -132,6 +155,7 @@ format :html do
132
155
 
133
156
  def signup_link
134
157
  return unless signup_ok?
158
+
135
159
  link_to tr(:sign_up), path: { action: :new, mark: :signup }
136
160
  end
137
161
 
@@ -0,0 +1,1015 @@
1
+
2
+ :css
3
+ /* Basic reset */
4
+ * {
5
+ margin: 0;
6
+ padding: 0;
7
+ }
8
+
9
+ table {
10
+ width: 100%;
11
+ border-collapse: collapse;
12
+ }
13
+
14
+ th, td {
15
+ vertical-align: top;
16
+ text-align: left;
17
+ }
18
+
19
+ textarea {
20
+ resize: none;
21
+ }
22
+
23
+ body {
24
+ font-size: 10pt;
25
+ }
26
+
27
+ body, td, input, textarea {
28
+ font-family: helvetica neue, lucida grande, sans-serif;
29
+ line-height: 1.5;
30
+ color: #333;
31
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
32
+ }
33
+
34
+ html {
35
+ background: #f0f0f5;
36
+ }
37
+
38
+ .clearfix::after{
39
+ clear: both;
40
+ content: ".";
41
+ display: block;
42
+ height: 0;
43
+ visibility: hidden;
44
+ }
45
+
46
+ /* ---------------------------------------------------------------------
47
+ * Basic layout
48
+ * --------------------------------------------------------------------- */
49
+
50
+ /* Small */
51
+ @media screen and (max-width: 1100px) {
52
+ html {
53
+ overflow-y: scroll;
54
+ }
55
+
56
+ body {
57
+ margin: 0 20px;
58
+ }
59
+
60
+ header.exception {
61
+ margin: 0 -20px;
62
+ }
63
+
64
+ nav.sidebar {
65
+ padding: 0;
66
+ margin: 20px 0;
67
+ }
68
+
69
+ ul.frames {
70
+ max-height: 200px;
71
+ overflow: auto;
72
+ }
73
+ }
74
+
75
+ /* Wide */
76
+ @media screen and (min-width: 1100px) {
77
+ header.exception {
78
+ position: fixed;
79
+ top: 0;
80
+ left: 0;
81
+ right: 0;
82
+ }
83
+
84
+ nav.sidebar,
85
+ .frame_info {
86
+ position: fixed;
87
+ top: 95px;
88
+ bottom: 0;
89
+
90
+ box-sizing: border-box;
91
+
92
+ overflow-y: auto;
93
+ overflow-x: hidden;
94
+ }
95
+
96
+ nav.sidebar {
97
+ width: 40%;
98
+ left: 20px;
99
+ top: 115px;
100
+ bottom: 20px;
101
+ }
102
+
103
+ .frame_info {
104
+ right: 0;
105
+ left: 40%;
106
+
107
+ padding: 20px;
108
+ padding-left: 10px;
109
+ margin-left: 30px;
110
+ }
111
+ }
112
+
113
+ nav.sidebar {
114
+ background: #d3d3da;
115
+ border-top: solid 3px #a33;
116
+ border-bottom: solid 3px #a33;
117
+ border-radius: 4px;
118
+ box-shadow: 0 0 6px rgba(0, 0, 0, 0.2), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
119
+ }
120
+
121
+ /* ---------------------------------------------------------------------
122
+ * Header
123
+ * --------------------------------------------------------------------- */
124
+
125
+ header.exception {
126
+ padding: 18px 20px;
127
+
128
+ height: 59px;
129
+ min-height: 59px;
130
+
131
+ overflow: hidden;
132
+
133
+ background-color: #20202a;
134
+ color: #aaa;
135
+ text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
136
+ font-weight: 200;
137
+ box-shadow: inset 0 -5px 3px -3px rgba(0, 0, 0, 0.05), inset 0 -1px 0 rgba(0, 0, 0, 0.05);
138
+
139
+ -webkit-text-smoothing: antialiased;
140
+ }
141
+
142
+ /* Heading */
143
+ header.exception h2 {
144
+ font-weight: 200;
145
+ font-size: 11pt;
146
+ }
147
+
148
+ header.exception h2,
149
+ header.exception p {
150
+ line-height: 1.4em;
151
+ overflow: hidden;
152
+ white-space: pre;
153
+ text-overflow: ellipsis;
154
+ }
155
+
156
+ header.exception h2 strong {
157
+ font-weight: 700;
158
+ color: #d55;
159
+ }
160
+
161
+ header.exception p {
162
+ font-weight: 200;
163
+ font-size: 20pt;
164
+ color: white;
165
+ }
166
+
167
+ header.exception:hover {
168
+ height: auto;
169
+ z-index: 2;
170
+ }
171
+
172
+ header.exception:hover h2,
173
+ header.exception:hover p {
174
+ padding-right: 20px;
175
+ overflow-y: auto;
176
+ word-wrap: break-word;
177
+ white-space: pre-wrap;
178
+ height: auto;
179
+ max-height: 7.5em;
180
+ }
181
+
182
+ @media screen and (max-width: 1100px) {
183
+ header.exception {
184
+ height: auto;
185
+ }
186
+
187
+ header.exception h2,
188
+ header.exception p {
189
+ padding-right: 20px;
190
+ overflow-y: auto;
191
+ word-wrap: break-word;
192
+ height: auto;
193
+ max-height: 7em;
194
+ }
195
+ }
196
+
197
+ <haml_silent>
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+ </haml_silent>
212
+ /* ---------------------------------------------------------------------
213
+ * Navigation
214
+ * --------------------------------------------------------------------- */
215
+
216
+ nav.tabs {
217
+ border-bottom: solid 1px #ddd;
218
+
219
+ background-color: #eee;
220
+ text-align: center;
221
+
222
+ padding: 6px;
223
+
224
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
225
+ }
226
+
227
+ nav.tabs a {
228
+ display: inline-block;
229
+
230
+ height: 22px;
231
+ line-height: 22px;
232
+ padding: 0 10px;
233
+
234
+ text-decoration: none;
235
+ font-size: 8pt;
236
+ font-weight: bold;
237
+
238
+ color: #999;
239
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
240
+ }
241
+
242
+ nav.tabs a.selected {
243
+ color: white;
244
+ background: rgba(0, 0, 0, 0.5);
245
+ border-radius: 16px;
246
+ box-shadow: 1px 1px 0 rgba(255, 255, 255, 0.1);
247
+ text-shadow: 0 0 4px rgba(0, 0, 0, 0.4), 0 1px 0 rgba(0, 0, 0, 0.4);
248
+ }
249
+
250
+ nav.tabs a.disabled {
251
+ text-decoration: line-through;
252
+ text-shadow: none;
253
+ cursor: default;
254
+ }
255
+
256
+ /* ---------------------------------------------------------------------
257
+ * Sidebar
258
+ * --------------------------------------------------------------------- */
259
+
260
+ ul.frames {
261
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
262
+ }
263
+
264
+ /* Each item */
265
+ ul.frames li {
266
+ background-color: #f8f8f8;
267
+ background: -webkit-linear-gradient(top, #f8f8f8 80%, #f0f0f0);
268
+ background: -moz-linear-gradient(top, #f8f8f8 80%, #f0f0f0);
269
+ background: linear-gradient(top, #f8f8f8 80%, #f0f0f0);
270
+ box-shadow: inset 0 -1px 0 #e2e2e2;
271
+ padding: 7px 20px;
272
+
273
+ cursor: pointer;
274
+ overflow: hidden;
275
+ }
276
+
277
+ ul.frames .name,
278
+ ul.frames .location {
279
+ overflow: hidden;
280
+ height: 1.5em;
281
+
282
+ white-space: nowrap;
283
+ word-wrap: none;
284
+ text-overflow: ellipsis;
285
+ }
286
+
287
+ ul.frames .method {
288
+ color: #966;
289
+ }
290
+
291
+ ul.frames .location {
292
+ font-size: 0.85em;
293
+ font-weight: 400;
294
+ color: #999;
295
+ }
296
+
297
+ ul.frames .line {
298
+ font-weight: bold;
299
+ }
300
+
301
+ /* Selected frame */
302
+ ul.frames li.selected {
303
+ background: #38a;
304
+ box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.1), inset 0 2px 0 rgba(255, 255, 255, 0.01), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
305
+ }
306
+
307
+ ul.frames li.selected .name,
308
+ ul.frames li.selected .method,
309
+ ul.frames li.selected .location {
310
+ color: white;
311
+ text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
312
+ }
313
+
314
+ ul.frames li.selected .location {
315
+ opacity: 0.6;
316
+ }
317
+
318
+ /* Iconography */
319
+ ul.frames li {
320
+ padding-left: 60px;
321
+ position: relative;
322
+ }
323
+
324
+ ul.frames li .icon {
325
+ display: block;
326
+ width: 20px;
327
+ height: 20px;
328
+ line-height: 20px;
329
+ border-radius: 15px;
330
+
331
+ text-align: center;
332
+
333
+ background: white;
334
+ border: solid 2px #ccc;
335
+
336
+ font-size: 9pt;
337
+ font-weight: 200;
338
+ font-style: normal;
339
+
340
+ position: absolute;
341
+ top: 14px;
342
+ left: 20px;
343
+ }
344
+
345
+ ul.frames .icon.application {
346
+ background: #808090;
347
+ border-color: #555;
348
+ }
349
+
350
+ ul.frames .icon.application:before {
351
+ content: 'A';
352
+ color: white;
353
+ text-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
354
+ }
355
+
356
+ /* Responsiveness -- flow to single-line mode */
357
+ @media screen and (max-width: 1100px) {
358
+ ul.frames li {
359
+ padding-top: 6px;
360
+ padding-bottom: 6px;
361
+ padding-left: 36px;
362
+ line-height: 1.3;
363
+ }
364
+
365
+ ul.frames li .icon {
366
+ width: 11px;
367
+ height: 11px;
368
+ line-height: 11px;
369
+
370
+ top: 7px;
371
+ left: 10px;
372
+ font-size: 5pt;
373
+ }
374
+
375
+ ul.frames .name,
376
+ ul.frames .location {
377
+ display: inline-block;
378
+ line-height: 1.3;
379
+ height: 1.3em;
380
+ }
381
+
382
+ ul.frames .name {
383
+ margin-right: 10px;
384
+ }
385
+ }
386
+
387
+ /* ---------------------------------------------------------------------
388
+ * Monospace
389
+ * --------------------------------------------------------------------- */
390
+
391
+ pre, code, .be-repl input, .be-repl .command-line span, textarea, .code_linenums {
392
+ font-family: menlo, lucida console, monospace;
393
+ font-size: 8pt;
394
+ }
395
+
396
+ /* ---------------------------------------------------------------------
397
+ * Display area
398
+ * --------------------------------------------------------------------- */
399
+
400
+ .trace_info {
401
+ background: #fff;
402
+ padding: 6px;
403
+ border-radius: 3px;
404
+ margin-bottom: 2px;
405
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.03), 1px 1px 0 rgba(0, 0, 0, 0.05), -1px 1px 0 rgba(0, 0, 0, 0.05), 0 0 0 4px rgba(0, 0, 0, 0.04);
406
+ }
407
+
408
+ .code_block{
409
+ background: #f1f1f1;
410
+ border-left: 1px solid #ccc;
411
+ }
412
+
413
+ /* Titlebar */
414
+ .trace_info .title {
415
+ background: #f1f1f1;
416
+
417
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
418
+ overflow: hidden;
419
+ padding: 6px 10px;
420
+
421
+ border: solid 1px #ccc;
422
+ border-bottom: 0;
423
+
424
+ border-top-left-radius: 2px;
425
+ border-top-right-radius: 2px;
426
+ }
427
+
428
+ .trace_info .title .name,
429
+ .trace_info .title .location {
430
+ font-size: 9pt;
431
+ line-height: 26px;
432
+ height: 26px;
433
+ overflow: hidden;
434
+ }
435
+
436
+ .trace_info .title .location {
437
+ float: left;
438
+ font-weight: bold;
439
+ font-size: 10pt;
440
+ }
441
+
442
+ .trace_info .title .location a {
443
+ color:inherit;
444
+ text-decoration:none;
445
+ border-bottom:1px solid #aaaaaa;
446
+ }
447
+
448
+ .trace_info .title .location a:hover {
449
+ border-color:#666666;
450
+ }
451
+
452
+ .trace_info .title .name {
453
+ float: right;
454
+ font-weight: 200;
455
+ }
456
+
457
+ .code, .be-console, .unavailable {
458
+ background: #fff;
459
+ padding: 5px;
460
+
461
+ box-shadow: inset 3px 3px 3px rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
462
+ }
463
+
464
+ .code_linenums{
465
+ background:#f1f1f1;
466
+ padding-top:10px;
467
+ padding-bottom:9px;
468
+ float:left;
469
+ }
470
+
471
+ .code_linenums span{
472
+ display:block;
473
+ padding:0 12px;
474
+ }
475
+
476
+ .code {
477
+ margin-bottom: -1px;
478
+ border-top-left-radius:2px;
479
+ padding: 10px 0;
480
+ overflow: auto;
481
+ }
482
+
483
+ .code pre{
484
+ padding-left:12px;
485
+ min-height:16px;
486
+ }
487
+
488
+ /* Source unavailable */
489
+ p.unavailable {
490
+ padding: 20px 0 40px 0;
491
+ text-align: center;
492
+ color: #b99;
493
+ font-weight: bold;
494
+ }
495
+
496
+ p.unavailable:before {
497
+ content: '\00d7';
498
+ display: block;
499
+
500
+ color: #daa;
501
+
502
+ text-align: center;
503
+ font-size: 40pt;
504
+ font-weight: normal;
505
+ margin-bottom: -10px;
506
+ }
507
+
508
+ @-webkit-keyframes highlight {
509
+ 0% { background: rgba(220, 30, 30, 0.3); }
510
+ 100% { background: rgba(220, 30, 30, 0.1); }
511
+ }
512
+ @-moz-keyframes highlight {
513
+ 0% { background: rgba(220, 30, 30, 0.3); }
514
+ 100% { background: rgba(220, 30, 30, 0.1); }
515
+ }
516
+ @keyframes highlight {
517
+ 0% { background: rgba(220, 30, 30, 0.3); }
518
+ 100% { background: rgba(220, 30, 30, 0.1); }
519
+ }
520
+
521
+ .code .highlight, .code_linenums .highlight {
522
+ background: rgba(220, 30, 30, 0.1);
523
+ -webkit-animation: highlight 400ms linear 1;
524
+ -moz-animation: highlight 400ms linear 1;
525
+ animation: highlight 400ms linear 1;
526
+ }
527
+
528
+ /* REPL shell */
529
+ .be-console {
530
+ padding: 0 1px 10px 1px;
531
+ border-bottom-left-radius: 2px;
532
+ border-bottom-right-radius: 2px;
533
+ }
534
+
535
+ .be-console pre {
536
+ padding: 10px 10px 0 10px;
537
+ max-height: 400px;
538
+ overflow-x: none;
539
+ overflow-y: auto;
540
+ margin-bottom: -3px;
541
+ word-wrap: break-word;
542
+ white-space: pre-wrap;
543
+ }
544
+
545
+ /* .command-line > span + input */
546
+ .be-console .command-line {
547
+ display: table;
548
+ width: 100%;
549
+ }
550
+
551
+ .be-console .command-line span,
552
+ .be-console .command-line input {
553
+ display: table-cell;
554
+ }
555
+
556
+ .be-console .command-line span {
557
+ width: 1%;
558
+ padding-right: 5px;
559
+ padding-left: 10px;
560
+ white-space: pre;
561
+ }
562
+
563
+ .be-console .command-line input {
564
+ width: 99%;
565
+ }
566
+
567
+ /* Input box */
568
+ .be-console input,
569
+ .be-console input:focus {
570
+ outline: 0;
571
+ border: 0;
572
+ padding: 0;
573
+ background: transparent;
574
+ margin: 0;
575
+ }
576
+
577
+ /* Hint text */
578
+ .hint {
579
+ margin: 15px 0 20px 0;
580
+ font-size: 8pt;
581
+ color: #8080a0;
582
+ padding-left: 20px;
583
+ }
584
+
585
+ .hint:before {
586
+ content: '\25b2';
587
+ margin-right: 5px;
588
+ opacity: 0.5;
589
+ }
590
+
591
+ /* ---------------------------------------------------------------------
592
+ * Variable infos
593
+ * --------------------------------------------------------------------- */
594
+
595
+ .sub {
596
+ padding: 10px 0;
597
+ margin: 10px 0;
598
+ }
599
+
600
+ .sub:before {
601
+ content: '';
602
+ display: block;
603
+ width: 100%;
604
+ height: 4px;
605
+
606
+ border-radius: 2px;
607
+ background: rgba(0, 150, 200, 0.05);
608
+ box-shadow: 1px 1px 0 rgba(255, 255, 255, 0.7), inset 0 0 0 1px rgba(0, 0, 0, 0.04), inset 2px 2px 2px rgba(0, 0, 0, 0.07);
609
+ }
610
+
611
+ .sub h3 {
612
+ color: #39a;
613
+ font-size: 1.1em;
614
+ margin: 10px 0;
615
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
616
+
617
+ -webkit-font-smoothing: antialiased;
618
+ }
619
+
620
+ .sub .inset {
621
+ overflow-y: auto;
622
+ }
623
+
624
+ .sub table {
625
+ table-layout: fixed;
626
+ }
627
+
628
+ .sub table td {
629
+ border-top: dotted 1px #ddd;
630
+ padding: 7px 1px;
631
+ }
632
+
633
+ .sub table td.name {
634
+ width: 150px;
635
+
636
+ font-weight: bold;
637
+ font-size: 0.8em;
638
+ padding-right: 20px;
639
+
640
+ word-wrap: break-word;
641
+ }
642
+
643
+ .sub table td pre {
644
+ max-height: 15em;
645
+ overflow-y: auto;
646
+ }
647
+
648
+ .sub table td pre {
649
+ width: 100%;
650
+
651
+ word-wrap: break-word;
652
+ white-space: normal;
653
+ }
654
+
655
+ /* "(object doesn't support inspect)" */
656
+ .sub .unsupported {
657
+ font-family: sans-serif;
658
+ color: #777;
659
+ }
660
+
661
+ /* ---------------------------------------------------------------------
662
+ * Scrollbar
663
+ * --------------------------------------------------------------------- */
664
+
665
+ nav.sidebar::-webkit-scrollbar,
666
+ .inset pre::-webkit-scrollbar,
667
+ .be-console pre::-webkit-scrollbar,
668
+ .code::-webkit-scrollbar {
669
+ width: 10px;
670
+ height: 10px;
671
+ }
672
+
673
+ .inset pre::-webkit-scrollbar-thumb,
674
+ .be-console pre::-webkit-scrollbar-thumb,
675
+ .code::-webkit-scrollbar-thumb {
676
+ background: #ccc;
677
+ border-radius: 5px;
678
+ }
679
+
680
+ nav.sidebar::-webkit-scrollbar-thumb {
681
+ background: rgba(0, 0, 0, 0.0);
682
+ border-radius: 5px;
683
+ }
684
+
685
+ nav.sidebar:hover::-webkit-scrollbar-thumb {
686
+ background-color: #999;
687
+ background: -webkit-linear-gradient(left, #aaa, #999);
688
+ }
689
+
690
+ .be-console pre:hover::-webkit-scrollbar-thumb,
691
+ .inset pre:hover::-webkit-scrollbar-thumb,
692
+ .code:hover::-webkit-scrollbar-thumb {
693
+ background: #888;
694
+ }
695
+ :javascript
696
+ (function() {
697
+ var elements = ["section", "nav", "header", "footer", "audio"];
698
+ for (var i = 0; i < elements.length; i++) {
699
+ document.createElement(elements[i]);
700
+ }
701
+ })();
702
+ :javascript
703
+ if (window.Turbolinks) {
704
+ for(var i=0; i < document.styleSheets.length; i++) {
705
+ if(document.styleSheets[i].href)
706
+ document.styleSheets[i].disabled = true;
707
+ }
708
+ if (window.Turbolinks.controller) {
709
+ // Turbolinks > 5 (see https://github.com/turbolinks/turbolinks/issues/6)
710
+ document.addEventListener("turbolinks:load", function restoreCSS(e) {
711
+ for(var i=0; i < document.styleSheets.length; i++) {
712
+ document.styleSheets[i].disabled = false;
713
+ }
714
+ document.removeEventListener("turbolinks:load", restoreCSS, false);
715
+ });
716
+ } else {
717
+ document.addEventListener("page:restore", function restoreCSS(e) {
718
+ for(var i=0; i < document.styleSheets.length; i++) {
719
+ document.styleSheets[i].disabled = false;
720
+ }
721
+ document.removeEventListener("page:restore", restoreCSS, false);
722
+ });
723
+ }
724
+ }
725
+ .top
726
+ %header.exception
727
+ %h2
728
+ %strong= exception_type
729
+ %span
730
+ at #{request_path}
731
+ %p= exception_message
732
+ %section.backtrace
733
+ %nav.sidebar
734
+ %nav.tabs
735
+ %a#application_frames{:href => "#"} Application Frames
736
+ %a#all_frames{:href => "#"} All Frames
737
+ %ul.frames
738
+ - backtrace_frames.each_with_index do |frame, index|
739
+ %li{:class => "#{frame.context}", "data-context" => "#{frame.context}", "data-index" => index}
740
+ %span.stroke
741
+ %i{:class => "icon #{frame.context}"}
742
+ .info
743
+ .name
744
+ %strong= frame.class_name
745
+ %span.method= frame.method_name
746
+ .location
747
+ %span.filename>= frame.pretty_path
748
+ , line
749
+ %span.line= frame.line
750
+ - backtrace_frames.each_with_index do |frame, index|
751
+ .frame_info{:id => "frame_info_#{index}", :style => "display:none;"}
752
+ :javascript
753
+ (function() {
754
+
755
+ var OID = "#{id}";
756
+
757
+ var previousFrame = null;
758
+ var previousFrameInfo = null;
759
+ var allFrames = document.querySelectorAll("ul.frames li");
760
+ var allFrameInfos = document.querySelectorAll(".frame_info");
761
+
762
+ function apiCall(method, opts, cb) {
763
+ var req = new XMLHttpRequest();
764
+ req.open("POST", "//" + window.location.host + "/__better_errors/" + OID + "/" + method, true);
765
+ req.setRequestHeader("Content-Type", "application/json");
766
+ req.send(JSON.stringify(opts));
767
+ req.onreadystatechange = function() {
768
+ if(req.readyState == 4) {
769
+ var res = JSON.parse(req.responseText);
770
+ cb(res);
771
+ }
772
+ };
773
+ }
774
+
775
+ function escapeHTML(html) {
776
+ return html.replace(/&/, "&amp;").replace(/</g, "&lt;");
777
+ }
778
+
779
+ function REPL(index) {
780
+ this.index = index;
781
+
782
+ var previousCommands = JSON.parse(localStorage.getItem("better_errors_previous_commands"));
783
+ if(previousCommands === null) {
784
+ localStorage.setItem("better_errors_previous_commands", JSON.stringify([]));
785
+ previousCommands = [];
786
+ }
787
+
788
+ this.previousCommandOffset = previousCommands.length;
789
+ }
790
+
791
+ REPL.all = [];
792
+
793
+ REPL.prototype.install = function(containerElement) {
794
+ this.container = containerElement;
795
+
796
+ this.promptElement = this.container.querySelector(".command-line .prompt");
797
+ this.inputElement = this.container.querySelector("input");
798
+ this.outputElement = this.container.querySelector("pre");
799
+
800
+ var self = this;
801
+ this.inputElement.onkeydown = function(ev) {
802
+ self.onKeyDown(ev);
803
+ };
804
+
805
+ this.setPrompt(">>");
806
+
807
+ REPL.all[this.index] = this;
808
+ }
809
+
810
+ REPL.prototype.focus = function() {
811
+ this.inputElement.focus();
812
+ };
813
+
814
+ REPL.prototype.setPrompt = function(prompt) {
815
+ this._prompt = prompt;
816
+ this.promptElement.innerHTML = escapeHTML(prompt);
817
+ };
818
+
819
+ REPL.prototype.getInput = function() {
820
+ return this.inputElement.value;
821
+ };
822
+
823
+ REPL.prototype.setInput = function(text) {
824
+ this.inputElement.value = text;
825
+
826
+ if(this.inputElement.setSelectionRange) {
827
+ // set cursor to end of input
828
+ this.inputElement.setSelectionRange(text.length, text.length);
829
+ }
830
+ };
831
+
832
+ REPL.prototype.writeRawOutput = function(output) {
833
+ this.outputElement.innerHTML += output;
834
+ this.outputElement.scrollTop = this.outputElement.scrollHeight;
835
+ };
836
+
837
+ REPL.prototype.writeOutput = function(output) {
838
+ this.writeRawOutput(escapeHTML(output));
839
+ };
840
+
841
+ REPL.prototype.sendInput = function(line) {
842
+ var self = this;
843
+ apiCall("eval", { "index": this.index, source: line }, function(response) {
844
+ if(response.error) {
845
+ self.writeOutput(response.error + "\n");
846
+ }
847
+ self.writeOutput(self._prompt + " ");
848
+ self.writeRawOutput(response.highlighted_input + "\n");
849
+ self.writeOutput(response.result);
850
+ self.setPrompt(response.prompt);
851
+ self.setInput(response.prefilled_input);
852
+ });
853
+ };
854
+
855
+ REPL.prototype.onEnterKey = function() {
856
+ var text = this.getInput();
857
+ if(text != "" && text !== undefined) {
858
+ var previousCommands = JSON.parse(localStorage.getItem("better_errors_previous_commands"));
859
+ this.previousCommandOffset = previousCommands.push(text);
860
+ if(previousCommands.length > 100) {
861
+ previousCommands.splice(0, 1);
862
+ this.previousCommandOffset -= 1;
863
+ }
864
+ localStorage.setItem("better_errors_previous_commands", JSON.stringify(previousCommands));
865
+ }
866
+ this.setInput("");
867
+ this.sendInput(text);
868
+ };
869
+
870
+ REPL.prototype.onNavigateHistory = function(direction) {
871
+ this.previousCommandOffset += direction;
872
+ var previousCommands = JSON.parse(localStorage.getItem("better_errors_previous_commands"));
873
+
874
+ if(this.previousCommandOffset < 0) {
875
+ this.previousCommandOffset = -1;
876
+ this.setInput("");
877
+ return;
878
+ }
879
+
880
+ if(this.previousCommandOffset >= previousCommands.length) {
881
+ this.previousCommandOffset = previousCommands.length;
882
+ this.setInput("");
883
+ return;
884
+ }
885
+
886
+ this.setInput(previousCommands[this.previousCommandOffset]);
887
+ };
888
+
889
+ REPL.prototype.onKeyDown = function(ev) {
890
+ if(ev.keyCode == 13) {
891
+ this.onEnterKey();
892
+ } else if(ev.keyCode == 38 || (ev.ctrlKey && ev.keyCode == 80)) {
893
+ // the user pressed the up arrow or Ctrl-P
894
+ this.onNavigateHistory(-1);
895
+ ev.preventDefault();
896
+ return false;
897
+ } else if(ev.keyCode == 40 || (ev.ctrlKey && ev.keyCode == 78)) {
898
+ // the user pressed the down arrow or Ctrl-N
899
+ this.onNavigateHistory(1);
900
+ ev.preventDefault();
901
+ return false;
902
+ }
903
+ };
904
+
905
+ function switchTo(el) {
906
+ if(previousFrameInfo) previousFrameInfo.style.display = "none";
907
+ previousFrameInfo = el;
908
+
909
+ el.style.display = "block";
910
+
911
+ var replInput = el.querySelector('.be-console input');
912
+ if (replInput) replInput.focus();
913
+ }
914
+
915
+ function selectFrameInfo(index) {
916
+ var el = allFrameInfos[index];
917
+ if(el) {
918
+ if (el.loaded) {
919
+ return switchTo(el);
920
+ }
921
+
922
+ apiCall("variables", { "index": index }, function(response) {
923
+ el.loaded = true;
924
+ if(response.error) {
925
+ el.innerHTML = "<h2 class='error'>" + escapeHTML(response.error) + "</h2>";
926
+ if(response.explanation) {
927
+ el.innerHTML += "<p class='explanation'>" + escapeHTML(response.explanation) + "</p>";
928
+ }
929
+ el.innerHTML += "<p><a target='_new' href='https://github.com/BetterErrors/better_errors'>More about Better Errors</a></p>";
930
+ } else {
931
+ el.innerHTML = response.html;
932
+
933
+ var repl = el.querySelector(".be-repl .be-console");
934
+ if(repl) {
935
+ new REPL(index).install(repl);
936
+ }
937
+ }
938
+ switchTo(el);
939
+ });
940
+ }
941
+ }
942
+
943
+ for(var i = 0; i < allFrames.length; i++) {
944
+ (function(i, el) {
945
+ var el = allFrames[i];
946
+ el.onclick = function() {
947
+ if(previousFrame) {
948
+ previousFrame.className = "";
949
+ }
950
+ el.className = "selected";
951
+ previousFrame = el;
952
+
953
+ selectFrameInfo(el.attributes["data-index"].value);
954
+ };
955
+ })(i);
956
+ }
957
+
958
+ // Click the first application frame
959
+ (
960
+ document.querySelector(".frames li.application") ||
961
+ document.querySelector(".frames li")
962
+ ).onclick();
963
+
964
+ // This is the second query performed for frames; maybe the 'allFrames' list
965
+ // currently used and this list can be better used to avoid the repetition:
966
+ var applicationFramesCount = document.querySelectorAll(
967
+ "ul.frames li[data-context=application]"
968
+ ).length;
969
+
970
+ var applicationFramesButtonIsInstalled = false;
971
+ var applicationFramesButton = document.getElementById("application_frames");
972
+ var allFramesButton = document.getElementById("all_frames");
973
+
974
+ // The application frames button only needs to be bound if
975
+ // there are actually any application frames to look at.
976
+ var installApplicationFramesButton = function() {
977
+ applicationFramesButton.onclick = function() {
978
+ allFramesButton.className = "";
979
+ applicationFramesButton.className = "selected";
980
+ for(var i = 0; i < allFrames.length; i++) {
981
+ if(allFrames[i].attributes["data-context"].value == "application") {
982
+ allFrames[i].style.display = "block";
983
+ } else {
984
+ allFrames[i].style.display = "none";
985
+ }
986
+ }
987
+ return false;
988
+ };
989
+
990
+ applicationFramesButtonIsInstalled = true;
991
+ }
992
+
993
+ allFramesButton.onclick = function() {
994
+ if(applicationFramesButtonIsInstalled) {
995
+ applicationFramesButton.className = "";
996
+ }
997
+
998
+ allFramesButton.className = "selected";
999
+ for(var i = 0; i < allFrames.length; i++) {
1000
+ allFrames[i].style.display = "block";
1001
+ }
1002
+ return false;
1003
+ };
1004
+
1005
+ // If there are no application frames, select the 'All Frames'
1006
+ // tab by default.
1007
+ if(applicationFramesCount > 0) {
1008
+ installApplicationFramesButton();
1009
+ applicationFramesButton.onclick();
1010
+ } else {
1011
+ applicationFramesButton.className = "disabled";
1012
+ applicationFramesButton.title = "No application frames available";
1013
+ allFramesButton.onclick();
1014
+ }
1015
+ })();