card 1.20.4 → 1.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/card.gemspec +9 -9
  4. data/db/migrate_core_cards/20170515101262_add_advanced_edit_cards.rb +20 -0
  5. data/db/migrate_core_cards/20170608083819_add_full_width_layout_card.rb +23 -0
  6. data/db/migrate_core_cards/20170608200649_add_input_options_codename.rb +8 -0
  7. data/db/seed/new/card_actions.yml +783 -791
  8. data/db/seed/new/card_acts.yml +65 -47
  9. data/db/seed/new/card_changes.yml +3198 -3177
  10. data/db/seed/new/card_references.yml +604 -534
  11. data/db/seed/new/cards.yml +2355 -2256
  12. data/db/seed/test/fixtures/card_actions.yml +1795 -1803
  13. data/db/seed/test/fixtures/card_acts.yml +264 -246
  14. data/db/seed/test/fixtures/card_changes.yml +6275 -6184
  15. data/db/seed/test/fixtures/card_references.yml +1305 -1263
  16. data/db/seed/test/fixtures/cards.yml +3393 -3298
  17. data/db/seed/test/seed.rb +2 -2
  18. data/db/version_core_cards.txt +1 -1
  19. data/lib/card.rb +4 -0
  20. data/lib/card/act_manager/subdirector_array.rb +1 -0
  21. data/lib/card/auth/current.rb +7 -3
  22. data/lib/card/env.rb +5 -0
  23. data/lib/card/env/success.rb +1 -1
  24. data/lib/card/format/names.rb +3 -13
  25. data/lib/card/model/save_helper.rb +4 -6
  26. data/lib/card/query.rb +2 -1
  27. data/lib/card/query/attributes.rb +34 -14
  28. data/lib/card/query/value.rb +3 -4
  29. data/lib/card/set/format.rb +29 -4
  30. data/lib/card/set/format/haml_views.rb +25 -13
  31. data/lib/card/set/trait.rb +1 -0
  32. data/lib/card/set_pattern.rb +17 -1
  33. data/lib/card/subcards.rb +3 -2
  34. data/lib/generators/card/format/format_generator.rb +2 -0
  35. data/lib/generators/card/set/set_generator.rb +2 -0
  36. data/lib/generators/card/template/USAGE +10 -0
  37. data/lib/generators/card/template/template_generator.rb +46 -0
  38. data/lib/generators/card/template/templates/haml_template.erb +1 -0
  39. data/mod/Modfile +1 -1
  40. data/mod/account/set/all/account.rb +9 -5
  41. data/mod/account/set/right/account.rb +17 -5
  42. data/mod/account/set/self/account_links.rb +1 -2
  43. data/mod/account/set/type/signup.rb +4 -5
  44. data/mod/account/set/type/user.rb +1 -1
  45. data/mod/account/spec/set/all/account_spec.rb +2 -2
  46. data/mod/account/spec/set/right/account_spec.rb +2 -2
  47. data/mod/account/spec/set/right/email_spec.rb +1 -1
  48. data/mod/account/spec/set/right/password_spec.rb +1 -1
  49. data/mod/account/spec/set/self/signin_spec.rb +2 -2
  50. data/mod/account/spec/set/type/signup_spec.rb +4 -0
  51. data/mod/ace_editor/set/abstract/ace_editor.rb +6 -3
  52. data/mod/ace_editor/set/self/script_ace.rb +1 -0
  53. data/mod/admin/set/self/admin.rb +1 -1
  54. data/mod/admin/set/self/version.rb +1 -0
  55. data/mod/basic_formats/format/css_format.rb +1 -0
  56. data/mod/basic_formats/format/csv_format.rb +1 -0
  57. data/mod/basic_formats/format/file_format.rb +1 -0
  58. data/mod/basic_formats/format/js_format.rb +1 -0
  59. data/mod/basic_formats/format/json_format.rb +1 -0
  60. data/mod/basic_formats/format/rss_format.rb +1 -0
  61. data/mod/basic_formats/format/xml_format.rb +1 -0
  62. data/mod/basic_formats/set/all/all_csv.rb +1 -1
  63. data/mod/basic_formats/set/all/base.rb +11 -3
  64. data/mod/basic_formats/set/all/json.rb +50 -8
  65. data/mod/basic_formats/set/all/rss.rb +21 -7
  66. data/mod/basic_formats/set/self/01_head/javascript.rb +1 -1
  67. data/mod/basic_formats/set/self/head.rb +1 -1
  68. data/mod/basic_formats/spec/set/all/base_spec.rb +13 -0
  69. data/mod/basic_types/set/type/html.rb +6 -2
  70. data/mod/basic_types/set/type/plain_text.rb +2 -3
  71. data/mod/bootstrap/lib/bootstrap.rb +2 -2
  72. data/mod/bootstrap/lib/bootstrap/basic_tags.rb +1 -1
  73. data/mod/bootstrap/lib/bootstrap/component.rb +2 -3
  74. data/mod/bootstrap/lib/bootstrap/component/form.rb +6 -5
  75. data/mod/bootstrap/lib/bootstrap/component/horizontal_form.rb +1 -1
  76. data/mod/bootstrap/lib/bootstrap/component/layout.rb +3 -3
  77. data/mod/bootstrap/lib/bootstrap/component_loader.rb +0 -2
  78. data/mod/bootstrap/lib/bootstrap/delegate.rb +2 -2
  79. data/mod/bootstrap/lib/bootstrapper.rb +1 -1
  80. data/mod/bootstrap/set/all/bootstrap/accordion.rb +1 -1
  81. data/mod/bootstrap/set/all/bootstrap/form.rb +2 -2
  82. data/mod/bootstrap/set/all/bootstrap/helper.rb +1 -0
  83. data/mod/bootstrap/set/all/bootstrap/wrapper.rb +1 -1
  84. data/mod/bootstrap/set/self/bootstrap_js.rb +1 -1
  85. data/mod/bootstrap/set/self/bootswatch_shared.rb +6 -6
  86. data/mod/bootstrap/set/self/script_mods.rb +1 -1
  87. data/mod/bootstrap/spec/set/all/bootstrap/bootstrap_builder_spec.rb +7 -6
  88. data/mod/bootstrap/spec/set/all/bootstrap/bootstrap_spec.rb +2 -1
  89. data/mod/bootstrap/spec/set/all/bootstrap/form_spec.rb +6 -3
  90. data/mod/bootstrap/spec/set/all/bootstrap/layout_spec.rb +3 -2
  91. data/mod/carrierwave/set/abstract/attachment.rb +1 -3
  92. data/mod/carrierwave/set/abstract/attachment/paths.rb +1 -1
  93. data/mod/carrierwave/set/abstract/attachment/storage_type.rb +11 -1
  94. data/mod/carrierwave/set/type/file.rb +3 -3
  95. data/mod/carrierwave/spec/lib/carrier_wave/file_card_uploader_spec.rb +3 -0
  96. data/mod/carrierwave/spec/set/type/file_spec.rb +24 -6
  97. data/mod/carrierwave/spec/set/type/image_spec.rb +3 -0
  98. data/mod/core/chunk/link.rb +1 -1
  99. data/mod/core/chunk/nest.rb +2 -1
  100. data/mod/core/chunk/query_reference.rb +1 -1
  101. data/mod/core/chunk/reference.rb +1 -0
  102. data/mod/core/chunk/uri.rb +4 -3
  103. data/mod/core/set/abstract/lock.rb +26 -0
  104. data/mod/core/set/all/assign_attributes.rb +8 -4
  105. data/mod/core/set/all/collection.rb +16 -7
  106. data/mod/core/set/all/content.rb +6 -0
  107. data/mod/core/set/all/event.rb +1 -1
  108. data/mod/core/set/all/fetch.rb +2 -2
  109. data/mod/core/set/all/haml.rb +5 -15
  110. data/mod/core/set/all/initialize.rb +2 -2
  111. data/mod/core/set/all/name.rb +1 -1
  112. data/mod/core/set/all/permissions.rb +28 -16
  113. data/mod/core/set/all/rules.rb +1 -2
  114. data/mod/core/set/all/subcards.rb +3 -3
  115. data/mod/core/set/all/templating.rb +5 -1
  116. data/mod/core/set/all/trash.rb +1 -1
  117. data/mod/core/set/all/utils.rb +1 -1
  118. data/mod/core/spec/set/all/actify_spec.rb +1 -1
  119. data/mod/core/spec/set/all/assign_attributes_spec.rb +2 -2
  120. data/mod/core/spec/set/all/collection_spec.rb +6 -3
  121. data/mod/core/spec/set/all/export_spec.rb +40 -112
  122. data/mod/core/spec/set/all/name_spec.rb +1 -1
  123. data/mod/core/spec/set/all/permissions_spec.rb +7 -7
  124. data/mod/core/spec/set/all/rules2_spec.rb +25 -25
  125. data/mod/core/spec/set/all/rules_spec.rb +2 -7
  126. data/mod/developer/set/all/event_viz.rb +1 -1
  127. data/mod/developer/set/right/debug.rb +1 -1
  128. data/mod/history/lib/card/act.rb +1 -0
  129. data/mod/history/lib/card/act/act_renderer.rb +23 -20
  130. data/mod/history/lib/card/act/act_renderer/absolute_act_renderer.rb +0 -1
  131. data/mod/history/lib/card/act/act_renderer/relative_act_renderer.rb +1 -0
  132. data/mod/history/lib/card/action.rb +1 -1
  133. data/mod/history/lib/card/action/action_renderer.rb +2 -2
  134. data/mod/history/lib/card/change.rb +2 -1
  135. data/mod/history/set/all/action_view.rb +1 -1
  136. data/mod/history/set/all/content_history.rb +7 -4
  137. data/mod/history/set/all/history.rb +6 -6
  138. data/mod/machines/file/all_script_machine_output/file.js +50 -34
  139. data/mod/machines/file/all_style_machine_output/file.css +1 -1
  140. data/mod/machines/lib/javascript/wagn.js.coffee +29 -18
  141. data/mod/machines/lib/javascript/wagn_layout.js.coffee +7 -3
  142. data/mod/machines/lib/stylesheets/style_cards.scss +10 -10
  143. data/mod/machines/set/abstract/machine.rb +5 -28
  144. data/mod/machines/set/abstract/script.rb +7 -4
  145. data/mod/machines/set/all/reset_machines.rb +1 -1
  146. data/mod/machines/set/self/script_jquery_helper.rb +2 -2
  147. data/mod/machines/set/self/script_slot.rb +1 -1
  148. data/mod/machines/set/type/coffee_script.rb +3 -2
  149. data/mod/machines/set/type/css.rb +7 -3
  150. data/mod/machines/set/type/scss.rb +7 -1
  151. data/mod/machines/spec/set/type/coffeescript_spec.rb +1 -1
  152. data/mod/machines/spec/set/type/javascript_spec.rb +1 -1
  153. data/mod/machines/spec/set/type/scss_spec.rb +3 -2
  154. data/mod/machines/spec/set/type/skin_spec.rb +1 -1
  155. data/mod/machines/spec/shared_examples/machine.rb +5 -3
  156. data/mod/machines/spec/shared_examples/machine_input.rb +1 -0
  157. data/mod/notifications/format/email_html_format.rb +1 -0
  158. data/mod/notifications/set/all/follow.rb +1 -1
  159. data/mod/notifications/set/all/observer.rb +1 -1
  160. data/mod/notifications/set/all/send_notifications.rb +2 -2
  161. data/mod/notifications/set/self/follow_defaults.rb +3 -8
  162. data/mod/notifications/set/type/email_template/email_config.rb +2 -2
  163. data/mod/notifications/set/type_plus_right/user/follow.rb +2 -2
  164. data/mod/notifications/spec/set/all/follow_spec.rb +7 -0
  165. data/mod/notifications/spec/set/all/notify_spec.rb +3 -0
  166. data/mod/notifications/spec/set/all/observer_spec.rb +1 -1
  167. data/mod/notifications/spec/set/right/followers_spec.rb +1 -0
  168. data/mod/pointer/set/abstract/00_paging_params.rb +11 -0
  169. data/mod/pointer/set/abstract/{00_paging.rb → 01_paging.rb} +10 -6
  170. data/mod/pointer/set/abstract/{00_paging → 01_paging}/paging_links.rb +0 -0
  171. data/mod/pointer/set/abstract/{01_pointer.rb → 02_pointer.rb} +26 -5
  172. data/mod/pointer/set/abstract/{01_pointer → 02_pointer}/edit.rb +3 -5
  173. data/mod/pointer/set/self/input_options.rb +12 -0
  174. data/mod/pointer/spec/set/self/input_options_spec.rb +8 -0
  175. data/mod/pointer/spec/set/type/pointer_spec.rb +3 -2
  176. data/mod/prosemirror_editor/set/abstract/prosemirror_editor.rb +1 -1
  177. data/mod/prosemirror_editor/set/self/script_prosemirror.rb +1 -0
  178. data/mod/settings/lib/card/setting.rb +1 -2
  179. data/mod/settings/set/abstract/permission.rb +1 -1
  180. data/mod/settings/set/self/add_help.rb +1 -1
  181. data/mod/settings/set/self/autoname.rb +1 -1
  182. data/mod/settings/set/self/csv_structure.rb +2 -0
  183. data/mod/settings/set/self/help.rb +1 -1
  184. data/mod/settings/set/self/input.rb +1 -2
  185. data/mod/settings/set/self/options.rb +2 -2
  186. data/mod/settings/set/self/options_label.rb +2 -2
  187. data/mod/settings/set/type/setting.rb +1 -1
  188. data/mod/settings/spec/set/right/script_spec.rb +1 -1
  189. data/mod/settings/spec/set/right/style_spec.rb +1 -1
  190. data/mod/solid_cache/set/abstract/solid_cache.rb +5 -3
  191. data/mod/solid_cache/spec/set/abstract/solid_cache_spec.rb +4 -3
  192. data/mod/standard/set/abstract/01_search_params.rb +4 -3
  193. data/mod/standard/set/abstract/search.rb +2 -1
  194. data/mod/standard/set/abstract/toolbar_split_button.rb +22 -0
  195. data/mod/standard/set/all/links.rb +3 -3
  196. data/mod/standard/set/all/rich_html/classy.rb +37 -0
  197. data/mod/standard/set/all/rich_html/editing.rb +6 -2
  198. data/mod/standard/set/all/rich_html/editor.rb +50 -0
  199. data/mod/standard/set/all/rich_html/form.rb +19 -12
  200. data/mod/standard/set/all/rich_html/form_elements.rb +2 -2
  201. data/mod/standard/set/all/rich_html/formgroup.rb +2 -1
  202. data/mod/standard/set/all/rich_html/header.rb +2 -27
  203. data/mod/standard/set/all/rich_html/menu.rb +1 -1
  204. data/mod/standard/set/all/rich_html/new.rb +5 -1
  205. data/mod/standard/set/all/rich_html/toolbar.rb +15 -60
  206. data/mod/standard/set/all/rich_html/wrapper.rb +6 -3
  207. data/mod/standard/set/right/when_created.rb +2 -2
  208. data/mod/standard/set/rstar/rules_editor.rb +10 -7
  209. data/mod/standard/set/self/activity_toolbar_button.rb +14 -0
  210. data/mod/standard/set/self/recent.rb +7 -2
  211. data/mod/standard/set/self/rules_toolbar_button.rb +42 -0
  212. data/mod/standard/set/self/search.rb +19 -6
  213. data/mod/standard/set/type/basic.rb +6 -6
  214. data/mod/standard/set/type/cardtype.rb +7 -3
  215. data/mod/standard/set/type/date.rb +2 -4
  216. data/mod/standard/set/type/layout_type.rb +1 -0
  217. data/mod/standard/set/type/list.rb +1 -1
  218. data/mod/standard/set/type/listed_by.rb +1 -2
  219. data/mod/standard/set/type/number.rb +4 -2
  220. data/mod/standard/set/type/phrase.rb +4 -2
  221. data/mod/standard/set/type/search_type.rb +11 -3
  222. data/mod/standard/set/type/set.rb +8 -8
  223. data/mod/standard/set/type/toggle.rb +1 -3
  224. data/mod/standard/set/type/uri.rb +6 -2
  225. data/mod/standard/spec/chunk/include_spec.rb +3 -2
  226. data/mod/standard/spec/chunk/query_reference_spec.rb +2 -2
  227. data/mod/standard/spec/set/all/history_spec.rb +1 -0
  228. data/mod/standard/spec/set/all/links_spec.rb +1 -0
  229. data/mod/standard/spec/set/all/rich_html/toolbar_spec.rb +2 -0
  230. data/mod/standard/spec/set/self/activity_toolbar_button_spec.rb +22 -0
  231. data/mod/standard/spec/set/type/email_template/email_config_spec.rb +10 -8
  232. data/mod/standard/spec/set/type/email_template_spec.rb +1 -0
  233. data/mod/standard/spec/set/type/list_spec.rb +2 -0
  234. data/mod/standard/spec/set/type/listed_by_spec.rb +5 -0
  235. data/mod/standard/spec/set/type/search_type_spec.rb +1 -1
  236. data/mod/standard/spec/set/type/toggle_spec.rb +1 -2
  237. data/mod/standard/spec/set/type/uri_spec.rb +0 -1
  238. data/mod/tinymce_editor/db/migrate_cards/20160804112560_add_tinymce_cards.rb +3 -1
  239. data/mod/tinymce_editor/set/abstract/tinymce_editor.rb +1 -1
  240. data/mod/tinymce_editor/set/self/script_tinymce.rb +1 -0
  241. data/mod/twitter/db/migrate_cards/20170305112346_add_twitter_cards.rb +1 -1
  242. data/mod/twitter/set/type/twitter_template.rb +1 -1
  243. data/spec/lib/card/format_spec.rb +26 -7
  244. data/spec/lib/card/loader_spec.rb +96 -35
  245. data/spec/lib/card/query_spec.rb +0 -1
  246. data/spec/support/card_spec_loader.rb +1 -0
  247. data/spec/support/helper/card_helper.rb +0 -36
  248. data/spec/support/helper/set_helper.rb +80 -0
  249. data/spec/support/matchers.rb +74 -0
  250. data/tmpsets/set/mod001-core/all/actify.rb +5 -6
  251. data/tmpsets/set/mod001-core/all/fetch.rb +14 -12
  252. data/tmpsets/set/mod001-core/all/name.rb +1 -1
  253. data/tmpsets/set/mod001-core/all/permissions.rb +12 -22
  254. data/tmpsets/set/mod001-core/all/tracked_attributes.rb +76 -0
  255. data/tmpsets/set/mod001-core/all/utils.rb +40 -3
  256. data/tmpsets/set/mod002-history/all/history.rb +1 -2
  257. data/tmpsets/set/mod008-solid_cache/abstract/solid_cache.rb +1 -1
  258. data/tmpsets/set/mod013-carrierwave/abstract/attachment.rb +282 -0
  259. data/tmpsets/set/mod013-carrierwave/type/file.rb +155 -0
  260. data/tmpsets/set/mod013-carrierwave/type/image.rb +96 -0
  261. data/tmpsets/set/mod014-admin/self/admin.rb +113 -0
  262. data/tmpsets/set/mod014-admin/self/admin_info.rb +110 -0
  263. data/tmpsets/set/mod014-admin/self/version.rb +15 -0
  264. data/tmpsets/set/mod015-developer/all/event_viz.rb +59 -0
  265. data/tmpsets/set/mod015-developer/all/view_viz.rb +30 -0
  266. data/tmpsets/set/mod015-developer/right/debug.rb +96 -0
  267. metadata +52 -22
@@ -1,8 +1,8 @@
1
1
  # -*- encoding : utf-8 -*-
2
+
2
3
  require "sass"
3
4
  include_set Abstract::Machine
4
5
  include_set Abstract::MachineInput
5
- include_set Abstract::AceEditor
6
6
 
7
7
  store_machine_output filetype: "css"
8
8
 
@@ -36,8 +36,12 @@ format do
36
36
  end
37
37
 
38
38
  format :html do
39
- def default_editor_args args
40
- args[:ace_mode] = "css"
39
+ def editor
40
+ :ace_editor
41
+ end
42
+
43
+ def ace_mode
44
+ :css
41
45
  end
42
46
 
43
47
  def default_nest_view
@@ -2,7 +2,7 @@ include_set Type::Css
2
2
 
3
3
  format do
4
4
  view :core, cache: :never do |_args|
5
- compile_scss(process_content _render_raw)
5
+ compile_scss(process_content(_render_raw))
6
6
  end
7
7
 
8
8
  def compile_scss scss, style=:expanded
@@ -12,3 +12,9 @@ format do
12
12
  "#{e.message}"
13
13
  end
14
14
  end
15
+
16
+ format :html do
17
+ def ace_mode
18
+ :scss
19
+ end
20
+ end
@@ -6,7 +6,7 @@ describe Card::Set::Type::CoffeeScript do
6
6
  let(:changed_coffee) { 'alert "Hello" ' }
7
7
  let(:compressed_changed_coffee) { '(function(){alert("Hello")}).call(this);' }
8
8
 
9
- it_should_behave_like "content machine", that_produces: :js do
9
+ it_behaves_like "content machine", that_produces: :js do
10
10
  let(:machine_card) do
11
11
  Card.gimme! "coffee machine", type: Card::CoffeeScriptID,
12
12
  content: coffee
@@ -10,7 +10,7 @@ describe Card::Set::Type::JavaScript do
10
10
  "//#{source}\n#{content}"
11
11
  end
12
12
 
13
- it_should_behave_like "content machine", that_produces: :js do
13
+ it_behaves_like "content machine", that_produces: :js do
14
14
  let(:machine_card) do
15
15
  Card.gimme! "test javascript", type: :java_script, content: js
16
16
  end
@@ -15,6 +15,7 @@ describe Card::Set::Type::Scss do
15
15
  SCSS
16
16
  end
17
17
  let(:compressed_changed_css) { "a{color:#fedcba}\n" }
18
+
18
19
  before do
19
20
  @scss_card = Card[:style_cards]
20
21
  end
@@ -28,7 +29,7 @@ describe Card::Set::Type::Scss do
28
29
  expect(@scss_card.format(:css).render_core).not_to match(/CodeRay/)
29
30
  end
30
31
 
31
- it_should_behave_like "machine input" do
32
+ it_behaves_like "machine input" do
32
33
  let(:create_machine_input_card) do
33
34
  Card.gimme! "test scss", type: :scss, content: scss
34
35
  end
@@ -52,7 +53,7 @@ describe Card::Set::Type::Scss do
52
53
  end
53
54
  end
54
55
 
55
- it_should_behave_like "content machine", that_produces: :css do
56
+ it_behaves_like "content machine", that_produces: :css do
56
57
  let(:machine_card) { Card.gimme! "test scss", type: :scss, content: scss }
57
58
  let(:card_content) do
58
59
  { in: scss, out: compressed_css,
@@ -8,7 +8,7 @@ describe Card::Set::Type::Skin do
8
8
  let(:new_css) { "#box{display: none }\n" }
9
9
  let(:compressed_new_css) { "#box{display:none}\n" }
10
10
 
11
- it_should_behave_like "pointer machine", that_produces: :css do
11
+ it_behaves_like "pointer machine", that_produces: :css do
12
12
  let(:machine_card) do
13
13
  Card.gimme! "test skin machine", type: :skin, content: ""
14
14
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  shared_examples_for "machine" do |args|
4
4
  let(:filetype) { args[:that_produces] }
5
+
5
6
  context "machine is run" do
6
7
  before do
7
8
  machine.update_machine_output
@@ -22,7 +23,7 @@ end
22
23
  shared_examples_for "content machine" do |args|
23
24
  let(:filetype) { args[:that_produces] }
24
25
 
25
- it_should_behave_like "machine", args do
26
+ it_behaves_like "machine", args do
26
27
  let(:machine) { machine_card }
27
28
  end
28
29
 
@@ -50,7 +51,6 @@ shared_examples_for "content machine" do |args|
50
51
  end
51
52
 
52
53
  shared_examples_for "pointer machine" do |args|
53
- let(:filetype) { args[:that_produces] }
54
54
  subject do
55
55
  # We build the following structure:
56
56
  #
@@ -106,7 +106,9 @@ shared_examples_for "pointer machine" do |args|
106
106
  change_machine
107
107
  end
108
108
 
109
- it_should_behave_like "machine", args do
109
+ let(:filetype) { args[:that_produces] }
110
+
111
+ it_behaves_like "machine", args do
110
112
  let(:machine) { machine_card }
111
113
  end
112
114
 
@@ -5,6 +5,7 @@ shared_examples_for "machine input" do
5
5
  myinput = create_machine_input_card
6
6
  myinput
7
7
  end
8
+
8
9
  let!(:machine) do
9
10
  f = create_machine_card
10
11
  f << create_machine_input_card
@@ -1,4 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
+
2
3
  class Card
3
4
  class Format
4
5
  class EmailHtmlFormat < Card::Format::HtmlFormat
@@ -10,7 +10,7 @@ event :cache_expired_for_new_set, :store,
10
10
  end
11
11
 
12
12
  event :cache_expired_for_type_change, :store,
13
- on: :update, changed: [:type_id, :name] do
13
+ on: :update, changed: %i[type_id name] do
14
14
  # FIXME: expire (also?) after save
15
15
  Card.follow_caches_expired
16
16
  end
@@ -1,4 +1,4 @@
1
- [:create, :update, :delete].each do |action|
1
+ %i[create update delete].each do |action|
2
2
  event "observer_#{action}".to_sym, :integrate, on: action do
3
3
  execute_card_events on: action
4
4
  end
@@ -135,8 +135,8 @@ format do
135
135
 
136
136
  relevant_fields =
137
137
  case action.action_type
138
- when :create then [:cardtype, :content]
139
- when :update then [:name, :cardtype, :content]
138
+ when :create then %i[cardtype content]
139
+ when :update then %i[name cardtype content]
140
140
  when :delete then [:content]
141
141
  end
142
142
 
@@ -31,7 +31,8 @@ end
31
31
 
32
32
  format :html do
33
33
  view :edit, perms: :update, tags: :unknown_ok do
34
- frame_and_form :update do
34
+ frame_and_form :update, hidden: { success: "_self",
35
+ card: { update_all_users: false } } do
35
36
  [
36
37
  _optional_render_content_formgroup,
37
38
  _optional_render_confirm_update_all,
@@ -59,7 +60,7 @@ format :html do
59
60
  cancel_button href: path(view: :edit, id: card.id)
60
61
  end
61
62
 
62
- view :confirm_update_all do |args|
63
+ view :confirm_update_all do |_args|
63
64
  wrap do
64
65
  alert "info" do
65
66
  %(
@@ -70,10 +71,4 @@ format :html do
70
71
  end
71
72
  end
72
73
  end
73
-
74
- def default_edit_args args
75
- args[:hidden] ||= {}
76
- args[:hidden].reverse_merge!(success: "_self",
77
- card: { update_all_users: false })
78
- end
79
74
  end
@@ -2,7 +2,7 @@ def email_config args={}
2
2
  config = {}
3
3
  args[:context] ||= self
4
4
 
5
- [:to, :from, :cc, :bcc].each do |field_name|
5
+ %i[to from cc bcc].each do |field_name|
6
6
  process_email_field(field_name, config, args) do |field_card|
7
7
  field_card.process_email_addresses(
8
8
  args[:context], { format: "email_text" }, args
@@ -44,7 +44,7 @@ def process_email_field field, config, args
44
44
  elsif (field_card = fetch(trait: field))
45
45
  # configuration can be anything visible to configurer
46
46
  user = (args[:follower] && Card.fetch(args[:follower])) ||
47
- field_card.updater
47
+ field_card.updater
48
48
  Auth.as(user) do
49
49
  yield(field_card)
50
50
  end
@@ -107,7 +107,7 @@ format :html do
107
107
 
108
108
  view :following_list, cache: :never do |_args|
109
109
  if !Auth.signed_in? || Auth.current_id != card.left.id
110
- hide_buttons = [:delete_follow_rule_button, :add_follow_rule_button]
110
+ hide_buttons = %i[delete_follow_rule_button add_follow_rule_button]
111
111
  end
112
112
 
113
113
  sets = followed_by_set
@@ -135,7 +135,7 @@ format :html do
135
135
  end
136
136
  end
137
137
  if !Auth.signed_in? || Auth.current_id != card.left.id
138
- hide_buttons = [:delete_follow_rule_button, :add_follow_rule_button]
138
+ hide_buttons = %i[delete_follow_rule_button add_follow_rule_button]
139
139
  end
140
140
  never = Card[:never].name
141
141
  wrap_with :div, class: "pointer-list-editor" do
@@ -17,23 +17,28 @@ describe Card::Set::All::Follow do
17
17
  end
18
18
 
19
19
  subject { Card[cardname].follower_names.sort }
20
+
20
21
  context "followers of No One Sees Me" do
21
22
  let(:cardname) { "No One Sees Me" }
23
+
22
24
  it { is_expected.to eq([]) }
23
25
  end
24
26
 
25
27
  context "followers of Magnifier" do
26
28
  let(:cardname) { "Magnifier" }
29
+
27
30
  it { is_expected.to eq([]) }
28
31
  end
29
32
 
30
33
  context "followers of Magnifier+lens" do
31
34
  let(:cardname) { "Magnifier+lens" }
35
+
32
36
  it { is_expected.to eq ["Big Brother", "Narcissist"] }
33
37
  end
34
38
 
35
39
  context "followers of Sunglasses" do
36
40
  let(:cardname) { "Sunglasses" }
41
+
37
42
  it do
38
43
  is_expected.to eq ["Big Brother", "Narcissist", "Optic fan", "Sara",
39
44
  "Sunglasses fan"]
@@ -42,6 +47,7 @@ describe Card::Set::All::Follow do
42
47
 
43
48
  context "followers of Sunglasses+tint" do
44
49
  let(:cardname) { "Sunglasses+tint" }
50
+
45
51
  it do
46
52
  is_expected.to eq ["Big Brother", "Narcissist", "Optic fan", "Sara",
47
53
  "Sunglasses fan"]
@@ -50,6 +56,7 @@ describe Card::Set::All::Follow do
50
56
 
51
57
  context "followers of Google glass" do
52
58
  let(:cardname) { "Google glass" }
59
+
53
60
  it { is_expected.to eq ["Big Brother", "Optic fan", "Sara"] }
54
61
  end
55
62
  end
@@ -37,6 +37,7 @@ shared_examples_for "notifications" do
37
37
  )
38
38
  @card.format(format: format).render_list_of_changes(action: action)
39
39
  end
40
+
40
41
  it { is_expected.to include "content: #{content}" }
41
42
  end
42
43
  context "for a given action id" do
@@ -48,6 +49,7 @@ shared_examples_for "notifications" do
48
49
  @card.format(format: format)
49
50
  .render_list_of_changes(action_id: action_id)
50
51
  end
52
+
51
53
  it { is_expected.to include "content: #{content}" }
52
54
  end
53
55
  end
@@ -141,6 +143,7 @@ describe Card::Set::All::SendNotifications do
141
143
  follow_option: "*always"
142
144
  ).text_part.body.raw_source
143
145
  end
146
+
144
147
  before do
145
148
  create_or_update! "#{name}+*self+*read",
146
149
  type: "Pointer", content: "[[Administrator]]"
@@ -1,7 +1,7 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  describe Card::Set::Type::EmailTemplate do
4
- before :each do
4
+ before do
5
5
  Card::Auth.as_bot do
6
6
  Card.create! name: "mail template", type_code: "email_template",
7
7
  subcards: {
@@ -28,6 +28,7 @@ describe Card::Set::Right::Followers do
28
28
 
29
29
  describe "item_names" do
30
30
  subject { @card.followers_card.item_names.sort }
31
+
31
32
  it "is an array of followers" do
32
33
  @card = Card["All Eyes On Me"]
33
34
  is_expected.to eq ["Big Brother", "John", "Sara"]
@@ -0,0 +1,11 @@
1
+ format do
2
+ def limit_param
3
+ @limit ||=
4
+ Env.params[:limit].present? ? Env.params.delete(:limit).to_i : default_limit
5
+ end
6
+
7
+ def offset_param
8
+ @offset ||=
9
+ Env.params[:offset].present? ? Env.params.delete(:offset).to_i : 0
10
+ end
11
+ end
@@ -1,11 +1,12 @@
1
+ include_set Abstract::PagingParams
2
+
1
3
  format do
2
4
  def limit
3
- default_limit
5
+ limit_param
4
6
  end
5
7
 
6
8
  def offset
7
- return 0 unless Env.params[:offset].present?
8
- Env.params[:offset].to_i
9
+ offset_param
9
10
  end
10
11
 
11
12
  def search_with_params args={}
@@ -20,7 +21,7 @@ end
20
21
  format :html do
21
22
  def with_paging path_args={}
22
23
  paging_path_args path_args
23
- output [yield, _optional_render_paging]
24
+ output [yield(@paging_path_args), _optional_render_paging]
24
25
  end
25
26
 
26
27
  view :paging, cache: :never do
@@ -59,11 +60,14 @@ format :html do
59
60
  end
60
61
 
61
62
  def paging_path_args local_args={}
62
- @paging_path_args ||= {
63
+ @paging_path_args ||= {}
64
+ @paging_path_args.reverse_merge!(
63
65
  limit: limit,
66
+ offset: offset,
64
67
  view: paging_view,
65
68
  slot: voo.slot_options
66
- }.merge(extra_paging_path_args)
69
+ )
70
+ @paging_path_args.merge! extra_paging_path_args
67
71
  @paging_path_args.merge local_args
68
72
  end
69
73
 
@@ -19,6 +19,10 @@ stage_method :changed_item_cards do
19
19
  end
20
20
 
21
21
  format do
22
+ def default_limit
23
+ 20
24
+ end
25
+
22
26
  def item_links args={}
23
27
  card.item_cards(args).map do |item_card|
24
28
  subformat(item_card).render_link
@@ -40,7 +44,8 @@ format do
40
44
  end
41
45
 
42
46
  def pointer_items args={}
43
- card.item_cards.map do |item_card|
47
+ page_args = args.extract! :limit, :offset
48
+ card.item_cards(page_args).map do |item_card|
44
49
  nest_item item_card, args do |rendered, item_view|
45
50
  wrap_item rendered, item_view
46
51
  end
@@ -50,14 +55,19 @@ end
50
55
 
51
56
  format :html do
52
57
  view :core do
53
- wrap_with :div, pointer_items, class: "pointer-list"
58
+ with_paging do |paging_args|
59
+ wrap_with :div, pointer_items(paging_args.extract!(:limit, :offset)),
60
+ class: "pointer-list"
61
+ end
54
62
  end
55
63
 
56
64
  view :closed_content do
57
65
  item_view = implicit_item_view
58
66
  item_view = item_view == "name" ? "name" : "link"
59
67
  wrap_with :div, class: "pointer-list" do
60
- pointer_items(view: item_view).join ", "
68
+ # unlikely that more than 100 items fit in closed content
69
+ # even if every item is only one character
70
+ pointer_items(view: item_view, limit: 100, offset: 0).join ", "
61
71
  end
62
72
  end
63
73
 
@@ -98,17 +108,28 @@ end
98
108
 
99
109
  format :rss do
100
110
  def raw_feed_items
101
- @raw_feed_items ||= card.item_cards
111
+ @raw_feed_items ||= card.item_cards(limit: limit, offset: offset)
102
112
  end
103
113
  end
104
114
 
105
115
  format :json do
116
+ def max_depth
117
+ params[:max_depth] || 1
118
+ end
119
+
106
120
  view :export_items do |args|
107
121
  item_args = args.merge view: :export
108
122
  card.known_item_cards.map do |item_card|
109
123
  nest_item item_card, item_args
110
124
  end.flatten.reject(&:blank?)
111
125
  end
126
+
127
+ def essentials
128
+ return if @depth > max_depth
129
+ card.item_cards.map do |item|
130
+ nest item, view: :essentials
131
+ end
132
+ end
112
133
  end
113
134
 
114
135
  # If a card's type and content are updated in the same action, the new module
@@ -164,7 +185,7 @@ def item_names args={}
164
185
  raw_items = content.to_s.split(/\n+/)
165
186
  if args[:limit].present? && args[:limit].to_i > 0
166
187
  offset = args[:offset] || 0
167
- raw_items = raw_items[offset, args[:limit].to_i]
188
+ raw_items = raw_items[offset, args[:limit].to_i] || []
168
189
  end
169
190
  raw_items.map do |line|
170
191
  item_name = line.gsub(/\[\[|\]\]/, "").strip