zen 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ coverage/
2
+ spec/database.db
3
+
4
+ # Ignore common dotfiles
5
+ .yardoc
6
+ *.rbc
7
+ *.swp
8
+ .DS_Store
9
+
10
+ # Ignore general files and directories
11
+ doc
12
+ pkg/*.gem
13
+
14
+ # Keep the .gitkeep files.
15
+ !.gitkeep
data/.mailmap ADDED
@@ -0,0 +1,2 @@
1
+ YorickPeterse <yorickpeterse@gmail.com> YorickPeterse <info@yorickpeterse.com>
2
+ YorickPeterse <yorickpeterse@gmail.com> Yorick Peterse <info@yorickpeterse.com>
data/.rvmrc ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bash
2
+ rvm use --create 1.9.2@zen
data/.travis.yml CHANGED
@@ -1,6 +1,11 @@
1
1
  script: "gem install ramaze; rake test"
2
2
  rvm:
3
3
  - 1.9.2
4
- - rbx
5
- - jruby
6
- - 1.8.7
4
+
5
+ notifications:
6
+ disabled: true
7
+
8
+ branches:
9
+ only:
10
+ - develop
11
+ - master
data/AUTHORS CHANGED
@@ -1,5 +1,4 @@
1
1
  Following persons have contributed to Zen.
2
2
  (Sorted by number of submitted patches, then alphabetically)
3
3
 
4
- 115 YorickPeterse <info@yorickpeterse.com>
5
- 1 Yorick Peterse <info@yorickpeterse.com>
4
+ 184 YorickPeterse <yorickpeterse@gmail.com>
data/CHANGELOG.md CHANGED
@@ -1,28 +1,59 @@
1
- ## 0.2.7 - June 16th, 2011
1
+ ## 0.2.8 - August 3, 2011
2
+
3
+ * Replaced RSpec with Bacon.
4
+ * When retrieving section entries comments are now retrieved properly.
5
+ * Comments and categories are no longer retrieved by default when calling the
6
+ section entries plugin.
7
+ * Statuses of comments and section entries are now stored in a separate table.
8
+ * Plugins can be called as a singleton using Zen::Plugin.plugin.
9
+ * The column menu_items.order has been renamed to menu_items.sort_order.
10
+ * The accessor method for settings that defines the possible values now accepts
11
+ a Proc, this makes it possible for conditional possible values and such.
12
+ * Various performance tweaks.
13
+ * The rake task proto:package has been removed.
14
+ * The core package have been cleaned up and are much more robust thanks to
15
+ better validation of various objects such as category groups when viewing a
16
+ list of categories.
17
+ * Assets can now be loaded for specific methods using Zen::Asset by specifying
18
+ the :method key.
19
+ * Users can now create their own custom field types.
20
+ * Overview pages now paginate their results so they display a maximum of 20 rows
21
+ per page.
22
+ * All references to "css_class" and "css_id" have been replaced with
23
+ "html_class" and "html_id".
24
+ * Ramaze::Helper::Common has been removed.
25
+ * Tables can now be sorted by clicking on the headers.
26
+ * The required permissions for the #save() methods of all controllers have been
27
+ set correctly (issue #28).
28
+ * The executable now uses OptionParser instead of Commander.
29
+ * The total code coverage has been increased to 95.63% meaning Zen has become
30
+ even more stable than ever.
31
+ * Fixed a few broken migrations.
32
+
33
+ ## 0.2.7 - June 16, 2011
2
34
 
3
35
  * Started using Ramaze.setup for Gem management.
4
- * Websites can no longer be marked as "offline", this was a rather useless feature anyway.
36
+ * Websites can no longer be marked as "offline", this was a rather useless
37
+ feature anyway.
5
38
  * Fixed various bugs
6
39
 
7
- ## 0.2.6.1 - June 1st, 2011
40
+ ## 0.2.6.1 - June 1, 2011
8
41
 
9
- * Dropped Zen.settings and modified the settings plugin so that it works properly when
10
- using a multi-process based environment such as Unicorn.
42
+ * Dropped Zen.settings and modified the settings plugin so that it works
43
+ properly when using a multi-process based environment such as Unicorn.
11
44
 
12
- ## 0.2.6 - May 29th, 2011
45
+ ## 0.2.6 - May 29, 2011
13
46
 
14
47
  * Zen is now using RVM for gem management and such.
15
- * Began working on making Zen compatible with at least JRuby. Rubinius isn't worth the
16
- effort at this time.
17
- * Removed Ramaze::Helper::Common.notification in favor of Ramaze::Helper::Message.
18
- * Dropped Zen::Database, Zen::Settings and most of the options in favor of instance
19
- variables set in the main Zen module. See commit
20
- [d40ee1c2e518a323b2983e1bcfb7a0d863bf3b2f][d40ee1c2e518a323b2983e1bcfb7a0d863bf3b2f]
21
- for more information.
48
+ * Began working on making Zen compatible with at least JRuby. Rubinius isn't
49
+ worth the effort at this time.
50
+ * Removed Ramaze::Helper::Common.notification in favor of
51
+ Ramaze::Helper::Message.
52
+ * Dropped Zen::Database, Zen::Settings and most of the options in favor of
53
+ instance variables set in the main Zen module. See commit
54
+ d40ee1c2e518a323b2983e1bcfb7a0d863bf3b2f for more information.
22
55
  * Translated Zen to Dutch.
23
56
  * Re-organized the application prototypes to make them easier to use/understand.
24
- * Implemented the anti-spam system as a plugin and added a decent XSS protection system
25
- using Loofah.
57
+ * Implemented the anti-spam system as a plugin and added a decent XSS protection
58
+ system using Loofah.
26
59
  * Various changes to the Javascript classes.
27
-
28
- [d40ee1c2e518a323b2983e1bcfb7a0d863bf3b2f]: https://github.com/zen-cms/Zen-Core/commit/d40ee1c2e518a323b2983e1bcfb7a0d863bf3b2f
data/README.md CHANGED
@@ -1,16 +1,17 @@
1
1
  # README
2
2
 
3
- Zen is a modular CMS written on top of the awesome Ramaze framework. Zen was built out of
4
- the frustration with Expression Engine, a popular CMS built on top of the Codeigniter
5
- framework which in turn is written using PHP. While I really like Codeigniter,
6
- ExpressionEngine and EllisLab there were several problems that bothered me. So I set out
7
- to write a system that's loosely based on ExpressionEngine but fits my needs. Because of
8
- this certain features may seem similar to those provided by EE and while at certain
9
- points there are similarities there are also pretty big differences.
3
+ Zen is a modular CMS written on top of the awesome Ramaze framework. Zen was
4
+ built out of the frustration with Expression Engine, a popular CMS built on top
5
+ of the Codeigniter framework which in turn is written using PHP. While I really
6
+ like Codeigniter, ExpressionEngine and EllisLab there were several problems
7
+ that bothered me. So I set out to write a system that's loosely based on
8
+ ExpressionEngine but fits my needs. Because of this certain features may seem
9
+ similar to those provided by EE and while at certain points there are
10
+ similarities there are also pretty big differences.
10
11
 
11
12
  ## Requirements
12
13
 
13
- * Ramaze 2011.01.30 or newer
14
+ * Ramaze 2011.01.30 or newer
14
15
  * Ruby 1.9.2
15
16
  * A database (MySQL, PostgreSQL, etc)
16
17
 
@@ -19,47 +20,50 @@ points there are similarities there are also pretty big differences.
19
20
  Installing Zen using Rubygems is probably the easiest way:
20
21
 
21
22
  $ gem install zen
22
- $ zen app application_name
23
+ $ zen create application_name
23
24
 
24
25
  If you like to hack with the core of Zen it's best to install it using Git:
25
26
 
26
- $ git clone git://github.com/zen-cms/zen-core.git
27
+ $ git clone git://github.com/zen-cms/Zen-Core.git
27
28
  $ cd zen-core
28
29
  $ rake build:gem
29
30
 
30
31
  ## Database Support
31
32
 
32
- Technically Zen should run on any given DBMS that's supported by Sequel as Zen doesn't
33
- use any DBMS specific field types. However, there might be a chance that it won't work.
34
- If you happen to have any problems getting Zen running using your database of choice
35
- feel free to submit a ticket or post it on the mailing list.
33
+ Technically Zen should run on any given DBMS that's supported by Sequel as Zen
34
+ doesn't use any DBMS specific field types. However, there might be a chance that
35
+ it won't work. If you happen to have any problems getting Zen running using your
36
+ database of choice feel free to submit a ticket or post it on the mailing
37
+ list.
36
38
 
37
- The Zen website itself is tested and served using MySQL, SQLite3 works just as fine and
38
- PostgreSQL will be tested in the near future.
39
+ The Zen website itself is tested and served using MySQL, SQLite3 works just as
40
+ fine and PostgreSQL will be tested in the near future.
39
41
 
40
42
  ## Running Zen
41
43
 
42
- Zen can be run using any webserver as long as it supports Rack. Thin, Unicorn or Passenger,
43
- they should all work. The main website of Zen is served using Unicorn and Nginx,
44
- development is done using WEBRick and Unicorn.
44
+ Zen can be run using any webserver as long as it supports Rack. Thin, Unicorn or
45
+ Passenger, they should all work. The main website of Zen is served using Unicorn
46
+ and Nginx, development is done using WEBRick and Unicorn.
45
47
 
46
48
  ## Documentation
47
49
 
48
- The documentation (both the userguide and the API docs) can be found on the website,
49
- located [here][zen documentation].
50
+ The documentation (both the userguide and the API docs) can be found on the
51
+ website, located [here][zen documentation].
50
52
 
51
53
  ## Hacking/Contributing
52
54
 
53
- Zen follows a relatively strict set of guidelines when it comes to developing core features
54
- and making sure everything goes along smoothly. When working with Git a branch model based
55
- on [nvie's branch model][nvie branch model] is used. This means that the "master" branch
56
- is directly used for pushing Gems and thus should *always* contain stable code. Develop
57
- is used to contain less stable (but not unstable) commits that will be pushed into "master"
58
- from time to time. All other branches, e.g. "rspec2" will be used for individual features.
55
+ Zen follows a relatively strict set of guidelines when it comes to developing
56
+ core features and making sure everything goes along smoothly. When working with
57
+ Git a branch model based on [nvie's branch model][nvie branch model] is used.
58
+ This means that the "master" branch is directly used for pushing Gems and thus
59
+ should *always* contain stable code. Develop is used to contain less stable (but
60
+ not unstable) commits that will be pushed into "master" from time to time. All
61
+ other branches, e.g. "rspec2" will be used for individual features.
59
62
 
60
- Besides following this model developers are also expected to write tests using either
61
- RSpec or Capybara for their features. Capybara is used to test controllers and browser
62
- based tests while RSpec is used to test libraries, helpers, etc.
63
+ Besides following this model developers are also expected to write tests using
64
+ either RSpec or Capybara for their features. Capybara is used to test
65
+ controllers and browser based tests while RSpec is used to test libraries,
66
+ helpers, etc.
63
67
 
64
68
  ## Coding Standards
65
69
 
@@ -68,28 +72,29 @@ based tests while RSpec is used to test libraries, helpers, etc.
68
72
  * Document your code, that includes CSS and Javascript files.
69
73
  * No tabs at all times.
70
74
  * Markdown is used for all markup.
71
- * The maximum width of each line should be no more than 90 characters, this makes it
72
- easier to read code in terminals or when using split view modes.
75
+ * The maximum width of each line should be no more than 80 characters, this
76
+ makes it easier to read code in terminals or when using split view modes. The
77
+ limit used to be 90 characters but this was decreased to fit the Ruby coding
78
+ standards. Existing code using the 90 character limit will be changed over
79
+ time.
73
80
 
74
81
  ## Community
75
82
 
76
83
  * [Website][zen website]
77
84
  * [Mailing list][mailing list]
78
85
 
79
- Zen does not have it's own IRC channel at this time but you can usually find me in any
80
- of the following channels on Freenode:
86
+ Zen does not have it's own IRC channel at this time but you can usually find me
87
+ in any of the following channels on Freenode:
81
88
 
82
89
  * \#forrst-chat
83
90
  * \#ramaze
84
- * \#codeigniter
85
- * \#mootools
86
91
 
87
92
  ## License
88
93
 
89
- Zen is licensed under the MIT license. For more information about this license open
90
- the file "LICENSE".
94
+ Zen is licensed under the MIT license. For more information about this license
95
+ open the file "LICENSE".
91
96
 
92
97
  [zen website]: http://zen-cms.com/
93
- [zen documentation]: http://zen-cms.com/userguide/
98
+ [zen documentation]: http://zen-cms.com/userguide/index.html
94
99
  [nvie branch model]: http://nvie.com/posts/a-successful-git-branching-model/
95
100
  [mailing list]: https://groups.google.com/forum/#!forum/zen-cms
data/Rakefile CHANGED
@@ -1,5 +1,9 @@
1
1
  require File.expand_path('../lib/zen', __FILE__)
2
2
 
3
+ module Zen
4
+ Gemspec = Gem::Specification::load(__DIR__('zen.gemspec'))
5
+ end
6
+
3
7
  # Load all tasks
4
8
  Dir.glob(File.expand_path('../lib/zen/task/*.rake', __FILE__)).each do |f|
5
9
  import(f)
data/bin/zen CHANGED
@@ -1,34 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
- require 'ramaze'
3
- require File.expand_path('../../lib/zen/version', __FILE__)
4
-
5
- Ramaze.setup(:verbose => false) do
6
- gem 'commander', ['~> 4.0.4']
7
- end
8
-
9
- require 'commander/import'
10
-
11
- # Set the extra information message
12
- information = <<-MSG
13
- * Website: http://zen-cms.com/
14
- * Github: https://github.com/zen-cms
15
- * License: MIT License
16
- MSG
17
2
 
18
- # Set the details of the application
19
- program :name , 'Zen'
20
- program :version , Zen::Version
21
- program :description, 'Zen is a modular CMS written using Ramaze.'
22
-
23
- program :help, 'Example' , '$ zen [COMMAND] [OPTIONS]'
24
- program :help, 'Information', information.strip
25
-
26
- program :help_formatter, Commander::HelpFormatter::TerminalCompact
3
+ require 'ramaze'
4
+ require 'optparse'
27
5
 
28
- # Load all the commands
29
- commands = File.expand_path('../../lib/zen/bin/*.rb', __FILE__)
30
- commands = Dir.glob(commands)
6
+ require __DIR__('../lib/zen/version')
7
+ require __DIR__('../lib/zen/bin/runner')
31
8
 
32
- commands.each do |cmd|
33
- require cmd
34
- end
9
+ Zen::Bin::Runner.run
data/lib/zen.rb CHANGED
@@ -3,7 +3,7 @@ require 'ramaze'
3
3
  require 'yaml'
4
4
 
5
5
  Ramaze.setup(:verbose => false) do
6
- gem 'sequel' , ['~> 3.24.1']
6
+ gem 'sequel' , ['~> 3.26']
7
7
  gem 'bcrypt-ruby' , ['~> 2.1.4'], :lib => 'bcrypt'
8
8
  gem 'sequel_sluggable', ['~> 0.0.6']
9
9
  gem 'loofah' , ['~> 1.0.0']
@@ -12,8 +12,9 @@ end
12
12
  require __DIR__('zen/version')
13
13
 
14
14
  ##
15
- # Main module for Zen, all other modules and classes will be placed inside this module.
16
- # This module loads all required classes and is used for starting the application.
15
+ # Main module for Zen, all other modules and classes will be placed inside this
16
+ # module. This module loads all required classes and is used for starting the
17
+ # application.
17
18
  #
18
19
  # @author Yorick Peterse
19
20
  # @since 0.1
@@ -25,8 +26,8 @@ module Zen
25
26
 
26
27
  class << self
27
28
  ##
28
- # Variable that will contain a database connection that was established using
29
- # Sequel.connect.
29
+ # Variable that will contain a database connection that was established
30
+ # using Sequel.connect.
30
31
  #
31
32
  # @author Yorick Peterse
32
33
  # @since 0.2.6
@@ -63,15 +64,8 @@ module Zen
63
64
  css = File.join(p, 'admin/css/global.css')
64
65
  js = File.join(p, 'admin/js/global.js')
65
66
 
66
- # Load the CSS file if it's there
67
- if File.exist?(css)
68
- ::Zen::Asset.stylesheet(['global'], :global => true)
69
- end
70
-
71
- # Load the JS file if it's there
72
- if File.exist?(js)
73
- ::Zen::Asset.javascript(['global'], :global => true)
74
- end
67
+ Zen::Asset.stylesheet(['global'], :global => true) if File.exist?(css)
68
+ Zen::Asset.javascript(['global'], :global => true) if File.exist?(js)
75
69
  end
76
70
  end
77
71
 
@@ -85,9 +79,10 @@ module Zen
85
79
  # Migrate all settings
86
80
  begin
87
81
  plugin(:settings, :migrate)
88
- rescue
82
+ rescue => e
89
83
  Ramaze::Log.warn(
90
- "Failed to migrate the settings, make sure the database table is up to date"
84
+ 'Failed to migrate the settings, make sure the database ' + \
85
+ 'table is up to date'
91
86
  )
92
87
  end
93
88
  end
@@ -110,7 +105,6 @@ Zen::Language.load('zen_general')
110
105
 
111
106
  # Load all additional files
112
107
  require __DIR__('zen/plugin/helper')
113
- require __DIR__('zen/plugin/controller')
114
108
  require __DIR__('zen/plugin/markup/lib/markup')
115
109
 
116
110
  require __DIR__('zen/package')
@@ -123,7 +117,7 @@ require __DIR__('zen/controller/admin_controller')
123
117
  require __DIR__('zen/controller/main_controller')
124
118
  require __DIR__('zen/controller/preview')
125
119
 
126
- # Load the cache for the settings. This has to be done outside any of the init methods as
127
- # that would make it impossible to set a custom cache.
120
+ # Load the cache for the settings. This has to be done outside any of the init
121
+ # methods as that would make it impossible to set a custom cache.
128
122
  Ramaze::Cache.options.names.push(:settings)
129
123
  Ramaze::Cache.options.settings = Ramaze::Cache::LRU
data/lib/zen/asset.rb CHANGED
@@ -3,16 +3,18 @@ require 'ramaze/gestalt'
3
3
  #:nodoc:
4
4
  module Zen
5
5
  ##
6
- # The Asset module is a module used to register what Javascript files and stylesheets
7
- # should be loaded for the current request. This can be very useful if you want to add
8
- # a widget to all pages or override a certain stylesheet.
6
+ # The Asset module is a module used to register what Javascript files and
7
+ # stylesheets should be loaded for the current request. This can be very
8
+ # useful if you want to add a widget to all pages or override a certain
9
+ # stylesheet.
9
10
  #
10
11
  # ## Adding Assets
11
12
  #
12
- # Assets can be added by calling either Zen::Asset.stylesheet or Zen::Asset.javascript.
13
- # Both take an array of files and a hash with some configuration options, for more info
14
- # on the exact usage and all the available parameters see the individual methods. Here
15
- # are a few quick examples of loading files:
13
+ # Assets can be added by calling either Zen::Asset.stylesheet or
14
+ # Zen::Asset.javascript. Both take an array of files and a hash with some
15
+ # configuration options, for more info on the exact usage and all the
16
+ # available parameters see the individual methods. Here are a few quick
17
+ # examples of loading files:
16
18
  #
17
19
  # # Load 3 Javascript files of which 2 will be loaded globally
18
20
  # Zen::Asset.javascript(
@@ -27,18 +29,19 @@ module Zen
27
29
  #
28
30
  # ## Customizing Options
29
31
  #
30
- # This module uses Innate::Optioned to provide a few options that can be changed. The
31
- # following options are available:
32
+ # This module uses Innate::Optioned to provide a few options that can be
33
+ # changed. The following options are available:
32
34
  #
33
35
  # * prefix: The global prefix to use for all assets, set to "admin" by default.
34
- # * javascript_prefix: The prefix to use for all Javascript files on top of the global
35
- # prefix.
36
- # * stylesheet_prefix: Similar to the javascript_prefix option but for stylesheets.
36
+ # * javascript_prefix: The prefix to use for all Javascript files on top of
37
+ # the globalprefix.
38
+ # * stylesheet_prefix: Similar to the javascript_prefix option but for
39
+ # stylesheets.
37
40
  #
38
41
  # ## Building Assets
39
42
  #
40
- # Building assets shouldn't be required as Zen already does this but if you happen to
41
- # need it you can build the files as following:
43
+ # Building assets shouldn't be required as Zen already does this but if you
44
+ # happen to need it you can build the files as following:
42
45
  #
43
46
  # Zen::Asset.build(:stylesheet)
44
47
  # Zen::Asset.build(:javascript)
@@ -46,9 +49,9 @@ module Zen
46
49
  # ## Controller Usage
47
50
  #
48
51
  # While this module can be called by any other piece of code the class
49
- # Zen::Controller::AdminController provides shortcuts to Zen::Asset.javascript and
50
- # Zen::Asset.stylesheet. These shortcuts work identical but are defined as class methods
51
- # and thus can be used inside your class declaration:
52
+ # Zen::Controller::AdminController provides shortcuts to Zen::Asset.javascript
53
+ # and Zen::Asset.stylesheet. These shortcuts work identical but are defined
54
+ # as class methods and thus can be used inside your class declaration:
52
55
  #
53
56
  # class Something < Zen::Controller::AdminController
54
57
  # stylesheet ['reset'], :global => true
@@ -60,19 +63,15 @@ module Zen
60
63
  module Asset
61
64
  include ::Innate::Optioned
62
65
 
63
- class << self
64
- include ::Innate::Trinity
65
- end
66
-
67
66
  options.dsl do
68
- o 'Prefix for both Javascript files and stylesheets', :prefix , 'admin'
69
- o 'Prefix for Javascript files on top of :prefix' , :javascript_prefix, 'js'
70
- o 'Prefix for stylesheets on top of :prefix' , :stylesheet_prefix, 'css'
67
+ o 'Prefix for JS and CSS files' , :prefix , 'admin'
68
+ o 'Prefix for JS files on top of :prefix', :javascript_prefix, 'js'
69
+ o 'Prefix for CSS on top of :prefix' , :stylesheet_prefix, 'css'
71
70
  end
72
71
 
73
72
  ##
74
- # Hash containing all the global and controller specific stylesheets that have to be
75
- # loaded when calling build_stylesheets.
73
+ # Hash containing all the global and controller specific stylesheets that
74
+ # have to be loaded when calling build_stylesheets.
76
75
  #
77
76
  # @author Yorick Peterse
78
77
  # @since 0.2.5
@@ -82,8 +81,8 @@ module Zen
82
81
  }
83
82
 
84
83
  ##
85
- # Hash containing all the global and controller specific stylesheets to load when
86
- # calling build_javascripts.
84
+ # Hash containing all the global and controller specific stylesheets to
85
+ # load when calling build_javascripts.
87
86
  #
88
87
  # @author Yorick Peterse
89
88
  # @since 0.2.5
@@ -93,9 +92,9 @@ module Zen
93
92
  }
94
93
 
95
94
  ##
96
- # Registers the given Javascripts files so that they're either loaded for the
97
- # current action or for all actions. Note that the first argument of this method
98
- # should always be an array.
95
+ # Registers the given Javascripts files so that they're either loaded for
96
+ # the current action or for all actions. Note that the first argument of
97
+ # this method should always be an array.
99
98
  #
100
99
  # @example
101
100
  # # Loads /admin/js/users/access_rules.js for the current action only
@@ -106,17 +105,13 @@ module Zen
106
105
  #
107
106
  # @author Yorick Peterse
108
107
  # @since 0.2.5
109
- # @param [Array] files An array of Javascript files (without their extensions) to
110
- # load relatively to the root of the application (/).
111
- # @param [Hash] options A hash containing additional options.
112
- # @option options [TrueClass] :global When set to true the specified files will be
113
- # loaded globally rather than just for the current action.
114
- # @option options [String/Symbol] controller The name of the controller for which
115
- # the specified files should be loaded.
108
+ # @see Zen::Asset.process
116
109
  #
117
110
  def self.javascript(files, options = {})
118
111
  options = {
119
- :prefix => File.join('/', self.options.prefix, self.options.javascript_prefix),
112
+ :prefix => File.join(
113
+ '/', self.options.prefix, self.options.javascript_prefix
114
+ ),
120
115
  :type => :javascript
121
116
  }.merge(options)
122
117
 
@@ -124,24 +119,21 @@ module Zen
124
119
  end
125
120
 
126
121
  ##
127
- # Registers a number of stylesheets that can either be loaded globally or for the
128
- # current action.
122
+ # Registers a number of stylesheets that can either be loaded globally or
123
+ # for the current action.
129
124
  #
130
125
  # @example
131
126
  # Zen::Asset.stylesheet ['foobar/admin_template'], :global => true
132
127
  #
133
128
  # @author Yorick Peterse
134
129
  # @since 0.2.5
135
- # @param [Array] files A list of stylesheets (without their extensions) to load.
136
- # @param [Hash] options A hash containing additional options to use.
137
- # @option options [TrueClass] :global When set to true all the specified stylesheets
138
- # will be loaded globally rather than just for the current action.
139
- # @option options [String/Symbol] controller The name of the controller for which
140
- # the specified files should be loaded.
130
+ # @see Zen::Asset.process
141
131
  #
142
132
  def self.stylesheet(files, options = {})
143
133
  options = {
144
- :prefix => File.join('/', self.options.prefix, self.options.stylesheet_prefix),
134
+ :prefix => File.join(
135
+ '/', self.options.prefix, self.options.stylesheet_prefix
136
+ ),
145
137
  :type => :stylesheet
146
138
  }.merge(options)
147
139
 
@@ -149,8 +141,8 @@ module Zen
149
141
  end
150
142
 
151
143
  ##
152
- # Builds either all Javascript files or stylesheets. This method will load both the
153
- # global and action specific files.
144
+ # Builds either all Javascript files or stylesheets. This method will load
145
+ # both the global and action specific files.
154
146
  #
155
147
  # @example
156
148
  # # Build the HTML tags for all stylesheets
@@ -167,9 +159,16 @@ module Zen
167
159
  def self.build(type)
168
160
  type = type.to_sym
169
161
  attrs = {}
170
- controller = action.node.to_s.to_sym
162
+ controller = Ramaze::Current.action.node.to_s.to_sym
163
+ method = Ramaze::Current.action.method.to_s.to_sym
171
164
  gestalt = Ramaze::Gestalt.new
172
165
 
166
+ # The method in Ramaze::Current.action.method does not always contain the
167
+ # method since the assets are built in a layout.
168
+ if method.empty? and Ramaze::Current.actions[-2]
169
+ method = Ramaze::Current.actions[-2].method.to_s.to_sym
170
+ end
171
+
173
172
  # Set the basic elements of the tag
174
173
  if type === :stylesheet
175
174
  tag = :link
@@ -184,7 +183,13 @@ module Zen
184
183
 
185
184
  # Get all the files to build
186
185
  if !files[controller].nil?
187
- files = files[:global] + files[controller]
186
+ if files[controller].key?(method)
187
+ files = files[:global] + files[controller][method]
188
+ elsif !files[controller][:__all].nil?
189
+ files = files[:global] + files[controller][:__all]
190
+ else
191
+ files = files[:global]
192
+ end
188
193
  else
189
194
  files = files[:global]
190
195
  end
@@ -211,19 +216,29 @@ module Zen
211
216
  # Stores the given files in the correct hash based on the specified options.
212
217
  #
213
218
  # @example
214
- # process(['foobar', 'baz'], :global => false, :type => :javascript, :prefix => 'js')
219
+ # process(
220
+ # ['foobar', 'baz'],
221
+ # :global => false,
222
+ # :type => :javascript,
223
+ # :prefix => 'js'
224
+ # )
215
225
  #
216
226
  # @author Yorick Peterse
217
227
  # @since 0.2.5
218
228
  # @param [Array] files An array of files to load.
219
229
  # @param [Hash] options A hash containing all the required options.
220
- # @option options [TrueClass] :global Specifies that all the files should be loaded
221
- # globally.
222
- # @option options [Symbol] :type The type of asset that's loaded, can either be
223
- # :javascript or :stylesheet.
230
+ # @option options [TrueClass] :global Specifies that all the files should be
231
+ # loaded globally.
232
+ # @option options [Symbol] :type The type of asset that's loaded, can either
233
+ # be :javascript or :stylesheet.
224
234
  # @option options [String] :prefix The prefix to use for all the assets.
225
- # @option options [TrueClass] :global
226
- # @option options [Symbol/String] :controller
235
+ # @option options [TrueClass] :global When set to true the specified files
236
+ # will be loaded globally.
237
+ # @option options [Symbol/String] :controller The class of the controller
238
+ # for which the assets should be loaded.
239
+ # @option options [Symbol/String/Array] :method A string or symbol that
240
+ # represents a single method for which to load the assets OR an array of
241
+ # methods.
227
242
  #
228
243
  def self.process(files, options)
229
244
  # Determine whether the files should be loaded globally
@@ -242,14 +257,34 @@ module Zen
242
257
  ext = '.css'
243
258
  end
244
259
 
260
+ # Get the method to load the assets for
261
+ if options.key?(:method) and options[:method].class != Array
262
+ options[:method] = [options[:method]]
263
+ end
264
+
245
265
  # Add all the files
246
266
  files.each do |f|
247
- f = f.to_s + ext
248
- f = File.join(options[:prefix], f)
249
- save[key] ||= []
267
+ f = f.to_s + ext
268
+ f = File.join(options[:prefix], f)
250
269
 
251
- if !save[key].include?(f)
252
- save[key].push(f)
270
+ # Load the assets for all the given methods
271
+ if options.key?(:method)
272
+ options[:method].each do |method|
273
+ method = method.to_sym
274
+ save[key] ||= {}
275
+ save[key][method] ||= []
276
+
277
+ save[key][method].push(f) unless save[key][method].include?(f)
278
+ end
279
+ # Load the assets for all methods in the controller
280
+ else
281
+ if key === :global
282
+ save[key].push(f) unless save[key].include?(f)
283
+ else
284
+ save[key] ||= {}
285
+ save[key][:__all] ||= []
286
+ save[key][:__all].push(f) unless save[key][:__all].include?(f)
287
+ end
253
288
  end
254
289
  end
255
290
  end