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
@@ -22,7 +22,7 @@ end
22
22
 
23
23
  def mod_dir new_mod=nil
24
24
  mod_name = new_mod || mod
25
- dir = Card::Mod::Loader.mod_dirs.path(mod_name) || (mod_name == :test && "test")
25
+ dir = Card::Mod::Loader.mod_dirs.path(mod_name) || (mod_name.to_sym == :test && "test")
26
26
 
27
27
  raise Error, "can't find mod \"#{mod_name}\"" unless dir
28
28
  dir
@@ -31,7 +31,12 @@ end
31
31
 
32
32
  event :validate_storage_type_update, :validate,
33
33
  on: :update do
34
- if cloud? && storage_type_changed?
34
+ # FIXME: make it possible to retrieve the file from cloud storage
35
+ # to store it somewhere else. Currently, it only works to change the
36
+ # storage type if a new file is provided
37
+ # i.e. `update_attributes storage_type: :local` fails but
38
+ # `update_attributes storage_type: :local, file: [file handle]` is ok
39
+ if cloud? && storage_type_changed? && !file_changed?
35
40
  errors.add :storage_type, "moving files from cloud elsewhere "\
36
41
  "is not supported"
37
42
  end
@@ -42,6 +47,11 @@ event :loose_coded_status_on_update, :initialize, on: :update, when: :coded? do
42
47
  @new_storage_type ||= storage_type_from_config
43
48
  end
44
49
 
50
+ event :change_bucket_if_read_only, :initialize, on: :update, when: :cloud? do
51
+ return unless bucket_config[:read_only]
52
+ @new_storage_type = storage_type_from_config
53
+ end
54
+
45
55
  event :update_public_link_on_create, :integrate, on: :create, when: :local? do
46
56
  update_public_link
47
57
  end
@@ -40,7 +40,7 @@ end
40
40
 
41
41
  format :file do
42
42
  # returns send_file args. not in love with this...
43
- view :core, cache: :never do |_args|
43
+ view :core, cache: :never do |args|
44
44
  # this means we only support known formats. dislike.
45
45
  attachment_format = card.attachment_format(params[:format])
46
46
  return _render_not_found unless attachment_format
@@ -76,7 +76,7 @@ format :file do
76
76
  end
77
77
 
78
78
  format :html do
79
- view :core do |args|
79
+ view :core do |_args|
80
80
  handle_source do |source|
81
81
  "<a href=\"#{source}\">Download #{showname voo.title}</a>"
82
82
  end
@@ -93,7 +93,7 @@ format :html do
93
93
  ""
94
94
  end
95
95
 
96
- view :preview_editor, tags: :unknown_ok, cache: :never do |args|
96
+ view :preview_editor, tags: :unknown_ok, cache: :never do |_args|
97
97
  cached_upload_card_name = Card::Env.params[:attachment_upload]
98
98
  cached_upload_card_name.gsub!(/\[\w+\]$/, "[action_id_of_cached_upload]")
99
99
  <<-HTML
@@ -22,6 +22,7 @@ describe CarrierWave::FileCardUploader do
22
22
  describe "#db_content" do
23
23
  context "coded file" do
24
24
  subject { coded_file }
25
+
25
26
  it "returns correct identifier" do
26
27
  expect(subject.attachment.db_content)
27
28
  .to eq ":logo/standard.png"
@@ -35,6 +36,7 @@ describe CarrierWave::FileCardUploader do
35
36
 
36
37
  context "local file" do
37
38
  subject { local_file }
39
+
38
40
  it "returns correct identifier" do
39
41
  expect(subject.attachment.db_content)
40
42
  .to eq "~#{subject.id}/#{subject.last_action_id}.txt"
@@ -58,6 +60,7 @@ describe CarrierWave::FileCardUploader do
58
60
 
59
61
  context "web file" do
60
62
  subject { web_file }
63
+
61
64
  it "returns correct identifier" do
62
65
  expect(subject.attachment.db_content)
63
66
  .to eq "http://web.de/test.txt"
@@ -58,6 +58,7 @@ describe Card::Set::Type::File do
58
58
  end
59
59
  context "storage type: protected" do
60
60
  subject { source_view protected_file }
61
+
61
62
  it "renders protected url to be processed by wagn" do
62
63
  is_expected.to(
63
64
  eq "/files/~#{protected_file.id}/#{protected_file.last_action_id}.txt"
@@ -67,6 +68,7 @@ describe Card::Set::Type::File do
67
68
 
68
69
  context "storage type: unprotected" do
69
70
  subject { source_view unprotected_file }
71
+
70
72
  it "renders relative url" do
71
73
  is_expected.to(
72
74
  eq "/files/~#{unprotected_file.id}/"\
@@ -77,6 +79,7 @@ describe Card::Set::Type::File do
77
79
 
78
80
  context "storage type: web" do
79
81
  subject { source_view web_file }
82
+
80
83
  it "renders saved url" do
81
84
  is_expected.to eq web_url
82
85
  end
@@ -84,6 +87,7 @@ describe Card::Set::Type::File do
84
87
 
85
88
  context "storage type: coded" do
86
89
  subject { source_view coded_file }
90
+
87
91
  it "renders protected url to be processed by wagn" do
88
92
  is_expected.to(
89
93
  eq "/files/:#{coded_file.codename}/standard-medium.png"
@@ -93,6 +97,7 @@ describe Card::Set::Type::File do
93
97
 
94
98
  context "storage type: cloud" do
95
99
  subject { source_view cloud_file }
100
+
96
101
  it "renders absolute url to cloud" do
97
102
  is_expected
98
103
  .to eq "http://#{directory}.s3.amazonaws.com/"\
@@ -131,6 +136,7 @@ describe Card::Set::Type::File do
131
136
  context "storage type:" do
132
137
  context "protected" do
133
138
  subject { protected_file }
139
+
134
140
  it "stores correct identifier (~<card id>/<action id>.<ext>)" do
135
141
  expect(subject.content)
136
142
  .to eq "~#{subject.id}/#{subject.last_action_id}.txt"
@@ -163,6 +169,7 @@ describe Card::Set::Type::File do
163
169
 
164
170
  context "unprotected" do
165
171
  subject { unprotected_file }
172
+
166
173
  it "creates public symlink" do
167
174
  subject
168
175
  expect(public_path_exist?).to be_truthy
@@ -171,6 +178,7 @@ describe Card::Set::Type::File do
171
178
 
172
179
  context "web" do
173
180
  subject { web_file }
181
+
174
182
  it "saves url as identifier" do
175
183
  expect(subject.content).to eq web_url
176
184
  end
@@ -214,12 +222,13 @@ describe Card::Set::Type::File do
214
222
  FileUtils.rm_rf mod_path
215
223
  Card::Mod::Loader.mod_dirs.mods.delete "test_mod"
216
224
  end
217
- let(:file_path) { File.join mod_path, "file", "mod_file", "file.txt" }
218
-
219
225
  subject do
220
226
  create_file_card :coded, test_file,
221
227
  codename: "mod_file", mod: "test_mod"
222
228
  end
229
+
230
+ let(:file_path) { File.join mod_path, "file", "mod_file", "file.txt" }
231
+
223
232
  it "stores correct identifier (:<codename>/<mod_name>.<ext>)" do
224
233
  expect(subject.content)
225
234
  .to eq ":#{subject.codename}/test_mod.txt"
@@ -247,6 +256,7 @@ describe Card::Set::Type::File do
247
256
 
248
257
  describe "cloud" do
249
258
  subject { cloud_file }
259
+
250
260
  it "stores correct identifier "\
251
261
  "((<bucket>)/<card id>/<action id>.<ext>)" do
252
262
  expect(subject.content)
@@ -316,6 +326,7 @@ describe Card::Set::Type::File do
316
326
  create_file_card :coded, test_file,
317
327
  codename: "mod_file", mod: "test_mod"
318
328
  end
329
+
319
330
  it "changes storage type to default" do
320
331
  storage_config :local
321
332
  subject.update_attributes! file: test_file(2)
@@ -337,6 +348,7 @@ describe Card::Set::Type::File do
337
348
 
338
349
  context "when read rules are restricted" do
339
350
  subject { unprotected_file }
351
+
340
352
  it "removes public svmlink" do
341
353
  expect(public_path_exist?).to be_truthy
342
354
  Card::Auth.as_bot do
@@ -349,6 +361,7 @@ describe Card::Set::Type::File do
349
361
 
350
362
  context "when read rules changed to 'Anyone'" do
351
363
  subject { protected_file }
364
+
352
365
  it "creates public symlink" do
353
366
  expect(public_path_exist?).to be_falsey
354
367
  Card::Auth.as_bot do
@@ -378,12 +391,13 @@ describe Card::Set::Type::File do
378
391
  storage_type: @storage_type || :cloud
379
392
  end
380
393
  end
394
+
381
395
  context "from cloud to local" do
382
396
  before { storage_config :cloud }
383
397
  after { Cardio.config.file_storage = :local }
384
398
  it "copies file to local file system" do
385
399
  # not yet supported
386
- expect { subject.update_attributes!(storage_type: :local) }
400
+ expect { Card[subject.name].update_attributes!(storage_type: :local) }
387
401
  .to raise_error(ActiveRecord::RecordInvalid)
388
402
  # expect(subject.content)
389
403
  # .to eq "~#{subject.id}/#{subject.last_action_id - 1}.txt"
@@ -416,6 +430,7 @@ describe Card::Set::Type::File do
416
430
 
417
431
  context "from coded to local" do
418
432
  subject { Card[:logo] }
433
+
419
434
  it "copies file to mod" do
420
435
  @storage_type = :local
421
436
  Card::Auth.as_bot do
@@ -450,6 +465,7 @@ describe Card::Set::Type::File do
450
465
  empty_ok: true, storage_type: :cloud,
451
466
  bucket: :test_bucket).bucket_config
452
467
  end
468
+
453
469
  let(:bucket_config) do
454
470
  {
455
471
  test_bucket: {
@@ -471,14 +487,15 @@ describe Card::Set::Type::File do
471
487
  }
472
488
  }
473
489
  end
490
+
474
491
  before do
475
492
  @old_bucket_config = Cardio.config.file_buckets
476
493
  Cardio.config.file_buckets = bucket_config
477
494
  end
478
495
  after do
479
496
  Cardio.config.file_buckets = @old_bucket_config
480
- %w(PROVIDER CREDENTIALS_PROVIDER TEST_BUCKET_PROVIDER
481
- TEST_BUCKET_CREDENTIALS_PROVIDER).each do |key|
497
+ %w[PROVIDER CREDENTIALS_PROVIDER TEST_BUCKET_PROVIDER
498
+ TEST_BUCKET_CREDENTIALS_PROVIDER].each do |key|
482
499
  ENV.delete key
483
500
  end
484
501
  end
@@ -492,7 +509,7 @@ describe Card::Set::Type::File do
492
509
  expect { subject }.to raise_error(Card::Error)
493
510
  end
494
511
 
495
- it "it takes config from env variables" do
512
+ it "takes config from env variables" do
496
513
  Cardio.config.file_buckets = {}
497
514
  ENV["PROVIDER"] = "env provider"
498
515
  ENV["CREDENTIALS_PROVIDER"] = "env cred provider"
@@ -540,6 +557,7 @@ describe Card::Set::Type::File do
540
557
  end
541
558
 
542
559
  let(:directory) { "philipp-test" }
560
+
543
561
  def storage_config type=:local
544
562
  Cardio.config.file_storage = type
545
563
  Wagn.config.file_buckets = {
@@ -27,6 +27,7 @@ describe Card::Set::Type::Image do
27
27
  end
28
28
  end
29
29
  subject { Card["image card"] }
30
+
30
31
  it "stores correct identifier" do
31
32
  expect(subject.content)
32
33
  .to eq "~#{subject.id}/#{subject.last_action_id}.jpg"
@@ -98,6 +99,7 @@ describe Card::Set::Type::Image do
98
99
 
99
100
  describe "*logo mod image" do
100
101
  subject { Card[:logo] }
102
+
101
103
  it "exists" do
102
104
  expect(subject.image.size).to be > 0
103
105
  end
@@ -140,6 +142,7 @@ describe Card::Set::Type::Image do
140
142
  image: File.new(File.join(FIXTURES_PATH, "mao2.jpg"))
141
143
  end
142
144
  end
145
+
143
146
  it "deletes all versions" do
144
147
  path = subject.image.path
145
148
  small_path = subject.image.small.path
@@ -37,7 +37,7 @@ module Card::Content::Chunk
37
37
  # there's probably a better way to do the following.
38
38
  # point is to find the first pipe that's not inside an nest
39
39
  return unless string.index "|"
40
- string_copy = "#{string}" # had to do this to create new string?!
40
+ string_copy = string.dup
41
41
  string.scan(/\{\{[^\}]*\}\}/) do |incl|
42
42
  string_copy.gsub! incl, ("x" * incl.length)
43
43
  end
@@ -97,7 +97,8 @@ class Card
97
97
  def each_option attr_string
98
98
  return if attr_string.blank?
99
99
  attr_string.strip.split(";").each do |pair|
100
- value, key = pair.split(":").reverse
100
+ # key is optional for view option
101
+ value, key = pair.split(":", 2).reverse
101
102
  key ||= self.class::DEFAULT_OPTION.to_s
102
103
  yield key.strip, value.strip
103
104
  end
@@ -22,7 +22,7 @@ module Card::Content::Chunk
22
22
  Card::Query::OPERATORS.keys +
23
23
  Card::Query::ATTRIBUTES.keys +
24
24
  Card::Query::CONJUNCTIONS.keys +
25
- %w(desc asc count)
25
+ %w[desc asc count]
26
26
  ).map(&:to_name)
27
27
  )
28
28
 
@@ -1,4 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
+
2
3
  class Card
3
4
  class Content
4
5
  module Chunk
@@ -1,4 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
+
2
3
  require "uri"
3
4
 
4
5
  # This wiki chunk matches arbitrary URIs, using patterns from the Ruby URI
@@ -20,7 +21,7 @@ require "uri"
20
21
  # [iso3166]: http://geotags.com/iso3166/
21
22
  module Card::Content::Chunk
22
23
  class URI < Abstract
23
- SCHEMES = %w(irc http https ftp ssh git sftp file ldap ldaps mailto).freeze
24
+ SCHEMES = %w[irc http https ftp ssh git sftp file ldap ldaps mailto].freeze
24
25
 
25
26
  REJECTED_PREFIX_RE = %w{! ": " ' ](}.map { |s| Regexp.escape s } * "|"
26
27
 
@@ -47,7 +48,7 @@ module Card::Content::Chunk
47
48
 
48
49
  def context_ok? content, chunk_start
49
50
  preceding_string = content[chunk_start - 2..chunk_start - 1]
50
- !(preceding_string =~ /(?:#{REJECTED_PREFIX_RE})$/)
51
+ preceding_string !~ /(?:#{REJECTED_PREFIX_RE})$/
51
52
  end
52
53
  end
53
54
 
@@ -57,7 +58,7 @@ module Card::Content::Chunk
57
58
  chunk.gsub!(/(?:&nbsp;)+/, "")
58
59
 
59
60
  @trailing_punctuation =
60
- if %w{, . ) ! ? :}.member?(last_char)
61
+ if %w[, . ) ! ? :].member?(last_char)
61
62
  @text.chop!
62
63
  chunk.chop!
63
64
  last_char
@@ -0,0 +1,26 @@
1
+ def lock
2
+ was_already_locked = locked?
3
+ return if was_already_locked
4
+ Auth.as_bot do
5
+ lock!
6
+ yield
7
+ end
8
+ ensure
9
+ unlock! unless was_already_locked
10
+ end
11
+
12
+ def lock_cache_key
13
+ "UPDATE-LOCK:#{key}"
14
+ end
15
+
16
+ def locked?
17
+ Card.cache.read lock_cache_key
18
+ end
19
+
20
+ def lock!
21
+ Card.cache.write lock_cache_key, true
22
+ end
23
+
24
+ def unlock!
25
+ Card.cache.write lock_cache_key, false
26
+ end
@@ -11,14 +11,13 @@ def assign_attributes args={}
11
11
  end
12
12
 
13
13
  def assign_set_specific_attributes
14
- return unless @set_specific.present?
15
- @set_specific.each_pair do |name, value|
14
+ set_specific.each_pair do |name, value|
16
15
  send "#{name}=", value
17
16
  end
18
17
  end
19
18
 
20
19
  def extract_subcard_args! args
21
- subcards = args.delete("subcards") || args.delete(:subcards) || {}
20
+ subcards = args.delete("subcards") || args.delete(:subcards) || {}
22
21
  if (subfields = args.delete("subfields") || args.delete(:subfields))
23
22
  subfields.each_pair do |key, value|
24
23
  subcards[cardname.field(key)] = value
@@ -74,7 +73,7 @@ end
74
73
  def stash_set_specific_attributes args
75
74
  @set_specific = {}
76
75
  Card.set_specific_attributes.each do |key|
77
- @set_specific[key] = args.delete(key) if args[key]
76
+ set_specific[key] = args.delete(key) if args.key?(key)
78
77
  end
79
78
  end
80
79
 
@@ -103,3 +102,8 @@ def extract_type_id! args={}
103
102
  end
104
103
  type_id
105
104
  end
105
+
106
+ # 'set' refers to the noun not the verb
107
+ def set_specific
108
+ @set_specific ||= {}
109
+ end
@@ -355,22 +355,29 @@ format :csv do
355
355
  end
356
356
 
357
357
  def name_with_field_rows
358
- list = card.item_names
359
- columns = columns_from_referees list.first
358
+ return [] unless row_card_names.present?
360
359
 
361
- list.map do |item_name|
360
+ row_card_names.map do |item_name|
362
361
  CSV.generate_line row_from_field_names(item_name, columns)
363
362
  end.join
364
363
  end
365
364
 
366
- def columns_from_referees referer
365
+ def row_card_names
366
+ @row_cards ||= card.item_names
367
+ end
368
+
369
+ def columns
367
370
  columns = []
368
- Card.fetch(referer).format.each_nested_field do |chunk|
371
+ csv_structure_card.format.each_nested_field do |chunk|
369
372
  columns << chunk.referee_name.tag
370
373
  end
371
374
  columns
372
375
  end
373
376
 
377
+ def csv_structure_card
378
+ card.rule_card(:csv_structure) || Card.fetch(row_card_names.first)
379
+ end
380
+
374
381
  def row_from_field_names parent_name, field_names, view=:core
375
382
  field_names.each_with_object([parent_name]) do |field, row|
376
383
  row << nest([parent_name, field], view: view)
@@ -395,10 +402,12 @@ format :csv do
395
402
  end
396
403
 
397
404
  def column_title opts
398
- if %w(name link).member? opts[:view]
405
+ if opts[:title]
406
+ opts[:title]
407
+ elsif %w[name link].member? opts[:view]
399
408
  opts[:view]
400
409
  else
401
410
  opts[:nest_name].to_name.tag
402
411
  end
403
412
  end
404
- end
413
+ end