card 0.0.1 → 1.15.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (514) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +4 -0
  3. data/GPL +331 -0
  4. data/LICENSE +16 -0
  5. data/VERSION +1 -0
  6. data/card.gemspec +48 -19
  7. data/config/initializers/01_init_ruby_extensions.rb +7 -0
  8. data/config/initializers/inflections.rb +13 -0
  9. data/config/initializers/mime_types.rb +13 -0
  10. data/config/initializers/notification.rb +4 -0
  11. data/config/initializers/recaptcha.rb +6 -0
  12. data/config/initializers/uuid_state_file.rb +3 -0
  13. data/db/bootstrap/card_actions.yml +3872 -0
  14. data/db/bootstrap/card_acts.yml +7 -0
  15. data/db/bootstrap/card_changes.yml +11909 -0
  16. data/db/bootstrap/card_references.yml +3970 -0
  17. data/db/bootstrap/cards.yml +10805 -0
  18. data/db/migrate/20110511221913_require_earlier_migrations.rb +19 -0
  19. data/db/migrate/20120105203350_require_1_8_migrations.rb +15 -0
  20. data/db/migrate/20121111025347_require_1_10_migrations.rb +15 -0
  21. data/db/migrate/20121118114000_split_link_type.rb +16 -0
  22. data/db/migrate/20121118115000_update_link_type.rb +19 -0
  23. data/db/migrate/20130106052640_table_cleanup.rb +25 -0
  24. data/db/migrate/20130109015336_trunk_left.rb +14 -0
  25. data/db/migrate/20130411210957_update_codenames.rb +14 -0
  26. data/db/migrate/20140822073704_create_new_revision_tables.rb +43 -0
  27. data/db/migrate/20141001105348_move_revisions_to_actions.rb +62 -0
  28. data/db/migrate/20141121172918_rename_card_migration_table.rb +15 -0
  29. data/db/migrate/20141208132159_remove_present_from_reference_table.rb +9 -0
  30. data/db/migrate/20141216053032_better_index_names.rb +24 -0
  31. data/db/migrate_core_cards/20130411191151_renaming_for_menu.rb +49 -0
  32. data/db/migrate_core_cards/20130411211600_delete_old_related_tab_cards.rb +18 -0
  33. data/db/migrate_core_cards/20130419215612_import_help_text.rb +13 -0
  34. data/db/migrate_core_cards/20130823192433_add_style_cards.rb +87 -0
  35. data/db/migrate_core_cards/20130910183318_move_styles_to_content.rb +11 -0
  36. data/db/migrate_core_cards/20130920214038_jsonize_tinymce.rb +15 -0
  37. data/db/migrate_core_cards/20130920291703_update_stylesheets.rb +18 -0
  38. data/db/migrate_core_cards/20130927191728_account_events.rb +21 -0
  39. data/db/migrate_core_cards/20131016172445_common_css_patch.rb +12 -0
  40. data/db/migrate_core_cards/20140110193325_reset_account_request_type.rb +11 -0
  41. data/db/migrate_core_cards/20140307231621_user_data_to_cards.rb +73 -0
  42. data/db/migrate_core_cards/20140317035504_account_requests_to_signups.rb +51 -0
  43. data/db/migrate_core_cards/20140512155840_add_script_cards.rb +83 -0
  44. data/db/migrate_core_cards/20140629222005_add_email_cards.rb +134 -0
  45. data/db/migrate_core_cards/20140725180118_config_card_updates.rb +9 -0
  46. data/db/migrate_core_cards/20141111083921_delete_machine_output.rb +9 -0
  47. data/db/migrate_core_cards/20141115034214_config_descriptions_etc.rb +14 -0
  48. data/db/migrate_core_cards/20141119001955_make_symlinks_relative.rb +15 -0
  49. data/db/migrate_core_cards/20141120120605_fix_notification_html_message.rb +10 -0
  50. data/db/migrate_core_cards/20141204061304_watchers_to_following.rb +38 -0
  51. data/db/migrate_core_cards/20141208132416_partial_reference_type.rb +7 -0
  52. data/db/migrate_core_cards/20141208162106_add_ace_script.rb +12 -0
  53. data/db/migrate_core_cards/20141216155251_add_more_following_cards.rb +24 -0
  54. data/db/migrate_core_cards/20141230204340_uri_codename.rb +13 -0
  55. data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +17 -0
  56. data/db/migrate_core_cards/20150220134731_following_to_follow_rule.rb +18 -0
  57. data/db/migrate_core_cards/data/1.11_help_text.json +410 -0
  58. data/db/migrate_core_cards/data/1.12_stylesheets/classic_cards.scss +100 -0
  59. data/db/migrate_core_cards/data/1.12_stylesheets/common.scss +226 -0
  60. data/db/migrate_core_cards/data/1.12_stylesheets/right_sidebar.scss +27 -0
  61. data/db/migrate_core_cards/data/1.12_stylesheets/traditional.scss +152 -0
  62. data/db/migrate_core_cards/data/1.13_config_text.json +32 -0
  63. data/db/migrate_core_cards/data/1.14_config_descriptions_etc.json +77 -0
  64. data/db/migrate_core_cards/data/bootstrap_layout.json +81 -0
  65. data/db/migrate_core_cards/data/mailer/follower_notification_email.html +9 -0
  66. data/db/migrate_core_cards/data/mailer/follower_notification_email.txt +11 -0
  67. data/db/migrate_core_cards/data/mailer/mail_config.json +22 -0
  68. data/db/migrate_core_cards/data/mailer/password_reset_email.html +10 -0
  69. data/db/migrate_core_cards/data/mailer/password_reset_email.txt +11 -0
  70. data/db/migrate_core_cards/data/mailer/signup_alert_email.html +7 -0
  71. data/db/migrate_core_cards/data/mailer/signup_alert_email.txt +5 -0
  72. data/db/migrate_core_cards/data/mailer/verification_email.html +9 -0
  73. data/db/migrate_core_cards/data/mailer/verification_email.txt +8 -0
  74. data/db/schema.rb +128 -0
  75. data/db/seeds.rb +8 -0
  76. data/db/version.txt +1 -0
  77. data/db/version_core_cards.txt +1 -0
  78. data/lib/card.rb +46 -3
  79. data/lib/card/active_record_ext.rb +77 -0
  80. data/lib/card/auth.rb +181 -0
  81. data/lib/card/cache.rb +199 -0
  82. data/lib/card/chunk.rb +104 -0
  83. data/lib/card/codename.rb +72 -0
  84. data/lib/card/content.rb +211 -0
  85. data/lib/card/core_ext.rb +105 -0
  86. data/lib/card/core_migration.rb +6 -0
  87. data/lib/card/diff.rb +430 -0
  88. data/lib/card/env.rb +52 -0
  89. data/lib/card/exceptions.rb +44 -0
  90. data/lib/card/format.rb +563 -0
  91. data/lib/card/loader.rb +165 -0
  92. data/lib/card/log.rb +450 -0
  93. data/lib/card/mailer.rb +37 -0
  94. data/lib/card/migration.rb +145 -0
  95. data/lib/card/name.rb +45 -0
  96. data/lib/card/query.rb +81 -0
  97. data/lib/card/query/card_clause.rb +527 -0
  98. data/lib/card/query/clause.rb +21 -0
  99. data/lib/card/query/ref_clause.rb +47 -0
  100. data/lib/card/query/value_clause.rb +65 -0
  101. data/lib/card/reference.rb +63 -0
  102. data/lib/card/set.rb +369 -0
  103. data/lib/card/set_pattern.rb +168 -0
  104. data/lib/card/simplecov_helper.rb +61 -0
  105. data/lib/card/spec_helper.rb +68 -0
  106. data/lib/card/version.rb +9 -2
  107. data/lib/cardio.rb +145 -0
  108. data/lib/generators/card.rb +32 -0
  109. data/lib/generators/card/format/USAGE +9 -0
  110. data/lib/generators/card/format/format_generator.rb +27 -0
  111. data/lib/generators/card/format/templates/format_spec_template.erb +5 -0
  112. data/lib/generators/card/format/templates/format_template.erb +3 -0
  113. data/lib/generators/card/migration/USAGE +24 -0
  114. data/lib/generators/card/migration/migration_generator.rb +38 -0
  115. data/lib/generators/card/migration/templates/card_migration.erb +10 -0
  116. data/lib/generators/card/set/USAGE +15 -0
  117. data/lib/generators/card/set/set_generator.rb +29 -0
  118. data/lib/generators/card/set/templates/set_spec_template.erb +5 -0
  119. data/lib/generators/card/set/templates/set_template.erb +1 -0
  120. data/mod/01_core/chunk/include.rb +85 -0
  121. data/mod/01_core/chunk/link.rb +87 -0
  122. data/mod/01_core/chunk/literal.rb +24 -0
  123. data/mod/01_core/chunk/reference.rb +53 -0
  124. data/mod/01_core/chunk/uri.rb +135 -0
  125. data/mod/01_core/format/data_format.rb +2 -0
  126. data/mod/01_core/format/html_format.rb +129 -0
  127. data/mod/01_core/format/text_format.rb +10 -0
  128. data/mod/01_core/layout/blank.html +5 -0
  129. data/mod/01_core/layout/default.html +20 -0
  130. data/mod/01_core/layout/noside.html +16 -0
  131. data/mod/01_core/layout/pre.html +2 -0
  132. data/mod/01_core/layout/simple.html +5 -0
  133. data/mod/01_core/set/all/active_card.rb +35 -0
  134. data/mod/01_core/set/all/collection.rb +142 -0
  135. data/mod/01_core/set/all/content.rb +64 -0
  136. data/mod/01_core/set/all/erb.rb +11 -0
  137. data/mod/01_core/set/all/fetch.rb +228 -0
  138. data/mod/01_core/set/all/haml.rb +7 -0
  139. data/mod/01_core/set/all/initialize.rb +49 -0
  140. data/mod/01_core/set/all/name.rb +275 -0
  141. data/mod/01_core/set/all/pattern.rb +56 -0
  142. data/mod/01_core/set/all/permissions.rb +284 -0
  143. data/mod/01_core/set/all/phases.rb +185 -0
  144. data/mod/01_core/set/all/references.rb +118 -0
  145. data/mod/01_core/set/all/rules.rb +315 -0
  146. data/mod/01_core/set/all/states.rb +16 -0
  147. data/mod/01_core/set/all/templating.rb +120 -0
  148. data/mod/01_core/set/all/tracked_attributes.rb +114 -0
  149. data/mod/01_core/set/all/trash.rb +50 -0
  150. data/mod/01_core/set/all/type.rb +85 -0
  151. data/mod/01_core/set/all/utils.rb +85 -0
  152. data/mod/01_core/set_pattern/01_all.rb +11 -0
  153. data/mod/01_core/set_pattern/02_all_plus.rb +13 -0
  154. data/mod/01_core/set_pattern/03_type.rb +23 -0
  155. data/mod/01_core/set_pattern/04_star.rb +15 -0
  156. data/mod/01_core/set_pattern/05_rstar.rb +17 -0
  157. data/mod/01_core/set_pattern/06_right.rb +20 -0
  158. data/mod/01_core/set_pattern/07_type_plus_right.rb +23 -0
  159. data/mod/01_core/set_pattern/08_self.rb +19 -0
  160. data/mod/01_core/spec/chunk/literal_spec.rb +14 -0
  161. data/mod/01_core/spec/chunk/uri_spec.rb +292 -0
  162. data/mod/01_core/spec/format/data_format_spec.rb +5 -0
  163. data/mod/01_core/spec/format/html_format_spec.rb +140 -0
  164. data/mod/01_core/spec/format/text_format_spec.rb +5 -0
  165. data/mod/01_core/spec/set/all/active_card_spec.rb +5 -0
  166. data/mod/01_core/spec/set/all/attribute_tracking_spec.rb +21 -0
  167. data/mod/01_core/spec/set/all/collection_spec.rb +65 -0
  168. data/mod/01_core/spec/set/all/content_spec.rb +15 -0
  169. data/mod/01_core/spec/set/all/fetch_spec.rb +204 -0
  170. data/mod/01_core/spec/set/all/initialize_spec.rb +58 -0
  171. data/mod/01_core/spec/set/all/name_spec.rb +61 -0
  172. data/mod/01_core/spec/set/all/pattern_spec.rb +81 -0
  173. data/mod/01_core/spec/set/all/permissions_spec.rb +505 -0
  174. data/mod/01_core/spec/set/all/phases_spec.rb +6 -0
  175. data/mod/01_core/spec/set/all/references_spec.rb +8 -0
  176. data/mod/01_core/spec/set/all/rules2_spec.rb +250 -0
  177. data/mod/01_core/spec/set/all/rules_spec.rb +130 -0
  178. data/mod/01_core/spec/set/all/states_spec.rb +5 -0
  179. data/mod/01_core/spec/set/all/templating_spec.rb +111 -0
  180. data/mod/01_core/spec/set/all/tracked_attributes_spec.rb +328 -0
  181. data/mod/01_core/spec/set/all/trash_spec.rb +34 -0
  182. data/mod/01_core/spec/set/all/type_spec.rb +71 -0
  183. data/mod/01_core/spec/set/all/utils_spec.rb +5 -0
  184. data/mod/01_history/lib/card/act.rb +60 -0
  185. data/mod/01_history/lib/card/action.rb +176 -0
  186. data/mod/01_history/lib/card/change.rb +29 -0
  187. data/mod/01_history/set/all/actions.rb +47 -0
  188. data/mod/01_history/set/all/content_history.rb +131 -0
  189. data/mod/01_history/set/all/history.rb +296 -0
  190. data/mod/02_basic_types/format/css_format.rb +6 -0
  191. data/mod/02_basic_types/format/csv_format.rb +6 -0
  192. data/mod/02_basic_types/format/file_format.rb +3 -0
  193. data/mod/02_basic_types/format/js_format.rb +6 -0
  194. data/mod/02_basic_types/format/json_format.rb +6 -0
  195. data/mod/02_basic_types/format/rss_format.rb +11 -0
  196. data/mod/02_basic_types/format/xml_format.rb +6 -0
  197. data/mod/02_basic_types/set/all/all_css.rb +42 -0
  198. data/mod/02_basic_types/set/all/all_csv.rb +52 -0
  199. data/mod/02_basic_types/set/all/all_js.rb +7 -0
  200. data/mod/02_basic_types/set/all/base.rb +122 -0
  201. data/mod/02_basic_types/set/all/file.rb +13 -0
  202. data/mod/02_basic_types/set/all/json.rb +66 -0
  203. data/mod/02_basic_types/set/all/rss.rb +72 -0
  204. data/mod/02_basic_types/set/all/text.rb +8 -0
  205. data/mod/02_basic_types/set/type/plain_text.rb +10 -0
  206. data/mod/02_basic_types/set/type/pointer.rb +323 -0
  207. data/mod/02_basic_types/spec/set/all/all_css_spec.rb +10 -0
  208. data/mod/02_basic_types/spec/set/all/all_csv_spec.rb +9 -0
  209. data/mod/02_basic_types/spec/set/all/base_spec.rb +57 -0
  210. data/mod/02_basic_types/spec/set/all/file_spec.rb +5 -0
  211. data/mod/02_basic_types/spec/set/all/json_spec.rb +26 -0
  212. data/mod/02_basic_types/spec/set/all/rss_spec.rb +8 -0
  213. data/mod/02_basic_types/spec/set/all/text_spec.rb +5 -0
  214. data/mod/02_basic_types/spec/set/type/plain_text_spec.rb +11 -0
  215. data/mod/02_basic_types/spec/set/type/pointer_spec.rb +103 -0
  216. data/mod/03_machines/lib/card/machine.rb +185 -0
  217. data/mod/03_machines/lib/card/machine_input.rb +40 -0
  218. data/mod/03_machines/lib/javascript/ace.js +18204 -0
  219. data/mod/03_machines/lib/javascript/html5shiv-printshiv.js +1 -0
  220. data/mod/03_machines/lib/javascript/jquery-ui.js +14913 -0
  221. data/mod/03_machines/lib/javascript/jquery.autosize.js +274 -0
  222. data/mod/03_machines/lib/javascript/jquery.fileupload.js +1114 -0
  223. data/mod/03_machines/lib/javascript/jquery.iframe-transport.js +185 -0
  224. data/mod/03_machines/lib/javascript/jquery.js +4 -0
  225. data/mod/03_machines/lib/javascript/jquery.ui.autocomplete.html.js +41 -0
  226. data/mod/03_machines/lib/javascript/jquery_ujs.js +469 -0
  227. data/mod/03_machines/lib/javascript/jquerymobile.js +15454 -0
  228. data/mod/03_machines/lib/javascript/theme-textmate.js +130 -0
  229. data/mod/03_machines/lib/javascript/tinymce.js +13 -0
  230. data/mod/03_machines/lib/javascript/wagn.js.coffee +336 -0
  231. data/mod/03_machines/lib/javascript/wagn_menu.js +72 -0
  232. data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +446 -0
  233. data/mod/03_machines/lib/stylesheets/functional.scss +184 -0
  234. data/mod/03_machines/lib/stylesheets/jquery-ui-smoothness.css +1178 -0
  235. data/mod/03_machines/lib/stylesheets/standard.scss +760 -0
  236. data/mod/03_machines/set/right/machine_output.rb +20 -0
  237. data/mod/03_machines/set/self/script_ace.rb +8 -0
  238. data/mod/03_machines/set/self/script_card_menu.rb +8 -0
  239. data/mod/03_machines/set/self/script_html5shiv_printshiv.rb +7 -0
  240. data/mod/03_machines/set/self/script_jquery.rb +8 -0
  241. data/mod/03_machines/set/self/script_jquery_helper.rb +14 -0
  242. data/mod/03_machines/set/self/script_slot.rb +9 -0
  243. data/mod/03_machines/set/self/script_tinymce.rb +8 -0
  244. data/mod/03_machines/set/self/style_functional.rb +8 -0
  245. data/mod/03_machines/set/self/style_jquery_ui_smoothness.rb +8 -0
  246. data/mod/03_machines/set/self/style_standard.rb +8 -0
  247. data/mod/03_machines/set/type/coffee_script.rb +61 -0
  248. data/mod/03_machines/set/type/css.rb +45 -0
  249. data/mod/03_machines/set/type/java_script.rb +38 -0
  250. data/mod/03_machines/set/type/scss.rb +23 -0
  251. data/mod/03_machines/set/type/skin.rb +12 -0
  252. data/mod/03_machines/spec/lib/shared_machine_examples.rb +175 -0
  253. data/mod/03_machines/spec/lib/shared_machine_input_examples.rb +65 -0
  254. data/mod/03_machines/spec/set/right/machine_output_spec.rb +5 -0
  255. data/mod/03_machines/spec/set/self/style_functional_spec.rb +5 -0
  256. data/mod/03_machines/spec/set/self/style_jquery_ui_smoothness_spec.rb +5 -0
  257. data/mod/03_machines/spec/set/self/style_standard_spec.rb +5 -0
  258. data/mod/03_machines/spec/set/type/coffeescript_spec.rb +29 -0
  259. data/mod/03_machines/spec/set/type/css_spec.rb +34 -0
  260. data/mod/03_machines/spec/set/type/javascript_spec.rb +28 -0
  261. data/mod/03_machines/spec/set/type/scss_spec.rb +56 -0
  262. data/mod/03_machines/spec/set/type/skin_spec.rb +70 -0
  263. data/mod/04_settings/lib/card/setting.rb +65 -0
  264. data/mod/04_settings/set/right/add_help.rb +11 -0
  265. data/mod/04_settings/set/right/comment.rb +91 -0
  266. data/mod/04_settings/set/right/create.rb +3 -0
  267. data/mod/04_settings/set/right/default.rb +3 -0
  268. data/mod/04_settings/set/right/delete.rb +4 -0
  269. data/mod/04_settings/set/right/help.rb +3 -0
  270. data/mod/04_settings/set/right/read.rb +2 -0
  271. data/mod/04_settings/set/right/script.rb +10 -0
  272. data/mod/04_settings/set/right/structure.rb +4 -0
  273. data/mod/04_settings/set/right/style.rb +10 -0
  274. data/mod/04_settings/set/right/update.rb +2 -0
  275. data/mod/04_settings/set/self/accountable.rb +3 -0
  276. data/mod/04_settings/set/self/add_help.rb +2 -0
  277. data/mod/04_settings/set/self/autoname.rb +2 -0
  278. data/mod/04_settings/set/self/captcha.rb +2 -0
  279. data/mod/04_settings/set/self/comment.rb +2 -0
  280. data/mod/04_settings/set/self/create.rb +2 -0
  281. data/mod/04_settings/set/self/default.rb +2 -0
  282. data/mod/04_settings/set/self/delete.rb +2 -0
  283. data/mod/04_settings/set/self/help.rb +2 -0
  284. data/mod/04_settings/set/self/input.rb +2 -0
  285. data/mod/04_settings/set/self/layout.rb +2 -0
  286. data/mod/04_settings/set/self/on_create.rb +2 -0
  287. data/mod/04_settings/set/self/on_delete.rb +2 -0
  288. data/mod/04_settings/set/self/on_update.rb +2 -0
  289. data/mod/04_settings/set/self/options.rb +2 -0
  290. data/mod/04_settings/set/self/options_label.rb +2 -0
  291. data/mod/04_settings/set/self/read.rb +2 -0
  292. data/mod/04_settings/set/self/script.rb +2 -0
  293. data/mod/04_settings/set/self/structure.rb +2 -0
  294. data/mod/04_settings/set/self/style.rb +2 -0
  295. data/mod/04_settings/set/self/table_of_contents.rb +2 -0
  296. data/mod/04_settings/set/self/thanks.rb +2 -0
  297. data/mod/04_settings/set/self/update.rb +2 -0
  298. data/mod/04_settings/set/type/setting.rb +82 -0
  299. data/mod/04_settings/spec/set/right/add_help_spec.rb +5 -0
  300. data/mod/04_settings/spec/set/right/comment_spec.rb +41 -0
  301. data/mod/04_settings/spec/set/right/create_spec.rb +10 -0
  302. data/mod/04_settings/spec/set/right/default_spec.rb +5 -0
  303. data/mod/04_settings/spec/set/right/delete_spec.rb +5 -0
  304. data/mod/04_settings/spec/set/right/help_spec.rb +5 -0
  305. data/mod/04_settings/spec/set/right/read_spec.rb +5 -0
  306. data/mod/04_settings/spec/set/right/script_spec.rb +24 -0
  307. data/mod/04_settings/spec/set/right/structure_spec.rb +17 -0
  308. data/mod/04_settings/spec/set/right/style_spec.rb +29 -0
  309. data/mod/04_settings/spec/set/right/update_spec.rb +5 -0
  310. data/mod/04_settings/spec/set/type/setting_spec.rb +10 -0
  311. data/mod/05_email/format/email_html_format.rb +9 -0
  312. data/mod/05_email/format/email_text_format.rb +11 -0
  313. data/mod/05_email/lib/card/follow_option.rb +90 -0
  314. data/mod/05_email/set/all/email_html.rb +5 -0
  315. data/mod/05_email/set/all/email_text.rb +5 -0
  316. data/mod/05_email/set/all/follow.rb +256 -0
  317. data/mod/05_email/set/all/notify.rb +223 -0
  318. data/mod/05_email/set/all/observer.rb +27 -0
  319. data/mod/05_email/set/right/bcc.rb +45 -0
  320. data/mod/05_email/set/right/cc.rb +3 -0
  321. data/mod/05_email/set/right/follow.rb +9 -0
  322. data/mod/05_email/set/right/follow_fields.rb +3 -0
  323. data/mod/05_email/set/right/followers.rb +30 -0
  324. data/mod/05_email/set/right/following.rb +52 -0
  325. data/mod/05_email/set/right/from.rb +3 -0
  326. data/mod/05_email/set/right/html_message.rb +3 -0
  327. data/mod/05_email/set/right/to.rb +3 -0
  328. data/mod/05_email/set/self/always.rb +14 -0
  329. data/mod/05_email/set/self/created.rb +21 -0
  330. data/mod/05_email/set/self/edited.rb +24 -0
  331. data/mod/05_email/set/self/follow.rb +2 -0
  332. data/mod/05_email/set/self/follow_defaults.rb +66 -0
  333. data/mod/05_email/set/self/never.rb +15 -0
  334. data/mod/05_email/set/type/email_template.rb +113 -0
  335. data/mod/05_email/set/type_plus_right/user/follow.rb +176 -0
  336. data/mod/05_email/spec/set/all/follow_spec.rb +133 -0
  337. data/mod/05_email/spec/set/all/notify_spec.rb +364 -0
  338. data/mod/05_email/spec/set/all/observer_spec.rb +76 -0
  339. data/mod/05_email/spec/set/right/followers_spec.rb +126 -0
  340. data/mod/05_email/spec/set/right/following_spec.rb +4 -0
  341. data/mod/05_email/spec/set/self/follow_defaults_spec.rb +18 -0
  342. data/mod/05_standard/file/103/icon-6566.ico +0 -0
  343. data/mod/05_standard/file/103/large-6566.ico +0 -0
  344. data/mod/05_standard/file/103/medium-6566.ico +0 -0
  345. data/mod/05_standard/file/103/original-6566.ico +0 -0
  346. data/mod/05_standard/file/103/small-6566.ico +0 -0
  347. data/mod/05_standard/file/79/icon-6556.png +0 -0
  348. data/mod/05_standard/file/79/large-6556.png +0 -0
  349. data/mod/05_standard/file/79/medium-6556.png +0 -0
  350. data/mod/05_standard/file/79/original-6556.png +0 -0
  351. data/mod/05_standard/file/79/small-6556.png +0 -0
  352. data/mod/05_standard/file/790/icon-6419.png +0 -0
  353. data/mod/05_standard/file/790/large-6419.png +0 -0
  354. data/mod/05_standard/file/790/medium-6419.png +0 -0
  355. data/mod/05_standard/file/790/original-6419.png +0 -0
  356. data/mod/05_standard/file/790/small-6419.png +0 -0
  357. data/mod/05_standard/set/all/account.rb +67 -0
  358. data/mod/05_standard/set/all/attach.rb +152 -0
  359. data/mod/05_standard/set/all/comment.rb +39 -0
  360. data/mod/05_standard/set/all/error.rb +214 -0
  361. data/mod/05_standard/set/all/event_viz.rb +62 -0
  362. data/mod/05_standard/set/all/links.rb +110 -0
  363. data/mod/05_standard/set/all/rich_html/content.rb +173 -0
  364. data/mod/05_standard/set/all/rich_html/editing.rb +145 -0
  365. data/mod/05_standard/set/all/rich_html/form.rb +234 -0
  366. data/mod/05_standard/set/all/rich_html/header.rb +64 -0
  367. data/mod/05_standard/set/all/rich_html/wrapper.rb +105 -0
  368. data/mod/05_standard/set/right/account.rb +180 -0
  369. data/mod/05_standard/set/right/email.rb +52 -0
  370. data/mod/05_standard/set/right/password.rb +39 -0
  371. data/mod/05_standard/set/right/salt.rb +5 -0
  372. data/mod/05_standard/set/right/stats.rb +35 -0
  373. data/mod/05_standard/set/right/status.rb +9 -0
  374. data/mod/05_standard/set/right/token.rb +5 -0
  375. data/mod/05_standard/set/right/when_created.rb +5 -0
  376. data/mod/05_standard/set/right/when_last_edited.rb +5 -0
  377. data/mod/05_standard/set/rstar/rules.rb +407 -0
  378. data/mod/05_standard/set/self/account_links.rb +61 -0
  379. data/mod/05_standard/set/self/alerts.rb +5 -0
  380. data/mod/05_standard/set/self/all.rb +21 -0
  381. data/mod/05_standard/set/self/foot.rb +8 -0
  382. data/mod/05_standard/set/self/head.rb +121 -0
  383. data/mod/05_standard/set/self/navbox.rb +20 -0
  384. data/mod/05_standard/set/self/now.rb +6 -0
  385. data/mod/05_standard/set/self/recent.rb +48 -0
  386. data/mod/05_standard/set/self/search.rb +43 -0
  387. data/mod/05_standard/set/self/signin.rb +121 -0
  388. data/mod/05_standard/set/self/stats.rb +91 -0
  389. data/mod/05_standard/set/self/version.rb +9 -0
  390. data/mod/05_standard/set/type/basic.rb +46 -0
  391. data/mod/05_standard/set/type/cardtype.rb +43 -0
  392. data/mod/05_standard/set/type/date.rb +8 -0
  393. data/mod/05_standard/set/type/file.rb +85 -0
  394. data/mod/05_standard/set/type/html.rb +22 -0
  395. data/mod/05_standard/set/type/image.rb +67 -0
  396. data/mod/05_standard/set/type/layout_type.rb +14 -0
  397. data/mod/05_standard/set/type/number.rb +19 -0
  398. data/mod/05_standard/set/type/phrase.rb +3 -0
  399. data/mod/05_standard/set/type/search_type.rb +243 -0
  400. data/mod/05_standard/set/type/set.rb +198 -0
  401. data/mod/05_standard/set/type/signup.rb +144 -0
  402. data/mod/05_standard/set/type/toggle.rb +12 -0
  403. data/mod/05_standard/set/type/uri.rb +11 -0
  404. data/mod/05_standard/set/type/user.rb +72 -0
  405. data/mod/05_standard/spec/chunk/include_spec.rb +186 -0
  406. data/mod/05_standard/spec/chunk/link_spec.rb +61 -0
  407. data/mod/05_standard/spec/format/css_format_spec.rb +5 -0
  408. data/mod/05_standard/spec/format/csv_format_spec.rb +5 -0
  409. data/mod/05_standard/spec/format/email_html_format_spec.rb +5 -0
  410. data/mod/05_standard/spec/format/file_format_spec.rb +5 -0
  411. data/mod/05_standard/spec/format/js_format_spec.rb +5 -0
  412. data/mod/05_standard/spec/format/json_format_spec.rb +5 -0
  413. data/mod/05_standard/spec/format/rss_format_spec.rb +5 -0
  414. data/mod/05_standard/spec/format/xml_format_spec.rb +5 -0
  415. data/mod/05_standard/spec/set/all/account_spec.rb +137 -0
  416. data/mod/05_standard/spec/set/all/attach_spec.rb +9 -0
  417. data/mod/05_standard/spec/set/all/comment_spec.rb +5 -0
  418. data/mod/05_standard/spec/set/all/email_html_spec.rb +15 -0
  419. data/mod/05_standard/spec/set/all/error_spec.rb +9 -0
  420. data/mod/05_standard/spec/set/all/event_viz_spec.rb +9 -0
  421. data/mod/05_standard/spec/set/all/history_spec.rb +173 -0
  422. data/mod/05_standard/spec/set/all/rich_html/form_spec.rb +43 -0
  423. data/mod/05_standard/spec/set/all/rich_html/wrapper_spec.rb +28 -0
  424. data/mod/05_standard/spec/set/right/account_spec.rb +162 -0
  425. data/mod/05_standard/spec/set/right/email_spec.rb +55 -0
  426. data/mod/05_standard/spec/set/right/password_spec.rb +45 -0
  427. data/mod/05_standard/spec/set/right/salt_spec.rb +5 -0
  428. data/mod/05_standard/spec/set/right/stats_spec.rb +13 -0
  429. data/mod/05_standard/spec/set/right/status_spec.rb +5 -0
  430. data/mod/05_standard/spec/set/right/token_spec.rb +5 -0
  431. data/mod/05_standard/spec/set/right/when_created_spec.rb +7 -0
  432. data/mod/05_standard/spec/set/right/when_last_edited_spec.rb +7 -0
  433. data/mod/05_standard/spec/set/rstar/rules_spec.rb +25 -0
  434. data/mod/05_standard/spec/set/self/account_links_spec.rb +9 -0
  435. data/mod/05_standard/spec/set/self/alerts_spec.rb +5 -0
  436. data/mod/05_standard/spec/set/self/all_spec.rb +48 -0
  437. data/mod/05_standard/spec/set/self/foot_spec.rb +5 -0
  438. data/mod/05_standard/spec/set/self/head_spec.rb +17 -0
  439. data/mod/05_standard/spec/set/self/navbox_spec.rb +7 -0
  440. data/mod/05_standard/spec/set/self/now_spec.rb +7 -0
  441. data/mod/05_standard/spec/set/self/recent_spec.rb +5 -0
  442. data/mod/05_standard/spec/set/self/search_spec.rb +5 -0
  443. data/mod/05_standard/spec/set/self/signin_spec.rb +73 -0
  444. data/mod/05_standard/spec/set/self/stats_spec.rb +12 -0
  445. data/mod/05_standard/spec/set/self/version_spec.rb +7 -0
  446. data/mod/05_standard/spec/set/type/basic_spec.rb +5 -0
  447. data/mod/05_standard/spec/set/type/cardtype_spec.rb +5 -0
  448. data/mod/05_standard/spec/set/type/date_spec.rb +7 -0
  449. data/mod/05_standard/spec/set/type/email_template_spec.rb +208 -0
  450. data/mod/05_standard/spec/set/type/file_spec.rb +5 -0
  451. data/mod/05_standard/spec/set/type/html_spec.rb +23 -0
  452. data/mod/05_standard/spec/set/type/image_spec.rb +16 -0
  453. data/mod/05_standard/spec/set/type/layout_type_spec.rb +7 -0
  454. data/mod/05_standard/spec/set/type/number_spec.rb +7 -0
  455. data/mod/05_standard/spec/set/type/phrase_spec.rb +7 -0
  456. data/mod/05_standard/spec/set/type/search_type_spec.rb +27 -0
  457. data/mod/05_standard/spec/set/type/set_spec.rb +26 -0
  458. data/mod/05_standard/spec/set/type/signup_spec.rb +228 -0
  459. data/mod/05_standard/spec/set/type/toggle_spec.rb +12 -0
  460. data/mod/05_standard/spec/set/type/uri_spec.rb +41 -0
  461. data/mod/05_standard/spec/set/type/user_spec.rb +5 -0
  462. data/mod/06_bootstrap/lib/javascript/bootstrap.js +2306 -0
  463. data/mod/06_bootstrap/lib/javascript/bootstrap.min.js +7 -0
  464. data/mod/06_bootstrap/lib/stylesheets/bootstrap-theme.css +476 -0
  465. data/mod/06_bootstrap/lib/stylesheets/bootstrap.css +6565 -0
  466. data/mod/06_bootstrap/lib/stylesheets/darkly.css +6583 -0
  467. data/mod/06_bootstrap/set/all/bootstrap/form.rb +37 -0
  468. data/mod/06_bootstrap/set/all/bootstrap/header.rb +29 -0
  469. data/mod/06_bootstrap/set/all/bootstrap/wrapper.rb +12 -0
  470. data/mod/06_bootstrap/set/all/rich_bootstrap.rb +28 -0
  471. data/mod/06_bootstrap/set/self/bootstrap_css.rb +7 -0
  472. data/mod/06_bootstrap/set/self/bootstrap_js.rb +7 -0
  473. data/mod/06_bootstrap/set/self/bootstrap_theme_css.rb +7 -0
  474. data/mod/06_bootstrap/set/self/navbox.rb +32 -0
  475. data/mod/06_bootstrap/set/type/search_type.rb +79 -0
  476. data/mod/06_bootstrap/spec/set/all/bootstrap/form_spec.rb +13 -0
  477. data/spec/lib/card/action_spec.rb +14 -0
  478. data/spec/lib/card/auth_spec.rb +17 -0
  479. data/spec/lib/card/cache_spec.rb +122 -0
  480. data/spec/lib/card/chunk_spec.rb +17 -0
  481. data/spec/lib/card/codename_spec.rb +25 -0
  482. data/spec/lib/card/content_spec.rb +314 -0
  483. data/spec/lib/card/diff_spec.rb +210 -0
  484. data/spec/lib/card/format_spec.rb +82 -0
  485. data/spec/lib/card/loader_spec.rb +39 -0
  486. data/spec/lib/card/log_spec.rb +270 -0
  487. data/spec/lib/card/name_spec.rb +279 -0
  488. data/spec/lib/card/query_spec.rb +456 -0
  489. data/spec/lib/card/reference_spec.rb +213 -0
  490. data/spec/lib/card/set_pattern_spec.rb +56 -0
  491. data/spec/lib/card/set_spec.rb +88 -0
  492. data/spec/mailers/mailer_spec.rb +64 -0
  493. data/spec/models/card/cardtype_spec.rb +216 -0
  494. data/spec/models/card/create_spec.rb +82 -0
  495. data/spec/models/card/trash_spec.rb +260 -0
  496. data/spec/models/card/type_transition_spec.rb +161 -0
  497. data/spec/models/card/validation_spec.rb +36 -0
  498. data/spec/models/card_spec.rb +177 -0
  499. data/spec/spec_helper.rb +130 -0
  500. data/test/fixtures/.gitkeep +0 -0
  501. data/test/fixtures/card_actions.yml +5706 -0
  502. data/test/fixtures/card_acts.yml +835 -0
  503. data/test/fixtures/card_changes.yml +17182 -0
  504. data/test/fixtures/card_references.yml +5405 -0
  505. data/test/fixtures/cards.yml +15533 -0
  506. data/test/fixtures/mao2.jpg +0 -0
  507. data/test/fixtures/rails.gif +0 -0
  508. data/test/seed.rb +201 -0
  509. metadata +762 -38
  510. data/.gitignore +0 -17
  511. data/Gemfile +0 -4
  512. data/LICENSE.txt +0 -22
  513. data/README.md +0 -29
  514. data/Rakefile +0 -1
@@ -0,0 +1,198 @@
1
+
2
+ format :html do
3
+
4
+ view :core do |args|
5
+ body = card.setting_codenames_by_group.map do |group, data|
6
+ next if group.nil? || data.nil?
7
+ group_name = Card::Setting.group_names[group] || group.to_s
8
+ content_tag(:tr, :class=>"rule-group") do
9
+ (["#{group_name} Rules"]+%w{Content Set}).map do |heading|
10
+ content_tag(:th, :class=>'rule-heading') { heading }
11
+ end * "\n"
12
+ end +
13
+ raw( data.map do |setting|
14
+ rule_card = card.fetch(:trait=>setting, :new=>{})
15
+ nest rule_card, :view=>:closed_rule
16
+ end * "\n" )
17
+ end.compact * ''
18
+ %{
19
+ #{
20
+ unless args[:unlabeled]
21
+ %{ <h2 class="set-label">#{ card.label }</h2> }
22
+ end
23
+ }
24
+ #{ content_tag('table', :class=>'set-rules') { body } }
25
+ }
26
+ end
27
+
28
+
29
+ view :editor do |args|
30
+ 'Cannot currently edit Sets' #ENGLISH
31
+ end
32
+
33
+ view :template_link do |args|
34
+ args.delete :style
35
+ wrap args do
36
+ link = view_link args[:inc_syntax], :template_editor, :class=>'slotter' #, 'slot-include'=>include_syntax
37
+ "{{#{link}}}"
38
+ end
39
+ end
40
+
41
+ view :template_closer do |args|
42
+ view_link '', :template_link, :class=>'slotter glyphicon glyphicon-remove template-editor-close'
43
+ end
44
+
45
+ view :template_editor do |args|
46
+ wrap args do
47
+ %{
48
+ <div class="template-editor-left">{{</div>
49
+ <div class="template-editor-main">
50
+ #{ render_template_editor_frame args }
51
+ </div>
52
+ <div class="template-editor-right">}}</div>
53
+ }
54
+ end
55
+ end
56
+
57
+ view :template_editor_frame do |args|
58
+ frame :no_slot=>true, :title=>card.label, :menu_hack=>:template_closer do
59
+ _render_core args.merge(:unlabeled=>true)
60
+ end
61
+ end
62
+
63
+ view :closed_content do |args|
64
+ ''
65
+ end
66
+
67
+ end
68
+
69
+
70
+ include Card::Set::Type::SearchType
71
+
72
+ def followed_by? user_id = nil
73
+ all_members_followed_by? user_id
74
+ end
75
+
76
+
77
+ def default_follow_set_card
78
+ self
79
+ end
80
+
81
+ def inheritable?
82
+ return true if junction_only?
83
+ cardname.trunk_name.junction? and cardname.tag_name.key == Card::SelfSet.pattern.key
84
+ end
85
+
86
+ def subclass_for_set
87
+ set_class_key = tag.codename
88
+ Card.set_patterns.find do |sub|
89
+ cardname.tag_name.key == sub.pattern.key
90
+ end
91
+ end
92
+
93
+ def junction_only?()
94
+ if @junction_only.nil?
95
+ @junction_only = subclass_for_set.junction_only
96
+ else
97
+ @junction_only
98
+ end
99
+ end
100
+
101
+ def reset_set_patterns
102
+ Card.members( key ).each do |mem|
103
+ Card.expire mem
104
+ end
105
+ end
106
+
107
+ def label
108
+ if klass = subclass_for_set
109
+ klass.label cardname.left
110
+ else
111
+ ''
112
+ end
113
+ end
114
+
115
+ def follow_label
116
+ if klass = subclass_for_set
117
+ klass.follow_label cardname.left
118
+ else
119
+ ''
120
+ end
121
+ end
122
+
123
+ def follow_rule_name user=nil
124
+ if user
125
+ if user.kind_of? String
126
+ "#{name}+#{user}+#{Card[:follow].name}"
127
+ else
128
+ "#{name}+#{user.name}+#{Card[:follow].name}"
129
+ end
130
+ else
131
+ "#{name}+#{Card[:all].name}+#{Card[:follow].name}"
132
+ end
133
+ end
134
+
135
+ # def to_following_item_name args
136
+ # left_part = follow_rule_name( args[:user] )
137
+ # option = args[:option] || if (rule_card = Card.fetch(left_part))
138
+ # rule_card.content
139
+ # else
140
+ # Card[:nothing].name
141
+ # end
142
+ #
143
+ # "#{left_part}+#{option}"
144
+ # end
145
+
146
+ def all_user_ids_with_rule_for setting_code
147
+ Card.all_user_ids_with_rule_for self, setting_code
148
+ end
149
+
150
+
151
+ def setting_codenames_by_group
152
+ result = {}
153
+ Card::Setting.groups.each do |group, settings|
154
+ visible_settings = settings.reject { |s| !s or !s.applies_to_cardtype(prototype.type_id) }
155
+ unless visible_settings.empty?
156
+ result[group] = visible_settings.map { |s| s.codename }
157
+ end
158
+ end
159
+ result
160
+ end
161
+
162
+ def all_members_followed?
163
+ all_members_followed_by? Auth.current_id
164
+ end
165
+
166
+ def all_members_followed_by? user_id = nil
167
+ if !prototype.followed_by? user_id
168
+ return false
169
+ elsif set_followed_by? user_id
170
+ return true
171
+ else
172
+ broader_sets.each do |b_s|
173
+ if (set_card = Card.fetch(b_s)) && set_card.set_followed_by?(user_id)
174
+ return true
175
+ end
176
+ end
177
+ end
178
+ return false
179
+ end
180
+
181
+ def set_followed?
182
+ set_followed_by? Auth.current_id
183
+ end
184
+
185
+ def set_followed_by? user_id = nil
186
+ return ( user_id && (user = Card.find(user_id)) && Card.fetch(follow_rule_name(user.name)) ) ||
187
+ Card.fetch(follow_rule_name)
188
+ end
189
+
190
+ def broader_sets
191
+ prototype.set_names[1..-1]
192
+ end
193
+
194
+
195
+ def prototype
196
+ opts = subclass_for_set.prototype_args self.cardname.trunk_name
197
+ Card.fetch opts[:name], :new=>opts
198
+ end
@@ -0,0 +1,144 @@
1
+
2
+ format :html do
3
+
4
+ def default_new_args args
5
+ super args
6
+ args.merge!(
7
+ :optional_help => :show, #, :optional_menu=>:never
8
+ :buttons => button_tag( 'Submit', :disable_with=>'Submitting' ),
9
+ :account => card.fetch( :trait=>:account, :new=>{} ),
10
+ :title => 'Sign up',
11
+ :hidden => {
12
+ :success => (card.rule(:thanks) || '_self'),
13
+ 'card[type_id]' => card.type_id
14
+ }
15
+ )
16
+
17
+ if Auth.signed_in? and args[:account].confirm_ok?
18
+ args[:title] = 'Invite'
19
+ args[:buttons] = button_tag 'Send Invitation'
20
+ args[:hidden][:success] = '_self'
21
+ end
22
+ end
23
+
24
+ view :new do |args|
25
+ #FIXME - make more use of standard new view?
26
+
27
+ frame_and_form :create, args, 'main-success'=>"REDIRECT" do
28
+ [
29
+ _render_name_fieldset( :help=>'usually first and last name' ),
30
+ _optional_render( :account_fieldsets, args),
31
+ ( card.structure ? edit_slot : ''),
32
+ _optional_render( :button_fieldset, args )
33
+ ]
34
+ end
35
+ end
36
+
37
+
38
+ view :account_fieldsets do |args|
39
+ sub_args = { :structure => true }
40
+ sub_args[:no_password] = true if Auth.signed_in?
41
+ Auth.as_bot { subformat( args[:account] )._render :content_fieldset, sub_args } #YUCK!!!!
42
+ end
43
+
44
+
45
+ view :core do |args|
46
+ headings, links = [], []
47
+ if !card.new_card? #necessary?
48
+ by_anon = card.creator_id == AnonymousID
49
+ headings << %(<strong>#{ card.name }</strong> #{ 'was' if !by_anon } signed up on #{ format_date card.created_at })
50
+ if account = card.account
51
+ token_action = 'Send'
52
+ if account.token.present?
53
+ headings << "A verification email has been sent #{ "to #{account.email}" if account.email_card.ok? :read }"
54
+ token_action = 'Resend'
55
+ end
56
+ if account.confirm_ok?
57
+ links << link_to( "#{token_action} verification email", card_path("update/~#{card.id}?approve_with_token=true" ) )
58
+ links << link_to( "Approve without verification", card_path("update/~#{card.id}?approve_without_token=true") )
59
+ end
60
+ if card.ok? :delete
61
+ links << link_to( "Deny and delete", card_path("delete/~#{card.id}") )
62
+ end
63
+ headings << links * '' if links.any?
64
+ else
65
+ headings << "ERROR: signup card missing account"
66
+ end
67
+ end
68
+ %{<div class="invite-links">
69
+ #{ headings.map { |h| "<div>#{h}</div>"} * "\n" }
70
+ </div>
71
+ #{ process_content render_raw }
72
+ }
73
+ end
74
+ end
75
+
76
+ event :activate_by_token, :before=>:approve, :on=>:update, :when=>proc{ |c| c.has_token? } do
77
+ result = account ? account.authenticate_by_token( @env_token ) : "no account associated with #{name}"
78
+ case result
79
+ when Integer
80
+ abort :failure, 'no field manipulation mid-activation' if subcards.present?
81
+ # necessary because the rest of the action is performed as Wagn Bot
82
+ activate_account
83
+ Auth.signin id
84
+ Auth.as_bot
85
+ Env.params[:success] = ''
86
+ when :token_expired
87
+ resend_activation_token
88
+ abort :success
89
+ else
90
+ abort :failure, "signup activation error: #{result}" # bad token or account
91
+ end
92
+ end
93
+
94
+ def has_token?
95
+ @env_token = Env.params[:token]
96
+ end
97
+
98
+ event :activate_account do
99
+ subcards['+*account'] = {'+*status'=>'active'}
100
+ self.type_id = Card.default_accounted_type_id
101
+ account.send_welcome_email
102
+ end
103
+
104
+ event :approve_with_token, :on=>:update, :before=>:approve, :when=>proc {|c| Env.params[:approve_with_token] } do
105
+ abort :failure, 'illegal approval' unless account.confirm_ok?
106
+ account.reset_token
107
+ account.send_account_verification_email
108
+ end
109
+
110
+ event :approve_without_token, :on=>:update, :before=>:approve, :when=>proc {|c| Env.params[:approve_without_token] } do
111
+ abort :failure, 'illegal approval' unless account.confirm_ok?
112
+ activate_account
113
+ end
114
+
115
+ event :resend_activation_token do
116
+ account.reset_token
117
+ account.send_account_verification_email
118
+ Env.params[:success] = {
119
+ :id => '_self',
120
+ :view => 'message',
121
+ :message => "Sorry, this token has expired. Please check your email for a new password reset link."
122
+ }
123
+ end
124
+
125
+ def signed_in_as_me_without_password?
126
+ Auth.signed_in? && Auth.current_id==id && account.password.blank?
127
+ end
128
+
129
+ event :redirect_to_edit_password, :on=>:update, :after=>:store, :when=>proc {|c| c.signed_in_as_me_without_password? } do
130
+ Env.params[:success] = account.edit_password_success_args
131
+ end
132
+
133
+ event :preprocess_account_subcards, :before=>:process_subcards, :on=>:create do
134
+ #FIXME: use codenames!
135
+ email, password = subcards.delete('+*account+*email'), subcards.delete('+*account+*password')
136
+ subcards['+*account'] ||={}
137
+ subcards['+*account']['+*email'] = email if email
138
+ subcards['+*account']['+*password' ]=password if password
139
+ end
140
+
141
+ event :act_as_current_for_extend_phase, :before=>:extend, :on=>:create do
142
+ Auth.current_id = self.id
143
+ end
144
+
@@ -0,0 +1,12 @@
1
+
2
+ view :core do |args|
3
+ case card.raw_content.to_i
4
+ when 1; 'yes'
5
+ when 0; 'no'
6
+ else ; '?'
7
+ end
8
+ end
9
+
10
+ view :editor do |args|
11
+ check_box :content
12
+ end
@@ -0,0 +1,11 @@
1
+ format do
2
+ include Phrase::Format
3
+
4
+ view :core do |args|
5
+ web_link _render_raw(args), :text=> render_title(args)
6
+ end
7
+
8
+ view :url_link do |args|
9
+ web_link _render_raw(args)
10
+ end
11
+ end
@@ -0,0 +1,72 @@
1
+
2
+ include Basic
3
+
4
+ attr_accessor :email
5
+
6
+ format :html do
7
+
8
+ view :setup, :tags=>:unknown_ok, :perms=>lambda { |r| Auth.needs_setup? } do |args|
9
+ help_text = 'To get started, set up an account.'
10
+ if Card.config.action_mailer.perform_deliveries == false
11
+ help_text += '<br>WARNING: Email delivery is turned off. Change settings in config/application.rb to send sign up notifications.'
12
+ end
13
+ args.merge!( {
14
+ :title=>'Welcome, Wagneer!',
15
+ :optional_help=>:show,
16
+ :optional_menu=>:never,
17
+ :help_text=>help_text,
18
+ :buttons => button_tag( 'Set up', :disable_with=>'Setting up' ),
19
+ :hidden => {
20
+ :success => "REDIRECT: #{ Card.path_setting '/' }",
21
+ 'card[type_id]' => Card.default_accounted_type_id,
22
+ 'setup'=>true
23
+ }
24
+ } )
25
+
26
+ account = card.fetch :trait=>:account, :new=>{}
27
+
28
+ Auth.as_bot do
29
+ frame_and_form :create, args do
30
+ [
31
+ _render_name_fieldset( :help=>'usually first and last name' ),
32
+ subformat(account)._render( :content_fieldset, :structure=>true ),
33
+ _render_button_fieldset( args )
34
+ ]
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+
41
+ event :setup_as_bot, :before=>:check_permissions, :on=>:create, :when=>proc{ |c| Card::Env.params[:setup] } do
42
+ abort :failure unless Auth.needs_setup?
43
+ Auth.as_bot
44
+ # we need bot authority to set the initial administrator roles
45
+ # this is granted and inspected here as a separate event for
46
+ # flexibility and security when configuring initial setups
47
+ end
48
+
49
+ event :setup_first_user, :before=>:process_subcards, :on=>:create, :when=>proc{ |c| Card::Env.params[:setup] } do
50
+ subcards['signup alert email+*to'] = name
51
+ subcards['+*roles'] = { :content => Card[:administrator].name }
52
+
53
+ email, password = subcards.delete('+*account+*email'), subcards.delete('+*account+*password')
54
+ subcards['+*account'] = { '+*email'=>email, '+*password'=>password }
55
+ end
56
+
57
+ event :signin_after_setup, :before=>:extend, :on=>:create, :when=>proc{ |c| Card::Env.params[:setup] } do
58
+ Card.cache.delete Auth::NEED_SETUP_KEY
59
+ Auth.signin id
60
+ end
61
+
62
+ def follow follow_name, option = '*always'
63
+ if (card = Card.fetch(follow_name)) && (set_card = card.default_follow_set_card)
64
+ if (follow_rule = Card.fetch(set_card.follow_rule_name(name), :new=>{}))
65
+ follow_rule.drop_item "*never"
66
+ follow_rule.add_item option
67
+ follow_rule.save!
68
+ end
69
+ end
70
+ end
71
+
72
+
@@ -0,0 +1,186 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ describe Card::Chunk::Include, "Inclusion" do
4
+ include ActionView::Helpers::TextHelper
5
+
6
+ context "syntax parsing" do
7
+ before do
8
+ @class= Card::Chunk::Include
9
+ end
10
+
11
+ it "should ignore invisible comments" do
12
+ expect(render_content("{{## now you see nothing}}")).to eq('')
13
+ end
14
+
15
+ it "should handle visible comments" do
16
+ expect(render_content("{{# now you see me}}")).to eq('<!-- # now you see me -->')
17
+ expect(render_content("{{# -->}}")).to eq('<!-- # --&gt; -->')
18
+ end
19
+
20
+ it "should handle empty inclusions" do
21
+ instance = @class.new( @class.full_match( '{{ }}' ) , nil )
22
+ expect(instance.name).to eq('')
23
+ expect(instance.options[:inc_syntax]).to eq(' ')
24
+ instance1 = @class.new( @class.full_match( '{{|}}' ) , nil )
25
+ expect(instance1.name).to eq('')
26
+ expect(instance1.options[:inc_syntax]).to eq('|')
27
+
28
+ end
29
+
30
+ it "should handle no pipes" do
31
+ instance = @class.new( @class.full_match( '{{toy}}') , nil )
32
+ expect(instance.name).to eq('toy')
33
+ expect(instance.options[:inc_name]).to eq('toy')
34
+ expect(instance.options.key?(:view)).to eq(false)
35
+ end
36
+
37
+ it "should strip the name" do
38
+ expect(@class.new( @class.full_match( '{{ toy }}') , nil ).name).to eq('toy')
39
+ end
40
+
41
+ it 'should strip html tags' do
42
+ expect(@class.new( @class.full_match( '{{ <span>toy</span> }}') , nil ).name).to eq('toy')
43
+ instance = @class.new( @class.full_match( '{{ <span>toy|open</span> }}') , nil )
44
+ expect(instance.name).to eq('toy')
45
+ expect(instance.options[:view]).to eq('open')
46
+ end
47
+
48
+ it "should handle single pipe" do
49
+ options = @class.new( @class.full_match('{{toy|view:link;hide:me}}'), nil ).options
50
+ expect(options[:inc_name]).to eq('toy')
51
+ expect(options[:view]).to eq('link')
52
+ expect(options[:hide]).to eq('me')
53
+ expect(options.key?(:items)).to eq(false)
54
+ end
55
+
56
+ it "should handle multiple pipes" do
57
+ options = @class.new( @class.full_match('{{box|open|closed}}'), nil ).options
58
+ expect(options[:inc_name]).to eq('box')
59
+ expect(options[:view]).to eq('open')
60
+ expect(options[:items][:view]).to eq('closed')
61
+ expect(options[:items].key?(:items)).to eq(false)
62
+ end
63
+
64
+ it "should handle multiple pipes with blank lists" do
65
+ options = @class.new( @class.full_match('{{box||closed}}'), nil ).options
66
+ expect(options[:inc_name]).to eq('box')
67
+ expect(options[:view]).to eq(nil)
68
+ expect(options[:items][:view]).to eq('closed')
69
+ end
70
+
71
+ it "should treat :item as view of next level" do
72
+ options = @class.new( @class.full_match('{{toy|link;item:name}}'), nil ).options
73
+ expect(options[:inc_name]).to eq('toy')
74
+ expect(options[:view]).to eq('link')
75
+ expect(options[:items][:view]).to eq('name')
76
+ end
77
+ end
78
+
79
+ context "rendering" do
80
+
81
+ it "should handle absolute names" do
82
+ alpha = newcard 'Alpha', "Pooey"
83
+ beta = newcard 'Beta', "{{Alpha}}"
84
+ result = beta.format.render_core
85
+ assert_view_select result, 'div[class~="card-content"]', "Pooey"
86
+ end
87
+
88
+ it "should handle simple relative names" do
89
+ alpha = newcard 'Alpha', "{{#{Card::Name.joint}Beta}}"
90
+ beta = newcard 'Beta'
91
+ alpha_beta = Card.create :name=>"#{alpha.name}#{Card::Name.joint}Beta", :content=>"Woot"
92
+ assert_view_select alpha.format.render_core, 'div[class~=card-content]', "Woot"
93
+ end
94
+
95
+ it "should handle complex relative names" do
96
+ bob_city = Card.create! :name=>'bob+city', :content=> "Sparta"
97
+ Card::Auth.as_bot { address_tmpl = Card.create! :name=>'address+*right+*structure', :content =>"{{_left+city}}" }
98
+ bob_address = Card.create! :name=>'bob+address'
99
+
100
+ r=bob_address.reload.format.render_core
101
+ assert_view_select r, 'div[class~=card-content]', "Sparta"
102
+ expect(Card.fetch("bob+address").includees.map(&:name)).to eq([bob_city.name])
103
+ end
104
+
105
+ it "should handle nesting" do
106
+ alpha = newcard 'Alpha', "{{Beta}}"
107
+ beta = newcard 'Beta', "{{Delta}}"
108
+ delta = newcard 'Delta', "Booya"
109
+ r= alpha .format.render_core
110
+ #warn "r=#{r}"
111
+ assert_view_select r, 'div[class~=card-content]'
112
+ expect(r).to match(/Booya/)
113
+ end
114
+
115
+ it "should handle options when nesting" do
116
+ Card.create! :type=>'Pointer', :name=>'Livable', :content=>'[[Earth]]'
117
+ Card.create! :name=>'Earth'
118
+
119
+ expect(render_content('{{Livable|core;item:link}}')).to eq(render_content('{{Livable|core|link}}'))
120
+ expect(render_content('{{Livable|core;item:name}}')).to eq(render_content('{{Livable|core|name}}'))
121
+ end
122
+
123
+ it "should prevent recursion" do
124
+ oak = Card.create! :name=>'Oak', :content=>'{{Quentin}}'
125
+ qnt = Card.create! :name=>'Quentin', :content=>'{{Admin}}'
126
+ adm = Card['Quentin']
127
+ adm.update_attributes :content => "{{Oak}}"
128
+ result = adm.format.render_core
129
+ expect(result).to match('too deep')
130
+ end
131
+
132
+ it "should handle missing cards" do
133
+ @a = Card.create :name=>'boo', :content=>"hey {{+there}}"
134
+ r=@a.format.render_core
135
+ assert_view_select r, 'div[data-card-name="boo+there"][class~="missing-view"]'
136
+ end
137
+
138
+ it "should handle structured cards" do
139
+ age = newcard('age')
140
+ template = Card['*template']
141
+ specialtype = Card.create :type_code=>'Cardtype', :name=>'SpecialType'
142
+
143
+ specialtype_template = specialtype.fetch(:trait=>:type,:new=>{}).fetch(:trait=>:structure,:new=>{})
144
+ specialtype_template.content = "{{#{Card::Name.joint}age}}"
145
+ Card::Auth.as_bot { specialtype_template.save! }
146
+ assert_equal "{{#{Card::Name.joint}age}}", specialtype_template.format.render_raw
147
+
148
+ wooga = Card.create! :name=>'Wooga', :type=>'SpecialType'
149
+ wooga_age = Card.create!( :name=>"#{wooga.name}#{Card::Name.joint}age", :content=> "39" )
150
+ expect(wooga_age.format.render_core).to eq("39")
151
+ #warn "cards #{wooga.inspect}, #{wooga_age.inspect}"
152
+ expect(wooga_age.includers.map(&:name)).to eq(['Wooga'])
153
+ end
154
+
155
+ it "should handle shading" do
156
+ alpha = newcard 'Alpha', "Pooey"
157
+ beta = newcard 'Beta', "{{Alpha|shade:off}}"
158
+ r=newcard('Bee', "{{Alpha|shade:off}}").format.render_core
159
+ assert_view_select r, 'div[style~="shade:off;"]' do
160
+ assert_select 'div[class~=card-content]', "Pooey"
161
+ end
162
+ r=newcard('Cee', "{{Alpha| shade: off }}").format.render_core
163
+ assert_view_select r, 'div[style~="shade:off;"]' do
164
+ assert_select 'div[class~=card-content]', "Pooey"
165
+ end
166
+ r=newcard('Dee', "{{Alpha| shade:off }}").format.render_core
167
+ assert_view_select r, 'div[style~="shade:off;"]' do
168
+ assert_select 'div[class~="card-content"]', "Pooey"
169
+ end
170
+ r=newcard('Eee', "{{Alpha| shade:on }}").format.render_core
171
+ assert_view_select r, 'div[style~="shade:on;"]' do
172
+ assert_select 'div[class~="card-content"]', "Pooey"
173
+ end
174
+ end
175
+
176
+ #FIXME - should move code and test to core_ext or some such
177
+ it 'Hash.new_from_semicolon_attr_list should work' do
178
+ expect(Hash.new_from_semicolon_attr_list("")).to eq({})
179
+ expect(Hash.new_from_semicolon_attr_list(nil)).to eq({})
180
+ expect(Hash.new_from_semicolon_attr_list("a:b;c:4" )).to eq({:a=>'b', :c=>'4'})
181
+ expect(Hash.new_from_semicolon_attr_list("d:b;e:4; ")).to eq({:d=>'b', :e=>'4'})
182
+ end
183
+
184
+ end
185
+
186
+ end