zen 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (303) hide show
  1. data/.gitignore +15 -0
  2. data/.mailmap +2 -0
  3. data/.rvmrc +2 -0
  4. data/.travis.yml +8 -3
  5. data/AUTHORS +1 -2
  6. data/CHANGELOG.md +48 -17
  7. data/README.md +44 -39
  8. data/Rakefile +4 -0
  9. data/bin/zen +5 -30
  10. data/lib/zen.rb +13 -19
  11. data/lib/zen/asset.rb +99 -64
  12. data/lib/zen/bin/create.rb +94 -0
  13. data/lib/zen/bin/runner.rb +118 -0
  14. data/lib/zen/controller/admin_controller.rb +52 -36
  15. data/lib/zen/controller/base_controller.rb +5 -5
  16. data/lib/zen/controller/frontend_controller.rb +7 -7
  17. data/lib/zen/controller/main_controller.rb +12 -10
  18. data/lib/zen/controller/preview.rb +15 -11
  19. data/lib/zen/helper/acl.rb +73 -53
  20. data/lib/zen/helper/blue_form_vendor.rb +689 -0
  21. data/lib/zen/helper/breadcrumb.rb +23 -19
  22. data/lib/zen/helper/message.rb +3 -3
  23. data/lib/zen/helper/theme.rb +18 -13
  24. data/lib/zen/language.rb +62 -58
  25. data/lib/zen/language/en/zen_general.yml +2 -4
  26. data/lib/zen/language/nl/zen_general.yml +2 -4
  27. data/lib/zen/layout/admin.xhtml +3 -12
  28. data/lib/zen/layout/login.xhtml +1 -6
  29. data/lib/zen/model/methods.rb +6 -6
  30. data/lib/zen/model/settings.rb +5 -4
  31. data/lib/zen/package.rb +47 -38
  32. data/lib/zen/package/all.rb +3 -5
  33. data/lib/zen/package/base.rb +7 -7
  34. data/lib/zen/package/categories/lib/categories.rb +8 -3
  35. data/lib/zen/package/categories/lib/categories/controller/categories.rb +81 -55
  36. data/lib/zen/package/categories/lib/categories/controller/category_groups.rb +45 -44
  37. data/lib/zen/package/categories/lib/categories/helper/category.rb +88 -0
  38. data/lib/zen/package/categories/lib/categories/language/en/categories.yml +5 -4
  39. data/lib/zen/package/categories/lib/categories/language/en/category_groups.yml +5 -4
  40. data/lib/zen/package/categories/lib/categories/language/nl/categories.yml +5 -4
  41. data/lib/zen/package/categories/lib/categories/language/nl/category_groups.yml +5 -4
  42. data/lib/zen/package/categories/lib/categories/model/category.rb +15 -13
  43. data/lib/zen/package/categories/lib/categories/model/category_group.rb +3 -3
  44. data/lib/zen/package/categories/lib/categories/plugin/categories.rb +36 -25
  45. data/lib/zen/package/categories/lib/categories/view/admin/categories/form.xhtml +49 -56
  46. data/lib/zen/package/categories/lib/categories/view/admin/categories/index.xhtml +48 -35
  47. data/lib/zen/package/categories/lib/categories/view/admin/category-groups/form.xhtml +36 -29
  48. data/lib/zen/package/categories/lib/categories/view/admin/category-groups/index.xhtml +42 -37
  49. data/lib/zen/package/comments/lib/comments.rb +4 -1
  50. data/lib/zen/package/comments/lib/comments/controller/comments.rb +39 -32
  51. data/lib/zen/package/comments/lib/comments/controller/comments_form.rb +45 -26
  52. data/lib/zen/package/comments/lib/comments/helper/comment.rb +35 -0
  53. data/lib/zen/package/comments/lib/comments/language/en/comments.yml +9 -7
  54. data/lib/zen/package/comments/lib/comments/language/nl/comments.yml +10 -8
  55. data/lib/zen/package/comments/lib/comments/model/comment.rb +31 -17
  56. data/lib/zen/package/comments/lib/comments/model/comment_status.rb +15 -0
  57. data/lib/zen/package/comments/lib/comments/plugin/anti_spam.rb +27 -18
  58. data/lib/zen/package/comments/lib/comments/plugin/comments.rb +25 -20
  59. data/lib/zen/package/comments/lib/comments/view/admin/comments/form.xhtml +61 -54
  60. data/lib/zen/package/comments/lib/comments/view/admin/comments/index.xhtml +38 -23
  61. data/lib/zen/package/comments/migrations/1308774099_comment_status.rb +60 -0
  62. data/lib/zen/package/custom_fields/lib/custom_fields.rb +33 -7
  63. data/lib/zen/package/custom_fields/lib/custom_fields/blue_form_parameters.rb +209 -0
  64. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +50 -47
  65. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_types.rb +215 -0
  66. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_fields.rb +111 -73
  67. data/lib/zen/package/custom_fields/lib/custom_fields/helper/custom_field.rb +79 -0
  68. data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_field_groups.yml +20 -19
  69. data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_field_types.yml +40 -0
  70. data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_fields.yml +34 -32
  71. data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_groups.yml +5 -4
  72. data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_types.yml +40 -0
  73. data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_fields.yml +18 -16
  74. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field.rb +31 -11
  75. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_method.rb +15 -0
  76. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_type.rb +50 -0
  77. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb +28 -7
  78. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/form.xhtml +33 -28
  79. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/index.xhtml +48 -46
  80. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-types/form.xhtml +61 -0
  81. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-types/index.xhtml +93 -0
  82. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/form.xhtml +105 -99
  83. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/index.xhtml +43 -39
  84. data/lib/zen/package/custom_fields/migrations/1295255665_create_schema.rb +47 -16
  85. data/lib/zen/package/custom_fields/migrations/1310659580_custom_field_types.rb +148 -0
  86. data/lib/zen/package/custom_fields/migrations/1311694920_rename_css_class.rb +11 -0
  87. data/lib/zen/package/menus/lib/menus/controller/menu_items.rb +40 -35
  88. data/lib/zen/package/menus/lib/menus/controller/menus.rb +47 -43
  89. data/lib/zen/package/menus/lib/menus/helper/{menu_item.rb → menu.rb} +42 -15
  90. data/lib/zen/package/menus/lib/menus/language/en/menu_items.yml +5 -5
  91. data/lib/zen/package/menus/lib/menus/language/en/menus.yml +9 -8
  92. data/lib/zen/package/menus/lib/menus/language/nl/menu_items.yml +8 -8
  93. data/lib/zen/package/menus/lib/menus/language/nl/menus.yml +11 -10
  94. data/lib/zen/package/menus/lib/menus/model/menu.rb +5 -5
  95. data/lib/zen/package/menus/lib/menus/model/menu_item.rb +6 -5
  96. data/lib/zen/package/menus/lib/menus/plugin/menus.rb +41 -43
  97. data/lib/zen/package/menus/lib/menus/view/admin/menu-items/form.xhtml +59 -63
  98. data/lib/zen/package/menus/lib/menus/view/admin/menu-items/index.xhtml +35 -30
  99. data/lib/zen/package/menus/lib/menus/view/admin/menus/form.xhtml +46 -37
  100. data/lib/zen/package/menus/lib/menus/view/admin/menus/index.xhtml +37 -37
  101. data/lib/zen/package/menus/migrations/1297184342_create_schema.rb +5 -5
  102. data/lib/zen/package/menus/migrations/1308671733_rename_order_column.rb +11 -0
  103. data/lib/zen/package/menus/migrations/1311695030_rename_css_class.rb +17 -0
  104. data/lib/zen/package/sections/lib/sections.rb +18 -11
  105. data/lib/zen/package/sections/lib/sections/controller/section_entries.rb +115 -109
  106. data/lib/zen/package/sections/lib/sections/controller/sections.rb +72 -50
  107. data/lib/zen/package/sections/lib/sections/helper/section.rb +53 -0
  108. data/lib/zen/package/sections/lib/sections/language/en/section_entries.yml +5 -4
  109. data/lib/zen/package/sections/lib/sections/language/en/sections.yml +5 -4
  110. data/lib/zen/package/sections/lib/sections/language/nl/section_entries.yml +5 -4
  111. data/lib/zen/package/sections/lib/sections/language/nl/sections.yml +5 -4
  112. data/lib/zen/package/sections/lib/sections/model/section.rb +17 -9
  113. data/lib/zen/package/sections/lib/sections/model/section_entry.rb +192 -13
  114. data/lib/zen/package/sections/lib/sections/model/section_entry_status.rb +13 -0
  115. data/lib/zen/package/sections/lib/sections/plugin/section_entries.rb +60 -39
  116. data/lib/zen/package/sections/lib/sections/plugin/sections.rb +14 -11
  117. data/lib/zen/package/sections/lib/sections/view/admin/form.xhtml +100 -97
  118. data/lib/zen/package/sections/lib/sections/view/admin/index.xhtml +41 -39
  119. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/form.xhtml +95 -215
  120. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/index.xhtml +48 -40
  121. data/lib/zen/package/sections/migrations/1308672298_use_id_for_default_section.rb +40 -0
  122. data/lib/zen/package/sections/migrations/1308813320_section_entry_statuses.rb +58 -0
  123. data/lib/zen/package/settings/lib/settings/controller/settings.rb +5 -8
  124. data/lib/zen/package/settings/lib/settings/model/setting.rb +2 -37
  125. data/lib/zen/package/settings/lib/settings/plugin/setting_base.rb +18 -1
  126. data/lib/zen/package/settings/lib/settings/plugin/settings.rb +13 -7
  127. data/lib/zen/package/settings/lib/settings/view/admin/settings/index.xhtml +2 -1
  128. data/lib/zen/package/users/lib/users.rb +3 -1
  129. data/lib/zen/package/users/lib/users/controller/access_rules.rb +77 -60
  130. data/lib/zen/package/users/lib/users/controller/user_groups.rb +41 -36
  131. data/lib/zen/package/users/lib/users/controller/users.rb +48 -42
  132. data/lib/zen/package/users/lib/users/helper/users.rb +72 -0
  133. data/lib/zen/package/users/lib/users/language/en/access_rules.yml +6 -5
  134. data/lib/zen/package/users/lib/users/language/en/user_groups.yml +5 -4
  135. data/lib/zen/package/users/lib/users/language/en/users.yml +1 -0
  136. data/lib/zen/package/users/lib/users/language/nl/access_rules.yml +5 -4
  137. data/lib/zen/package/users/lib/users/language/nl/user_groups.yml +5 -4
  138. data/lib/zen/package/users/lib/users/language/nl/users.yml +1 -0
  139. data/lib/zen/package/users/lib/users/model/access_rule.rb +5 -1
  140. data/lib/zen/package/users/lib/users/model/user.rb +17 -10
  141. data/lib/zen/package/users/lib/users/public/admin/js/users/access_rules.js +10 -37
  142. data/lib/zen/package/users/lib/users/public/admin/js/users/lib/access_rules.js +49 -0
  143. data/lib/zen/package/users/lib/users/view/admin/access-rules/form.xhtml +105 -96
  144. data/lib/zen/package/users/lib/users/view/admin/access-rules/index.xhtml +48 -41
  145. data/lib/zen/package/users/lib/users/view/admin/user-groups/form.xhtml +42 -32
  146. data/lib/zen/package/users/lib/users/view/admin/user-groups/index.xhtml +43 -38
  147. data/lib/zen/package/users/lib/users/view/admin/users/form.xhtml +76 -67
  148. data/lib/zen/package/users/lib/users/view/admin/users/index.xhtml +43 -41
  149. data/lib/zen/package/users/lib/users/view/admin/users/login.xhtml +12 -9
  150. data/lib/zen/package/users/migrations/1295281013_create_schema.rb +2 -2
  151. data/lib/zen/plugin.rb +56 -50
  152. data/lib/zen/plugin/markup/lib/markup/markup.rb +33 -21
  153. data/lib/zen/public/admin/css/zen/buttons.css +11 -7
  154. data/lib/zen/public/admin/css/zen/datepicker.css +6 -6
  155. data/lib/zen/public/admin/css/zen/forms.css +2 -1
  156. data/lib/zen/public/admin/css/zen/general.css +15 -10
  157. data/lib/zen/public/admin/css/zen/layout.css +51 -20
  158. data/lib/zen/public/admin/css/zen/tables.css +39 -11
  159. data/lib/zen/public/admin/css/zen/tabs.css +6 -4
  160. data/lib/zen/public/admin/css/zen/window.css +11 -11
  161. data/lib/zen/public/{favicon.ico → admin/favicon.ico} +0 -0
  162. data/lib/zen/public/admin/images/zen/icons/asc.png +0 -0
  163. data/lib/zen/public/admin/images/zen/icons/desc.png +0 -0
  164. data/lib/zen/public/admin/js/vendor/datepicker.js +0 -11
  165. data/lib/zen/public/admin/js/{mootools → vendor/mootools}/core.js +0 -1
  166. data/lib/zen/public/admin/js/{mootools → vendor/mootools}/more.js +100 -29
  167. data/lib/zen/public/admin/js/zen/index.js +48 -0
  168. data/lib/zen/public/admin/js/zen/lib/asset.js +111 -0
  169. data/lib/zen/public/admin/js/zen/{editor.js → lib/editor.js} +107 -127
  170. data/lib/zen/public/admin/js/zen/{editor → lib/editor}/markdown.js +7 -9
  171. data/lib/zen/public/admin/js/zen/{editor → lib/editor}/textile.js +7 -9
  172. data/lib/zen/public/admin/js/zen/lib/html_table.js +143 -0
  173. data/lib/zen/public/admin/js/zen/{tabs.js → lib/tabs.js} +40 -37
  174. data/lib/zen/public/admin/js/zen/{window.js → lib/window.js} +24 -20
  175. data/lib/zen/spec/bacon/color_output.rb +39 -0
  176. data/lib/zen/spec/helper.rb +152 -0
  177. data/lib/zen/spec/simplecov.rb +22 -0
  178. data/lib/zen/task/build.rake +20 -43
  179. data/lib/zen/task/clean.rake +2 -6
  180. data/lib/zen/task/db.rake +8 -12
  181. data/lib/zen/task/package.rake +4 -10
  182. data/lib/zen/task/plugin.rake +3 -9
  183. data/lib/zen/task/proto.rake +0 -62
  184. data/lib/zen/task/test.rake +6 -3
  185. data/lib/zen/task/theme.rake +4 -11
  186. data/lib/zen/theme.rb +22 -24
  187. data/lib/zen/validation.rb +34 -27
  188. data/lib/zen/version.rb +2 -8
  189. data/lib/zen/view/head.xhtml +7 -0
  190. data/lib/zen/view/main.xhtml +7 -22
  191. data/{proto/package/migrations → pkg}/.gitkeep +0 -0
  192. data/proto/app/app.rb +1 -0
  193. data/proto/app/config/config.rb +5 -4
  194. data/proto/app/config/database.rb +19 -41
  195. data/proto/app/config/middlewares.rb +32 -29
  196. data/proto/{package/lib/package/view/admin/package/index.xhtml → app/log/database/dev/.gitkeep} +0 -0
  197. data/proto/app/log/database/live/.gitkeep +0 -0
  198. data/spec/Rakefile +26 -0
  199. data/spec/fixtures/zen/asset.rb +18 -0
  200. data/spec/fixtures/zen/helper/acl.rb +39 -0
  201. data/spec/fixtures/zen/helper/message.rb +19 -0
  202. data/spec/fixtures/zen/language/en/spec.yml +10 -0
  203. data/spec/fixtures/zen/language/nl/spec.yml +7 -0
  204. data/spec/fixtures/zen/package.rb +17 -0
  205. data/spec/fixtures/zen/package/comments/controller/comments_form.rb +27 -0
  206. data/spec/fixtures/zen/package/settings/plugin/settings.rb +20 -0
  207. data/spec/fixtures/zen/plugin.rb +7 -0
  208. data/spec/fixtures/zen/theme/404.xhtml +1 -0
  209. data/spec/fixtures/zen/theme/default-section/index.xhtml +1 -0
  210. data/spec/fixtures/zen/theme/helper/404.xhtml +1 -0
  211. data/spec/fixtures/zen/theme/helper/partial.xhtml +1 -0
  212. data/spec/fixtures/zen/theme/helper/wrong_partial.xhtml +1 -0
  213. data/spec/fixtures/zen/theme/partials/partial.xhtml +1 -0
  214. data/spec/fixtures/zen/theme/theme.rb +11 -0
  215. data/spec/fixtures/zen/validation.rb +22 -0
  216. data/spec/helper.rb +41 -0
  217. data/spec/zen/all.rb +5 -0
  218. data/spec/zen/asset.rb +97 -0
  219. data/spec/zen/bin/create.rb +89 -0
  220. data/spec/zen/bin/runner.rb +47 -0
  221. data/spec/zen/controller/admin_controller.rb +26 -0
  222. data/spec/zen/controller/main_controller.rb +81 -0
  223. data/spec/zen/controller/preview.rb +33 -0
  224. data/spec/zen/helper/acl.rb +149 -0
  225. data/spec/zen/helper/breadcrumb.rb +38 -0
  226. data/spec/zen/helper/message.rb +31 -0
  227. data/spec/zen/helper/theme.rb +58 -0
  228. data/spec/zen/language.rb +55 -0
  229. data/spec/zen/package.rb +23 -0
  230. data/spec/zen/package/categories/controller/categories.rb +123 -0
  231. data/spec/zen/package/categories/controller/category_groups.rb +108 -0
  232. data/spec/zen/package/categories/helper/category.rb +75 -0
  233. data/spec/zen/package/categories/plugin/categories.rb +92 -0
  234. data/spec/zen/package/comments/controller/comments.rb +134 -0
  235. data/spec/zen/package/comments/controller/comments_form.rb +343 -0
  236. data/spec/zen/package/comments/helper/comment.rb +47 -0
  237. data/spec/zen/package/comments/plugin/anti_spam.rb +59 -0
  238. data/spec/zen/package/comments/plugin/comments.rb +107 -0
  239. data/spec/zen/package/custom_fields/blue_form_parameters.rb +183 -0
  240. data/spec/zen/package/custom_fields/controller/custom_field_groups.rb +120 -0
  241. data/spec/zen/package/custom_fields/controller/custom_field_types.rb +169 -0
  242. data/spec/zen/package/custom_fields/controller/custom_fields.rb +158 -0
  243. data/spec/zen/package/custom_fields/helper/custom_field.rb +86 -0
  244. data/spec/zen/package/menus/controller/menu_items.rb +110 -0
  245. data/spec/zen/package/menus/controller/menus.rb +110 -0
  246. data/spec/zen/package/menus/helper/menu.rb +75 -0
  247. data/spec/zen/package/menus/plugin/menus.rb +120 -0
  248. data/spec/zen/package/sections/controller/section_entries.rb +201 -0
  249. data/spec/zen/package/sections/controller/sections.rb +116 -0
  250. data/spec/zen/package/sections/helper/section.rb +74 -0
  251. data/spec/zen/package/sections/plugin/section_entries.rb +161 -0
  252. data/spec/zen/package/sections/plugin/sections.rb +75 -0
  253. data/spec/zen/package/settings/controller/settings.rb +36 -0
  254. data/spec/zen/package/settings/plugin/settings.rb +33 -0
  255. data/spec/zen/package/users/controller/access_rules.rb +90 -0
  256. data/spec/zen/package/users/controller/user_groups.rb +101 -0
  257. data/spec/zen/package/users/controller/users.rb +130 -0
  258. data/spec/zen/package/users/helper/users.rb +97 -0
  259. data/spec/zen/plugin.rb +64 -0
  260. data/spec/zen/plugin/helper.rb +11 -0
  261. data/spec/zen/plugin/markup.rb +44 -0
  262. data/spec/zen/theme.rb +41 -0
  263. data/spec/zen/validation.rb +63 -0
  264. data/zen.gemspec +36 -0
  265. metadata +159 -113
  266. data/MANIFEST +0 -266
  267. data/lib/zen/bin/app.rb +0 -40
  268. data/lib/zen/ext/string.rb +0 -185
  269. data/lib/zen/helper/common.rb +0 -106
  270. data/lib/zen/package/categories/lib/categories/view/admin/categories/edit.xhtml +0 -7
  271. data/lib/zen/package/categories/lib/categories/view/admin/categories/new.xhtml +0 -7
  272. data/lib/zen/package/categories/lib/categories/view/admin/category-groups/edit.xhtml +0 -7
  273. data/lib/zen/package/categories/lib/categories/view/admin/category-groups/new.xhtml +0 -7
  274. data/lib/zen/package/comments/lib/comments/view/admin/comments/edit.xhtml +0 -7
  275. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/edit.xhtml +0 -7
  276. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/new.xhtml +0 -7
  277. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/edit.xhtml +0 -7
  278. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/new.xhtml +0 -7
  279. data/lib/zen/package/menus/lib/menus/view/admin/menu-items/edit.xhtml +0 -7
  280. data/lib/zen/package/menus/lib/menus/view/admin/menu-items/new.xhtml +0 -7
  281. data/lib/zen/package/menus/lib/menus/view/admin/menus/edit.xhtml +0 -7
  282. data/lib/zen/package/menus/lib/menus/view/admin/menus/new.xhtml +0 -7
  283. data/lib/zen/package/sections/lib/sections/view/admin/edit.xhtml +0 -7
  284. data/lib/zen/package/sections/lib/sections/view/admin/new.xhtml +0 -7
  285. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/edit.xhtml +0 -7
  286. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/new.xhtml +0 -7
  287. data/lib/zen/package/users/lib/users/view/admin/access-rules/edit.xhtml +0 -7
  288. data/lib/zen/package/users/lib/users/view/admin/access-rules/new.xhtml +0 -7
  289. data/lib/zen/package/users/lib/users/view/admin/user-groups/edit.xhtml +0 -7
  290. data/lib/zen/package/users/lib/users/view/admin/user-groups/new.xhtml +0 -7
  291. data/lib/zen/package/users/lib/users/view/admin/users/edit.xhtml +0 -7
  292. data/lib/zen/package/users/lib/users/view/admin/users/new.xhtml +0 -7
  293. data/lib/zen/plugin/controller.rb +0 -59
  294. data/lib/zen/public/admin/css/zen/notifications.css +0 -84
  295. data/lib/zen/public/admin/images/zen/icons/large/error.png +0 -0
  296. data/lib/zen/public/admin/images/zen/icons/large/notice.png +0 -0
  297. data/lib/zen/public/admin/images/zen/icons/large/success.png +0 -0
  298. data/lib/zen/public/admin/js/zen/core.js +0 -73
  299. data/lib/zen/public/admin/js/zen/init.js +0 -80
  300. data/proto/package/lib/package.rb +0 -21
  301. data/proto/package/lib/package/controller/controllers.rb +0 -50
  302. data/proto/package/lib/package/language/en/languages.yml +0 -4
  303. data/proto/package/lib/package/model/model.rb +0 -12
@@ -3,9 +3,9 @@ module Comments
3
3
  #:nodoc:
4
4
  module Controller
5
5
  ##
6
- # Frontend controller for the comments system used for saving user-submitted comments.
7
- # When the anti-spam system is enabled Zen will use Defensio to check if the comment is
8
- # spam or ham.
6
+ # Frontend controller for the comments system used for saving user-submitted
7
+ # comments. When the anti-spam system is enabled Zen will use Defensio to
8
+ # check if the comment is spam or ham.
9
9
  #
10
10
  # @author Yorick Peterse
11
11
  # @since 0.1
@@ -13,7 +13,8 @@ module Comments
13
13
  class CommentsForm < Zen::Controller::FrontendController
14
14
  include ::Comments::Model
15
15
 
16
- map('/comments-form')
16
+ map '/comments-form'
17
+ helper :message
17
18
 
18
19
  before_all do
19
20
  csrf_protection(:save) do
@@ -22,8 +23,8 @@ module Comments
22
23
  end
23
24
 
24
25
  ##
25
- # Creates a new comment for the section entry. Once the comment has been saved
26
- # the user will be redirected back to the previous page.
26
+ # Creates a new comment for the section entry. Once the comment has been
27
+ # saved the user will be redirected back to the previous page.
27
28
  #
28
29
  # @author Yorick Peterse
29
30
  # @since 0.1
@@ -33,21 +34,34 @@ module Comments
33
34
 
34
35
  comment = Comment.new
35
36
  post = request.subset(
36
- :section_entry, :user_id, :comment, :name, :website, :email
37
+ :section_entry,
38
+ :user_id,
39
+ :comment,
40
+ :name,
41
+ :website,
42
+ :email
37
43
  )
38
44
 
45
+ # Get all the comment statuses.
46
+ comment_statuses = {}
47
+ draft_status = Sections::Model::SectionEntryStatus[
48
+ :name => 'draft'
49
+ ].id
50
+
51
+ ::Comments::Model::CommentStatus.all.each do |status|
52
+ comment_statuses[status.name] = status.id
53
+ end
54
+
39
55
  entry = ::Sections::Model::SectionEntry[post['section_entry']]
40
56
 
41
57
  # Remove empty values
42
58
  post.each { |k, v| post.delete(k) if v.empty? }
43
59
 
44
- if post.key?('user_id')
45
- comment.user_id = post['user_id']
46
- end
47
-
48
- # Set the comment data
60
+ comment.user_id = post['user_id'] if post.key?('user_id')
49
61
  comment.comment = post['comment']
50
62
 
63
+ # If no user ID is specified we'll use the name, website and Email of
64
+ # the POST data.
51
65
  if !post.key?('user_id')
52
66
  ['name', 'website', 'email'].each do |k|
53
67
  if post.key?(k)
@@ -56,31 +70,36 @@ module Comments
56
70
  end
57
71
  end
58
72
 
59
- comment.section_entry_id = entry.id
60
-
61
73
  # Validate the section entry
62
- if entry.nil?
74
+ if entry.nil? or entry.section_entry_status_id === draft_status
63
75
  message(:error, lang('comments.errors.invalid_entry'))
64
76
  redirect_referrer
65
77
  end
66
78
 
67
- section = entry.section
79
+ comment.section_entry_id = entry.id
80
+ section = entry.section
81
+
82
+ # Section valid?
83
+ if section.nil?
84
+ message(:error, lang('comments.errors.invalid_entry'))
85
+ redirect_referrer
86
+ end
68
87
 
69
88
  # Comments allowed?
70
- if section.comment_allow == false
89
+ if section.comment_allow === false
71
90
  message(:error, lang('comments.errors.comments_not_allowed'))
72
91
  redirect_referrer
73
92
  end
74
93
 
75
94
  # Comments require an account?
76
- if section.comment_require_account == true and session[:user].nil?
95
+ if section.comment_require_account === true and session[:user].nil?
77
96
  message(:error, lang('comments.errors.comments_require_account'))
78
97
  redirect_referrer
79
98
  end
80
99
 
81
100
  # Require moderation?
82
- if section.comment_moderate == true
83
- comment.status = 'closed'
101
+ if section.comment_moderate === true
102
+ comment.comment_status_id = comment_statuses['closed']
84
103
  end
85
104
 
86
105
  # Require anti-spam validation?
@@ -91,12 +110,12 @@ module Comments
91
110
  # Time to validate the Defensio response
92
111
  if spam === false
93
112
  if section.comment_moderate == true
94
- comment.status = 'closed'
113
+ comment.comment_status_id = comment_statuses['closed']
95
114
  else
96
- comment.status = 'open'
115
+ comment.comment_status_id = comment_statuses['open']
97
116
  end
98
117
  else
99
- comment.status = 'spam'
118
+ comment.comment_status_id = comment_statuses['spam']
100
119
  end
101
120
  end
102
121
 
@@ -116,6 +135,6 @@ module Comments
116
135
 
117
136
  redirect_referrer
118
137
  end
119
- end
120
- end
121
- end
138
+ end # CommentsForm
139
+ end # Controller
140
+ end # Comments
@@ -0,0 +1,35 @@
1
+ #:nodoc:
2
+ module Ramaze
3
+ #:nodoc:
4
+ module Helper
5
+ ##
6
+ # Helper used by the comments package.
7
+ #
8
+ # @author Yorick Peterse
9
+ # @since 0.2.8
10
+ #
11
+ module Comment
12
+ ##
13
+ # Given a comment ID this method checks if that ID results in a valid
14
+ # instance of Comments::Model::Comment. If this is the case the object is
15
+ # returned, otherwise the user is redirected back to the comment overview
16
+ # and is shown a message.
17
+ #
18
+ # @author Yorick Peterse
19
+ # @since 0.2.8
20
+ # @param [Fixnum] comment_id The ID of the comment to validate.
21
+ # @return [Comments::Model::Comment]
22
+ #
23
+ def validate_comment(comment_id)
24
+ comment = ::Comments::Model::Comment[comment_id]
25
+
26
+ if comment.nil?
27
+ message(:error, lang('comments.errors.invalid_comment'))
28
+ redirect(::Comments::Controller::Comments.r(:index))
29
+ else
30
+ return comment
31
+ end
32
+ end
33
+ end # Comment
34
+ end # Helper
35
+ end # Ramaze
@@ -31,15 +31,17 @@ success:
31
31
  new : 'The new comment has been created.'
32
32
  save : 'The comment has been modified.'
33
33
  delete : 'All selected comments have been deleted.'
34
- moderate : "The comment has been posted but mush be approved by an administrator before it's displayed."
34
+ moderate : "The comment has been posted but must be approved by an administrator before it's displayed."
35
35
 
36
36
  errors:
37
- new : 'Failed to create the new comment.'
38
- save : 'Failed to modify the comment.'
39
- delete : 'Failed to delete the comment with ID #%s.'
40
- no_delete : "You haven't specified any comments to delete."
41
- invalid_entry : 'The specified section entry is invalid.'
42
- comments_not_allowed : "Comments aren't allowed for this section."
37
+ new : 'Failed to create the new comment.'
38
+ save : 'Failed to modify the comment.'
39
+ delete : 'Failed to delete the comment with ID #%s.'
40
+ no_delete : "You haven't specified any comments to delete."
41
+ invalid_entry : 'The specified section entry is invalid.'
42
+ comments_not_allowed : "Comments aren't allowed for this section."
43
+ comments_require_account: 'You need to be logged in to post a comment.'
44
+ invalid_comment : 'The specified comment is invalid.'
43
45
 
44
46
  buttons:
45
47
  delete : 'Delete selected comments'
@@ -24,7 +24,7 @@ messages:
24
24
  no_comments: 'Er zijn nog geen reacties toegevoegd.'
25
25
 
26
26
  placeholders:
27
- anti_spam_system: 'Het anti-spam systeem dat gebruikt moet worden voor het verifiëren
27
+ anti_spam_system: 'Het anti-spam systeem dat gebruikt moet worden voor het verifiëren
28
28
  van reacties.'
29
29
  defensio_key: 'De API sleutel voor het Defensio anti-spam systeem.'
30
30
 
@@ -32,16 +32,18 @@ success:
32
32
  new : 'De reactie is aangemaakt.'
33
33
  save : 'De reactie is aangepast.'
34
34
  delete : 'Alle geselecteerde reacties zijn verwijderd.'
35
- moderate: 'De reactie moet eerst worden goedgekeurd door een beheerder voordat het kan
35
+ moderate: 'De reactie moet eerst worden goedgekeurd door een beheerder voordat het kan
36
36
  worden weergegeven'
37
37
 
38
38
  errors:
39
- new : 'De reactie kon niet worden aangemaakt.'
40
- save : 'De reactie kon niet worden aangepast.'
41
- delete : 'De reactie met ID #%s kon niet worden verwijderd.'
42
- no_delete : 'U moet ten minste 1 reactie specificeren om te verwijderen.'
43
- invalid_entry : 'Het gespecificeerde artikel is ongeldig.'
44
- comments_not_allowed: 'Reacties zijn niet toegestaan voor deze sectie.'
39
+ new : 'De reactie kon niet worden aangemaakt.'
40
+ save : 'De reactie kon niet worden aangepast.'
41
+ delete : 'De reactie met ID #%s kon niet worden verwijderd.'
42
+ no_delete : 'U moet ten minste 1 reactie specificeren om te verwijderen.'
43
+ invalid_entry : 'Het gespecificeerde artikel is ongeldig.'
44
+ comments_not_allowed : 'Reacties zijn niet toegestaan voor deze sectie.'
45
+ comments_require_account: 'Je moet ingelogd zijn om reacties te kunnen plaatsen.'
46
+ invalid_comment : 'De opgegeven reactie is ongeldig.'
45
47
 
46
48
  buttons:
47
49
  delete: 'Geselecteerde reacties verwijderen'
@@ -3,14 +3,15 @@ module Comments
3
3
  #:nodoc:
4
4
  module Model
5
5
  ##
6
- # Model that represents a single comment. This model has the following relations:
6
+ # Model that represents a single comment. This model has the following
7
+ # relations:
7
8
  #
8
9
  # * section entry (many to one)
9
10
  # * user (many to one)
10
11
  #
11
12
  # The following plugins are used:
12
13
  #
13
- # * timestamps
14
+ # * timestamps
14
15
  #
15
16
  # @author Yorick Peterse
16
17
  # @since 0.1
@@ -18,11 +19,12 @@ module Comments
18
19
  class Comment < Sequel::Model
19
20
  include ::Zen::Language
20
21
 
21
- many_to_one :section_entry, :class => "Sections::Model::SectionEntry"
22
- many_to_one :user, :class => "Users::Model::User"
23
-
22
+ many_to_one :section_entry, :class => "Sections::Model::SectionEntry"
23
+ many_to_one :user, :class => "Users::Model::User"
24
+ many_to_one :comment_status, :class => 'Comments::Model::CommentStatus'
25
+
24
26
  plugin :timestamps, :create => :created_at, :update => :updated_at
25
-
27
+
26
28
  ##
27
29
  # Specify the validation rules for each comment.
28
30
  #
@@ -30,7 +32,8 @@ module Comments
30
32
  # @since 0.1
31
33
  #
32
34
  def validate
33
- validates_presence :comment
35
+ validates_presence [:comment, :section_entry_id]
36
+ validates_integer [:comment_status_id, :section_entry_id]
34
37
 
35
38
  if user_id.nil?
36
39
  validates_presence :email
@@ -50,11 +53,13 @@ module Comments
50
53
  def self.status_hash
51
54
  ::Zen::Language.load('comments')
52
55
 
53
- return {
54
- 'open' => lang('comments.labels.open'),
55
- 'closed' => lang('comments.labels.closed'),
56
- 'spam' => lang('comments.labels.spam')
57
- }
56
+ statuses = {}
57
+
58
+ ::Comments::Model::CommentStatus.all.each do |status|
59
+ statuses[status.id] = lang("comments.labels.#{status.name}")
60
+ end
61
+
62
+ return statuses
58
63
  end
59
64
 
60
65
  ##
@@ -64,8 +69,8 @@ module Comments
64
69
  # @since 0.2.6
65
70
  #
66
71
  def before_create
72
+ prepare_comment
67
73
  super
68
- sanitize
69
74
  end
70
75
 
71
76
  ##
@@ -75,24 +80,33 @@ module Comments
75
80
  # @since 0.2.6
76
81
  #
77
82
  def before_save
83
+ prepare_comment
78
84
  super
79
- sanitize
80
85
  end
81
86
 
82
87
  ##
83
- # Cleans all the input data of nasty stuff.
88
+ # Cleans all the input data of nasty stuff and ensures certain fields have
89
+ # the correct values.
84
90
  #
85
91
  # @author Yorick Peterse
86
92
  # @since 0.2.6
87
93
  #
88
- def sanitize
94
+ def prepare_comment
89
95
  [:name, :website, :email, :comment].each do |field|
90
96
  got = send(field)
91
97
 
92
98
  if !got.nil?
93
- send("#{field}=", Loofah.fragment(got).scrub!(:whitewash).scrub!(:nofollow).to_s)
99
+ send("#{field}=", Loofah.fragment(got).scrub!(:whitewash) \
100
+ .scrub!(:nofollow).to_s)
94
101
  end
95
102
  end
103
+
104
+ # Get the default status of a comment
105
+ if self.comment_status_id.nil?
106
+ self.comment_status_id = ::Comments::Model::CommentStatus[
107
+ :name => 'closed'
108
+ ].id
109
+ end
96
110
  end
97
111
  end # Comment
98
112
  end # Model
@@ -0,0 +1,15 @@
1
+ #:nodoc:
2
+ module Comments
3
+ #:nodoc:
4
+ module Model
5
+ ##
6
+ # Model used for managing the statuses of a comment.
7
+ #
8
+ # @author Yorick Peterse
9
+ # @since 0.2.8
10
+ #
11
+ class CommentStatus < Sequel::Model
12
+ many_to_one :comment, :class => 'Comments::Model::CommentStatus'
13
+ end # CommentStatus
14
+ end # Model
15
+ end # Comments
@@ -3,34 +3,38 @@ module Comments
3
3
  #:nodoc:
4
4
  module Plugin
5
5
  ##
6
- # A plugin that can be used to verify a comment against an external (or internal)
7
- # service to see if it's spam or ham.
6
+ # A plugin that can be used to verify a comment against an external (or
7
+ # internal) service to see if it's spam or ham.
8
8
  #
9
9
  # ## Usage
10
10
  #
11
11
  # plugin(:anti_spam, engine, author, email, url, comment)
12
12
  #
13
- # Note that all variables are required. This is because certain anti-spam systems may
14
- # verify the name of the author or the entered Email address besides just the comment.
15
- # When using Defensio you're only required to set the comment:
13
+ # Note that all variables are required. This is because certain anti-spam
14
+ # systems may verify the name of the author or the entered Email address
15
+ # besides just the comment. When using Defensio you're only required to set
16
+ # the comment:
16
17
  #
17
- # plugin(:anti_spam, :defensio, nil, nil, nil, 'Hello, this is a comment.')
18
+ # plugin(
19
+ # :anti_spam, :defensio, nil, nil, nil, 'Hello, this is a comment.'
20
+ # )
18
21
  #
19
22
  # ## Supported Systems
20
23
  #
21
- # Currently the plugin only supports Defensio, this engine requires the setting
22
- # "defensio_key" to contain a valid Defensio API key.
24
+ # Currently the plugin only supports Defensio, this engine requires the
25
+ # setting "defensio_key" to contain a valid Defensio API key.
23
26
  #
24
27
  # ## Adding Systems
25
28
  #
26
29
  # Adding a system is done in two steps. First you should update the hash
27
- # Comments::PLugin::AntiSpam::Registered so that it includes your system. The keys of
28
- # this hash are symbols that match the name of the engine used when calling the
29
- # plugin() method. The values are the Gems to require.
30
+ # Comments::PLugin::AntiSpam::Registered so that it includes your system.
31
+ # The keys of this hash are symbols that match the name of the engine used
32
+ # when calling the plugin() method. The values are the Gems to require.
30
33
  #
31
34
  # Once this has been done you should add a method to the class
32
- # Comments::Plugin::AntiSpam who's name matches the key set in the Registered hash. If
33
- # your anti-spam solution is called "cake" then you'd do something like the following:
35
+ # Comments::Plugin::AntiSpam who's name matches the key set in the
36
+ # Registered hash. If your anti-spam solution is called "cake" then you'd
37
+ # do something like the following:
34
38
  #
35
39
  # Comments::Plugin::AntiSpam::Registered[:cake] = 'cake-gem'
36
40
  #
@@ -44,8 +48,8 @@ module Comments
44
48
  # end
45
49
  # end
46
50
  #
47
- # The return value of the method added should be a boolean, true for spam and false
48
- # for ham.
51
+ # The return value of the method added should be a boolean, true for spam
52
+ # and false for ham.
49
53
  #
50
54
  # @author Yorick Peterse
51
55
  # @since 0.2.6
@@ -54,7 +58,8 @@ module Comments
54
58
  include ::Zen::Plugin::Helper
55
59
 
56
60
  ##
57
- # Hash containing all the supported anti-spam engines and their Gems to load.
61
+ # Hash containing all the supported anti-spam engines and their Gems to
62
+ # load.
58
63
  #
59
64
  # @author Yorick Peterse
60
65
  # @since 0.2.6
@@ -75,13 +80,17 @@ module Comments
75
80
  # @param [String] comment The comment.
76
81
  #
77
82
  def initialize(engine, author, email, url, comment)
78
- @engine, @author, @email, @url, @comment = engine, author, email, url, comment
83
+ @engine, @author, @email, @url, @comment = engine, author, email, \
84
+ url, comment
79
85
 
80
86
  validate_type(engine, :engine, [Symbol])
81
87
 
82
88
  # Load the correct gem
83
89
  if !Registered.key?(@engine) or !respond_to?(@engine)
84
- raise(::Zen::PluginError, "The anti-spam engine \"#{@engine}\" is invalid")
90
+ raise(
91
+ ::Zen::PluginError,
92
+ "The anti-spam engine \"#{@engine}\" is invalid"
93
+ )
85
94
  end
86
95
 
87
96
  begin