zen 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (373) hide show
  1. data/.gems +3 -2
  2. data/.rvmrc +1 -1
  3. data/.travis.yml +5 -0
  4. data/.yardopts +2 -1
  5. data/LICENSE +1 -1
  6. data/README.md +28 -24
  7. data/Rakefile +5 -2
  8. data/guide/asset_management.md +6 -6
  9. data/guide/autosaving_forms.md +42 -0
  10. data/guide/changelog.md +41 -0
  11. data/guide/faq.md +49 -0
  12. data/guide/getting_started.md +24 -13
  13. data/guide/hacking.md +40 -9
  14. data/guide/images/categories/categories.png +0 -0
  15. data/guide/images/categories/category_groups.png +0 -0
  16. data/guide/images/categories/new_category.png +0 -0
  17. data/guide/images/categories/new_category_group.png +0 -0
  18. data/guide/images/comments/comments.png +0 -0
  19. data/guide/images/comments/edit_comment.png +0 -0
  20. data/guide/images/custom_fields/custom_field_groups.png +0 -0
  21. data/guide/images/custom_fields/custom_field_types.png +0 -0
  22. data/guide/images/custom_fields/custom_fields.png +0 -0
  23. data/guide/images/custom_fields/edit_custom_field_general.png +0 -0
  24. data/guide/images/custom_fields/edit_custom_field_group.png +0 -0
  25. data/guide/images/custom_fields/edit_custom_field_settings.png +0 -0
  26. data/guide/images/custom_fields/edit_custom_field_type.png +0 -0
  27. data/guide/images/dashboard/added.png +0 -0
  28. data/guide/images/dashboard/columns.png +0 -0
  29. data/guide/images/dashboard/dashboard.png +0 -0
  30. data/guide/images/dashboard/options.png +0 -0
  31. data/guide/images/menus/edit_menu.png +0 -0
  32. data/guide/images/menus/edit_menu_item.png +0 -0
  33. data/guide/images/menus/menu_item_hierarchy.png +0 -0
  34. data/guide/images/menus/menu_items.png +0 -0
  35. data/guide/images/menus/menus.png +0 -0
  36. data/guide/images/sections/edit_entry.png +0 -0
  37. data/guide/images/sections/edit_entry_categories.png +0 -0
  38. data/guide/images/sections/edit_entry_general.png +0 -0
  39. data/guide/images/sections/edit_entry_meta.png +0 -0
  40. data/guide/images/sections/edit_section_comments.png +0 -0
  41. data/guide/images/sections/edit_section_general.png +0 -0
  42. data/guide/images/sections/edit_section_groups.png +0 -0
  43. data/guide/images/sections/entries.png +0 -0
  44. data/guide/images/sections/sections.png +0 -0
  45. data/guide/images/settings/overview_general.png +0 -0
  46. data/guide/images/settings/overview_security.png +0 -0
  47. data/guide/images/settings/overview_user.png +0 -0
  48. data/guide/images/users/edit_user.png +0 -0
  49. data/guide/images/users/edit_user_group.png +0 -0
  50. data/guide/images/users/edit_user_group_permissions.png +0 -0
  51. data/guide/images/users/edit_user_permissions.png +0 -0
  52. data/guide/images/users/overview.png +0 -0
  53. data/guide/images/users/user_groups_overview.png +0 -0
  54. data/guide/installation.md +7 -1
  55. data/guide/javascript.md +36 -273
  56. data/guide/javascript/zen_autosave.md +26 -0
  57. data/guide/javascript/zen_editor.md +83 -0
  58. data/guide/javascript/zen_hash.md +34 -0
  59. data/guide/javascript/zen_htmltable.md +78 -0
  60. data/guide/javascript/zen_tabs.md +44 -0
  61. data/guide/javascript/zen_window.md +49 -0
  62. data/guide/zen_compared.md +201 -0
  63. data/lib/vendor/sequel_sluggable.rb +1 -1
  64. data/lib/zen.rb +64 -44
  65. data/lib/zen/asset_groups.rb +10 -10
  66. data/lib/zen/bin/create.rb +8 -1
  67. data/lib/zen/helper/breadcrumb.rb +4 -12
  68. data/lib/zen/helper/controller.rb +209 -6
  69. data/lib/zen/helper/locale.rb +19 -0
  70. data/lib/zen/helper/search.rb +1 -1
  71. data/lib/zen/helper/stacked_aspect.rb +7 -43
  72. data/lib/zen/helper/theme.rb +3 -3
  73. data/lib/zen/language.rb +5 -10
  74. data/lib/zen/language/translation.rb +1 -1
  75. data/lib/zen/layout/admin.xhtml +41 -25
  76. data/lib/zen/layout/login.xhtml +8 -3
  77. data/lib/zen/migrator.rb +54 -0
  78. data/lib/zen/model/helper.rb +20 -1
  79. data/lib/zen/model/init.rb +2 -0
  80. data/lib/zen/model/plugin/events.rb +158 -0
  81. data/lib/zen/package.rb +32 -6
  82. data/lib/zen/package/all.rb +1 -0
  83. data/lib/zen/package/categories/lib/categories.rb +6 -6
  84. data/lib/zen/package/categories/lib/categories/controller/categories.rb +20 -83
  85. data/lib/zen/package/categories/lib/categories/controller/category_groups.rb +23 -74
  86. data/lib/zen/package/categories/lib/categories/model/category.rb +58 -1
  87. data/lib/zen/package/categories/lib/categories/model/category_group.rb +62 -2
  88. data/lib/zen/package/categories/lib/categories/view/admin/categories/form.xhtml +46 -40
  89. data/lib/zen/package/categories/lib/categories/view/admin/categories/index.xhtml +74 -75
  90. data/lib/zen/package/categories/lib/categories/view/admin/category-groups/form.xhtml +27 -24
  91. data/lib/zen/package/categories/lib/categories/view/admin/category-groups/index.xhtml +83 -86
  92. data/lib/zen/package/comments/lib/comments.rb +5 -5
  93. data/lib/zen/package/comments/lib/comments/controller/comments.rb +12 -64
  94. data/lib/zen/package/comments/lib/comments/controller/comments_form.rb +4 -22
  95. data/lib/zen/package/comments/lib/comments/model/comment.rb +65 -16
  96. data/lib/zen/package/comments/lib/comments/view/admin/comments/form.xhtml +52 -49
  97. data/lib/zen/package/comments/lib/comments/view/admin/comments/index.xhtml +52 -60
  98. data/lib/zen/package/comments/migrations/1308774099_comment_status.rb +1 -1
  99. data/lib/zen/package/custom_fields/lib/custom_fields.rb +11 -13
  100. data/lib/zen/package/custom_fields/lib/custom_fields/blue_form_parameters.rb +29 -13
  101. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +21 -50
  102. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_types.rb +27 -71
  103. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_fields.rb +25 -78
  104. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field.rb +48 -1
  105. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_group.rb +35 -1
  106. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_method.rb +3 -0
  107. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_type.rb +40 -1
  108. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb +1 -0
  109. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/form.xhtml +29 -26
  110. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/index.xhtml +96 -100
  111. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-types/form.xhtml +56 -53
  112. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-types/index.xhtml +82 -82
  113. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/form.xhtml +88 -85
  114. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/index.xhtml +83 -80
  115. data/lib/zen/package/dashboard/lib/dashboard.rb +28 -0
  116. data/lib/zen/package/dashboard/lib/dashboard/controller/dashboard.rb +154 -0
  117. data/lib/zen/package/dashboard/lib/dashboard/language/en/dashboard.rb +35 -0
  118. data/lib/zen/package/dashboard/lib/dashboard/language/nl/dashboard.rb +36 -0
  119. data/lib/zen/package/dashboard/lib/dashboard/model/widget.rb +45 -0
  120. data/lib/zen/package/dashboard/lib/dashboard/public/admin/dashboard/css/dashboard.css +74 -0
  121. data/lib/zen/package/dashboard/lib/dashboard/public/admin/dashboard/js/dashboard.js +102 -0
  122. data/lib/zen/package/dashboard/lib/dashboard/view/admin/index.xhtml +29 -0
  123. data/lib/zen/package/dashboard/lib/dashboard/view/admin/widget/welcome.xhtml +28 -0
  124. data/lib/zen/package/dashboard/lib/dashboard/widget.rb +292 -0
  125. data/lib/zen/package/dashboard/lib/dashboard/widget/welcome.rb +9 -0
  126. data/lib/zen/package/dashboard/migrations/1326411254_create_schema.rb +28 -0
  127. data/lib/zen/package/extensions/lib/extensions.rb +5 -5
  128. data/lib/zen/package/extensions/lib/extensions/view/admin/extensions/index.xhtml +72 -67
  129. data/lib/zen/package/menu.rb +6 -1
  130. data/lib/zen/package/menus/lib/menus.rb +6 -4
  131. data/lib/zen/package/menus/lib/menus/controller/menu_items.rb +69 -104
  132. data/lib/zen/package/menus/lib/menus/controller/menus.rb +19 -76
  133. data/lib/zen/package/menus/lib/menus/helper/menu.rb +54 -38
  134. data/lib/zen/package/menus/lib/menus/helper/menu_frontend.rb +7 -13
  135. data/lib/zen/package/menus/lib/menus/model/menu.rb +158 -2
  136. data/lib/zen/package/menus/lib/menus/model/menu_item.rb +73 -10
  137. data/lib/zen/package/menus/lib/menus/public/admin/menus/css/menus.css +47 -0
  138. data/lib/zen/package/menus/lib/menus/public/admin/menus/js/lib/nested_sortables.js +549 -0
  139. data/lib/zen/package/menus/lib/menus/public/admin/menus/js/menu_items.js +38 -0
  140. data/lib/zen/package/menus/lib/menus/view/admin/menu-items/form.xhtml +51 -61
  141. data/lib/zen/package/menus/lib/menus/view/admin/menu-items/index.xhtml +18 -81
  142. data/lib/zen/package/menus/lib/menus/view/admin/menus/form.xhtml +49 -44
  143. data/lib/zen/package/menus/lib/menus/view/admin/menus/index.xhtml +81 -83
  144. data/lib/zen/package/sections/lib/sections.rb +9 -4
  145. data/lib/zen/package/sections/lib/sections/controller/section_entries.rb +80 -132
  146. data/lib/zen/package/sections/lib/sections/controller/sections.rb +27 -73
  147. data/lib/zen/package/sections/lib/sections/helper/section.rb +44 -1
  148. data/lib/zen/package/sections/lib/sections/language/en/section_entries.rb +2 -0
  149. data/lib/zen/package/sections/lib/sections/language/nl/section_entries.rb +2 -0
  150. data/lib/zen/package/sections/lib/sections/model/section.rb +48 -1
  151. data/lib/zen/package/sections/lib/sections/model/section_entry.rb +55 -5
  152. data/lib/zen/package/sections/lib/sections/model/section_entry_status.rb +2 -0
  153. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/form.xhtml +76 -67
  154. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/index.xhtml +74 -79
  155. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/recent_entries.xhtml +45 -0
  156. data/lib/zen/package/sections/lib/sections/view/admin/sections/form.xhtml +119 -0
  157. data/lib/zen/package/sections/lib/sections/view/admin/sections/index.xhtml +96 -0
  158. data/lib/zen/package/sections/lib/sections/widget/recent_entries.rb +14 -0
  159. data/lib/zen/package/sections/migrations/1308813320_section_entry_statuses.rb +1 -1
  160. data/lib/zen/package/settings/lib/settings.rb +14 -5
  161. data/lib/zen/package/settings/lib/settings/controller/settings.rb +4 -4
  162. data/lib/zen/package/settings/lib/settings/language/nl/settings.rb +1 -1
  163. data/lib/zen/package/settings/lib/settings/setting.rb +1 -1
  164. data/lib/zen/package/settings/lib/settings/view/admin/settings/index.xhtml +21 -17
  165. data/lib/zen/package/users/lib/users.rb +18 -19
  166. data/lib/zen/package/users/lib/users/controller/user_groups.rb +23 -50
  167. data/lib/zen/package/users/lib/users/controller/users.rb +57 -89
  168. data/lib/zen/package/users/lib/users/helper/acl.rb +1 -0
  169. data/lib/zen/package/users/lib/users/language/en/user_groups.rb +1 -0
  170. data/lib/zen/package/users/lib/users/language/en/users.rb +2 -1
  171. data/lib/zen/package/users/lib/users/language/nl/user_groups.rb +1 -0
  172. data/lib/zen/package/users/lib/users/language/nl/users.rb +2 -1
  173. data/lib/zen/package/users/lib/users/model/permission.rb +13 -0
  174. data/lib/zen/package/users/lib/users/model/user.rb +57 -4
  175. data/lib/zen/package/users/lib/users/model/user_group.rb +37 -3
  176. data/lib/zen/package/users/lib/users/model/user_status.rb +4 -0
  177. data/lib/zen/package/users/lib/users/public/admin/{css/users/permissions.css → users/css/users.css} +0 -0
  178. data/lib/zen/package/users/lib/users/public/admin/{js/users/permissions.js → users/js/users.js} +4 -2
  179. data/lib/zen/package/users/lib/users/view/admin/user-groups/form.xhtml +51 -47
  180. data/lib/zen/package/users/lib/users/view/admin/user-groups/index.xhtml +62 -69
  181. data/lib/zen/package/users/lib/users/view/admin/users/form.xhtml +92 -82
  182. data/lib/zen/package/users/lib/users/view/admin/users/index.xhtml +68 -66
  183. data/lib/zen/package/users/lib/users/view/admin/users/login.xhtml +36 -28
  184. data/lib/zen/package/users/lib/users/view/admin/users/permissions.xhtml +5 -7
  185. data/lib/zen/package/users/lib/users/view/admin/users/register.xhtml +47 -41
  186. data/lib/zen/package/users/migrations/1320272365_status_ids.rb +1 -1
  187. data/lib/zen/public/admin/{js/vendor/mootools → mootools/js}/core.js +113 -108
  188. data/lib/zen/public/admin/{js/vendor/mootools → mootools/js}/more.js +99 -6
  189. data/lib/zen/public/admin/zen/css/buttons.css +106 -0
  190. data/lib/zen/public/admin/{css/zen → zen/css}/datepicker.css +45 -30
  191. data/lib/zen/public/admin/zen/css/editor.css +69 -0
  192. data/lib/zen/public/admin/{css/zen → zen/css}/forms.css +28 -30
  193. data/lib/zen/public/admin/zen/css/general.css +183 -0
  194. data/lib/zen/public/admin/zen/css/layout.css +224 -0
  195. data/lib/zen/public/admin/zen/css/messages.css +34 -0
  196. data/lib/zen/public/admin/{css/zen → zen/css}/reset.css +4 -9
  197. data/lib/zen/public/admin/zen/css/tables.css +57 -0
  198. data/lib/zen/public/admin/zen/css/tabs.css +84 -0
  199. data/lib/zen/public/admin/zen/css/window.css +74 -0
  200. data/lib/zen/public/admin/{images/zen → zen/images}/icons/asc.png +0 -0
  201. data/lib/zen/public/admin/{images/zen → zen/images}/icons/bold.png +0 -0
  202. data/lib/zen/public/admin/zen/images/icons/box.png +0 -0
  203. data/lib/zen/public/admin/zen/images/icons/categories.png +0 -0
  204. data/lib/zen/public/admin/{images/zen → zen/images}/icons/close.png +0 -0
  205. data/lib/zen/public/admin/zen/images/icons/comment.png +0 -0
  206. data/lib/zen/public/admin/{images/zen → zen/images}/icons/desc.png +0 -0
  207. data/lib/zen/public/admin/{images/zen → zen/images}/icons/edit.png +0 -0
  208. data/lib/zen/public/admin/{images/zen → zen/images}/icons/error.png +0 -0
  209. data/lib/zen/public/admin/zen/images/icons/external.png +0 -0
  210. data/lib/zen/public/admin/zen/images/icons/globe.png +0 -0
  211. data/lib/zen/public/admin/{images/zen → zen/images}/icons/italic.png +0 -0
  212. data/lib/zen/public/admin/{images/zen → zen/images}/icons/link.png +0 -0
  213. data/lib/zen/public/admin/zen/images/icons/lock.png +0 -0
  214. data/lib/zen/public/admin/{images/zen → zen/images}/icons/ol.png +0 -0
  215. data/lib/zen/public/admin/zen/images/icons/pages.png +0 -0
  216. data/lib/zen/public/admin/{images/zen → zen/images}/icons/preview.png +0 -0
  217. data/lib/zen/public/admin/zen/images/icons/relation.png +0 -0
  218. data/lib/zen/public/admin/zen/images/icons/settings.png +0 -0
  219. data/lib/zen/public/admin/zen/images/icons/template.png +0 -0
  220. data/lib/zen/public/admin/{images/zen → zen/images}/icons/ul.png +0 -0
  221. data/lib/zen/public/admin/{images/zen → zen/images}/icons/user.png +0 -0
  222. data/lib/zen/public/admin/zen/images/icons/user_group.png +0 -0
  223. data/lib/zen/public/admin/{js/zen → zen/js}/index.js +21 -9
  224. data/lib/zen/public/admin/zen/js/lib/autosave.js +185 -0
  225. data/lib/zen/public/admin/zen/js/lib/base.js +60 -0
  226. data/lib/zen/public/admin/{js/vendor → zen/js/lib}/datepicker.js +52 -28
  227. data/lib/zen/public/admin/{js/zen → zen/js}/lib/editor.js +23 -34
  228. data/lib/zen/public/admin/{js/zen → zen/js}/lib/editor/markdown.js +5 -1
  229. data/lib/zen/public/admin/{js/zen → zen/js}/lib/editor/textile.js +4 -0
  230. data/lib/zen/public/admin/zen/js/lib/hash.js +218 -0
  231. data/lib/zen/public/admin/{js/zen → zen/js}/lib/html_table.js +5 -0
  232. data/lib/zen/public/admin/zen/js/lib/tabs.js +194 -0
  233. data/lib/zen/public/admin/{js/zen → zen/js}/lib/window.js +54 -29
  234. data/lib/zen/security.rb +50 -0
  235. data/lib/zen/spec/helper.rb +5 -120
  236. data/lib/zen/spec/helper/capybara.rb +75 -0
  237. data/lib/zen/spec/helper/general.rb +75 -0
  238. data/lib/zen/spec/simplecov.rb +1 -0
  239. data/lib/zen/task/build.rake +2 -21
  240. data/lib/zen/task/clean.rake +1 -10
  241. data/lib/zen/task/db.rake +4 -10
  242. data/lib/zen/task/package.rake +2 -5
  243. data/lib/zen/task/setup.rake +1 -1
  244. data/lib/zen/task/test.rake +6 -6
  245. data/lib/zen/task/theme.rake +2 -5
  246. data/lib/zen/theme.rb +26 -22
  247. data/lib/zen/version.rb +1 -1
  248. data/lib/zen/view/bottom.xhtml +2 -3
  249. data/lib/zen/view/search.xhtml +3 -5
  250. data/proto/app/config/config.rb.erb +1 -1
  251. data/proto/app/theme/default/index.xhtml +116 -20
  252. data/proto/app/theme/partials/head.xhtml +9 -0
  253. data/proto/app/theme/partials/sidebar.xhtml +40 -0
  254. data/proto/app/theme/theme.rb +3 -0
  255. data/spec/Rakefile +1 -2
  256. data/spec/fixtures/zen/helper/stacked_aspect.rb +54 -0
  257. data/spec/fixtures/zen/package/dashboard/controller/widget.rb +15 -0
  258. data/spec/fixtures/zen/package/dashboard/widget.rb +5 -0
  259. data/spec/fixtures/zen/theme/theme.rb +2 -2
  260. data/spec/helper.rb +19 -10
  261. data/spec/zen/controller/admin_controller.rb +3 -3
  262. data/spec/zen/controller/main_controller.rb +7 -7
  263. data/spec/zen/controller/preview.rb +3 -3
  264. data/spec/zen/event.rb +4 -4
  265. data/spec/zen/helper/breadcrumb.rb +4 -8
  266. data/spec/zen/helper/controller.rb +47 -4
  267. data/spec/zen/helper/locale.rb +3 -3
  268. data/spec/zen/helper/message.rb +4 -4
  269. data/spec/zen/helper/stacked_aspect.rb +40 -0
  270. data/spec/zen/helper/theme.rb +9 -9
  271. data/spec/zen/language.rb +8 -8
  272. data/spec/zen/markup.rb +6 -6
  273. data/spec/zen/package.rb +11 -9
  274. data/spec/zen/package/categories/controller/categories.rb +56 -24
  275. data/spec/zen/package/categories/controller/category_groups.rb +55 -23
  276. data/spec/zen/package/categories/helper/category.rb +5 -5
  277. data/spec/zen/package/categories/helper/category_frontend.rb +5 -5
  278. data/spec/zen/package/comments/anti_spam.rb +4 -4
  279. data/spec/zen/package/comments/controller/comments.rb +95 -24
  280. data/spec/zen/package/comments/controller/comments_form.rb +31 -26
  281. data/spec/zen/package/comments/helper/comment.rb +3 -3
  282. data/spec/zen/package/comments/helper/comment_frontend.rb +6 -6
  283. data/spec/zen/package/custom_fields/blue_form_parameters.rb +8 -8
  284. data/spec/zen/package/custom_fields/controller/custom_field_groups.rb +58 -27
  285. data/spec/zen/package/custom_fields/controller/custom_field_types.rb +57 -27
  286. data/spec/zen/package/custom_fields/controller/custom_fields.rb +58 -27
  287. data/spec/zen/package/custom_fields/helper/custom_field.rb +7 -7
  288. data/spec/zen/package/dashboard/controller/dashboard.rb +147 -0
  289. data/spec/zen/package/dashboard/widget.rb +56 -0
  290. data/spec/zen/package/extensions/controller/extensions.rb +4 -4
  291. data/spec/zen/package/menus/controller/menu_items.rb +48 -39
  292. data/spec/zen/package/menus/controller/menus.rb +55 -24
  293. data/spec/zen/package/menus/helper/menu.rb +6 -14
  294. data/spec/zen/package/menus/helper/menu_frontend.rb +7 -7
  295. data/spec/zen/package/menus/model/menu.rb +121 -0
  296. data/spec/zen/package/menus/model/menu_item.rb +34 -0
  297. data/spec/zen/package/sections/controller/section_entries.rb +104 -39
  298. data/spec/zen/package/sections/controller/sections.rb +60 -27
  299. data/spec/zen/package/sections/helper/section.rb +5 -5
  300. data/spec/zen/package/sections/helper/section_frontend.rb +9 -9
  301. data/spec/zen/package/sections/widget.rb +44 -0
  302. data/spec/zen/package/settings/controller/settings.rb +18 -16
  303. data/spec/zen/package/settings/settings.rb +12 -12
  304. data/spec/zen/package/users/controller/user_groups.rb +61 -29
  305. data/spec/zen/package/users/controller/users.rb +118 -39
  306. data/spec/zen/package/users/helper/access.rb +3 -3
  307. data/spec/zen/package/users/helper/acl.rb +4 -4
  308. data/spec/zen/package/users/helper/users.rb +5 -5
  309. data/spec/zen/security.rb +25 -0
  310. data/spec/zen/theme.rb +20 -18
  311. data/spec/zen/validation.rb +5 -5
  312. data/spec/zen/vendor/sequel_sluggable.rb +12 -0
  313. data/zen.gemspec +27 -4
  314. metadata +182 -124
  315. data/AUTHORS +0 -4
  316. data/guide/_static/categories/categories.png +0 -0
  317. data/guide/_static/categories/category_groups.png +0 -0
  318. data/guide/_static/categories/new_category.png +0 -0
  319. data/guide/_static/categories/new_category_group.png +0 -0
  320. data/guide/_static/comments/comments.png +0 -0
  321. data/guide/_static/comments/edit_comment.png +0 -0
  322. data/guide/_static/custom_fields/custom_field_groups.png +0 -0
  323. data/guide/_static/custom_fields/custom_field_types.png +0 -0
  324. data/guide/_static/custom_fields/custom_fields.png +0 -0
  325. data/guide/_static/custom_fields/edit_custom_field_general.png +0 -0
  326. data/guide/_static/custom_fields/edit_custom_field_group.png +0 -0
  327. data/guide/_static/custom_fields/edit_custom_field_settings.png +0 -0
  328. data/guide/_static/custom_fields/edit_custom_field_type.png +0 -0
  329. data/guide/_static/menus/edit_menu.png +0 -0
  330. data/guide/_static/menus/edit_menu_item.png +0 -0
  331. data/guide/_static/menus/menu_items.png +0 -0
  332. data/guide/_static/menus/menus.png +0 -0
  333. data/guide/_static/sections/edit_entry.png +0 -0
  334. data/guide/_static/sections/edit_entry_categories.png +0 -0
  335. data/guide/_static/sections/edit_entry_general.png +0 -0
  336. data/guide/_static/sections/edit_entry_meta.png +0 -0
  337. data/guide/_static/sections/edit_section_comments.png +0 -0
  338. data/guide/_static/sections/edit_section_general.png +0 -0
  339. data/guide/_static/sections/edit_section_groups.png +0 -0
  340. data/guide/_static/sections/entries.png +0 -0
  341. data/guide/_static/sections/sections.png +0 -0
  342. data/guide/_static/settings/overview_general.png +0 -0
  343. data/guide/_static/settings/overview_security.png +0 -0
  344. data/guide/_static/settings/overview_user.png +0 -0
  345. data/guide/_static/users/edit_user.png +0 -0
  346. data/guide/_static/users/edit_user_group.png +0 -0
  347. data/guide/_static/users/edit_user_group_permissions.png +0 -0
  348. data/guide/_static/users/edit_user_permissions.png +0 -0
  349. data/guide/_static/users/overview.png +0 -0
  350. data/guide/_static/users/user_groups_overview.png +0 -0
  351. data/lib/zen/controller/translations.rb +0 -49
  352. data/lib/zen/package/sections/lib/sections/view/admin/form.xhtml +0 -113
  353. data/lib/zen/package/sections/lib/sections/view/admin/index.xhtml +0 -97
  354. data/lib/zen/public/admin/css/zen/buttons.css +0 -46
  355. data/lib/zen/public/admin/css/zen/editor.css +0 -88
  356. data/lib/zen/public/admin/css/zen/general.css +0 -109
  357. data/lib/zen/public/admin/css/zen/grid.css +0 -100
  358. data/lib/zen/public/admin/css/zen/layout.css +0 -184
  359. data/lib/zen/public/admin/css/zen/messages.css +0 -54
  360. data/lib/zen/public/admin/css/zen/tables.css +0 -97
  361. data/lib/zen/public/admin/css/zen/tabs.css +0 -47
  362. data/lib/zen/public/admin/css/zen/window.css +0 -73
  363. data/lib/zen/public/admin/images/zen/icons/accept.png +0 -0
  364. data/lib/zen/public/admin/images/zen/icons/add.png +0 -0
  365. data/lib/zen/public/admin/images/zen/icons/back.png +0 -0
  366. data/lib/zen/public/admin/images/zen/icons/delete.png +0 -0
  367. data/lib/zen/public/admin/images/zen/icons/help.png +0 -0
  368. data/lib/zen/public/admin/images/zen/icons/info.png +0 -0
  369. data/lib/zen/public/admin/images/zen/icons/logout.png +0 -0
  370. data/lib/zen/public/admin/images/zen/icons/pdf.png +0 -0
  371. data/lib/zen/public/admin/images/zen/icons/view.png +0 -0
  372. data/lib/zen/public/admin/js/zen/lib/tabs.js +0 -207
  373. data/lib/zen/view/main.xhtml +0 -19
@@ -1,4 +1,5 @@
1
1
  require 'ramaze/gestalt'
2
+ require 'ostruct'
2
3
  require __DIR__('package/menu')
3
4
 
4
5
  module Zen
@@ -28,6 +29,7 @@ module Zen
28
29
  # * root: the root directory of the package, this path should point to the
29
30
  # directory containing your ``helper/`` and ``language/`` directories as
30
31
  # well as any ``public/`` directories.
32
+ # * An innstance of OpenStruct that can be used for storing custom data.
31
33
  #
32
34
  # Setting these (and other) attributes is very easy:
33
35
  #
@@ -135,6 +137,9 @@ module Zen
135
137
  # The directory to all migrations.
136
138
  attr_accessor :migrations
137
139
 
140
+ # Instance of OpenStruct that can be used for storing custom data.
141
+ attr_reader :env
142
+
138
143
  class << self
139
144
  ##
140
145
  # Adds a new package along with all it's details such as the name, author,
@@ -192,15 +197,20 @@ module Zen
192
197
  # @return [String]
193
198
  #
194
199
  def build_menu(html_class = 'navigation', permissions = [])
195
- g = Ramaze::Gestalt.new
200
+ g = Ramaze::Gestalt.new
201
+ attrs = {:class => html_class}
202
+
203
+ if html_class.nil? or html_class.empty?
204
+ attrs.delete(:class)
205
+ end
196
206
 
197
- g.ul(:class => html_class) do
207
+ g.ul(attrs) do
198
208
  # Sort the hash
199
209
  keys = REGISTERED.keys.sort
200
210
 
201
211
  keys.each do |key|
202
212
  unless REGISTERED[key].menu.nil?
203
- g.out << REGISTERED[key].menu.html(permissions)
213
+ REGISTERED[key].menu.each { |m| g.out << m.html(permissions) }
204
214
  end
205
215
  end
206
216
  end
@@ -209,6 +219,15 @@ module Zen
209
219
  end
210
220
  end # class << self
211
221
 
222
+ ##
223
+ # Creates a new instance of the package.
224
+ #
225
+ # @since 12-02-2012
226
+ #
227
+ def initialize
228
+ @env = OpenStruct.new
229
+ end
230
+
212
231
  ##
213
232
  # Sets the name of the package. The name of a package should be a short and
214
233
  # unique name. A human readable version can be set using title=().
@@ -254,7 +273,11 @@ module Zen
254
273
  #
255
274
  def formatted_title
256
275
  if url
257
- return '<a href="%s" title="%s">%s</a>' % [url, title, title]
276
+ return '<a href="%s" title="%s" class="icon external">%s</a>' % [
277
+ url,
278
+ title,
279
+ title
280
+ ]
258
281
  else
259
282
  return title
260
283
  end
@@ -326,10 +349,11 @@ module Zen
326
349
  #
327
350
  def menu(title = nil, url = nil, options = {}, &block)
328
351
  if title.nil? and url.nil? and !block_given?
329
- return @menu
352
+ return @menus || []
330
353
  end
331
354
 
332
- @menu = Zen::Package::Menu.new(title, url, options, &block)
355
+ @menus ||= []
356
+ @menus << Zen::Package::Menu.new(title, url, options, &block)
333
357
  end
334
358
 
335
359
  ##
@@ -361,6 +385,8 @@ module Zen
361
385
  def permissions
362
386
  perms = {}
363
387
 
388
+ return perms if @permissions.nil?
389
+
364
390
  @permissions.each do |perm, title|
365
391
  begin
366
392
  perms[perm] = lang(title)
@@ -3,6 +3,7 @@
3
3
  # foreign keys might not work.
4
4
  require __DIR__('settings/lib/settings')
5
5
  require __DIR__('users/lib/users')
6
+ require __DIR__('dashboard/lib/dashboard')
6
7
  require __DIR__('sections/lib/sections')
7
8
  require __DIR__('comments/lib/comments')
8
9
  require __DIR__('categories/lib/categories')
@@ -7,11 +7,9 @@ Zen::Package.add do |p|
7
7
  p.root = __DIR__('categories')
8
8
  p.migrations = __DIR__('../migrations')
9
9
 
10
- p.menu(
11
- 'categories.titles.index',
10
+ p.menu 'categories.titles.index',
12
11
  '/admin/category-groups',
13
12
  :permission => :show_category_group
14
- )
15
13
 
16
14
  p.permission :show_category_group , 'category_groups.permissions.show'
17
15
  p.permission :edit_category_group , 'category_groups.permissions.edit'
@@ -24,12 +22,14 @@ Zen::Package.add do |p|
24
22
  p.permission :delete_category, 'categories.permissions.delete'
25
23
  end
26
24
 
27
- Zen::Language.load('categories')
28
- Zen::Language.load('category_groups')
29
-
30
25
  require __DIR__('categories/model/category_group')
31
26
  require __DIR__('categories/model/category')
32
27
  require __DIR__('categories/controller/category_groups')
33
28
  require __DIR__('categories/controller/categories')
34
29
 
35
30
  Zen::Controller::FrontendController.helper(:category_frontend)
31
+
32
+ Zen::Event.listen :post_start do
33
+ Zen::Language.load('categories')
34
+ Zen::Language.load('category_groups')
35
+ end
@@ -15,7 +15,7 @@ module Categories
15
15
  # you've reached the categories overview you'll be presented with an
16
16
  # overview that looks like the following image:
17
17
  #
18
- # ![Categories Overview](../../_static/categories/categories.png)
18
+ # ![Categories Overview](../../images/categories/categories.png)
19
19
  #
20
20
  # ## Adding/Editing Categories
21
21
  #
@@ -23,7 +23,7 @@ module Categories
23
23
  # If you want to create a new category instead you should click the button
24
24
  # "Add category". In both cases you'll end up with the following form:
25
25
  #
26
- # ![New Category](../../_static/categories/new_category.png)
26
+ # ![New Category](../../images/categories/new_category.png)
27
27
  #
28
28
  # In this form you can specify the following fields:
29
29
  #
@@ -49,48 +49,18 @@ module Categories
49
49
  # * new_category
50
50
  # * delete_category
51
51
  #
52
- # ## Events
53
- #
54
- # All available events will receive an instance of
55
- # {Categories::Model::Category}. Do note that the event
56
- # ``after_delete_category`` will receive an instance of this model *after*
57
- # ``#destroy()`` has been invoked on the instance. This means that you can
58
- # not save any changes made to the object as the database no longer
59
- # exists.
60
- #
61
- # Say you want to notify a user whenever a category is removed you could do
62
- # the following:
63
- #
64
- # # "mail" can be installed by running gem install mail.
65
- # require 'mail'
66
- #
67
- # Zen::Event.listen(:delete_category) do |category|
68
- # user = Users::Model::User[:name => 'admin']
69
- # Mail.deliver do
70
- # from 'example@domain.com'
71
- # to user.email
72
- # subject "Category \"#{category.name}\" has been removed"
73
- # "has been removed from the database."
74
- # end
75
- # end
76
- #
77
52
  # @since 0.1
78
53
  # @map /admin/categories
79
- # @event before_new_category
80
- # @event after_new_category
81
- # @event before_edit_category
82
- # @event after_edit_category
83
- # @event before_delete_category
84
- # @event after_delete_category
85
54
  #
86
55
  class Categories < Zen::Controller::AdminController
87
56
  map '/admin/categories'
88
57
  helper :category
89
58
  title 'categories.titles.%s'
90
59
 
91
- # Protect Categories#save() and Categories#delete() against CSRF attacks.
92
60
  csrf_protection :save, :delete
93
61
 
62
+ autosave Model::Category, Model::Category::COLUMNS, :edit_category
63
+
94
64
  ##
95
65
  # Show an overview of all existing categories and allow the user
96
66
  # manage these categories.
@@ -153,11 +123,8 @@ module Categories
153
123
 
154
124
  @category_group_id = category_group_id
155
125
 
156
- if flash[:form_data]
157
- @category = flash[:form_data]
158
- else
159
- @category = ::Categories::Model::Category.new
160
- end
126
+ @category = Model::Category.new
127
+ @category.set(flash[:form_data]) if flash[:form_data]
161
128
 
162
129
  render_view(:form)
163
130
  end
@@ -189,12 +156,9 @@ module Categories
189
156
  validate_category_group(category_group_id)
190
157
 
191
158
  @category_group_id = category_group_id
159
+ @category = validate_category(id, category_group_id)
192
160
 
193
- if flash[:form_data]
194
- @category = flash[:form_data]
195
- else
196
- @category = validate_category(id, category_group_id)
197
- end
161
+ @category.set(flash[:form_data]) if flash[:form_data]
198
162
 
199
163
  render_view(:form)
200
164
  end
@@ -206,64 +170,43 @@ module Categories
206
170
  # @since 0.1
207
171
  # @permission edit_category (when editing a category)
208
172
  # @permission new_category (when creating a category)
209
- # @event before_edit_category
210
- # @event after_edit_category
211
- # @event before_new_category
212
- # @event after_new_category
213
173
  #
214
174
  def save
215
- post = request.subset(
216
- :id,
217
- :parent_id,
218
- :name,
219
- :description,
220
- :slug,
221
- :category_group_id
222
- )
175
+ id = request.params['id']
176
+ post = post_fields(*Model::Category::COLUMNS)
223
177
 
224
178
  validate_category_group(post['category_group_id'])
225
179
 
226
180
  # Retrieve the category and set the notifications based on if the ID has
227
181
  # been specified or not.
228
- if post['id'] and !post['id'].empty?
182
+ if id and !id.empty?
229
183
  authorize_user!(:edit_category)
230
184
 
231
- category = validate_category(post['id'], post['category_group_id'])
232
- save_action = :save
233
- before_event = :before_edit_category
234
- after_event = :after_edit_category
185
+ category = validate_category(id, post['category_group_id'])
186
+ save_action = :save
235
187
  else
236
188
  authorize_user!(:new_category)
237
189
 
238
- category = ::Categories::Model::Category.new
239
- save_action = :new
240
- before_event = :before_new_category
241
- after_event = :after_new_category
190
+ category = ::Categories::Model::Category.new
191
+ save_action = :new
242
192
  end
243
193
 
244
- post.delete('id')
245
-
246
194
  success = lang("categories.success.#{save_action}")
247
195
  error = lang("categories.errors.#{save_action}")
248
196
 
249
- # Try to update the category
250
197
  begin
251
- post.each { |k, v| category.send("#{k}=", v) }
252
- Zen::Event.call(before_event, category)
253
-
198
+ category.set(post)
254
199
  category.save
255
200
  rescue => e
256
- Ramaze::Log.error(e.inspect)
201
+ Ramaze::Log.error(e)
257
202
  message(:error, error)
258
203
 
259
204
  flash[:form_errors] = category.errors
260
- flash[:form_data] = category
205
+ flash[:form_data] = post
261
206
 
262
207
  redirect_referrer
263
208
  end
264
209
 
265
- Zen::Event.call(after_event, category)
266
-
267
210
  message(:success, success)
268
211
  redirect(Categories.r(:edit, category.category_group_id, category.id))
269
212
  end
@@ -276,13 +219,11 @@ module Categories
276
219
  #
277
220
  # @since 0.1
278
221
  # @permission delete_category
279
- # @event before_delete_category
280
- # @event after_delete_category
281
222
  #
282
223
  def delete
283
224
  authorize_user!(:delete_category)
284
225
 
285
- post = request.subset(:category_ids)
226
+ post = post_fields(:category_ids)
286
227
 
287
228
  # Obviously we'll require some IDs
288
229
  if post['category_ids'].nil? or post['category_ids'].empty?
@@ -296,18 +237,14 @@ module Categories
296
237
 
297
238
  next if category.nil?
298
239
 
299
- Zen::Event.call(:before_delete_category, category)
300
-
301
240
  begin
302
241
  category.destroy
303
242
  rescue => e
304
- Ramaze::Log.error(e.inspect)
243
+ Ramaze::Log.error(e)
305
244
  message(:error, lang('categories.errors.delete') % id)
306
245
 
307
246
  redirect_referrer
308
247
  end
309
-
310
- Zen::Event.call(:after_delete_category, category)
311
248
  end
312
249
 
313
250
  message(:success, lang('categories.success.delete'))
@@ -32,7 +32,7 @@ module Categories
32
32
  # ``/admin/category-groups``. This overview looks like the image displayed
33
33
  # below.
34
34
  #
35
- # ![Category Group Overview](../../_static/categories/category_groups.png)
35
+ # ![Category Group Overview](../../images/categories/category_groups.png)
36
36
  #
37
37
  # Editing an existing group can be done by clicking on the name of a group
38
38
  # while managing the categories of a group is done by clicking the link
@@ -49,7 +49,7 @@ module Categories
49
49
  # existing group or create a new one. The form used to manage such a group
50
50
  # looks like the one in the image below.
51
51
  #
52
- # ![New Category Group](../../_static/categories/new_category_group.png)
52
+ # ![New Category Group](../../images/categories/new_category_group.png)
53
53
  #
54
54
  # In this form you can set the following fields:
55
55
  #
@@ -66,50 +66,20 @@ module Categories
66
66
  # * new_category_group
67
67
  # * delete_category_group
68
68
  #
69
- # ## Events
70
- #
71
- # All available events receive an instance of
72
- # {Categories::Model::CategoyGroup}. However, the
73
- # ``after_delete_category_group`` event will receive an instance that has
74
- # already been removed from the database. This means that you can not make
75
- # changes to the object and call ``#save()``.
76
- #
77
- # Example of logging when a new category group is created:
78
- #
79
- # Zen::Event.listen(:after_new_category_group) do |group|
80
- # Ramaze::Log.info("New category: \"#{group.name}\"")
81
- # end
82
- #
83
- # Maybe you want to automatically add a category group to a section:
84
- #
85
- # Zen::Event.listen(:after_new_category_group) do |group|
86
- # section = Sections::Model::Section[5]
87
- #
88
- # begin
89
- # section.add_category_group(group)
90
- # rescue => e
91
- # Ramaze::Log.error(e.inspect)
92
- # end
93
- # end
94
- #
95
69
  # @since 0.1
96
70
  # @map /admin/category-groups
97
- # @event before_new_category_group
98
- # @event after_new_category_group
99
- # @event before_edit_category_group
100
- # @event after_edit_category_group
101
- # @event before_delete_category_group
102
- # @event after_delete_category_group
103
71
  #
104
72
  class CategoryGroups < Zen::Controller::AdminController
105
73
  helper :category
106
74
  map '/admin/category-groups'
107
75
  title 'category_groups.titles.%s'
108
76
 
109
- # Protects CategoryGroups#save() and CategoryGroups#delete() against CSRF
110
- # attacks.
111
77
  csrf_protection :save, :delete
112
78
 
79
+ autosave Model::CategoryGroup,
80
+ Model::CategoryGroup::COLUMNS,
81
+ :edit_category_group
82
+
113
83
  ##
114
84
  # Show an overview of all existing category groups and allow the user
115
85
  # to create new category groups or manage individual categories.
@@ -123,10 +93,10 @@ module Categories
123
93
  set_breadcrumbs(lang('category_groups.titles.index'))
124
94
 
125
95
  @category_groups = search do |query|
126
- ::Categories::Model::CategoryGroup.search(query).order(:id.asc)
96
+ Model::CategoryGroup.search(query).order(:id.asc)
127
97
  end
128
98
 
129
- @category_groups ||= ::Categories::Model::CategoryGroup.order(:id.asc)
99
+ @category_groups ||= Model::CategoryGroup.order(:id.asc)
130
100
  @category_groups = paginate(@category_groups)
131
101
  end
132
102
 
@@ -145,7 +115,8 @@ module Categories
145
115
  lang('category_groups.titles.edit')
146
116
  )
147
117
 
148
- @category_group = flash[:form_data] || validate_category_group(id)
118
+ @category_group = validate_category_group(id)
119
+ @category_group.set(flash[:form_data]) if flash[:form_data]
149
120
 
150
121
  render_view(:form)
151
122
  end
@@ -164,11 +135,8 @@ module Categories
164
135
  lang('category_groups.titles.new')
165
136
  )
166
137
 
167
- if flash[:form_data]
168
- @category_group = flash[:form_data]
169
- else
170
- @category_group = ::Categories::Model::CategoryGroup.new
171
- end
138
+ @category_group = Model::CategoryGroup.new
139
+ @category_group.set(flash[:form_data]) if flash[:form_data]
172
140
 
173
141
  render_view(:form)
174
142
  end
@@ -181,54 +149,41 @@ module Categories
181
149
  # @since 0.1
182
150
  # @permission edit_category_group (when editing a group)
183
151
  # @permission new_category_group (when creating a group)
184
- # @event before_new_category_group
185
- # @event after_new_category_group
186
- # @event before_edit_category_group
187
- # @event after_edit_category_group
188
152
  #
189
153
  def save
190
- post = request.subset(:id, :name, :description)
154
+ post = post_fields(*Model::CategoryGroup::COLUMNS)
155
+ id = request.params['id']
191
156
 
192
157
  # Get/create the group and set the event names.
193
- if post['id'] and !post['id'].empty?
158
+ if id and !id.empty?
194
159
  authorize_user!(:edit_category_group)
195
160
 
196
- category_group = validate_category_group(post['id'])
161
+ category_group = validate_category_group(id)
197
162
  save_action = :save
198
- before_event = :before_edit_category_group
199
- after_event = :after_edit_category_group
200
163
  else
201
164
  authorize_user!(:new_category_group)
202
165
 
203
- category_group = ::Categories::Model::CategoryGroup.new
166
+ category_group = Model::CategoryGroup.new
204
167
  save_action = :new
205
- before_event = :before_new_category_group
206
- after_event = :after_new_category_group
207
168
  end
208
169
 
209
170
  success = lang("category_groups.success.#{save_action}")
210
171
  error = lang("category_groups.errors.#{save_action}")
211
172
 
212
- post.delete('id')
213
-
214
173
  # Set the values, call the events and try to save the category group.
215
174
  begin
216
- post.each { |k, v| category_group.send("#{k}=", v) }
217
- Zen::Event.call(before_event, category_group)
218
-
175
+ category_group.set(post)
219
176
  category_group.save
220
177
  rescue => e
221
178
  message(:error, error)
222
- Ramaze::Log.error(e.inspect)
179
+ Ramaze::Log.error(e)
223
180
 
224
- flash[:form_data] = category_group
181
+ flash[:form_data] = post
225
182
  flash[:form_errors] = category_group.errors
226
183
 
227
184
  redirect_referrer
228
185
  end
229
186
 
230
- Zen::Event.call(after_event, category_group)
231
-
232
187
  message(:success, success)
233
188
  redirect(CategoryGroups.r(:edit, category_group.id))
234
189
  end
@@ -239,13 +194,11 @@ module Categories
239
194
  #
240
195
  # @since 0.1
241
196
  # @permission delete_category_group
242
- # @event before_delete_category_group
243
- # @event after_delete_category_group
244
197
  #
245
198
  def delete
246
199
  authorize_user!(:delete_category_group)
247
200
 
248
- post = request.subset(:category_group_ids)
201
+ post = post_fields(:category_group_ids)
249
202
 
250
203
  if post['category_group_ids'].nil? or post['category_group_ids'].empty?
251
204
  message(:error, lang('category_groups.errors.no_delete'))
@@ -253,22 +206,18 @@ module Categories
253
206
  end
254
207
 
255
208
  post['category_group_ids'].each do |id|
256
- group = ::Categories::Model::CategoryGroup[id]
209
+ group = Model::CategoryGroup[id]
257
210
 
258
211
  next if group.nil?
259
212
 
260
- Zen::Event.call(:before_delete_category_group, group)
261
-
262
213
  begin
263
214
  group.destroy
264
215
  rescue => e
265
- Ramaze::Log.error(e.inspect)
216
+ Ramaze::Log.error(e)
266
217
  message(:error, lang('category_groups.errors.delete') % id)
267
218
 
268
219
  redirect_referrer
269
220
  end
270
-
271
- Zen::Event.call(:after_delete_category_group, group)
272
221
  end
273
222
 
274
223
  message(:success, lang('category_groups.success.delete'))