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
@@ -10,19 +10,33 @@ class Card
10
10
  if path
11
11
  @_card_source_root = path
12
12
  else
13
- @_card_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), "card", generator_name, "templates"))
13
+ @_card_source_root ||= File.expand_path(
14
+ File.join(File.dirname(__FILE__),
15
+ "card", generator_name, "templates")
16
+ )
14
17
  end
15
18
  end
16
19
 
17
20
  # Override Rails default banner (wagn is the command name).
18
21
  def banner
19
- "wagn generate #{namespace} #{arguments.map(&:usage) * ' '} [options]".gsub(/\s+/, " ")
22
+ usage_arguments = arguments.map(&:usage) * " "
23
+ text = "wagn generate #{namespace} #{usage_arguments} [options]"
24
+ text.gsub(/\s+/, " ")
20
25
  end
21
26
  end
22
27
 
23
28
  class NamedBase < ::Rails::Generators::NamedBase
24
29
  extend ClassMethods
30
+
31
+ def mod_path
32
+ @mod_path ||= begin
33
+ path_parts = ["mod", file_name]
34
+ path_parts.unshift Cardio.gem_root if options.core?
35
+ File.join(*path_parts)
36
+ end
37
+ end
25
38
  end
39
+
26
40
  class MigrationBase < ::ActiveRecord::Generators::Base
27
41
  extend ClassMethods
28
42
  end
@@ -8,19 +8,20 @@ class Card
8
8
  source_root File.expand_path("../templates", __FILE__)
9
9
 
10
10
  argument :module_name, required: true
11
- class_option "core", type: :boolean, aliases: "-c", default: false, group: :runtime,
11
+ class_option "core", type: :boolean, aliases: "-c",
12
+ default: false, group: :runtime,
12
13
  desc: "create format files in Card gem"
13
14
 
14
15
  def create_files
15
- mod_path = if options.core?
16
- File.join Cardio.gem_root, "mod", file_name
17
- else
18
- File.join "mod", file_name
19
- end
20
- format_path = File.join(mod_path, "format", "#{module_name}_format.rb")
21
- spec_path = File.join(mod_path, "spec", "format", "#{module_name}_format_spec.rb")
22
16
  template "format_template.erb", format_path
23
- template "format_spec_template.erb", spec_path
17
+ template "format_spec_template.erb", format_path("spec")
18
+ end
19
+
20
+ def format_path modifier=nil
21
+ suffix = modifier ? "_#{modifier}" : nil
22
+ filename = "#{module_name}_format#{suffix}.rb"
23
+ path_parts = [mod_path, modifier, "format", filename].compact
24
+ File.join(*path_parts)
24
25
  end
25
26
  end
26
27
  end
@@ -7,7 +7,8 @@ class Card
7
7
  class MigrationGenerator < MigrationBase
8
8
  source_root File.expand_path("../templates", __FILE__)
9
9
 
10
- class_option "core", type: :boolean, aliases: "-c", default: false, group: :runtime,
10
+ class_option "core", type: :boolean, aliases: "-c",
11
+ default: false, group: :runtime,
11
12
  desc: "Create card migration for card core"
12
13
 
13
14
  def create_migration_file
@@ -15,18 +16,22 @@ class Card
15
16
  mig_paths = Cardio.migration_paths(migration_type)
16
17
  raise "No migration directory for #{migration_type}" if mig_paths.blank?
17
18
  set_local_assigns!
18
- migration_template @migration_template, File.join(mig_paths.first, "#{file_name}.rb")
19
+ migration_template @migration_template,
20
+ File.join(mig_paths.first, "#{file_name}.rb")
19
21
  end
20
22
 
21
23
  protected
22
24
 
23
- # sets the default migration template that is being used for the generation of the migration
24
- # depending on the arguments which would be sent out in the command line, the migration template
25
+ # sets the default migration template that is being used for the
26
+ # generation of the migration
27
+ # depending on the arguments which would be sent out in the command line,
28
+ # the migration template
25
29
  # and the table name instance variables are setup.
26
30
 
27
31
  def set_local_assigns!
28
32
  @migration_template = "card_migration.erb"
29
- @migration_parent_class = options["core"] ? "Card::Migration::Core" : "Card::Migration"
33
+ @migration_parent_class =
34
+ options["core"] ? "Card::Migration::Core" : "Card::Migration"
30
35
  case file_name
31
36
  when /^(import)_(.*)(?:\.json)?/
32
37
  @migration_action = Regexp.last_match(1)
@@ -6,7 +6,7 @@ Example:
6
6
 
7
7
  This will create:
8
8
  mod/standard/set/type/tshirt.rb
9
- spec/mod/standard/set/type/tshirt_spec.rb
9
+ mod/standard/spec/set/type/tshirt_spec.rb
10
10
 
11
11
  wagn generate card:set standard type_plus_right basic about tshirt
12
12
 
@@ -9,19 +9,21 @@ class Card
9
9
 
10
10
  argument :set_pattern, required: true
11
11
  argument :anchors, required: true, type: :array
12
- class_option "core", type: :boolean, aliases: "-c", default: false, group: :runtime,
12
+ class_option "core", type: :boolean, aliases: "-c",
13
+ default: false, group: :runtime,
13
14
  desc: "create set files in Card gem"
14
15
 
15
16
  def create_files
16
- mod_path = if options.core?
17
- File.join Cardio.gem_root, "mod", file_name
18
- else
19
- File.join "mod", file_name
20
- end
21
- set_path = File.join(mod_path, "set", set_pattern, anchors[0..-2], "#{anchors.last}.rb")
22
- spec_path = File.join(mod_path, "spec", "set", set_pattern, anchors[0..-2], "#{anchors.last}_spec.rb")
23
17
  template "set_template.erb", set_path
24
- template "set_spec_template.erb", spec_path
18
+ template "set_spec_template.erb", set_path("spec")
19
+ end
20
+
21
+ def set_path modifier=nil
22
+ suffix = modifier ? "_#{modifier}" : nil
23
+ filename = "#{anchors.last}#{suffix}.rb"
24
+ dirs = anchors[0..-2]
25
+ path_parts = [mod_path, modifier, "set", set_pattern, dirs, filename]
26
+ File.join(*path_parts.compact)
25
27
  end
26
28
  end
27
29
  end
@@ -1,4 +1,3 @@
1
-
2
1
  include All::Permissions::Accounts
3
2
 
4
3
  card_accessor :email
@@ -30,12 +29,13 @@ def validate_token! test_token
30
29
  errors.empty?
31
30
  end
32
31
 
32
+ def refreshed_token # TODO: explain why needed
33
+ token_card.refresh(true).content
34
+ end
35
+
33
36
  format do
34
37
  view :verify_url do
35
- signup_name = card.cardname.left_name
36
- card_url "update/#{signup_name.url_key}" \
37
- "?token=#{card.token}" \
38
- "&live_token=true"
38
+ card_url path({ mark: card.cardname.left }.merge(token_path_opts))
39
39
  end
40
40
 
41
41
  view :verify_days do
@@ -43,9 +43,11 @@ format do
43
43
  end
44
44
 
45
45
  view :reset_password_url do
46
- card_url "update/#{card.cardname.url_key}" \
47
- "?token=#{card.token_card.refresh(true).content}" \
48
- "&live_token=true&event=reset_password"
46
+ card_url path({ mark: card, event: :reset_password }.merge(token_path_opts))
47
+ end
48
+
49
+ def token_path_opts
50
+ { action: :update, live_token: true, token: card.refreshed_token }
49
51
  end
50
52
 
51
53
  view :reset_password_days do
@@ -54,20 +56,14 @@ format do
54
56
  end
55
57
 
56
58
  format :html do
57
- view :raw do |args|
58
- content = []
59
- unless args[:no_email]
60
- content << "{{+#{Card[:email].name}|titled;title:email}}"
61
- end
62
- unless args[:no_password]
63
- content << "{{+#{Card[:password].name}|titled;title:password}}"
64
- end
65
- content * " "
59
+ view :raw do
60
+ %({{+#{Card[:email].name}|titled;title:email}}
61
+ {{+#{Card[:password].name}|titled;title:password}})
66
62
  end
67
63
 
68
- view :edit do |args|
69
- args[:structure] = true
70
- super args
64
+ view :edit do
65
+ voo.structure = true
66
+ super()
71
67
  end
72
68
  end
73
69
 
@@ -97,34 +93,36 @@ def confirm_ok?
97
93
  Card.new(type_id: Card.default_accounted_type_id).ok? :create
98
94
  end
99
95
 
100
- event :generate_confirmation_token, :prepare_to_store,
101
- on: :create,
102
- when: proc { |c| c.confirm_ok? } do
96
+ event :generate_confirmation_token,
97
+ :prepare_to_store, on: :create, when: :confirm_ok? do
103
98
  add_subfield :token, content: generate_token
104
99
  end
105
100
 
106
101
  event :reset_password,
107
- :prepare_to_validate, on: :update, when: proc { |c| c.reset_password? } do
108
- if validate_token! @env_token
109
- token_card.used!
110
- Auth.signin left_id
111
- success << edit_password_success_args
112
- else
113
- error_msg = errors.first.last
114
- send_reset_password_token
115
- msg = "Sorry, #{error_msg}. " \
116
- "Please check your email for a new password reset link."
117
- success << { id: "_self", view: "message", message: msg }
118
- end
102
+ :prepare_to_validate, on: :update, when: :reset_password? do
103
+ valid = validate_token! @env_token
104
+ success << (valid ? reset_password_success : reset_password_try_again)
119
105
  abort :success
120
106
  end
121
107
 
108
+ def reset_password_success
109
+ token_card.used!
110
+ Auth.signin left_id
111
+ { id: left.name, view: :related, related: { name: "+#{Card[:account].name}",
112
+ view: "edit" } }
113
+ end
114
+
115
+ def reset_password_try_again
116
+ send_reset_password_token
117
+ { id: "_self",
118
+ view: "message",
119
+ message: "Sorry, #{errors.first.last}. " \
120
+ "Please check your email for a new password reset link." }
121
+ end
122
+
123
+
122
124
  def edit_password_success_args
123
- {
124
- id: left.name,
125
- view: :related,
126
- related: { name: "+#{Card[:account].name}", view: "edit" }
127
- }
125
+
128
126
  end
129
127
 
130
128
  def reset_password?
@@ -27,7 +27,8 @@ def permanent?
27
27
  end
28
28
 
29
29
  def used!
30
- Auth.as_bot { delete! } unless permanent?
30
+ # immediate deletion was causing problems. commenting for now
31
+ # Auth.as_bot { delete! } unless permanent?
31
32
  end
32
33
 
33
34
  def term
@@ -1,80 +1,60 @@
1
1
 
2
2
  format :html do
3
- def item_links args
4
- [
5
- optional_render(:my_card, args),
6
- optional_render(:invite, args),
7
- optional_render(:sign_out, args),
8
- optional_render(:sign_up, args),
9
- optional_render(:sign_in, args)
10
- ]
11
- end
12
-
13
- view :sign_up, perms: ->(r) { r.show_signup_link? },
14
- denial: :blank do |args|
15
- link_to_card :signup, args[:link_text], args[:link_opts]
16
- end
17
-
18
- view :sign_in, perms: ->(_r) { !Auth.signed_in? },
19
- denial: :blank do |args|
20
- link_to_card :signin, args[:link_text], args[:link_opts]
21
- end
22
-
23
- view :sign_out, perms: ->(_r) { Auth.signed_in? },
24
- denial: :blank do |args|
25
- link_to_card :signin, args[:link_text], args[:link_opts]
3
+ def item_links _args=nil
4
+ [:my_card, :invite, :sign_out, :sign_up, :sign_in].map do |link_view|
5
+ optional_render link_view
6
+ end
26
7
  end
27
8
 
28
- view :invite, perms: ->(r) { r.show_invite_link? },
29
- denial: :blank do |args|
30
- link_to args[:link_text], args[:link_opts]
9
+ def self.link_options opts={}
10
+ options = { denial: :blank, cache: :never }.merge opts
11
+ options[:perms] = ->(r) { yield r } if block_given?
12
+ options.clone
31
13
  end
32
14
 
33
- view :my_card, perms: ->(_r) { Auth.signed_in? },
34
- denial: :blank do |_args|
35
- link_to_card Auth.current.cardname, nil, id: "my-card-link"
15
+ view :sign_up, link_options(&:show_signup_link?) do
16
+ link_to_card :signup, account_link_text(:sign_up),
17
+ class: classy("signup-link"),
18
+ path: { action: :new, mark: :signup }
36
19
  end
37
20
 
38
- def default_sign_up_args args
39
- account_link_text :sign_up, args
40
- account_link_opts "signup-link", args, action: :new, mark: :signup
21
+ view :sign_in, link_options { !Auth.signed_in? } do
22
+ link_to_card :signin, account_link_text(:sign_in),
23
+ class: classy("signin-link")
41
24
  end
42
25
 
43
- def default_sign_in_args args
44
- account_link_text :sign_in, args
45
- account_link_opts "signin-link", args
26
+ view :sign_out, link_options { Auth.signed_in? } do
27
+ link_to_card :signin, account_link_text(:sign_out),
28
+ class: classy("signout-link"),
29
+ path: { action: :delete }
46
30
  end
47
31
 
48
- def default_invite_args args
49
- account_link_text :invite, args
50
- account_link_opts "invite-a-friend-link", args, action: :new, mark: :signup
32
+ view :invite, link_options(&:show_invite_link?) do
33
+ link_to_card :signup, account_link_text(:invite),
34
+ class: classy("invite-link"),
35
+ path: { action: :new, mark: :signup }
51
36
  end
52
37
 
53
- def default_sign_out_args args
54
- account_link_text :sign_out, args
55
- account_link_opts "signout-link", args, action: :delete
38
+ view :my_card, link_options { Auth.signed_in? } do
39
+ link_to_card Auth.current.cardname, nil, id: "my-card-link"
56
40
  end
57
41
 
58
- def account_link_text purpose, args
59
- args[:link_text] =
60
- args.delete(:title) ||
42
+ def account_link_text purpose
43
+ voo.title ||
61
44
  I18n.t(purpose, scope: "mod.standard.set.self.account_links")
62
45
  end
63
46
 
64
- def account_link_opts id, args, path=nil
65
- args[:link_opts] ||= {}
66
- args[:link_opts][:id] ||= id
67
- args[:link_opts][:path] ||= path if path
47
+ view :raw do
48
+ item_links.join " "
68
49
  end
69
50
 
70
- view :raw do |args|
71
- item_links(args).join " "
72
- end
51
+ view(:navbar_right, cache: :never) { super() }
52
+
73
53
 
74
- view :core do |args|
54
+ view :core, cache: :never do
75
55
  status_class = Auth.signed_in? ? "logged-in" : "logged-out"
76
- content_tag :span, id: "logging", class: status_class do
77
- render_raw args
56
+ wrap_with :span, id: "logging", class: status_class do
57
+ render_raw
78
58
  end
79
59
  end
80
60
 
@@ -1,89 +1,105 @@
1
+ def consider_recaptcha?
2
+ false
3
+ end
1
4
 
2
5
  format :html do
3
- view :open do |args|
4
- args[:optional_help] = :show
5
- super args
6
+ view :open do
7
+ voo.show :help
8
+ super()
6
9
  end
7
10
 
8
- def default_title_args args
9
- args[:title] ||= I18n.t(:sign_in_title, # 'Sign In'
10
- scope: "mod.standard.set.self.signin")
11
+ # FIXME: need a generic solution for this
12
+ view :title do
13
+ voo.title ||= I18n.t(:sign_in_title, scope: "mod.standard.set.self.signin")
14
+ super()
11
15
  end
12
16
 
13
- view :open_content do |args|
17
+ view :open_content do
14
18
  # annoying step designed to avoid table of contents. sigh
15
- _render_core(args)
19
+ _render_core
16
20
  end
17
21
 
18
- view :closed_content do |_args|
22
+ view :closed_content do
19
23
  ""
20
24
  end
21
25
 
22
- def default_core_args args={}
23
- # 'Sign in' '...or sign up!' 'RESET PASSWORD'
24
- sign_in, or_sign_up, reset_password =
25
- I18n.t([:sign_in, :or_sign_up, :reset_password],
26
- scope: "mod.standard.set.self.signin")
27
- # since i18n-tasks doesn't understand bulk lookups, tell it keys are used
28
- # i18n-tasks-use t(:sign_in, scope: 'mod.standard.set.self.signin')
29
- # i18n-tasks-use t(:or_sign_up, scope: 'mod.standard.set.self.signin')
30
- # i18n-tasks-use t(:reset_password,
31
- # scope: 'mod.standard.set.self.signin')
32
- args[:buttons] = button_tag sign_in, situation: "primary"
33
- subformat(Card[:account_links]).render :sign_up, title: or_sign_up
34
- reset_link = link_to_view :edit, reset_password,
35
- path: { slot: { hide: :toolbar } }
36
- args[:buttons] += raw("<div style='float:right'>#{reset_link}</div>")
37
- # FIXME: hardcoded styling
38
- args
39
- end
40
-
41
- view :core do |args|
42
- form_args = {
43
- hidden: { success: "REDIRECT: #{Env.interrupted_action || '*previous'}" },
44
- recaptcha: :off
45
- }
26
+ view :core, cache: :never do
27
+ voo.structure = true
46
28
  with_nest_mode :edit do
47
- card_form :update, form_args do
29
+ card_form :update, recaptcha: :off do
48
30
  [
49
- _optional_render(:content_formgroup, args.merge(structure: true)),
50
- _optional_render(:button_formgroup, args)
51
- ].join
31
+ hidden_signin_fields,
32
+ _optional_render_content_formgroup,
33
+ _optional_render_signin_buttons
34
+ ]
52
35
  end
53
36
  end
54
37
  end
55
38
 
39
+ def hidden_signin_fields
40
+ hidden_field_tag :success,
41
+ "REDIRECT: #{Env.interrupted_action || '*previous'}"
42
+ end
43
+
44
+ view :signin_buttons do
45
+ button_formgroup do
46
+ [signin_button, signup_link, reset_password_link]
47
+ end
48
+ end
49
+
50
+ def signin_button
51
+ text = I18n.t :sign_in, scope: "mod.standard.set.self.signin"
52
+ button_tag text, situation: "primary"
53
+ end
54
+
55
+ def signup_link
56
+ text = I18n.t :or_sign_up, scope: "mod.standard.set.self.signin"
57
+ subformat(Card[:account_links]).render :sign_up, title: text
58
+ end
59
+
60
+ def reset_password_link
61
+ text = I18n.t :reset_password, scope: "mod.standard.set.self.signin"
62
+ reset_link = link_to_view :edit, text, path: { slot: { hide: :toolbar } }
63
+ # FIXME: inline styling
64
+ raw("<div style='float:right'>#{reset_link}</div>")
65
+ end
66
+
56
67
  # FORGOT PASSWORD
57
- view :edit do |args|
68
+ view :edit do
58
69
  @forgot_password = true
59
- args.merge!(
60
- title: I18n.t(:forgot_password, # 'Forgot Password'
61
- scope: "mod.standard.set.self.signin"),
62
- optional_help: :hide,
63
- buttons: button_tag(I18n.t(:reset_my_password, # 'Reset my password'
64
- scope: "mod.standard.set.self.signin"),
65
- situation: "primary"),
66
- structure: true,
67
- hidden: {
68
- reset_password: true,
69
- success: { view: :reset_password_success }
70
- }
70
+ voo.title ||= card.i18n_signin(:forgot_password)
71
+ voo.structure ||= true
72
+ voo.hide :help
73
+ Auth.as_bot { super() }
74
+ end
75
+
76
+ def edit_view_hidden
77
+ hidden_tags(
78
+ reset_password: true,
79
+ success: { view: :reset_password_success }
71
80
  )
72
- Auth.as_bot { super args }
73
81
  end
74
82
 
75
- view :raw do |_args|
76
- if @forgot_password
77
- "{{+#{Card[:email].name}|title:email;type:Phrase}}"
78
- else
79
- %(
80
- {{+#{Card[:email].name}|titled;title:email}}
81
- {{+#{Card[:password].name}|titled;title:password}}
82
- )
83
- end
83
+ view :edit_buttons do
84
+ text = I18n.t :reset_my_password, scope: "mod.standard.set.self.signin"
85
+ button_tag text, situation: "primary"
86
+ end
87
+
88
+ view :content_formgroup do
89
+ fields = [signin_field(:email)]
90
+ fields << signin_field(:password) unless @forgot_password
91
+ voo.edit_structure = fields
92
+
93
+ super()
94
+ end
95
+
96
+ def signin_field name
97
+ nest_name = "".to_name.trait(name)
98
+ [nest_name, { title: name.to_s, view: "titled",
99
+ nest_name: nest_name, skip_perms: true }]
84
100
  end
85
101
 
86
- view :reset_password_success do |_args|
102
+ view :reset_password_success do
87
103
  # 'Check your email for a link to reset your password'
88
104
  frame { I18n.t(:check_email, scope: "mod.standard.set.self.signin") }
89
105
  end
@@ -95,57 +111,55 @@ event :signin, :validate, on: :update do
95
111
  pword = subfield :password
96
112
  pword &&= pword.content
97
113
 
98
- unless email && pword
99
- abort :failure, I18n.t(:abort_bad_signin_args, # 'bad signin args'
100
- scope: "mod.standard.set.self.signin")
101
- end
114
+ authenticate_or_abort email, pword
115
+ end
102
116
 
117
+ def authenticate_or_abort email, pword
118
+ abort :failure, i18n_signin(:abort_bad_signin_args) unless email && pword
103
119
  if (account = Auth.authenticate(email, pword))
104
120
  Auth.signin account.left_id
105
121
  else
106
122
  account = Auth.find_account_by_email email
107
- error_msg =
108
- case
109
- when account.nil? then
110
- # 'Unrecognized email.'
111
- I18n.t(:error_unknown_email, scope: "mod.standard.set.self.signin")
112
- when !account.active? then
113
- # 'Sorry, that account is not active.'
114
- I18n.t(:error_not_active, scope: "mod.standard.set.self.signin")
115
- else
116
- # 'Wrong password'
117
- I18n.t(:error_wrong_password, scope: "mod.standard.set.self.signin")
118
- end
119
- errors.add :signin, error_msg
123
+ errors.add :signin, signin_error_message(account)
120
124
  abort :failure
121
125
  end
122
126
  end
123
127
 
128
+ def signin_error_message account
129
+ case
130
+ when account.nil? then i18n_signin(:error_unknown_email)
131
+ when !account.active? then i18n_signin(:error_not_active)
132
+ else i18n_signin(:error_wrong_password)
133
+ end
134
+ end
135
+
136
+ def i18n_signin key
137
+ I18n.t key, scope: "mod.standard.set.self.signin"
138
+ end
139
+
124
140
  event :signin_success, after: :signin do
125
141
  abort :success
126
142
  end
127
143
 
128
- event :send_reset_password_token,
129
- before: :signin, on: :update,
130
- when: proc { Env.params[:reset_password] } do
144
+ event :send_reset_password_token, before: :signin, on: :update,
145
+ when: proc { Env.params[:reset_password] } do
131
146
  email = subfield :email
132
147
  email &&= email.content
133
148
 
134
149
  account = Auth.find_account_by_email email
135
- if account
136
- if account.active?
137
- account.send_reset_password_token
138
- abort :success
139
- else
140
- errors.add :account, I18n.t(:error_not_active, # 'not active'
141
- scope: "mod.standard.set.self.signin")
142
- abort :failure
143
- end
150
+ send_reset_password_email_or_fail account
151
+ end
152
+
153
+ def send_reset_password_email_or_fail account
154
+ if account && account.active?
155
+ account.send_reset_password_token
156
+ abort :success
157
+ elsif account
158
+ errors.add :account, i18n_signin(:error_not_active)
144
159
  else
145
- errors.add :email, I18n.t(:error_not_recognized, # 'not recognized'
146
- scope: "mod.standard.set.self.signin")
147
- abort :failure
160
+ errors.add :email, i18n_signin(:error_not_recognized)
148
161
  end
162
+ abort :failure
149
163
  end
150
164
 
151
165
  event :signout, :validate, on: :delete do