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,8 +3,8 @@ module Comments
3
3
  #:nodoc
4
4
  module Plugin
5
5
  ##
6
- # The Comments plugin can be used to display a list of comments for a given section
7
- # entry.
6
+ # The Comments plugin can be used to display a list of comments for a given
7
+ # section entry.
8
8
  #
9
9
  # ## Usage
10
10
  #
@@ -26,18 +26,21 @@ module Comments
26
26
  include ::Comments::Model
27
27
 
28
28
  ##
29
- # Creates a new instance of the plugin and saves the specified configuration options.
29
+ # Creates a new instance of the plugin and saves the specified
30
+ # configuration options.
30
31
  #
31
32
  # @author Yorick Peterse
32
33
  # @since 0.2.5
33
- # @param [Hash] options Hash with a set of options that determine how the comments
34
- # should be retrieved.
35
- # @option options [String/Integer] :entry The slug or ID of the entry for which to
36
- # retrieve all comments.
37
- # @option options [Integer] :limit The maximum amount of comments to retrieve.
38
- # @option options [Integer] :offset The row offset, useful for pagination systems.
39
- # @option options [Boolean] :markup When set to true (default) the markup used in
40
- # each comment will be converted to the appropriate format.
34
+ # @param [Hash] options Hash with a set of options that determine how
35
+ # the comments should be retrieved.
36
+ # @option options [String/Integer] :entry The slug or ID of the entry for
37
+ # which to retrieve all comments.
38
+ # @option options [Integer] :limit The maximum amount of comments to
39
+ # retrieve.
40
+ # @option options [Integer] :offset The row offset, useful for pagination
41
+ # systems.
42
+ # @option options [Boolean] :markup When set to true (default) the markup
43
+ # used in each comment will be converted to the appropriate format.
41
44
  #
42
45
  def initialize(options = {})
43
46
  @options = {
@@ -55,8 +58,8 @@ module Comments
55
58
  end
56
59
 
57
60
  ##
58
- # Retrieves all comments based on the options set in the construct. The comments are
59
- # returned as an array.
61
+ # Retrieves all comments based on the options set in the construct. The
62
+ # comments are returned as an array.
60
63
  #
61
64
  # @author Yorick Peterse
62
65
  # @since 0.2.5
@@ -69,27 +72,29 @@ module Comments
69
72
  entry = SectionEntry[@options[:entry]]
70
73
  end
71
74
 
72
- # Now that we have the entry and the section we can start retrieving all the
73
- # comments.
75
+ # Now that we have the entry and the section we can start retrieving
76
+ # all the comments.
74
77
  comments = Comment.filter(:section_entry_id => entry.id) \
75
78
  .limit(@options[:limit], @options[:offset]) \
76
79
  .all
77
80
 
78
- # Don't bother with all code below this if/end if we don't want to convert the
79
- # markup of each comment.
81
+ # Don't bother with all code below this if/end if we don't want to
82
+ # convert the markup of each comment.
80
83
  if @options[:markup] === false
81
84
  return comments
82
85
  end
83
86
 
84
- # Get the section for the comments. This is required to determine what markup is
85
- # used for the comments.
87
+ # Get the section for the comments. This is required to determine what
88
+ # markup is used for the comments.
86
89
  section = entry.section
87
90
 
88
91
  # Convert the markup of each comment and convert each comment to a hash
89
92
  comments.each_with_index do |comment, index|
90
93
  user = comment.user
91
94
  comment = comment.values
92
- comment[:comment] = plugin(:markup, section.comment_format, comment[:comment])
95
+ comment[:comment] = plugin(
96
+ :markup, section.comment_format, comment[:comment]
97
+ )
93
98
 
94
99
  # Conver the userdata to a hash as well
95
100
  comment[:user] = {}
@@ -1,57 +1,64 @@
1
- #{
2
- form_for(
3
- @comment, :method => :post, :action => @form_save_url, :id => :comment_form
4
- ) do |f|
5
- f.input_hidden(:csrf_token, get_csrf_token)
6
- f.input_hidden(:id , @comment.id)
1
+ <article>
2
+ <header>
3
+ <h1>#{get_breadcrumbs}</h1>
4
+ </header>
7
5
 
8
- if !@comment.user
9
- name = @comment.name
10
- website = @comment.website
11
- email = @comment.email
12
- else
13
- name = @comment.user.name
14
- website = @comment.user.website
15
- email = @comment.user.email
16
- end
17
-
18
- f.input_text(
19
- lang('comments.labels.name'),
20
- :name,
21
- :value => name,
22
- :disabled => :disabled
23
- )
6
+ #{
7
+ form_for(
8
+ @comment,
9
+ :method => :post,
10
+ :action => Comments::Controller::Comments.r(:save),
11
+ :id => :comment_form
12
+ ) do |f|
13
+ f.input_hidden(:csrf_token, get_csrf_token)
14
+ f.input_hidden(:id , @comment.id)
15
+
16
+ if !@comment.user
17
+ name = @comment.name
18
+ website = @comment.website
19
+ email = @comment.email
20
+ else
21
+ name = @comment.user.name
22
+ website = @comment.user.website
23
+ email = @comment.user.email
24
+ end
25
+
26
+ f.input_text(
27
+ lang('comments.labels.name'),
28
+ :name,
29
+ :value => name,
30
+ :disabled => :disabled
31
+ )
24
32
 
25
- f.input_text(
26
- lang('comments.labels.website'),
27
- :website,
28
- :value => website
29
- )
30
-
31
- f.input_text(
32
- lang('comments.labels.email'),
33
- :email,
34
- :value => email
35
- )
36
-
37
- f.select(
38
- lang('comments.labels.status'),
39
- :status,
40
- :values => Comments::Model::Comment.status_hash,
41
- :selected => @comment.status,
42
- :size => 1
43
- )
44
-
45
- f.textarea(
46
- lang('comments.labels.comment'),
47
- :comment,
48
- :rows => 10
49
- )
50
-
51
- f.g.div(:class => 'clearfix') do
52
- f.g.div(:class => 'button') do
53
- f.g.input(:type => 'submit', :value => lang('comments.buttons.save'))
33
+ f.input_text(
34
+ lang('comments.labels.website'),
35
+ :website,
36
+ :value => website
37
+ )
38
+
39
+ f.input_text(
40
+ lang('comments.labels.email'),
41
+ :email,
42
+ :value => email
43
+ )
44
+
45
+ f.select(
46
+ lang('comments.labels.status'),
47
+ :comment_status_id,
48
+ :values => Comments::Model::Comment.status_hash,
49
+ :selected => @comment.comment_status_id,
50
+ :size => 1
51
+ )
52
+
53
+ f.textarea(
54
+ lang('comments.labels.comment'),
55
+ :comment,
56
+ :rows => 10
57
+ )
58
+
59
+ f.g.div(:class => 'button') do
60
+ f.g.input(:type => 'submit', :value => lang('comments.buttons.save'))
61
+ end
54
62
  end
55
- end
56
- end
57
- }
63
+ }
64
+ </article>
@@ -2,15 +2,16 @@
2
2
  <header>
3
3
  <h1>#{get_breadcrumbs}</h1>
4
4
  </header>
5
-
6
- <form method="post" action="#{@form_delete_url}">
5
+
6
+ <form method="post" action="#{Comments::Controller::Comments.r(:delete)}">
7
7
  <input type="hidden" name="csrf_token" value="#{get_csrf_token}" />
8
-
8
+
9
9
  <?r if @comments and !@comments.empty? ?>
10
- <table class="table">
10
+
11
+ <table>
11
12
  <thead>
12
13
  <?r if user_authorized?([:delete]) ?>
13
- <th>
14
+ <th class="no_sort">
14
15
  <input type="checkbox" />
15
16
  </th>
16
17
  <?r end ?>
@@ -23,31 +24,37 @@
23
24
  <th>#{lang('comments.labels.website')}</th>
24
25
  <th>#{lang('comments.labels.created_at')}</th>
25
26
  </thead>
26
- <tbody>
27
+ <tbody>
27
28
  <?r @comments.each do |comment| ?>
28
29
  <tr>
29
30
  <?r if user_authorized?([:delete]) ?>
30
31
  <td>
31
- <input type="checkbox" name="comment_ids[]" value="#{comment.id}" />
32
+ <input type="checkbox" name="comment_ids[]"
33
+ value="#{comment.id}" />
32
34
  </td>
33
35
  <?r end ?>
34
-
36
+
35
37
  <td>#{comment.id}</td>
36
-
38
+
37
39
  <?r if user_authorized?([:update]) ?>
38
40
  <td>
39
- #{anchor_to(
40
- "#{comment.comment[0, 15]}...",
41
- Comments::Controller::Comments.r(:edit, comment.id)
41
+ #{Comments::Controller::Comments.a(
42
+ comment.comment[0, 15].to_s + '...',
43
+ :edit,
44
+ comment.id
42
45
  )}
43
46
  </td>
44
47
  <?r else ?>
45
48
  <td>#{comment.comment[0, 15]}...</td>
46
49
  <?r end ?>
47
-
50
+
48
51
  <td>#{comment.section_entry.title}</td>
49
- <td>#{Comments::Model::Comment.status_hash[comment.status]}</td>
50
-
52
+ <td>
53
+ #{lang(
54
+ "comments.labels.#{comment.comment_status.name}"
55
+ )}
56
+ </td>
57
+
51
58
  <?r if !comment.user ?>
52
59
  <td>#{comment.name}</td>
53
60
  <td>#{comment.email}</td>
@@ -58,22 +65,30 @@
58
65
  <td>#{user.email}</td>
59
66
  <td>#{user.website}</td>
60
67
  <?r end ?>
61
- <td>#{comment.created_at.strftime(session[:user].date_format)}</td>
68
+ <td>
69
+ #{comment.created_at.strftime(
70
+ session[:user].date_format
71
+ )}
72
+ </td>
62
73
  </tr>
63
74
  <?r end ?>
64
75
  </tbody>
65
76
  </table>
77
+
78
+ #{
79
+ if @comments.respond_to?(:navigation) and @comments.page_count > 1
80
+ @comments.navigation
81
+ end
82
+ }
83
+
66
84
  <?r else ?>
67
85
  <p>#{lang('comments.messages.no_comments')}</p>
68
86
  <?r end ?>
69
-
70
- <?r if user_authorized?([:delete]) and @comments and !@comments.empty? ?>
71
- <div class="clearfix">
72
- <div class="button">
73
- <input type="submit" value="#{lang('comments.buttons.delete')}" />
74
- </div>
87
+
88
+ <?r if user_authorized?([:delete]) and !@comments.empty? ?>
89
+ <div class="button">
90
+ <input type="submit" value="#{lang('comments.buttons.delete')}" />
75
91
  </div>
76
92
  <?r end ?>
77
-
78
93
  </form>
79
94
  </article>
@@ -0,0 +1,60 @@
1
+ Sequel.migration do
2
+ # Updates the database with the changes specified in the block.
3
+ up do
4
+ create_table(:comment_statuses) do
5
+ primary_key :id
6
+
7
+ String :name, :null => false, :unique => true
8
+ end
9
+
10
+ # Get all the current comments so we can update the statuses
11
+ comments = Zen.database[:comments].all
12
+
13
+ # Replace the old status column
14
+ drop_column(:comments, :status)
15
+
16
+ alter_table(:comments) do
17
+ add_foreign_key(
18
+ :comment_status_id,
19
+ :comment_statuses,
20
+ :on_delete => :cascade,
21
+ :on_update => :cascade,
22
+ :key => :id
23
+ )
24
+ end
25
+
26
+ # Insert the possible statuses and migrate existing statuses over to the IDs
27
+ ['open', 'closed', 'spam'].each do |status|
28
+ status_id = Zen.database[:comment_statuses].insert({:name => status})
29
+
30
+ comments.each do |comment|
31
+ if comment[:status] === status
32
+ Zen.database[:comments].filter(:id => comment[:id]) \
33
+ .update(:comment_status_id => status_id)
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ # Reverts the changes made in the up() block.
40
+ down do
41
+ statuses = {}
42
+ comments = Zen.database[:comments].all
43
+
44
+ Zen.database[:comment_statuses].all.each do |status|
45
+ statuses[status[:id]] = status[:name]
46
+ end
47
+
48
+ # Put the old columns back in place
49
+ drop_column(:comments, :comment_status_id)
50
+ add_column(:comments, :status, String, :default => 'closed')
51
+
52
+ # Put the old statuses back in place
53
+ comments.each do |comment|
54
+ Zen.database.filter(:id => comment[:id]) \
55
+ .update(:status => statuses[comment[:comment_status_id]])
56
+ end
57
+
58
+ drop_table(:comment_statuses)
59
+ end
60
+ end
@@ -1,30 +1,56 @@
1
+ # Update the helpers path for the controllers
2
+ Ramaze::HelpersHelper.options.paths.push(__DIR__('custom_fields'))
3
+
4
+ # Update the language path
5
+ Zen::Language.options.paths.push(__DIR__('custom_fields'))
6
+
7
+ # Load all models
8
+ require __DIR__('custom_fields/model/custom_field_method')
9
+ require __DIR__('custom_fields/model/custom_field_type')
1
10
  require __DIR__('custom_fields/model/custom_field')
2
11
  require __DIR__('custom_fields/model/custom_field_group')
3
12
  require __DIR__('custom_fields/model/custom_field_value')
13
+
14
+ # Load all controllers
4
15
  require __DIR__('custom_fields/controller/custom_field_groups')
5
16
  require __DIR__('custom_fields/controller/custom_fields')
17
+ require __DIR__('custom_fields/controller/custom_field_types')
6
18
 
7
- Zen::Language.options.paths.push(__DIR__('custom_fields'))
19
+ require __DIR__('custom_fields/blue_form_parameters')
20
+
21
+ # Load all the language files
8
22
  Zen::Language.load('custom_fields')
9
23
  Zen::Language.load('custom_field_groups')
24
+ Zen::Language.load('custom_field_types')
10
25
 
26
+ # Define the package
11
27
  Zen::Package.add do |p|
12
28
  p.name = 'custom_fields'
13
29
  p.author = 'Yorick Peterse'
14
30
  p.url = 'http://yorickpeterse.com/'
15
- p.about = "The Custom Fields module is used to manage custom fields and custom
16
- field groups."
31
+ p.about = "The Custom Fields module is used to manage custom fields
32
+ and custom field groups."
17
33
 
18
34
  p.directory = __DIR__('custom_fields')
19
35
  p.migration_dir = __DIR__('../migrations')
20
36
 
21
37
  p.menu = [{
22
- :title => lang('custom_fields.titles.index'),
23
- :url => "admin/custom-field-groups"
38
+ :title => lang('custom_fields.titles.index'),
39
+ :url => "admin/custom-field-groups",
40
+ :children => [
41
+ {
42
+ :title => lang('custom_field_types.titles.index'),
43
+ :url => 'admin/custom-field-types'
44
+ }
45
+ ]
24
46
  }]
25
47
 
26
48
  p.controllers = {
27
- lang('custom_fields.titles.index') => CustomFields::Controller::CustomFields,
28
- lang('custom_field_groups.titles.index') => CustomFields::Controller::CustomFieldGroups
49
+ lang('custom_fields.titles.index') \
50
+ => CustomFields::Controller::CustomFields,
51
+ lang('custom_field_groups.titles.index') \
52
+ => CustomFields::Controller::CustomFieldGroups,
53
+ lang('custom_field_types.titles.index') \
54
+ => CustomFields::Controller::CustomFieldTypes
29
55
  }
30
56
  end
@@ -0,0 +1,209 @@
1
+ #:nodoc:
2
+ module CustomFields
3
+ ##
4
+ # The BlueFormParameters module is used to build an array of parameters for
5
+ # various BlueForm methods based on the type and method of a custom field.
6
+ #
7
+ # @author Yorick Peterse
8
+ # @since 0.2.8
9
+ #
10
+ module BlueFormParameters
11
+ class << self
12
+ ##
13
+ # Generates the required parameters for
14
+ # Ramaze::Helper::BlueForm::Form#input_text.
15
+ #
16
+ # @author Yorick Peterse
17
+ # @since 0.2.8
18
+ # @param [CustomFields::Model::CustomField] field The custom field to use
19
+ # for filling in classes, values, etc.
20
+ # @param [CustomFields::Model::CustomFieldValue] field_value The
21
+ # value of the custom field for a given entry.
22
+ # @return [Array]
23
+ #
24
+ def input_text(field, field_value)
25
+ type = field.custom_field_type
26
+ value = field_value.value rescue nil
27
+ params = [
28
+ :input_text,
29
+ field.name,
30
+ "custom_field_value_#{field.id}",
31
+ {:value => value}
32
+ ]
33
+
34
+ if !field.text_limit.nil?
35
+ params.last[:maxlength] = field.text_limit
36
+ end
37
+
38
+ if !field.description.nil?
39
+ params.last[:placeholder] = field.description
40
+ end
41
+
42
+ if !field.format.nil? and !field.format.empty? \
43
+ and type.allow_markup === true
44
+ params.last[:'data-format'] = field.format
45
+ end
46
+
47
+ if !type.html_class.nil? and !type.html_class.empty?
48
+ params.last[:class] = type.html_class
49
+ end
50
+
51
+ return params
52
+ end
53
+
54
+ ##
55
+ # Generates the required parameters for
56
+ # Ramaze::Helper::BlueForm::Form#input_password.
57
+ #
58
+ # @author Yorick Peterse
59
+ # @since 0.2.8
60
+ # @see CustomFields::BlueFormParameters.input_text
61
+ #
62
+ def input_password(field, field_value)
63
+ params = input_text(field, field_value)
64
+ params[0] = :input_password
65
+
66
+ params.last.delete(:'data-format')
67
+
68
+ return params
69
+ end
70
+
71
+ ##
72
+ # Generates the required parameters for
73
+ # Ramaze::Helper::BlueForm::Form#textarea.
74
+ #
75
+ # @author Yorick Peterse
76
+ # @since 0.2.8
77
+ # @see CustomFields::BlueFormParameters.input_text
78
+ #
79
+ def textarea(field, field_value)
80
+ params = input_text(field, field_value)
81
+ params[0] = :textarea
82
+
83
+ if !field.textarea_rows.nil?
84
+ params.last[:rows] = field.textarea_rows
85
+ end
86
+
87
+ # Remove the class "text]editor" if the field does not allow the text
88
+ # editor to be used.
89
+ if field.text_editor === false
90
+ params.last[:class].gsub!('text_editor', '')
91
+ end
92
+
93
+ return params
94
+ end
95
+
96
+ ##
97
+ # Generates the required parameters for
98
+ # Ramaze::Helper::BlueForm::Form#input_radio.
99
+ #
100
+ # @author Yorick Peterse
101
+ # @since 0.2.8
102
+ # @see CustomFields::BlueFormParameters.input_text
103
+ #
104
+ def input_radio(field, field_value)
105
+ type = field.custom_field_type
106
+ value = field_value.value rescue nil
107
+ params = [
108
+ :input_radio,
109
+ field.name,
110
+ "custom_field_value_#{field.id}",
111
+ value,
112
+ {}
113
+ ]
114
+
115
+ # Convert the string containing the possible values to a hash.
116
+ if !field.possible_values.nil? and !field.possible_values.empty?
117
+ params.last[:values] = {}
118
+
119
+ field.possible_values.split(/\n|\r\n/).each do |row|
120
+ if row.include?('|')
121
+ row = row.split('|', 2)
122
+ key, value = row[0], row[1]
123
+ else
124
+ key = value = row
125
+ end
126
+
127
+ params.last[:values][key] = value
128
+ end
129
+ end
130
+
131
+ return params
132
+ end
133
+
134
+ ##
135
+ # Generates the required parameters for
136
+ # Ramaze::Helper::BlueForm::Form#input_checkbox.
137
+ #
138
+ # @author Yorick Peterse
139
+ # @since 0.2.8
140
+ # @see CustomFields::BlueFormParameters.input_radio
141
+ #
142
+ def input_checkbox(field, field_value)
143
+ params = input_radio(field, field_value)
144
+ params[0] = :input_checkbox
145
+
146
+ return params
147
+ end
148
+
149
+ ##
150
+ # Generates the required parameters for
151
+ # Ramaze::Helper::BlueForm::Form#select.
152
+ #
153
+ # @author Yorick Peterse
154
+ # @since 0.2.8
155
+ # @see CustomFields::BlueFormParameters.input_text
156
+ #
157
+ def select(field, field_value)
158
+ type = field.custom_field_type
159
+ value = field_value.value rescue nil
160
+ params = [
161
+ :select,
162
+ field.name,
163
+ "custom_field_value_#{field.id}",
164
+ {:selected => value, :size => 1}
165
+ ]
166
+
167
+ # Convert the string containing the possible values to a hash.
168
+ if !field.possible_values.nil? and !field.possible_values.empty?
169
+ params.last[:values] = {}
170
+
171
+ field.possible_values.split(/\n|\r\n/).each do |row|
172
+ if row.include?('|')
173
+ row = row.split('|', 2)
174
+ key, value = row[0], row[1]
175
+ else
176
+ key = value = row
177
+ end
178
+
179
+ params.last[:values][key] = value
180
+ end
181
+ end
182
+
183
+ return params
184
+ end
185
+
186
+ ##
187
+ # Generates the required parameters for
188
+ # Ramaze::Helper::BlueForm::Form#select but allows multiple values to be
189
+ # selected.
190
+ #
191
+ # @author Yorick Peterse
192
+ # @since 0.2.8
193
+ # @see CustomFields::BlueFormParameters.select
194
+ #
195
+ def select_multiple(field, field_value)
196
+ params = select(field, field_value)
197
+
198
+ params.last[:multiple] = :multiple
199
+ params.last[:values] = params.last[:values].invert
200
+
201
+ params.last.delete(:size)
202
+
203
+ return params
204
+ end
205
+
206
+ private
207
+ end # class << self
208
+ end # BlueFormParameters
209
+ end # CustomFields