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
@@ -1,24 +1,15 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="#{plugin(:settings, :get, :language).value}">
3
3
  <head>
4
- <meta charset="utf-8" />
5
-
6
- <!-- Load all stylesheets -->
7
- #{::Zen::Asset.build(:stylesheet)}
8
-
9
- <title>#{@page_title}</title>
4
+ #{render_file(__DIR__('../view/head.xhtml'))}
10
5
  </head>
11
6
 
12
7
  <body id="admin">
13
8
  <div id="top">
14
9
  <header class="container">
15
- <!--
16
- Main navigation of the backend. Navigation items may be excluded if the user
17
- doesn't have the required permissions for the extension that created it.
18
- -->
19
10
  <nav id="main_nav" class="grid_12">
20
11
  #{Zen::Package.build_menu("left", extension_permissions)}
21
-
12
+
22
13
  <ul class="right clearfix">
23
14
  <li>
24
15
  <a href="/admin/users/logout">
@@ -39,7 +30,7 @@
39
30
  </nav>
40
31
  </header>
41
32
  </div>
42
-
33
+
43
34
  #{render_file(__DIR__('../view/main.xhtml'))}
44
35
  #{render_file(__DIR__('../view/bottom.xhtml'))}
45
36
  </body>
@@ -1,12 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="#{plugin(:settings, :get, :language).value}">
3
3
  <head>
4
- <meta charset="utf-8" />
5
-
6
- <!-- Load all stylesheets -->
7
- #{::Zen::Asset.build(:stylesheet)}
8
-
9
- <title>#{@page_title}</title>
4
+ #{render_file(__DIR__('../view/head.xhtml'))}
10
5
  </head>
11
6
 
12
7
  <body id="login">
@@ -3,10 +3,10 @@ module Sequel
3
3
  #:nodoc:
4
4
  class Model
5
5
  ##
6
- # Retrieves all primary values and an optional column and returns the results as
7
- # an array of hashes in which the keys of these hashes are the IDs and the values
8
- # the values of the specified column. This array can be used when creating <select>
9
- # elements using the BlueForm helper.
6
+ # Retrieves all primary values and an optional column and returns the
7
+ # results as an array of hashes in which the keys of these hashes are the
8
+ # IDs and the values the values of the specified column. This array can be
9
+ # used when creating <select> elements using the BlueForm helper.
10
10
  #
11
11
  # @example
12
12
  # Sections::Model::Section.pk_hash(:name) # => {1 => 'Blog', 2 => 'General'}
@@ -24,5 +24,5 @@ module Sequel
24
24
 
25
25
  return hash
26
26
  end
27
- end
28
- end
27
+ end # Model
28
+ end # Sequel
@@ -1,15 +1,16 @@
1
1
  Zen::Language.load('zen_models')
2
2
 
3
- # When passing a hash to update() or create() we'll ignore any keys that don't belong
4
- # in the table. This allows you to directly pass request.params to these methods
5
- # without having to filter the hash yourself.
3
+ # When passing a hash to update() or create() we'll ignore any keys that don't
4
+ # belong in the table. This allows you to directly pass request.params to these
5
+ # methods without having to filter the hash yourself.
6
6
  Sequel::Model.strict_param_setting = false
7
7
 
8
8
  # Load all the required plugins
9
9
  Sequel::Model.plugin :validation_helpers
10
10
  Sequel::Model.plugin :association_pks
11
11
 
12
- Sequel.extension(:migration)
12
+ Sequel.extension :migration
13
+ Sequel.extension :pagination
13
14
 
14
15
  Sequel::Plugins::ValidationHelpers::DEFAULT_OPTIONS.merge!(
15
16
  {
data/lib/zen/package.rb CHANGED
@@ -5,13 +5,13 @@ require __DIR__('package/base')
5
5
  #:nodoc:
6
6
  module Zen
7
7
  ##
8
- # Module used for registering extensions and themes, setting their details and the
9
- # whole shebang. Packages follow the same directory structure as Rubygems and can
10
- # actually be installed using either Rubygems or by storing them in a custom directory.
11
- # As long as you require the correct file you're good to go.
8
+ # Module used for registering extensions and themes, setting their details and
9
+ # the whole shebang. Packages follow the same directory structure as Rubygems
10
+ # and can actually be installed using either Rubygems or by storing them in a
11
+ # custom directory. As long as you require the correct file you're good to go.
12
12
  #
13
- # Packages are added or "described" using a simple block and the add() method as
14
- # following:
13
+ # Packages are added or "described" using a simple block and the add() method
14
+ # as following:
15
15
  #
16
16
  # Zen::Package.add do |ext|
17
17
  # # ....
@@ -29,12 +29,13 @@ module Zen
29
29
  #
30
30
  # ## ACL
31
31
  #
32
- # Packages allow developers to register controllers for the ACL system that ships with
33
- # Zen. Doing this means a user can set controller specific rules in the backend without
34
- # having to write any code. In order to register a set of controllers you'll need to
35
- # set the "controllers" attribute in the package block to a hash. The keys of this hash
36
- # should be a human readable name of the controller and the values the full namespace
37
- # of the controller as either a string or a constants:
32
+ # Packages allow developers to register controllers for the ACL system that
33
+ # ships with Zen. Doing this means a user can set controller specific rules
34
+ # in the backend without having to write any code. In order to register a set
35
+ # of controllers you'll need to set the "controllers" attribute in the package
36
+ # block to a hash. The keys of this hash should be a human readable name of
37
+ # the controller and the values the full namespace of the controller as either
38
+ # a string or a constants:
38
39
  #
39
40
  # Zen::Package.add do |pkg|
40
41
  # pkg.controllers = {
@@ -44,12 +45,15 @@ module Zen
44
45
  #
45
46
  # ## Menu Items
46
47
  #
47
- # The package system easily allows modules to add navigation/sub-navigation elements
48
- # to the backend menu. Each extension can have an attribute named "menu", this attribute
49
- # is an array of hashes. Each hash must have the following 2 keys (they're symbols):
48
+ # The package system easily allows modules to add navigation/sub-navigation
49
+ # elements to the backend menu. Each extension can have an attribute named
50
+ # "menu", this attribute is an array of hashes. Each hash must have the
51
+ # following 2 keys (they're symbols):
50
52
  #
51
- # * title: the value used for both the title tag and the text of the anchor element
52
- # * url: the URI the navigation item will point to. Leading slash isn't required
53
+ # * title: the value used for both the title tag and the text of the anchor
54
+ # element
55
+ # * url: the URI the navigation item will point to. Leading slash isn't
56
+ # required
53
57
  #
54
58
  # Optionally you can specify child elements using the "children" key. This key
55
59
  # will again contain an array of hashes just like regular navigation elements.
@@ -64,21 +68,23 @@ module Zen
64
68
  # :children => [{:title => "Child", :url => "admin/dashboard/child"}]
65
69
  # }]
66
70
  #
67
- # Once a certain number of navigation elements have been added you can generate the
68
- # HTML for a fully fledged navigation menu using the build_menu() method. This method
69
- # uses Gestalt to build the HTML and also takes care of permissions for each user/module.
71
+ # Once a certain number of navigation elements have been added you can
72
+ # generate the HTML for a fully fledged navigation menu using the
73
+ # build_menu() method. This method uses Gestalt to build the HTML and also
74
+ # takes care of permissions for each user/module.
70
75
  #
71
76
  # ## Migrations
72
77
  #
73
- # If your package uses it's own database tables it's best to use migrations as these make
74
- # it very easy to install/uninstall the extension. Migrations should be put in the root
75
- # directory of your extension. For example, if your extension is in "foobar" the
76
- # migrations should be located in "foobar/migrations", the lib directory in "foobar/lib",
77
- # etc.
78
+ # If your package uses it's own database tables it's best to use migrations as
79
+ # these make it very easy to install/uninstall the extension. Migrations
80
+ # should be put in the root directory of your extension. For example, if your
81
+ # extension is in "foobar" the migrations should be located in
82
+ # "foobar/migrations", the lib directory in "foobar/lib", etc.
78
83
  #
79
- # Migrations can be executed using the Thor task "package:migrate" or "db:migrate",
80
- # the latter will install all packages while the first one will only install the
81
- # specified packages. For more information on these tasks execute the following command:
84
+ # Migrations can be executed using the Thor task "package:migrate" or
85
+ # "db:migrate", the latter will install all packages while the first one will
86
+ # only install the specified packages. For more information on these tasks
87
+ # execute the following command:
82
88
  #
83
89
  # $ rake -T
84
90
  #
@@ -87,8 +93,8 @@ module Zen
87
93
  #
88
94
  module Package
89
95
  ##
90
- # Hash containing all the registered packages. The keys of this hash are the names
91
- # of all packages and the values the instances of Zen::Package::Base.
96
+ # Hash containing all the registered packages. The keys of this hash are the
97
+ # names of all packages and the values the instances of Zen::Package::Base.
92
98
  #
93
99
  # @author Yorick Peterse
94
100
  # @since 0.2.5
@@ -104,8 +110,9 @@ module Zen
104
110
  Controllers = []
105
111
 
106
112
  ##
107
- # Adds a new package along with all it's details such as the name, author, version
108
- # and so on. Extensions can be added using a simple block as following:
113
+ # Adds a new package along with all it's details such as the name, author,
114
+ # version and so on. Extensions can be added using a simple block as
115
+ # following:
109
116
  #
110
117
  # Zen::Package.add do |ext|
111
118
  # ext.name = "name"
@@ -121,12 +128,13 @@ module Zen
121
128
  # * url
122
129
  # * directory
123
130
  #
124
- # You can also set "migration_dir" to a directory with all migrations. By default
125
- # Zen will assume that it's 2 levels above your root directory.
131
+ # You can also set "migration_dir" to a directory with all migrations. By
132
+ # default Zen will assume that it's 2 levels above your root directory.
126
133
  #
127
134
  # @author Yorick Peterse
128
135
  # @since 0.1
129
- # @yield [package] Object containing all setters and getters for each package.
136
+ # @yield [package] Object containing all setters and getters for each
137
+ # package.
130
138
  #
131
139
  def self.add
132
140
  package = Zen::Package::Base.new
@@ -185,12 +193,13 @@ module Zen
185
193
  # of which each list item can contain N sub items.
186
194
  #
187
195
  # @author Yorick Peterse
188
- # @param [String] css_class A string of CSS classes to apply to the main UL element.
196
+ # @param [String] html_class A string of CSS classes to apply to the main UL
197
+ # element.
189
198
  # @param [Hash] permissions Hash containing the permissions as returned by
190
199
  # Ramaze::Helper::ACL.extension_permissions
191
200
  # @since 0.1
192
201
  #
193
- def self.build_menu(css_class = '', permissions = {})
202
+ def self.build_menu(html_class = '', permissions = {})
194
203
  @g = Ramaze::Gestalt.new
195
204
  @permissions = permissions
196
205
  menu_items = []
@@ -209,7 +218,7 @@ module Zen
209
218
  item[:title]
210
219
  end
211
220
 
212
- @g.ul :class => css_class do
221
+ @g.ul :class => html_class do
213
222
  if !menu_items.empty?
214
223
  menu_items.each do |m|
215
224
  self.nav_list(m)
@@ -1,8 +1,6 @@
1
- ##
2
- # Loads all core packages that ship with Zen. Note that it's important to load these
3
- # packages in the correct order as otherwise migrations that create foreign keys might
4
- # not work.
5
- #
1
+ # Loads all core packages that ship with Zen. Note that it's important to load
2
+ # these packages in the correct order as otherwise migrations that create
3
+ # foreign keys might not work.
6
4
  require __DIR__('users/lib/users')
7
5
  require __DIR__('settings/lib/settings')
8
6
  require __DIR__('sections/lib/sections')
@@ -3,7 +3,8 @@ module Zen
3
3
  #:nodoc:
4
4
  module Package
5
5
  ##
6
- # Base class used to store the data about packages such as the name, directory, etc.
6
+ # Base class used to store the data about packages such as the name,
7
+ # directory, etc.
7
8
  #
8
9
  # @author Yorick Peterse
9
10
  # @since 0.2.5
@@ -32,8 +33,8 @@ module Zen
32
33
  # Path to the directory containing all migrations
33
34
  attr_accessor :migration_dir
34
35
 
35
- # Array containing all controllers for the package. These classes will be used
36
- # by the ACL system.
36
+ # Array containing all controllers for the package. These classes will be
37
+ # used by the ACL system.
37
38
  attr_accessor :controllers
38
39
 
39
40
  ##
@@ -56,7 +57,6 @@ module Zen
56
57
  raise(::Zen::ValidationError, "The package #{name} already exists.")
57
58
  end
58
59
  end
59
-
60
- end
61
- end
62
- end
60
+ end # Base
61
+ end # Package
62
+ end # Zen
@@ -1,3 +1,6 @@
1
+ # Update the helper path before loading the controllers
2
+ Ramaze::HelpersHelper.options.paths.push(__DIR__('categories'))
3
+
1
4
  require __DIR__('categories/model/category_group')
2
5
  require __DIR__('categories/model/category')
3
6
  require __DIR__('categories/controller/category_groups')
@@ -14,8 +17,8 @@ Zen::Package.add do |p|
14
17
  p.name = 'categories'
15
18
  p.author = 'Yorick Peterse'
16
19
  p.url = 'http://yorickpeterse.com/'
17
- p.about = "Module for managing categories. Categories can be used to organize
18
- section entries."
20
+ p.about = "Module for managing categories. Categories can be used to
21
+ organize section entries."
19
22
 
20
23
  p.directory = __DIR__('categories')
21
24
  p.migration_dir = __DIR__('../migrations')
@@ -37,6 +40,8 @@ Zen::Plugin.add do |p|
37
40
  p.name = 'categories'
38
41
  p.author = 'Yorick Peterse'
39
42
  p.url = 'http://yorickpeterse.com/'
40
- p.about = 'Plugin that makes it easier to retrieve categories and category groups.'
43
+ p.about = 'Plugin that makes it easier to retrieve categories and category
44
+ groups.'
45
+
41
46
  p.plugin = Categories::Plugin::Categories
42
47
  end
@@ -3,10 +3,10 @@ module Categories
3
3
  #:nodoc:
4
4
  module Controller
5
5
  ##
6
- # Categories can be seen as "tags" for your section entries. They describe the
7
- # type of entry just like tags except that categories generally cover larger elements.
8
- # When adding a new entry categories aren't required so you're free to ignore
9
- # them if you don't need them.
6
+ # Categories can be seen as "tags" for your section entries. They describe
7
+ # the type of entry just like tags except that categories generally cover
8
+ # larger elements. When adding a new entry categories aren't required so
9
+ # you're free to ignore them if you don't need them.
10
10
  #
11
11
  # @author Yorick Peterse
12
12
  # @since 0.1
@@ -14,7 +14,8 @@ module Categories
14
14
  class Categories < Zen::Controller::AdminController
15
15
  include ::Categories::Model
16
16
 
17
- map('/admin/categories')
17
+ map '/admin/categories'
18
+ helper :category
18
19
 
19
20
  before_all do
20
21
  csrf_protection(:save, :delete) do
@@ -23,8 +24,8 @@ module Categories
23
24
  end
24
25
 
25
26
  ##
26
- # The constructor is used to set various options such as the form URLs and load
27
- # the language pack for the categories module.
27
+ # The constructor is used to set various options such as the form URLs and
28
+ # load the language pack for the categories module.
28
29
  #
29
30
  # The following language files are loaded:
30
31
  #
@@ -37,9 +38,6 @@ module Categories
37
38
  def initialize
38
39
  super
39
40
 
40
- @form_save_url = Categories.r(:save)
41
- @form_delete_url = Categories.r(:delete)
42
-
43
41
  Zen::Language.load('categories')
44
42
  Zen::Language.load('category_groups')
45
43
 
@@ -59,22 +57,26 @@ module Categories
59
57
  # * read
60
58
  #
61
59
  # @author Yorick Peterse
62
- # @param [Integer] category_group_id The ID of the category group that's currently
63
- # being managed by the user.
60
+ # @param [Fixnum] category_group_id The ID of the category group that's
61
+ # currently being managed by the user.
64
62
  # @since 0.1
65
63
  #
66
- def index category_group_id
67
- if !user_authorized?([:read])
68
- respond(lang('zen_general.errors.not_authorized'), 403)
69
- end
64
+ def index(category_group_id)
65
+ require_permissions(:read)
70
66
 
71
67
  set_breadcrumbs(
72
- anchor_to(lang('category_groups.titles.index'), CategoryGroups.r(:index)),
68
+ CategoryGroups.a(lang('category_groups.titles.index'), :index),
73
69
  lang('categories.titles.index')
74
70
  )
75
71
 
76
- @category_group_id = category_group_id.to_i
77
- @categories = CategoryGroup[@category_group_id].categories
72
+ # Validate the category group
73
+ category_group = validate_category_group(category_group_id)
74
+ @category_group_id = category_group_id
75
+ @categories = Category.filter(
76
+ :category_group_id => category_group_id
77
+ )
78
+
79
+ @categories = paginate(@categories)
78
80
  end
79
81
 
80
82
  ##
@@ -90,24 +92,30 @@ module Categories
90
92
  # @param [Integer] id The ID of the category to edit.
91
93
  # @since 0.1
92
94
  #
93
- def edit category_group_id, id
94
- if !user_authorized?([:read, :update])
95
- respond(lang('zen_general.errors.not_authorized'), 403)
96
- end
95
+ def edit(category_group_id, id)
96
+ require_permissions(:read, :update)
97
97
 
98
98
  set_breadcrumbs(
99
- anchor_to(lang('category_groups.titles.index'), CategoryGroups.r(:index)),
100
- anchor_to(lang('categories.titles.index'), Categories.r(:index, category_group_id)),
99
+ CategoryGroups.a(
100
+ lang('category_groups.titles.index'), :index
101
+ ),
102
+ Categories.a(
103
+ lang('categories.titles.index'), :index, category_group_id
104
+ ),
101
105
  lang('categories.titles.edit')
102
106
  )
103
107
 
104
- @category_group_id = category_group_id.to_i
108
+ validate_category_group(category_group_id)
109
+
110
+ @category_group_id = category_group_id
105
111
 
106
112
  if flash[:form_data]
107
113
  @category = flash[:form_data]
108
114
  else
109
- @category = Category[id.to_i]
115
+ @category = validate_category(id, category_group_id)
110
116
  end
117
+
118
+ render_view(:form)
111
119
  end
112
120
 
113
121
  ##
@@ -122,19 +130,25 @@ module Categories
122
130
  # @param [Integer] category_group_id The ID of the category group.
123
131
  # @since 0.1
124
132
  #
125
- def new category_group_id
126
- if !user_authorized?([:read, :create])
127
- respond(lang('zen_general.errors.not_authorized'), 403)
128
- end
133
+ def new(category_group_id)
134
+ require_permissions(:read, :create)
129
135
 
130
136
  set_breadcrumbs(
131
- anchor_to(lang('category_groups.titles.index'), CategoryGroups.r(:index)),
132
- anchor_to(lang('categories.titles.index'), Categories.r(:index, category_group_id)),
137
+ CategoryGroups.a(
138
+ lang('category_groups.titles.index'), :index
139
+ ),
140
+ Categories.a(
141
+ lang('categories.titles.index'), :index, category_group_id
142
+ ),
133
143
  lang('categories.titles.new')
134
144
  )
135
145
 
136
- @category_group_id = category_group_id.to_i
146
+ validate_category_group(category_group_id)
147
+
148
+ @category_group_id = category_group_id
137
149
  @category = Category.new
150
+
151
+ render_view(:form)
138
152
  end
139
153
 
140
154
  ##
@@ -150,25 +164,33 @@ module Categories
150
164
  # @since 0.1
151
165
  #
152
166
  def save
153
- if !user_authorized?([:create, :update])
154
- respond(lang('zen_general.errors.not_authorized'), 403)
155
- end
156
-
167
+ # Fetch all the required fields
157
168
  post = request.subset(
158
- :id, :parent_id, :name, :description, :slug, :category_group_id
169
+ :id,
170
+ :parent_id,
171
+ :name,
172
+ :description,
173
+ :slug,
174
+ :category_group_id
159
175
  )
160
176
 
177
+ # Validate the category group
178
+ validate_category_group(post['category_group_id'])
179
+
161
180
  # Retrieve the category and set the notifications based on if the ID has
162
181
  # been specified or not.
163
182
  if post['id'] and !post['id'].empty?
164
- @category = Category[post['id']]
183
+ require_permissions(:update)
184
+
185
+ category = validate_category(post['id'], post['category_group_id'])
165
186
  save_action = :save
166
187
  else
167
- @category = Category.new
188
+ require_permissions(:create)
189
+
190
+ category = Category.new
168
191
  save_action = :new
169
192
  end
170
193
 
171
- # Remove various keys
172
194
  post.delete('slug') if post['slug'].empty?
173
195
  post.delete('id')
174
196
 
@@ -178,17 +200,19 @@ module Categories
178
200
 
179
201
  # Try to update the category
180
202
  begin
181
- @category.update(post)
203
+ category.update(post)
182
204
  message(:success, flash_success)
183
205
  rescue
184
206
  message(:error, flash_error)
185
207
 
186
- flash[:form_errors] = @category.errors
187
- flash[:form_data] = @category
208
+ flash[:form_errors] = category.errors
209
+ flash[:form_data] = category
210
+
211
+ redirect_referrer
188
212
  end
189
213
 
190
- if @category.id
191
- redirect(Categories.r(:edit, post['category_group_id'], @category.id))
214
+ if category.id
215
+ redirect(Categories.r(:edit, post['category_group_id'], category.id))
192
216
  else
193
217
  redirect(Categories.r(:new, post['category_group_id']))
194
218
  end
@@ -196,9 +220,9 @@ module Categories
196
220
 
197
221
  ##
198
222
  # Delete all specified category groups and their categories. In
199
- # order to delete a number of groups an array of fields, named "category_group_ids"
200
- # is required. This array will contain all the primary values of each group that
201
- # has to be deleted.
223
+ # order to delete a number of groups an array of fields, named
224
+ # "category_group_ids" is required. This array will contain all the
225
+ # primary values of each group that has to be deleted.
202
226
  #
203
227
  # This method requires the following permissions:
204
228
  #
@@ -208,14 +232,13 @@ module Categories
208
232
  # @since 0.1
209
233
  #
210
234
  def delete
211
- if !user_authorized?([:delete])
212
- respond(lang('zen_general.errors.not_authorized'), 403)
213
- end
235
+ require_permissions(:delete)
214
236
 
215
237
  post = request.subset(:category_ids, :category_group_id)
216
238
 
217
239
  # Obviously we'll require some IDs
218
- if !request.params['category_ids'] or request.params['category_ids'].empty?
240
+ if !request.params['category_ids'] \
241
+ or request.params['category_ids'].empty?
219
242
  message(:error, lang('categories.errors.no_delete'))
220
243
  redirect(Categories.r(:index, post['category_group_id']))
221
244
  end
@@ -225,8 +248,11 @@ module Categories
225
248
  begin
226
249
  Category[id].destroy
227
250
  message(:success, lang('categories.success.delete'))
228
- rescue
251
+ rescue => e
252
+ Ramaze::Log.error(e.inspect)
229
253
  message(:error, lang('categories.errors.delete') % id)
254
+
255
+ redirect_referrer
230
256
  end
231
257
  end
232
258