card 1.16.1 → 1.16.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (372) hide show
  1. checksums.yaml +4 -4
  2. data/.yardoc/checksums +60 -0
  3. data/.yardoc/object_types +0 -0
  4. data/.yardoc/objects/root.dat +0 -0
  5. data/.yardoc/proxy_types +0 -0
  6. data/.yardopts +6 -0
  7. data/README_Developers.rdoc +100 -0
  8. data/VERSION +1 -1
  9. data/card.gemspec +18 -18
  10. data/db/migrate/20150724210803_add_comment_to_actions.rb +5 -0
  11. data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +70 -0
  12. data/db/migrate_core_cards/20150807205221_create_references_for_search_cards.rb +10 -0
  13. data/db/migrate_core_cards/data/1.12_stylesheets/common.scss +4 -2
  14. data/db/schema.rb +2 -1
  15. data/db/seed/new/card_actions.yml +2334 -12538
  16. data/db/seed/new/card_acts.yml +1 -1
  17. data/db/seed/new/card_changes.yml +7384 -38929
  18. data/db/seed/new/card_references.yml +207 -207
  19. data/db/seed/new/cards.yml +1364 -1440
  20. data/db/seed/test/fixtures/card_actions.yml +3285 -13219
  21. data/db/seed/test/fixtures/card_acts.yml +107 -107
  22. data/db/seed/test/fixtures/card_changes.yml +10830 -42375
  23. data/db/seed/test/fixtures/card_references.yml +393 -393
  24. data/db/seed/test/fixtures/cards.yml +1701 -1777
  25. data/db/version.txt +1 -1
  26. data/db/version_core_cards.txt +1 -1
  27. data/lib/card.rb +13 -3
  28. data/lib/card/chunk.rb +22 -15
  29. data/lib/card/content.rb +9 -8
  30. data/lib/card/diff.rb +79 -79
  31. data/lib/card/loader.rb +33 -33
  32. data/lib/card/name.rb +8 -0
  33. data/lib/card/set.rb +44 -17
  34. data/lib/card/set_pattern.rb +8 -0
  35. data/lib/cardio.rb +19 -3
  36. data/mod/01_core/chunk/link.rb +7 -6
  37. data/mod/01_core/chunk/query_reference.rb +65 -0
  38. data/mod/01_core/set/all/content.rb +1 -1
  39. data/mod/01_core/set/all/fetch.rb +15 -7
  40. data/mod/01_core/set/all/initialize.rb +4 -3
  41. data/mod/01_core/set/all/phases.rb +12 -8
  42. data/mod/01_core/set/all/references.rb +12 -6
  43. data/mod/01_core/set/all/rules.rb +14 -11
  44. data/mod/01_core/set/all/states.rb +2 -1
  45. data/mod/01_core/set/all/tracked_attributes.rb +14 -0
  46. data/mod/01_core/spec/set/all/collection_spec.rb +5 -5
  47. data/mod/01_core/spec/set/all/name_spec.rb +6 -6
  48. data/mod/01_history/lib/card/act.rb +2 -2
  49. data/mod/01_history/lib/card/action.rb +11 -2
  50. data/mod/01_history/set/all/actions.rb +4 -3
  51. data/mod/01_history/set/all/content_history.rb +1 -1
  52. data/mod/01_history/set/all/history.rb +55 -66
  53. data/mod/02_basic_types/set/all/file.rb +26 -3
  54. data/mod/02_basic_types/set/type/pointer.rb +13 -14
  55. data/mod/02_basic_types/spec/set/all/file_spec.rb +0 -1
  56. data/mod/03_machines/lib/card/machine.rb +4 -4
  57. data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +4 -17
  58. data/mod/03_machines/lib/stylesheets/style_cards.scss +5 -0
  59. data/mod/03_machines/set/right/machine_input.rb +3 -0
  60. data/mod/03_machines/set/right/machine_output.rb +4 -0
  61. data/mod/04_settings/lib/card/setting.rb +2 -1
  62. data/mod/04_settings/set/abstract/permission.rb +95 -0
  63. data/mod/04_settings/set/right/comment.rb +2 -90
  64. data/mod/04_settings/set/right/create.rb +2 -2
  65. data/mod/04_settings/set/right/delete.rb +2 -3
  66. data/mod/04_settings/set/right/read.rb +3 -2
  67. data/mod/04_settings/set/right/update.rb +3 -2
  68. data/mod/04_settings/set/self/recent_settings.rb +3 -0
  69. data/mod/04_settings/set/type/setting.rb +9 -1
  70. data/mod/05_email/set/all/notify.rb +2 -1
  71. data/mod/05_email/set/type/email_template.rb +17 -17
  72. data/mod/05_standard/file/credit_image/image-icon.png +0 -0
  73. data/mod/05_standard/file/credit_image/image-large.png +0 -0
  74. data/mod/05_standard/file/credit_image/image-medium.png +0 -0
  75. data/mod/05_standard/file/credit_image/image-original.png +0 -0
  76. data/mod/05_standard/file/credit_image/image-small.png +0 -0
  77. data/mod/05_standard/file/favicon/{icon-image.png → image-icon.png} +0 -0
  78. data/mod/05_standard/file/favicon/{large-image.png → image-large.png} +0 -0
  79. data/mod/05_standard/file/favicon/{medium-image.png → image-medium.png} +0 -0
  80. data/mod/05_standard/file/favicon/{original-image.png → image-original.png} +0 -0
  81. data/mod/05_standard/file/favicon/{small-image.png → image-small.png} +0 -0
  82. data/mod/05_standard/file/logo/{icon-image.png → image-icon.png} +0 -0
  83. data/mod/05_standard/file/logo/{large-image.png → image-large.png} +0 -0
  84. data/mod/05_standard/file/logo/{medium-image.png → image-medium.png} +0 -0
  85. data/mod/05_standard/file/logo/{original-image.png → image-original.png} +0 -0
  86. data/mod/05_standard/file/logo/{small-image.png → image-small.png} +0 -0
  87. data/mod/05_standard/lib/carrier_wave/cardmount.rb +79 -0
  88. data/mod/05_standard/lib/file_uploader.rb +127 -0
  89. data/mod/05_standard/lib/image_uploader.rb +35 -0
  90. data/mod/05_standard/set/abstract/attachment.rb +85 -0
  91. data/mod/05_standard/set/all/error.rb +1 -18
  92. data/mod/05_standard/set/all/event_viz.rb +17 -14
  93. data/mod/05_standard/set/all/rich_html/editing.rb +10 -10
  94. data/mod/05_standard/set/all/rich_html/toolbar.rb +44 -37
  95. data/mod/05_standard/set/right/account.rb +1 -1
  96. data/mod/05_standard/set/right/password.rb +9 -10
  97. data/mod/05_standard/set/self/recent.rb +1 -1
  98. data/mod/05_standard/set/type/file.rb +43 -31
  99. data/mod/05_standard/set/type/image.rb +22 -6
  100. data/mod/05_standard/set/type/search_type.rb +4 -2
  101. data/mod/05_standard/set/type/session.rb +7 -5
  102. data/mod/05_standard/set/type/set.rb +3 -1
  103. data/mod/05_standard/spec/set/all/history_spec.rb +1 -1
  104. data/mod/05_standard/spec/set/type/cardtype_spec.rb +3 -3
  105. data/mod/05_standard/spec/set/type/file_spec.rb +85 -1
  106. data/mod/05_standard/spec/set/type/image_spec.rb +89 -5
  107. data/mod/05_standard/spec/set/type/search_type_spec.rb +16 -1
  108. data/mod/06_bootstrap/file/{cerulean_skin/icon-image.png → cerulean_skin_image/image-icon.png} +0 -0
  109. data/mod/06_bootstrap/file/{cerulean_skin/large-image.png → cerulean_skin_image/image-large.png} +0 -0
  110. data/mod/06_bootstrap/file/{cerulean_skin/medium-image.png → cerulean_skin_image/image-medium.png} +0 -0
  111. data/mod/06_bootstrap/file/{cerulean_skin/original-image.png → cerulean_skin_image/image-original.png} +0 -0
  112. data/mod/06_bootstrap/file/{cerulean_skin/small-image.png → cerulean_skin_image/image-small.png} +0 -0
  113. data/mod/06_bootstrap/file/{cosmo_skin/icon-image.png → cosmo_skin_image/image-icon.png} +0 -0
  114. data/mod/06_bootstrap/file/{cosmo_skin/large-image.png → cosmo_skin_image/image-large.png} +0 -0
  115. data/mod/06_bootstrap/file/{cosmo_skin/medium-image.png → cosmo_skin_image/image-medium.png} +0 -0
  116. data/mod/06_bootstrap/file/{cosmo_skin/original-image.png → cosmo_skin_image/image-original.png} +0 -0
  117. data/mod/06_bootstrap/file/{cosmo_skin/small-image.png → cosmo_skin_image/image-small.png} +0 -0
  118. data/mod/06_bootstrap/file/{cyborg_skin/icon-image.png → cyborg_skin_image/image-icon.png} +0 -0
  119. data/mod/06_bootstrap/file/{cyborg_skin/large-image.png → cyborg_skin_image/image-large.png} +0 -0
  120. data/mod/06_bootstrap/file/{cyborg_skin/medium-image.png → cyborg_skin_image/image-medium.png} +0 -0
  121. data/mod/06_bootstrap/file/{cyborg_skin/original-image.png → cyborg_skin_image/image-original.png} +0 -0
  122. data/mod/06_bootstrap/file/{cyborg_skin/small-image.png → cyborg_skin_image/image-small.png} +0 -0
  123. data/mod/06_bootstrap/file/{darkly_skin/icon-image.png → darkly_skin_image/image-icon.png} +0 -0
  124. data/mod/06_bootstrap/file/{darkly_skin/large-image.png → darkly_skin_image/image-large.png} +0 -0
  125. data/mod/06_bootstrap/file/{darkly_skin/medium-image.png → darkly_skin_image/image-medium.png} +0 -0
  126. data/mod/06_bootstrap/file/{darkly_skin/original-image.png → darkly_skin_image/image-original.png} +0 -0
  127. data/mod/06_bootstrap/file/{darkly_skin/small-image.png → darkly_skin_image/image-small.png} +0 -0
  128. data/mod/06_bootstrap/file/{flatly_skin/icon-image.png → flatly_skin_image/image-icon.png} +0 -0
  129. data/mod/06_bootstrap/file/{flatly_skin/large-image.png → flatly_skin_image/image-large.png} +0 -0
  130. data/mod/06_bootstrap/file/{flatly_skin/medium-image.png → flatly_skin_image/image-medium.png} +0 -0
  131. data/mod/06_bootstrap/file/{flatly_skin/original-image.png → flatly_skin_image/image-original.png} +0 -0
  132. data/mod/06_bootstrap/file/{flatly_skin/small-image.png → flatly_skin_image/image-small.png} +0 -0
  133. data/mod/06_bootstrap/file/{journal_skin/icon-image.png → journal_skin_image/image-icon.png} +0 -0
  134. data/mod/06_bootstrap/file/{journal_skin/large-image.png → journal_skin_image/image-large.png} +0 -0
  135. data/mod/06_bootstrap/file/{journal_skin/medium-image.png → journal_skin_image/image-medium.png} +0 -0
  136. data/mod/06_bootstrap/file/{journal_skin/original-image.png → journal_skin_image/image-original.png} +0 -0
  137. data/mod/06_bootstrap/file/{journal_skin/small-image.png → journal_skin_image/image-small.png} +0 -0
  138. data/mod/06_bootstrap/file/{lumen_skin/icon-image.png → lumen_skin_image/image-icon.png} +0 -0
  139. data/mod/06_bootstrap/file/{lumen_skin/large-image.png → lumen_skin_image/image-large.png} +0 -0
  140. data/mod/06_bootstrap/file/{lumen_skin/medium-image.png → lumen_skin_image/image-medium.png} +0 -0
  141. data/mod/06_bootstrap/file/{lumen_skin/original-image.png → lumen_skin_image/image-original.png} +0 -0
  142. data/mod/06_bootstrap/file/{lumen_skin/small-image.png → lumen_skin_image/image-small.png} +0 -0
  143. data/mod/06_bootstrap/file/{paper_skin/icon-image.png → paper_skin_image/image-icon.png} +0 -0
  144. data/mod/06_bootstrap/file/{paper_skin/large-image.png → paper_skin_image/image-large.png} +0 -0
  145. data/mod/06_bootstrap/file/{paper_skin/medium-image.png → paper_skin_image/image-medium.png} +0 -0
  146. data/mod/06_bootstrap/file/{paper_skin/original-image.png → paper_skin_image/image-original.png} +0 -0
  147. data/mod/06_bootstrap/file/{paper_skin/small-image.png → paper_skin_image/image-small.png} +0 -0
  148. data/mod/06_bootstrap/file/{readable_skin/icon-image.png → readable_skin_image/image-icon.png} +0 -0
  149. data/mod/06_bootstrap/file/{readable_skin/large-image.png → readable_skin_image/image-large.png} +0 -0
  150. data/mod/06_bootstrap/file/{readable_skin/medium-image.png → readable_skin_image/image-medium.png} +0 -0
  151. data/mod/06_bootstrap/file/{readable_skin/original-image.png → readable_skin_image/image-original.png} +0 -0
  152. data/mod/06_bootstrap/file/{readable_skin/small-image.png → readable_skin_image/image-small.png} +0 -0
  153. data/mod/06_bootstrap/file/{sandstone_skin/icon-image.png → sandstone_skin_image/image-icon.png} +0 -0
  154. data/mod/06_bootstrap/file/{sandstone_skin/large-image.png → sandstone_skin_image/image-large.png} +0 -0
  155. data/mod/06_bootstrap/file/{sandstone_skin/medium-image.png → sandstone_skin_image/image-medium.png} +0 -0
  156. data/mod/06_bootstrap/file/{sandstone_skin/original-image.png → sandstone_skin_image/image-original.png} +0 -0
  157. data/mod/06_bootstrap/file/{sandstone_skin/small-image.png → sandstone_skin_image/image-small.png} +0 -0
  158. data/mod/06_bootstrap/file/{simplex_skin/icon-image.png → simplex_skin_image/image-icon.png} +0 -0
  159. data/mod/06_bootstrap/file/{simplex_skin/large-image.png → simplex_skin_image/image-large.png} +0 -0
  160. data/mod/06_bootstrap/file/{simplex_skin/medium-image.png → simplex_skin_image/image-medium.png} +0 -0
  161. data/mod/06_bootstrap/file/{simplex_skin/original-image.png → simplex_skin_image/image-original.png} +0 -0
  162. data/mod/06_bootstrap/file/{simplex_skin/small-image.png → simplex_skin_image/image-small.png} +0 -0
  163. data/mod/06_bootstrap/file/{slate_skin/icon-image.png → slate_skin_image/image-icon.png} +0 -0
  164. data/mod/06_bootstrap/file/{slate_skin/large-image.png → slate_skin_image/image-large.png} +0 -0
  165. data/mod/06_bootstrap/file/{slate_skin/medium-image.png → slate_skin_image/image-medium.png} +0 -0
  166. data/mod/06_bootstrap/file/{slate_skin/original-image.png → slate_skin_image/image-original.png} +0 -0
  167. data/mod/06_bootstrap/file/{slate_skin/small-image.png → slate_skin_image/image-small.png} +0 -0
  168. data/mod/06_bootstrap/file/{spacelab_skin/icon-image.png → spacelab_skin_image/image-icon.png} +0 -0
  169. data/mod/06_bootstrap/file/{spacelab_skin/large-image.png → spacelab_skin_image/image-large.png} +0 -0
  170. data/mod/06_bootstrap/file/{spacelab_skin/medium-image.png → spacelab_skin_image/image-medium.png} +0 -0
  171. data/mod/06_bootstrap/file/{spacelab_skin/original-image.png → spacelab_skin_image/image-original.png} +0 -0
  172. data/mod/06_bootstrap/file/{spacelab_skin/small-image.png → spacelab_skin_image/image-small.png} +0 -0
  173. data/mod/06_bootstrap/file/{superhero_skin/icon-image.png → superhero_skin_image/image-icon.png} +0 -0
  174. data/mod/06_bootstrap/file/{superhero_skin/large-image.png → superhero_skin_image/image-large.png} +0 -0
  175. data/mod/06_bootstrap/file/{superhero_skin/medium-image.png → superhero_skin_image/image-medium.png} +0 -0
  176. data/mod/06_bootstrap/file/{superhero_skin/original-image.png → superhero_skin_image/image-original.png} +0 -0
  177. data/mod/06_bootstrap/file/{superhero_skin/small-image.png → superhero_skin_image/image-small.png} +0 -0
  178. data/mod/06_bootstrap/file/{united_skin/icon-image.png → united_skin_image/image-icon.png} +0 -0
  179. data/mod/06_bootstrap/file/{united_skin/large-image.png → united_skin_image/image-large.png} +0 -0
  180. data/mod/06_bootstrap/file/{united_skin/medium-image.png → united_skin_image/image-medium.png} +0 -0
  181. data/mod/06_bootstrap/file/{united_skin/original-image.png → united_skin_image/image-original.png} +0 -0
  182. data/mod/06_bootstrap/file/{united_skin/small-image.png → united_skin_image/image-small.png} +0 -0
  183. data/mod/06_bootstrap/file/{yeti_skin/icon-image.png → yeti_skin_image/image-icon.png} +0 -0
  184. data/mod/06_bootstrap/file/{yeti_skin/large-image.png → yeti_skin_image/image-large.png} +0 -0
  185. data/mod/06_bootstrap/file/{yeti_skin/medium-image.png → yeti_skin_image/image-medium.png} +0 -0
  186. data/mod/06_bootstrap/file/{yeti_skin/original-image.png → yeti_skin_image/image-original.png} +0 -0
  187. data/mod/06_bootstrap/file/{yeti_skin/small-image.png → yeti_skin_image/image-small.png} +0 -0
  188. data/mod/06_bootstrap/lib/stylesheets/bootstrap_cards.scss +5 -3
  189. data/spec/lib/card/reference_spec.rb +8 -1
  190. data/tmpsets/README.md +2 -0
  191. data/tmpsets/set/mod001-01_core/all/active_card.rb +40 -0
  192. data/tmpsets/set/mod001-01_core/all/collection.rb +348 -0
  193. data/tmpsets/set/mod001-01_core/all/content.rb +68 -0
  194. data/tmpsets/set/mod001-01_core/all/erb.rb +17 -0
  195. data/tmpsets/set/mod001-01_core/all/fetch.rb +242 -0
  196. data/tmpsets/set/mod001-01_core/all/haml.rb +13 -0
  197. data/tmpsets/set/mod001-01_core/all/initialize.rb +56 -0
  198. data/tmpsets/set/mod001-01_core/all/name.rb +279 -0
  199. data/tmpsets/set/mod001-01_core/all/pattern.rb +62 -0
  200. data/tmpsets/set/mod001-01_core/all/permissions.rb +289 -0
  201. data/tmpsets/set/mod001-01_core/all/phases.rb +187 -0
  202. data/tmpsets/set/mod001-01_core/all/references.rb +130 -0
  203. data/tmpsets/set/mod001-01_core/all/rules.rb +324 -0
  204. data/tmpsets/set/mod001-01_core/all/states.rb +28 -0
  205. data/tmpsets/set/mod001-01_core/all/templating.rb +132 -0
  206. data/tmpsets/set/mod001-01_core/all/tracked_attributes.rb +136 -0
  207. data/tmpsets/set/mod001-01_core/all/trash.rb +56 -0
  208. data/tmpsets/set/mod001-01_core/all/type.rb +91 -0
  209. data/tmpsets/set/mod001-01_core/all/utils.rb +162 -0
  210. data/tmpsets/set/mod001-01_core/all/view_cache.rb +14 -0
  211. data/tmpsets/set/mod002-01_history/all/actions.rb +54 -0
  212. data/tmpsets/set/mod002-01_history/all/content_history.rb +140 -0
  213. data/tmpsets/set/mod002-01_history/all/history.rb +341 -0
  214. data/tmpsets/set/mod003-02_basic_types/all/all_css.rb +48 -0
  215. data/tmpsets/set/mod003-02_basic_types/all/all_csv.rb +58 -0
  216. data/tmpsets/set/mod003-02_basic_types/all/all_js.rb +13 -0
  217. data/tmpsets/set/mod003-02_basic_types/all/base.rb +128 -0
  218. data/tmpsets/set/mod003-02_basic_types/all/file.rb +42 -0
  219. data/tmpsets/set/mod003-02_basic_types/all/json.rb +72 -0
  220. data/tmpsets/set/mod003-02_basic_types/all/rss.rb +78 -0
  221. data/tmpsets/set/mod003-02_basic_types/all/text.rb +14 -0
  222. data/tmpsets/set/mod003-02_basic_types/type/html.rb +33 -0
  223. data/tmpsets/set/mod003-02_basic_types/type/plain_text.rb +16 -0
  224. data/tmpsets/set/mod003-02_basic_types/type/pointer.rb +358 -0
  225. data/tmpsets/set/mod004-03_machines/right/machine_input.rb +8 -0
  226. data/tmpsets/set/mod004-03_machines/right/machine_output.rb +30 -0
  227. data/tmpsets/set/mod004-03_machines/self/script_ace.rb +18 -0
  228. data/tmpsets/set/mod004-03_machines/self/script_card_menu.rb +17 -0
  229. data/tmpsets/set/mod004-03_machines/self/script_html5shiv_printshiv.rb +8 -0
  230. data/tmpsets/set/mod004-03_machines/self/script_jquery.rb +8 -0
  231. data/tmpsets/set/mod004-03_machines/self/script_jquery_helper.rb +18 -0
  232. data/tmpsets/set/mod004-03_machines/self/script_slot.rb +13 -0
  233. data/tmpsets/set/mod004-03_machines/self/script_tinymce.rb +8 -0
  234. data/tmpsets/set/mod004-03_machines/self/style_bootstrap_compatible.rb +11 -0
  235. data/tmpsets/set/mod004-03_machines/self/style_cards.rb +12 -0
  236. data/tmpsets/set/mod004-03_machines/self/style_jquery_ui_smoothness.rb +9 -0
  237. data/tmpsets/set/mod004-03_machines/type/coffee_script.rb +67 -0
  238. data/tmpsets/set/mod004-03_machines/type/css.rb +55 -0
  239. data/tmpsets/set/mod004-03_machines/type/java_script.rb +43 -0
  240. data/tmpsets/set/mod004-03_machines/type/scss.rb +28 -0
  241. data/tmpsets/set/mod004-03_machines/type/skin.rb +18 -0
  242. data/tmpsets/set/mod005-04_settings/abstract/permission.rb +101 -0
  243. data/tmpsets/set/mod005-04_settings/right/add_help.rb +17 -0
  244. data/tmpsets/set/mod005-04_settings/right/comment.rb +9 -0
  245. data/tmpsets/set/mod005-04_settings/right/create.rb +9 -0
  246. data/tmpsets/set/mod005-04_settings/right/default.rb +9 -0
  247. data/tmpsets/set/mod005-04_settings/right/delete.rb +9 -0
  248. data/tmpsets/set/mod005-04_settings/right/help.rb +9 -0
  249. data/tmpsets/set/mod005-04_settings/right/read.rb +9 -0
  250. data/tmpsets/set/mod005-04_settings/right/script.rb +16 -0
  251. data/tmpsets/set/mod005-04_settings/right/structure.rb +16 -0
  252. data/tmpsets/set/mod005-04_settings/right/style.rb +16 -0
  253. data/tmpsets/set/mod005-04_settings/right/update.rb +9 -0
  254. data/tmpsets/set/mod005-04_settings/self/accountable.rb +9 -0
  255. data/tmpsets/set/mod005-04_settings/self/add_help.rb +8 -0
  256. data/tmpsets/set/mod005-04_settings/self/autoname.rb +8 -0
  257. data/tmpsets/set/mod005-04_settings/self/captcha.rb +8 -0
  258. data/tmpsets/set/mod005-04_settings/self/create.rb +8 -0
  259. data/tmpsets/set/mod005-04_settings/self/default.rb +8 -0
  260. data/tmpsets/set/mod005-04_settings/self/delete.rb +8 -0
  261. data/tmpsets/set/mod005-04_settings/self/help.rb +8 -0
  262. data/tmpsets/set/mod005-04_settings/self/input.rb +7 -0
  263. data/tmpsets/set/mod005-04_settings/self/layout.rb +8 -0
  264. data/tmpsets/set/mod005-04_settings/self/on_create.rb +8 -0
  265. data/tmpsets/set/mod005-04_settings/self/on_delete.rb +8 -0
  266. data/tmpsets/set/mod005-04_settings/self/on_update.rb +8 -0
  267. data/tmpsets/set/mod005-04_settings/self/options.rb +8 -0
  268. data/tmpsets/set/mod005-04_settings/self/options_label.rb +8 -0
  269. data/tmpsets/set/mod005-04_settings/self/read.rb +8 -0
  270. data/tmpsets/set/mod005-04_settings/self/recent_settings.rb +8 -0
  271. data/tmpsets/set/mod005-04_settings/self/script.rb +8 -0
  272. data/tmpsets/set/mod005-04_settings/self/structure.rb +8 -0
  273. data/tmpsets/set/mod005-04_settings/self/style.rb +8 -0
  274. data/tmpsets/set/mod005-04_settings/self/table_of_contents.rb +8 -0
  275. data/tmpsets/set/mod005-04_settings/self/thanks.rb +8 -0
  276. data/tmpsets/set/mod005-04_settings/self/update.rb +8 -0
  277. data/tmpsets/set/mod005-04_settings/type/setting.rb +96 -0
  278. data/tmpsets/set/mod006-05_email/all/email_html.rb +11 -0
  279. data/tmpsets/set/mod006-05_email/all/email_text.rb +11 -0
  280. data/tmpsets/set/mod006-05_email/all/follow.rb +260 -0
  281. data/tmpsets/set/mod006-05_email/all/notify.rb +244 -0
  282. data/tmpsets/set/mod006-05_email/all/observer.rb +33 -0
  283. data/tmpsets/set/mod006-05_email/right/bcc.rb +51 -0
  284. data/tmpsets/set/mod006-05_email/right/cc.rb +9 -0
  285. data/tmpsets/set/mod006-05_email/right/follow.rb +90 -0
  286. data/tmpsets/set/mod006-05_email/right/follow_fields.rb +8 -0
  287. data/tmpsets/set/mod006-05_email/right/followers.rb +35 -0
  288. data/tmpsets/set/mod006-05_email/right/following.rb +58 -0
  289. data/tmpsets/set/mod006-05_email/right/from.rb +9 -0
  290. data/tmpsets/set/mod006-05_email/right/html_message.rb +9 -0
  291. data/tmpsets/set/mod006-05_email/right/to.rb +9 -0
  292. data/tmpsets/set/mod006-05_email/self/always.rb +20 -0
  293. data/tmpsets/set/mod006-05_email/self/created.rb +27 -0
  294. data/tmpsets/set/mod006-05_email/self/edited.rb +30 -0
  295. data/tmpsets/set/mod006-05_email/self/follow.rb +8 -0
  296. data/tmpsets/set/mod006-05_email/self/follow_defaults.rb +71 -0
  297. data/tmpsets/set/mod006-05_email/self/never.rb +21 -0
  298. data/tmpsets/set/mod006-05_email/type/email_template.rb +119 -0
  299. data/tmpsets/set/mod006-05_email/type_plus_right/user/follow.rb +182 -0
  300. data/tmpsets/set/mod007-05_standard/abstract/attachment.rb +91 -0
  301. data/tmpsets/set/mod007-05_standard/all/account.rb +73 -0
  302. data/tmpsets/set/mod007-05_standard/all/comment.rb +45 -0
  303. data/tmpsets/set/mod007-05_standard/all/error.rb +198 -0
  304. data/tmpsets/set/mod007-05_standard/all/event_viz.rb +75 -0
  305. data/tmpsets/set/mod007-05_standard/all/links.rb +153 -0
  306. data/tmpsets/set/mod007-05_standard/all/rich_html/content.rb +248 -0
  307. data/tmpsets/set/mod007-05_standard/all/rich_html/editing.rb +216 -0
  308. data/tmpsets/set/mod007-05_standard/all/rich_html/form.rb +238 -0
  309. data/tmpsets/set/mod007-05_standard/all/rich_html/header.rb +80 -0
  310. data/tmpsets/set/mod007-05_standard/all/rich_html/menu.rb +135 -0
  311. data/tmpsets/set/mod007-05_standard/all/rich_html/modal.rb +98 -0
  312. data/tmpsets/set/mod007-05_standard/all/rich_html/toolbar.rb +271 -0
  313. data/tmpsets/set/mod007-05_standard/all/rich_html/wrapper.rb +158 -0
  314. data/tmpsets/set/mod007-05_standard/right/account.rb +187 -0
  315. data/tmpsets/set/mod007-05_standard/right/discussion.rb +9 -0
  316. data/tmpsets/set/mod007-05_standard/right/email.rb +57 -0
  317. data/tmpsets/set/mod007-05_standard/right/password.rb +44 -0
  318. data/tmpsets/set/mod007-05_standard/right/salt.rb +11 -0
  319. data/tmpsets/set/mod007-05_standard/right/stats.rb +41 -0
  320. data/tmpsets/set/mod007-05_standard/right/status.rb +15 -0
  321. data/tmpsets/set/mod007-05_standard/right/token.rb +11 -0
  322. data/tmpsets/set/mod007-05_standard/right/when_created.rb +11 -0
  323. data/tmpsets/set/mod007-05_standard/right/when_last_edited.rb +11 -0
  324. data/tmpsets/set/mod007-05_standard/rstar/rules.rb +411 -0
  325. data/tmpsets/set/mod007-05_standard/self/account_links.rb +55 -0
  326. data/tmpsets/set/mod007-05_standard/self/alerts.rb +11 -0
  327. data/tmpsets/set/mod007-05_standard/self/all.rb +28 -0
  328. data/tmpsets/set/mod007-05_standard/self/foot.rb +14 -0
  329. data/tmpsets/set/mod007-05_standard/self/head.rb +126 -0
  330. data/tmpsets/set/mod007-05_standard/self/navbox.rb +39 -0
  331. data/tmpsets/set/mod007-05_standard/self/now.rb +12 -0
  332. data/tmpsets/set/mod007-05_standard/self/performance_log.rb +98 -0
  333. data/tmpsets/set/mod007-05_standard/self/recent.rb +54 -0
  334. data/tmpsets/set/mod007-05_standard/self/search.rb +49 -0
  335. data/tmpsets/set/mod007-05_standard/self/signin.rb +130 -0
  336. data/tmpsets/set/mod007-05_standard/self/stats.rb +109 -0
  337. data/tmpsets/set/mod007-05_standard/self/version.rb +15 -0
  338. data/tmpsets/set/mod007-05_standard/type/basic.rb +52 -0
  339. data/tmpsets/set/mod007-05_standard/type/cardtype.rb +78 -0
  340. data/tmpsets/set/mod007-05_standard/type/date.rb +14 -0
  341. data/tmpsets/set/mod007-05_standard/type/file.rb +103 -0
  342. data/tmpsets/set/mod007-05_standard/type/image.rb +89 -0
  343. data/tmpsets/set/mod007-05_standard/type/layout_type.rb +21 -0
  344. data/tmpsets/set/mod007-05_standard/type/number.rb +25 -0
  345. data/tmpsets/set/mod007-05_standard/type/phrase.rb +9 -0
  346. data/tmpsets/set/mod007-05_standard/type/search_type.rb +291 -0
  347. data/tmpsets/set/mod007-05_standard/type/session.rb +42 -0
  348. data/tmpsets/set/mod007-05_standard/type/set.rb +354 -0
  349. data/tmpsets/set/mod007-05_standard/type/signup.rb +150 -0
  350. data/tmpsets/set/mod007-05_standard/type/toggle.rb +18 -0
  351. data/tmpsets/set/mod007-05_standard/type/uri.rb +17 -0
  352. data/tmpsets/set/mod007-05_standard/type/user.rb +78 -0
  353. data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/form.rb +41 -0
  354. data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/helper.rb +150 -0
  355. data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/wrapper.rb +18 -0
  356. data/tmpsets/set/mod008-06_bootstrap/all/rich_bootstrap.rb +14 -0
  357. data/tmpsets/set/mod008-06_bootstrap/self/bootstrap_cards.rb +15 -0
  358. data/tmpsets/set/mod008-06_bootstrap/self/bootstrap_js.rb +13 -0
  359. data/tmpsets/set/mod008-06_bootstrap/self/bootswatch_shared.rb +38 -0
  360. data/tmpsets/set/mod008-06_bootstrap/self/smartmenu_css.rb +13 -0
  361. data/tmpsets/set/mod008-06_bootstrap/self/smartmenu_js.rb +12 -0
  362. data/tmpsets/set_pattern/100-all.rb +24 -0
  363. data/tmpsets/set_pattern/101-all_plus.rb +26 -0
  364. data/tmpsets/set_pattern/102-type.rb +36 -0
  365. data/tmpsets/set_pattern/103-star.rb +28 -0
  366. data/tmpsets/set_pattern/104-rstar.rb +30 -0
  367. data/tmpsets/set_pattern/105-right.rb +33 -0
  368. data/tmpsets/set_pattern/106-type_plus_right.rb +36 -0
  369. data/tmpsets/set_pattern/107-self.rb +32 -0
  370. metadata +306 -107
  371. data/mod/05_standard/set/all/attach.rb +0 -164
  372. data/mod/05_standard/spec/set/all/attach_spec.rb +0 -9
@@ -0,0 +1,187 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class Card; module Set; module Right; module Account; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/account.rb ~~~~~~~~~~~
3
+
4
+ include All::Permissions::Accounts
5
+
6
+ card_accessor :email
7
+ card_accessor :password
8
+ card_accessor :salt
9
+ card_accessor :status
10
+ card_accessor :token
11
+
12
+ def active? ; status=='active' end
13
+ def blocked? ; status=='blocked' end
14
+ def built_in? ; status=='system' end
15
+ def pending? ; status=='pending' end
16
+
17
+
18
+ def authenticate_by_token val
19
+ tcard = token_card or return :token_not_found
20
+ token == val or return :incorrect_token
21
+ tcard.updated_at > Card.config.token_expiry.ago or return :token_expired # > means "after"
22
+ left and left.accountable? or return :illegal_account #(overkill?)
23
+ Auth.as_bot { tcard.delete! }
24
+ left.id
25
+ end
26
+
27
+
28
+ format do
29
+ view :verify_url do |args|
30
+ card_url "update/#{card.cardname.left_name.url_key}?token=#{card.token}"
31
+ end
32
+
33
+ view :verify_days do |args|
34
+ ( Card.config.token_expiry / 1.day ).to_s
35
+ end
36
+
37
+ view :reset_password_url do |args|
38
+ card_url "update/#{card.cardname.url_key}?reset_token=#{card.token_card.refresh(true).content}"
39
+ end
40
+
41
+ view :reset_password_days do |args|
42
+ ( Card.config.token_expiry / 1.day ).to_s
43
+ end
44
+ end
45
+
46
+
47
+ format :html do
48
+
49
+ view :raw do |args|
50
+ content = []
51
+ content << "{{+#{Card[:email ].name}|titled;title:email}}" unless args[:no_email]
52
+ content << "{{+#{Card[:password].name}|titled;title:password}}" unless args[:no_password]
53
+ content * ' '
54
+ end
55
+
56
+ view :edit do |args|
57
+ args[:structure] = true
58
+ super args
59
+ end
60
+ end
61
+
62
+
63
+ event :validate_accountability, :on=>:create, :before=>:approve do
64
+ unless left and left.accountable?
65
+ errors.add :content, "not allowed on this card"
66
+ end
67
+ end
68
+
69
+ event :require_email, :on=>:create, :after=>:approve do
70
+ unless subcards["+#{Card[:email].name}"]
71
+ errors.add :email, 'required'
72
+ end
73
+ end
74
+
75
+
76
+ event :set_default_salt, :on=>:create, :before=>:process_subcards do
77
+ salt = Digest::SHA1.hexdigest "--#{Time.now.to_s}--"
78
+ Env[:salt] = salt # HACK!!! need viable mechanism to get this to password
79
+ subcards["+#{Card[:salt].name}"] ||= { :content => salt }
80
+ end
81
+
82
+ event :set_default_status, :on=>:create, :before=>:process_subcards do
83
+ default_status = ( Auth.needs_setup? ? 'active' : 'pending' )
84
+ subcards["+#{Card[:status].name}"] = { :content => default_status }
85
+ end
86
+
87
+ def confirm_ok?
88
+ Card.new( :type_id=>Card.default_accounted_type_id ).ok? :create
89
+ end
90
+
91
+ event :generate_confirmation_token, :on=>:create, :before=>:process_subcards, :when=>proc{ |c| c.confirm_ok? } do
92
+ subcards["+#{Card[:token].name}"] = {:content => generate_token }
93
+ end
94
+
95
+ event :reset_password, :on=>:update, :before=>:approve, :when=>proc{ |c| c.has_reset_token? } do
96
+ case ( result = authenticate_by_token @env_token )
97
+ when Integer
98
+ Auth.signin result
99
+ Env.params[:success] = edit_password_success_args
100
+ abort :success
101
+ when :token_expired
102
+ send_reset_password_token
103
+ Env.params[:success] = {
104
+ :id => '_self',
105
+ :view => 'message',
106
+ :message => "Sorry, this token has expired. Please check your email for a new password reset link."
107
+ }
108
+ abort :success
109
+ else
110
+ abort :failure, "error resetting password: #{result}" # bad token or account
111
+ end
112
+ end
113
+
114
+ def edit_password_success_args
115
+ {
116
+ :id=>left.name,
117
+ :view=>:related,
118
+ :related=>{ :name=>"+#{Card[:account].name}", :view=>'edit' }
119
+ }
120
+ end
121
+
122
+ def has_reset_token?
123
+ @env_token = Env.params[:reset_token]
124
+ end
125
+
126
+ event :reset_token do
127
+ Auth.as_bot do
128
+ token_card.update_attributes! :content => generate_token
129
+ end
130
+ end
131
+
132
+
133
+ event :send_welcome_email do
134
+ if ((welcome = Card['welcome email']) && welcome.type_code == :email_template)
135
+ welcome.deliver(:context=>left, :to=>self.email)
136
+ end
137
+ end
138
+
139
+ event :send_account_verification_email, :on=>:create, :after=>:extend, :when=>proc{ |c| c.token.present? } do
140
+ Card[:verification_email].deliver( :context => self, :to => self.email )
141
+ end
142
+
143
+ event :send_reset_password_token do
144
+ Auth.as_bot do
145
+ token_card.update_attributes! :content => generate_token
146
+ end
147
+ Card[:password_reset_email].deliver( :context => self, :to => self.email )
148
+ end
149
+
150
+ def ok_to_read
151
+ is_own_account? ? true : super
152
+ end
153
+
154
+
155
+ def changes_visible? act
156
+ act.relevant_actions_for(act.card).each do |action|
157
+ return true if action.card.ok? :read
158
+ end
159
+ return false
160
+ end
161
+
162
+ def send_change_notice act, followed_set, follow_option
163
+ if changes_visible?(act)
164
+ Auth.as(left.id) do
165
+ Card[:follower_notification_email].deliver(
166
+ :context => act.card,
167
+ :to => email,
168
+ :follower => left.name,
169
+ :followed_set => followed_set,
170
+ :follow_option => follow_option
171
+ )
172
+ end
173
+ end
174
+ end
175
+
176
+
177
+ format :email do
178
+ view :mail do |args|
179
+ args[:to] ||= card.email
180
+ super args
181
+ end
182
+ end
183
+
184
+
185
+
186
+ # ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/account.rb ~~~~~~~~~~~
187
+ end;end;end;end;
@@ -0,0 +1,9 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class Card; module Set; module Right; module Discussion; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/discussion.rb ~~~~~~~~~~~
3
+ def show_comment_box_in_related?
4
+ true
5
+ end
6
+
7
+
8
+ # ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/discussion.rb ~~~~~~~~~~~
9
+ end;end;end;end;
@@ -0,0 +1,57 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class Card; module Set; module Right; module Email; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/email.rb ~~~~~~~~~~~
3
+ #event :
4
+ include All::Permissions::Accounts
5
+
6
+ view :raw do |args|
7
+ case
8
+ when card.real? ; card.content
9
+ when card.left.account ; card.left.account.email #this supports legacy behavior (should be moved to User+*email+*type plus right)
10
+ else ''
11
+ end
12
+ end
13
+
14
+ view :core, :raw
15
+
16
+ event :validate_email, :after=>:approve, :on=>:save do
17
+ if content.present? && content !~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
18
+ errors.add :content, 'must be valid address'
19
+ end
20
+ end
21
+
22
+ event :validate_unique_email, :after=>:validate_email, :on=>:save do
23
+ if content.present?
24
+ Auth.as_bot do
25
+ wql = { :right_id=>Card::EmailID, :eq=>content }
26
+ wql[:not] = { :id => id } if id
27
+ if Card.search( wql ).first
28
+ errors.add :content, 'must be unique'
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ event :downcase_email, :before=>:approve, :on=>:save do
35
+ if content and content != content.downcase
36
+ self.content = content.downcase
37
+ end
38
+ end
39
+
40
+ def email_required?
41
+ !built_in?
42
+ end
43
+
44
+ def ok_to_read
45
+ if is_own_account? or Auth.always_ok?
46
+ true
47
+ else
48
+ deny_because "viewing email is restricted to administrators and account holders"
49
+ end
50
+ end
51
+
52
+ def is_own_account?
53
+ cardname.parts[0].to_name.key == Auth.as_card.cardname.key
54
+ end
55
+
56
+ # ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/email.rb ~~~~~~~~~~~
57
+ end;end;end;end;
@@ -0,0 +1,44 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class Card; module Set; module Right; module Password; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/password.rb ~~~~~~~~~~~
3
+
4
+ include All::Permissions::Accounts
5
+
6
+ view :editor do |args|
7
+ card.content = ''
8
+ autocomplete = (@parent && @parent.card.name=='*signin+*account') ? 'on' : 'off' #hack
9
+ password_field :content, :class=>'card-content', :autocomplete=>autocomplete
10
+ end
11
+
12
+ view :raw do |args|
13
+ '<em>encrypted</em>'
14
+ end
15
+
16
+ event :encrypt_password, :on=>:save, :after=>:process_subcards, :changed=>:content,
17
+ :when => proc{ |c| !Card::Env[:no_password_encryptions] } do
18
+ # no_password_encryptions = hack for import - fix with api for ignoring events
19
+
20
+ salt = (left && left.salt)
21
+ salt = Card::Env[:salt] unless salt.present? # hack - fix with better ORM handling
22
+ self.content = Auth.encrypt content, salt
23
+
24
+ # errors.add :password, 'need a valid salt'
25
+ # turns out we have a lot of existing account without a salt. not sure when that broke??
26
+ end
27
+
28
+ event :validate_password, :on=>:save, :before=>:approve do
29
+ unless content.length > 3
30
+ errors.add :password, 'must be at least 4 characters'
31
+ end
32
+ end
33
+
34
+ event :validate_password_present, :on=>:update, :before=>:approve do
35
+ abort :success if content.blank?
36
+ end
37
+
38
+ def ok_to_read
39
+ is_own_account? ? true : super
40
+ end
41
+
42
+
43
+ # ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/password.rb ~~~~~~~~~~~
44
+ end;end;end;end;
@@ -0,0 +1,11 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class Card; module Set; module Right; module Salt; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/salt.rb ~~~~~~~~~~~
3
+ include All::Permissions::Accounts
4
+
5
+ view :raw do |args|
6
+ "Private data"
7
+ end
8
+
9
+
10
+ # ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/salt.rb ~~~~~~~~~~~
11
+ end;end;end;end;
@@ -0,0 +1,41 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class Card; module Set; module Right; module Stats; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/stats.rb ~~~~~~~~~~~
3
+
4
+ view :core do |args|
5
+ if subject = card.left
6
+
7
+ frame args do
8
+ cache_card = Card.fetch(subject.key)
9
+ db_card = Card.find_by_key(subject.key)
10
+
11
+ table = if cache_card && db_card
12
+ %{<table class="show-cache">
13
+ <tr><th>Field</th><th>Cache Val</th><th>Database Val</th></tr>
14
+ #{
15
+ [ :name, :updated_at, :updater_id, :content ].map do |field|
16
+ %{<tr>#{ [ field, cache_card.send(field), db_card.send(field) ].map() { |cell| "<td>#{cell}</td>"}.join }</tr>}
17
+ end.join
18
+ }
19
+ </table>
20
+ }
21
+ end
22
+
23
+ %{
24
+ <h1>Cache/DB Comparison</h1>
25
+ #{ table }
26
+
27
+ <h1>Cached Card Inspect</h1>
28
+ #{ h cache_card.inspect }
29
+
30
+ <h1>Database Card Inspect</h1>
31
+ #{ h db_card.inspect }
32
+ }
33
+ end
34
+
35
+ end
36
+ end
37
+
38
+
39
+
40
+ # ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/stats.rb ~~~~~~~~~~~
41
+ end;end;end;end;
@@ -0,0 +1,15 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class Card; module Set; module Right; module Status; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/status.rb ~~~~~~~~~~~
3
+ include All::Permissions::Accounts
4
+
5
+ def ok_to_update
6
+ if is_own_account? && !Auth.always_ok?
7
+ deny_because you_cant('change the status of your own account')
8
+ else
9
+ super
10
+ end
11
+ end
12
+
13
+
14
+ # ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/status.rb ~~~~~~~~~~~
15
+ end;end;end;end;
@@ -0,0 +1,11 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class Card; module Set; module Right; module Token; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/token.rb ~~~~~~~~~~~
3
+ include All::Permissions::Accounts
4
+
5
+ view :raw do |args|
6
+ "Private data"
7
+ end
8
+
9
+
10
+ # ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/token.rb ~~~~~~~~~~~
11
+ end;end;end;end;
@@ -0,0 +1,11 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class Card; module Set; module Right; module WhenCreated; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/when_created.rb ~~~~~~~~~~~
3
+ view :raw do |args|
4
+ card.left.new_card? ? '' : card.left.created_at.strftime('%A, %B %d, %Y %I:%M %p %Z')
5
+ end
6
+
7
+ view :core, :raw
8
+
9
+
10
+ # ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/when_created.rb ~~~~~~~~~~~
11
+ end;end;end;end;
@@ -0,0 +1,11 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class Card; module Set; module Right; module WhenLastEdited; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/when_last_edited.rb ~~~~~~~~~~~
3
+ view :raw do |args|
4
+ card.left.new_card? ? '' : card.left.updated_at.strftime('%A, %B %d, %Y %I:%M %p %Z')
5
+ end
6
+
7
+ view :core, :raw
8
+
9
+
10
+ # ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/when_last_edited.rb ~~~~~~~~~~~
11
+ end;end;end;end;
@@ -0,0 +1,411 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class Card; module Set; module Rstar; module Rules; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/rstar/rules.rb ~~~~~~~~~~~
3
+ event :save_recently_edited_settings, :before=>:extend, :on=>:save, :when=>proc{|c| c.is_rule? } do
4
+ if (recent = Card[:recent_settings])
5
+ recent.insert_item 0, cardname.right
6
+ recent.save
7
+ end
8
+ end
9
+
10
+ format :html do
11
+
12
+ view :closed_rule, :tags=>:unknown_ok do |args|
13
+ return 'not a rule' if !card.is_rule? #these are helpful for handling non-rule rstar cards until we have real rule sets
14
+
15
+ rule_card = find_current_rule_card
16
+
17
+ rule_content = !rule_card ? '' : begin
18
+ subformat(rule_card)._render_closed_content :set_context=>card.cardname.trunk_name
19
+ end
20
+
21
+ cells = [
22
+ ["rule-setting",
23
+ link_to( card.cardname.tag.sub(/^\*/,''), path(:view=>:open_rule),
24
+ :class => 'edit-rule-link slotter', :remote => true, :rel=>'nofollow' )
25
+ ],
26
+ ["rule-content",
27
+ %{<div class="rule-content-container">
28
+ <span class="closed-content content">#{rule_content}</span>
29
+ </div> } ],
30
+ ["rule-set", (rule_card ? rule_card.trunk.label : '') ],
31
+ ]
32
+
33
+ extra_css_class = rule_card && !rule_card.new_card? ? 'known-rule' : 'missing-rule'
34
+
35
+ %{<tr class="card-slot closed-rule">} +
36
+ cells.map do |css_class, content|
37
+ %{<td class="rule-cell #{css_class} #{extra_css_class}">#{content}</td>}
38
+ end.join("\n") +
39
+ '</tr>'
40
+ end
41
+
42
+
43
+ view :open_rule, :tags=>:unknown_ok do |args|
44
+ return 'not a rule' if !card.is_rule?
45
+ current_rule = args[:current_rule]
46
+ setting_name = args[:setting_name]
47
+
48
+ edit_mode = !params[:success] && card.ok?( ( card.new_card? ? :create : :update ) )
49
+ #~~~~~~ handle reloading due to type change
50
+ if params[:type_reload] && card_args=params[:card]
51
+ if card_args[:name] && card_args[:name].to_name.key != current_rule.key
52
+ current_rule = Card.new card_args
53
+ else
54
+ current_rule = current_rule.refresh
55
+ current_rule.assign_attributes card_args
56
+ current_rule.include_set_modules
57
+ end
58
+ edit_mode = true
59
+ end
60
+
61
+ opts = {
62
+ :rule_context => card, # determines the set options and the success view
63
+ :set_context => card.rule_set_name,
64
+ }
65
+ rule_view = edit_mode ? :edit_rule : :show_rule
66
+
67
+ %{
68
+ <tr class="card-slot open-rule #{rule_view.to_s.sub '_', '-'}">
69
+ <td class="rule-cell" colspan="3">
70
+ <div class="rule-setting">
71
+ #{ view_link setting_name.sub(/^\*/,''), :closed_rule, :class=>'close-rule-link slotter' }
72
+ #{ card_link setting_name, :text=>"all #{setting_name} rules", :class=>'setting-link', :target=>'wagn_setting' }
73
+ </div>
74
+
75
+ <div class="alert alert-info rule-instruction">
76
+ #{ process_content "{{#{setting_name}+*right+*help|content}}" }
77
+ </div>
78
+
79
+ <div class="card-body">
80
+ #{ subformat( current_rule )._render rule_view, opts }
81
+ </div>
82
+ </td>
83
+ </tr>
84
+ }
85
+ end
86
+
87
+ def default_open_rule_args args
88
+ current_rule_card = find_current_rule_card || begin
89
+ Card.new :name=> "#{Card[:all].name}+#{card.rule_user_setting_name}"
90
+ end
91
+
92
+ args.reverse_merge! :current_rule => current_rule_card, :setting_name => card.rule_setting_name
93
+ end
94
+
95
+ view :show_rule, :tags=>:unknown_ok do |args|
96
+ return 'not a rule' if !card.is_rule?
97
+
98
+ if !card.new_card?
99
+ set = card.rule_set
100
+ args[:item] ||= :link
101
+ %{
102
+ <div class="rule-set">
103
+ <label>Applies to</label> #{ card_link set.cardname, :text=>set.label }:
104
+ </div>
105
+ #{ _render_core args }
106
+ }
107
+ else
108
+ 'No Current Rule'
109
+ end
110
+ end
111
+
112
+ view :edit_rule, :tags=>:unknown_ok do |args|
113
+ return 'not a rule' if !card.is_rule?
114
+ form_args = { :url=>path(:action=>:update, :no_id=>true),
115
+ :html=> {:class=>"card-form card-rule-form" } }
116
+ if args[:remote]
117
+ form_args[:remote] = true
118
+ form_args[:html][:class] += ' slotter'
119
+ end
120
+
121
+ form_for card, form_args do |form|
122
+ @form = form
123
+ %{
124
+ #{ hidden_success_formgroup args[:success]}
125
+ #{ editor args }
126
+ #{ edit_buttons args }
127
+ }
128
+ end
129
+ end
130
+
131
+ view :related_edit_rule, :view=>:edit_rule
132
+
133
+ def default_edit_rule_args args
134
+ args[:remote] ||= true
135
+ args[:rule_context] ||= card
136
+ args[:set_context] ||= card.rule_set_name
137
+ args[:set_selected] = params[:type_reload] ? card.rule_set_name : false
138
+ args[:set_options], args[:fallback_set] = args[:rule_context].set_options
139
+
140
+ args[:success] ||= {}
141
+ args[:success].reverse_merge!( {
142
+ :card => args[:rule_context],
143
+ :id => args[:rule_context].cardname.url_key,
144
+ :view => 'open_rule',
145
+ :item => 'view_rule'
146
+ })
147
+
148
+ args[:delete_button] ||= delete_button args
149
+ args[:cancel_button] ||=
150
+ begin
151
+ cancel_path = path :view=>( card.new_card? ? :closed_rule : :open_rule ), :success=>false
152
+ button_tag( 'Cancel', :class=>'rule-cancel-button slotter', :type=>'button',
153
+ :href=>cancel_path )
154
+ end
155
+ end
156
+
157
+ def default_related_edit_rule_args args
158
+ args[:remote] ||= false
159
+ args[:success] ||= {
160
+ :card => args[:parent] || card,
161
+ :id => (args[:parent] && args[:parent].cardname.url_key) || card.cardname.url_key,
162
+ :view => :open,
163
+ :item => nil
164
+ }
165
+ default_edit_rule_args args
166
+ args[:delete_button] = delete_button args, '.card-slot.related-view'
167
+ args[:cancel_button] = card_link( args[:success][:id], :text=>'Cancel',
168
+ :class=>'rule-cancel-button btn btn-default', :path_opts=>{:view=>args[:success][:view]} )
169
+ end
170
+
171
+ def delete_button args, slot_selector=nil
172
+ if !card.new_card?
173
+ b_args = { :remote=>true, :class=>'rule-delete-button slotter', :type=>'button' }
174
+ b_args['data-slot-selector'] = slot_selector if slot_selector
175
+ b_args[:href] = path :action=>:delete, :success=>args[:success]
176
+ if (fset = args[:fallback_set]) && (fcard = Card.fetch(fset))
177
+ b_args['data-confirm']="Deleting will revert to #{card.rule_setting_name} rule for #{fcard.label }"
178
+ end
179
+ %{<span class="rule-delete-section">#{ button_tag 'Delete', b_args }</span>}
180
+ end
181
+ end
182
+
183
+ # used keys for args:
184
+ # :success, :set_selected, :set_options, :rule_context
185
+ def editor args
186
+ wrap_with( :div, :class=>'card-editor' ) do
187
+ [
188
+ (type_formgroup( args ) if card.right.rule_type_editable),
189
+ formgroup( 'rule', content_field( form, args.merge(:skip_rev_id=>true) ), :editor=>'content' ),
190
+ set_selection( args )
191
+ ]
192
+ end
193
+ end
194
+
195
+
196
+ def type_formgroup args
197
+ formgroup 'type', type_field(
198
+ :href => path(:name=>args[:success][:card].name, :view=>args[:success][:view], :type_reload=>true),
199
+ :class => 'type-field rule-type-field live-type-field',
200
+ 'data-remote' => true
201
+ ), :editor=>'type'
202
+ end
203
+
204
+
205
+ def hidden_success_formgroup args
206
+ %{
207
+ #{ hidden_field_tag 'success[id]', args[:id] || args[:card].name }
208
+ #{ hidden_field_tag 'success[view]', args[:view] }
209
+ #{ hidden_field_tag 'success[item]', args[:item] }
210
+ }
211
+ end
212
+
213
+ def set_selection args
214
+ wrap_with( :div, :class=>'row') do
215
+ [
216
+ set_formgroup( args ),
217
+ related_set_formgroup( args)
218
+ ]
219
+ end
220
+ end
221
+
222
+ def set_formgroup args
223
+ current_set_key = card.new_card? ? Card[:all].cardname.key : card.rule_set_key # (should have a constant for this?)
224
+ tag = args[:rule_context].rule_user_setting_name
225
+ narrower_rules = []
226
+ option_list =
227
+ wrap_each_with :li, :class=>'radio' do
228
+ args[:set_options].map do |set_name, state|
229
+
230
+ checked = ( args[:set_selected] == set_name or current_set_key && args[:set_options].length==1 )
231
+ is_current = (state == :current)
232
+ warning = if narrower_rules.present?
233
+ plural = narrower_rules.size > 1 ? 's' : ''
234
+ "This rule will not have any effect on this card unless you delete the narrower rule#{plural} "+
235
+ "for #{narrower_rules.to_sentence}."
236
+ end
237
+ if is_current || state == :overwritten
238
+ narrower_rules << Card.fetch(set_name).label
239
+ narrower_rules.last[0] = narrower_rules.last[0].downcase
240
+ end
241
+ rule_name = "#{set_name}+#{tag}"
242
+ radio_button( :name, rule_name, :checked=>checked, :warning=>warning ) + %{
243
+ <label class="set-label" #{'current-set-label' if is_current }>
244
+ #{ card_link set_name, :text=> Card.fetch(set_name).label, :target=>'wagn_set' }
245
+ #{'<em>(current)</em>' if is_current }
246
+ #{"<em> #{card_link "#{set_name}+#{card.rule_user_setting_name}", :text=>"(overwritten)"}</em>" if state == :overwritten }
247
+ </label>
248
+ }.html_safe
249
+ end
250
+
251
+ end
252
+ formgroup 'set', "<ul>#{ option_list }</ul>", :editor => 'set', :class=>'col-xs-6'
253
+ end
254
+
255
+ def related_set_formgroup args
256
+ related_sets = args[:set_context] && Card.fetch(args[:set_context]).prototype.related_sets
257
+ return '' unless related_sets && related_sets.size > 0
258
+ tag = args[:rule_context].rule_user_setting_name
259
+ option_list =
260
+ wrap_each_with :li, :class=>'radio' do
261
+ related_sets.map do |set_name, label|
262
+ rule_name = "#{set_name}+#{tag}"
263
+ rule_card = Card.fetch rule_name, :skip_modules=>true
264
+ radio_button( :name, rule_name) + %{
265
+ <label class="set-label">
266
+ #{ card_link set_name, :text=>label, :target=>'wagn_set' }
267
+ #{"<em> #{card_link "#{set_name}+#{card.rule_user_setting_name}", :text=>"(exists)"}</em>" if rule_card}
268
+ </label>
269
+ }.html_safe
270
+ end
271
+ end
272
+ formgroup 'related set', "<ul>#{ option_list }</ul>", :editor => 'set', :class=>'col-xs-6'
273
+ end
274
+
275
+ def edit_buttons args
276
+ wrap_with( :div, :class=>'button-area' ) do
277
+ [
278
+ args[:delete_button],
279
+ button_tag( 'Submit', :class=>'rule-submit-button', :situation=>'primary' ),
280
+ args[:cancel_button]
281
+ ]
282
+ end
283
+ end
284
+
285
+ =begin
286
+ view :edit_rule2 do |args|
287
+
288
+ card_form :update do
289
+ [
290
+ _optional_render( :type_formgroup, args ),
291
+ _optional_render( :content_formgroup, args ),
292
+ _optional_render( :set_formgroup, args ),
293
+ _optional_render( :button_formgroup, args )
294
+ ]
295
+ end
296
+ end
297
+ =end
298
+
299
+
300
+
301
+ private
302
+
303
+ def find_current_rule_card
304
+ # self.card is a POTENTIAL rule; it quacks like a rule but may or may not exist.
305
+ # This generates a prototypical member of the POTENTIAL rule's set
306
+ # and returns that member's ACTUAL rule for the POTENTIAL rule's setting
307
+ if card.new_card?
308
+ if setting = card.right
309
+ card.set_prototype.rule_card setting.codename, :user=>card.rule_user
310
+ end
311
+ else
312
+ card
313
+ end
314
+ end
315
+
316
+ end
317
+
318
+
319
+ def rule_set_key
320
+ rule_set_name.key
321
+ end
322
+
323
+ def rule_set_name
324
+ if is_user_rule?
325
+ cardname.trunk_name.trunk_name
326
+ else
327
+ cardname.trunk_name
328
+ end
329
+ end
330
+
331
+ def rule_set
332
+ if is_user_rule?
333
+ self[0..-3]
334
+ else
335
+ trunk
336
+ end
337
+ end
338
+
339
+ def rule_setting_name
340
+ cardname.tag
341
+ end
342
+
343
+ def rule_user_setting_name
344
+ if is_user_rule?
345
+ "#{rule_user_name}+#{rule_setting_name}"
346
+ else
347
+ rule_setting_name
348
+ end
349
+ end
350
+
351
+ def rule_user_name
352
+ is_user_rule? ? cardname.trunk_name.tag : nil
353
+ end
354
+
355
+ def rule_user
356
+ is_user_rule? ? self[-2] : nil
357
+ end
358
+
359
+
360
+ #~~~~~~~~~~ determine the set options to which the user can apply the rule.
361
+ def set_options
362
+
363
+ first = new_card? ? 0 : set_prototype.set_names.index{|s| s.to_name.key == rule_set_key}
364
+ rule_cnt = 0
365
+ res = []
366
+ fallback_set = nil
367
+ set_prototype.set_names[first..-1].each do |set_name|
368
+ if Card.exists?("#{set_name}+#{rule_user_setting_name}")
369
+ rule_cnt += 1
370
+ res << if rule_cnt == 1
371
+ [set_name,:current]
372
+ else
373
+ fallback_set ||= set_name
374
+ [set_name,:overwritten]
375
+ end
376
+ else
377
+ res << (rule_cnt < 1 ? [set_name,:enabled] : [set_name,:disabled])
378
+ end
379
+ end
380
+
381
+ # fallback_set = if first > 0
382
+ # res[0..(first-1)].find do |set_name|
383
+ # Card.exists?("#{set_name}+#{rule_user_setting_name}")
384
+ # end
385
+ # end
386
+ # last = res.index{|s| s.to_name.key == cardname.trunk_name.key} || -1
387
+ # # note, the -1 can happen with virtual cards because the self set doesn't show up in the set_names. FIXME!!
388
+ # [res[first..last], fallback_set]
389
+ #
390
+ # The broadest set should always be the currently applied rule
391
+ # (for anything more general, they must explicitly choose to "DELETE" the current one)
392
+ # the narrowest rule should be the one attached to the set being viewed. So, eg, if you're looking at the "*all plus" set, you shouldn't
393
+ # have the option to create rules based on arbitrary narrower sets, though narrower sets will always apply to whatever prototype we create
394
+
395
+ return res, fallback_set
396
+ end
397
+
398
+ def set_prototype
399
+ if is_user_rule?
400
+ self[0..-3].prototype
401
+ else
402
+ trunk.prototype
403
+ end
404
+ end
405
+
406
+
407
+
408
+
409
+
410
+ # ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/rstar/rules.rb ~~~~~~~~~~~
411
+ end;end;end;end;