zen 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (303) hide show
  1. data/.gitignore +15 -0
  2. data/.mailmap +2 -0
  3. data/.rvmrc +2 -0
  4. data/.travis.yml +8 -3
  5. data/AUTHORS +1 -2
  6. data/CHANGELOG.md +48 -17
  7. data/README.md +44 -39
  8. data/Rakefile +4 -0
  9. data/bin/zen +5 -30
  10. data/lib/zen.rb +13 -19
  11. data/lib/zen/asset.rb +99 -64
  12. data/lib/zen/bin/create.rb +94 -0
  13. data/lib/zen/bin/runner.rb +118 -0
  14. data/lib/zen/controller/admin_controller.rb +52 -36
  15. data/lib/zen/controller/base_controller.rb +5 -5
  16. data/lib/zen/controller/frontend_controller.rb +7 -7
  17. data/lib/zen/controller/main_controller.rb +12 -10
  18. data/lib/zen/controller/preview.rb +15 -11
  19. data/lib/zen/helper/acl.rb +73 -53
  20. data/lib/zen/helper/blue_form_vendor.rb +689 -0
  21. data/lib/zen/helper/breadcrumb.rb +23 -19
  22. data/lib/zen/helper/message.rb +3 -3
  23. data/lib/zen/helper/theme.rb +18 -13
  24. data/lib/zen/language.rb +62 -58
  25. data/lib/zen/language/en/zen_general.yml +2 -4
  26. data/lib/zen/language/nl/zen_general.yml +2 -4
  27. data/lib/zen/layout/admin.xhtml +3 -12
  28. data/lib/zen/layout/login.xhtml +1 -6
  29. data/lib/zen/model/methods.rb +6 -6
  30. data/lib/zen/model/settings.rb +5 -4
  31. data/lib/zen/package.rb +47 -38
  32. data/lib/zen/package/all.rb +3 -5
  33. data/lib/zen/package/base.rb +7 -7
  34. data/lib/zen/package/categories/lib/categories.rb +8 -3
  35. data/lib/zen/package/categories/lib/categories/controller/categories.rb +81 -55
  36. data/lib/zen/package/categories/lib/categories/controller/category_groups.rb +45 -44
  37. data/lib/zen/package/categories/lib/categories/helper/category.rb +88 -0
  38. data/lib/zen/package/categories/lib/categories/language/en/categories.yml +5 -4
  39. data/lib/zen/package/categories/lib/categories/language/en/category_groups.yml +5 -4
  40. data/lib/zen/package/categories/lib/categories/language/nl/categories.yml +5 -4
  41. data/lib/zen/package/categories/lib/categories/language/nl/category_groups.yml +5 -4
  42. data/lib/zen/package/categories/lib/categories/model/category.rb +15 -13
  43. data/lib/zen/package/categories/lib/categories/model/category_group.rb +3 -3
  44. data/lib/zen/package/categories/lib/categories/plugin/categories.rb +36 -25
  45. data/lib/zen/package/categories/lib/categories/view/admin/categories/form.xhtml +49 -56
  46. data/lib/zen/package/categories/lib/categories/view/admin/categories/index.xhtml +48 -35
  47. data/lib/zen/package/categories/lib/categories/view/admin/category-groups/form.xhtml +36 -29
  48. data/lib/zen/package/categories/lib/categories/view/admin/category-groups/index.xhtml +42 -37
  49. data/lib/zen/package/comments/lib/comments.rb +4 -1
  50. data/lib/zen/package/comments/lib/comments/controller/comments.rb +39 -32
  51. data/lib/zen/package/comments/lib/comments/controller/comments_form.rb +45 -26
  52. data/lib/zen/package/comments/lib/comments/helper/comment.rb +35 -0
  53. data/lib/zen/package/comments/lib/comments/language/en/comments.yml +9 -7
  54. data/lib/zen/package/comments/lib/comments/language/nl/comments.yml +10 -8
  55. data/lib/zen/package/comments/lib/comments/model/comment.rb +31 -17
  56. data/lib/zen/package/comments/lib/comments/model/comment_status.rb +15 -0
  57. data/lib/zen/package/comments/lib/comments/plugin/anti_spam.rb +27 -18
  58. data/lib/zen/package/comments/lib/comments/plugin/comments.rb +25 -20
  59. data/lib/zen/package/comments/lib/comments/view/admin/comments/form.xhtml +61 -54
  60. data/lib/zen/package/comments/lib/comments/view/admin/comments/index.xhtml +38 -23
  61. data/lib/zen/package/comments/migrations/1308774099_comment_status.rb +60 -0
  62. data/lib/zen/package/custom_fields/lib/custom_fields.rb +33 -7
  63. data/lib/zen/package/custom_fields/lib/custom_fields/blue_form_parameters.rb +209 -0
  64. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +50 -47
  65. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_types.rb +215 -0
  66. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_fields.rb +111 -73
  67. data/lib/zen/package/custom_fields/lib/custom_fields/helper/custom_field.rb +79 -0
  68. data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_field_groups.yml +20 -19
  69. data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_field_types.yml +40 -0
  70. data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_fields.yml +34 -32
  71. data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_groups.yml +5 -4
  72. data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_types.yml +40 -0
  73. data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_fields.yml +18 -16
  74. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field.rb +31 -11
  75. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_method.rb +15 -0
  76. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_type.rb +50 -0
  77. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb +28 -7
  78. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/form.xhtml +33 -28
  79. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/index.xhtml +48 -46
  80. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-types/form.xhtml +61 -0
  81. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-types/index.xhtml +93 -0
  82. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/form.xhtml +105 -99
  83. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/index.xhtml +43 -39
  84. data/lib/zen/package/custom_fields/migrations/1295255665_create_schema.rb +47 -16
  85. data/lib/zen/package/custom_fields/migrations/1310659580_custom_field_types.rb +148 -0
  86. data/lib/zen/package/custom_fields/migrations/1311694920_rename_css_class.rb +11 -0
  87. data/lib/zen/package/menus/lib/menus/controller/menu_items.rb +40 -35
  88. data/lib/zen/package/menus/lib/menus/controller/menus.rb +47 -43
  89. data/lib/zen/package/menus/lib/menus/helper/{menu_item.rb → menu.rb} +42 -15
  90. data/lib/zen/package/menus/lib/menus/language/en/menu_items.yml +5 -5
  91. data/lib/zen/package/menus/lib/menus/language/en/menus.yml +9 -8
  92. data/lib/zen/package/menus/lib/menus/language/nl/menu_items.yml +8 -8
  93. data/lib/zen/package/menus/lib/menus/language/nl/menus.yml +11 -10
  94. data/lib/zen/package/menus/lib/menus/model/menu.rb +5 -5
  95. data/lib/zen/package/menus/lib/menus/model/menu_item.rb +6 -5
  96. data/lib/zen/package/menus/lib/menus/plugin/menus.rb +41 -43
  97. data/lib/zen/package/menus/lib/menus/view/admin/menu-items/form.xhtml +59 -63
  98. data/lib/zen/package/menus/lib/menus/view/admin/menu-items/index.xhtml +35 -30
  99. data/lib/zen/package/menus/lib/menus/view/admin/menus/form.xhtml +46 -37
  100. data/lib/zen/package/menus/lib/menus/view/admin/menus/index.xhtml +37 -37
  101. data/lib/zen/package/menus/migrations/1297184342_create_schema.rb +5 -5
  102. data/lib/zen/package/menus/migrations/1308671733_rename_order_column.rb +11 -0
  103. data/lib/zen/package/menus/migrations/1311695030_rename_css_class.rb +17 -0
  104. data/lib/zen/package/sections/lib/sections.rb +18 -11
  105. data/lib/zen/package/sections/lib/sections/controller/section_entries.rb +115 -109
  106. data/lib/zen/package/sections/lib/sections/controller/sections.rb +72 -50
  107. data/lib/zen/package/sections/lib/sections/helper/section.rb +53 -0
  108. data/lib/zen/package/sections/lib/sections/language/en/section_entries.yml +5 -4
  109. data/lib/zen/package/sections/lib/sections/language/en/sections.yml +5 -4
  110. data/lib/zen/package/sections/lib/sections/language/nl/section_entries.yml +5 -4
  111. data/lib/zen/package/sections/lib/sections/language/nl/sections.yml +5 -4
  112. data/lib/zen/package/sections/lib/sections/model/section.rb +17 -9
  113. data/lib/zen/package/sections/lib/sections/model/section_entry.rb +192 -13
  114. data/lib/zen/package/sections/lib/sections/model/section_entry_status.rb +13 -0
  115. data/lib/zen/package/sections/lib/sections/plugin/section_entries.rb +60 -39
  116. data/lib/zen/package/sections/lib/sections/plugin/sections.rb +14 -11
  117. data/lib/zen/package/sections/lib/sections/view/admin/form.xhtml +100 -97
  118. data/lib/zen/package/sections/lib/sections/view/admin/index.xhtml +41 -39
  119. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/form.xhtml +95 -215
  120. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/index.xhtml +48 -40
  121. data/lib/zen/package/sections/migrations/1308672298_use_id_for_default_section.rb +40 -0
  122. data/lib/zen/package/sections/migrations/1308813320_section_entry_statuses.rb +58 -0
  123. data/lib/zen/package/settings/lib/settings/controller/settings.rb +5 -8
  124. data/lib/zen/package/settings/lib/settings/model/setting.rb +2 -37
  125. data/lib/zen/package/settings/lib/settings/plugin/setting_base.rb +18 -1
  126. data/lib/zen/package/settings/lib/settings/plugin/settings.rb +13 -7
  127. data/lib/zen/package/settings/lib/settings/view/admin/settings/index.xhtml +2 -1
  128. data/lib/zen/package/users/lib/users.rb +3 -1
  129. data/lib/zen/package/users/lib/users/controller/access_rules.rb +77 -60
  130. data/lib/zen/package/users/lib/users/controller/user_groups.rb +41 -36
  131. data/lib/zen/package/users/lib/users/controller/users.rb +48 -42
  132. data/lib/zen/package/users/lib/users/helper/users.rb +72 -0
  133. data/lib/zen/package/users/lib/users/language/en/access_rules.yml +6 -5
  134. data/lib/zen/package/users/lib/users/language/en/user_groups.yml +5 -4
  135. data/lib/zen/package/users/lib/users/language/en/users.yml +1 -0
  136. data/lib/zen/package/users/lib/users/language/nl/access_rules.yml +5 -4
  137. data/lib/zen/package/users/lib/users/language/nl/user_groups.yml +5 -4
  138. data/lib/zen/package/users/lib/users/language/nl/users.yml +1 -0
  139. data/lib/zen/package/users/lib/users/model/access_rule.rb +5 -1
  140. data/lib/zen/package/users/lib/users/model/user.rb +17 -10
  141. data/lib/zen/package/users/lib/users/public/admin/js/users/access_rules.js +10 -37
  142. data/lib/zen/package/users/lib/users/public/admin/js/users/lib/access_rules.js +49 -0
  143. data/lib/zen/package/users/lib/users/view/admin/access-rules/form.xhtml +105 -96
  144. data/lib/zen/package/users/lib/users/view/admin/access-rules/index.xhtml +48 -41
  145. data/lib/zen/package/users/lib/users/view/admin/user-groups/form.xhtml +42 -32
  146. data/lib/zen/package/users/lib/users/view/admin/user-groups/index.xhtml +43 -38
  147. data/lib/zen/package/users/lib/users/view/admin/users/form.xhtml +76 -67
  148. data/lib/zen/package/users/lib/users/view/admin/users/index.xhtml +43 -41
  149. data/lib/zen/package/users/lib/users/view/admin/users/login.xhtml +12 -9
  150. data/lib/zen/package/users/migrations/1295281013_create_schema.rb +2 -2
  151. data/lib/zen/plugin.rb +56 -50
  152. data/lib/zen/plugin/markup/lib/markup/markup.rb +33 -21
  153. data/lib/zen/public/admin/css/zen/buttons.css +11 -7
  154. data/lib/zen/public/admin/css/zen/datepicker.css +6 -6
  155. data/lib/zen/public/admin/css/zen/forms.css +2 -1
  156. data/lib/zen/public/admin/css/zen/general.css +15 -10
  157. data/lib/zen/public/admin/css/zen/layout.css +51 -20
  158. data/lib/zen/public/admin/css/zen/tables.css +39 -11
  159. data/lib/zen/public/admin/css/zen/tabs.css +6 -4
  160. data/lib/zen/public/admin/css/zen/window.css +11 -11
  161. data/lib/zen/public/{favicon.ico → admin/favicon.ico} +0 -0
  162. data/lib/zen/public/admin/images/zen/icons/asc.png +0 -0
  163. data/lib/zen/public/admin/images/zen/icons/desc.png +0 -0
  164. data/lib/zen/public/admin/js/vendor/datepicker.js +0 -11
  165. data/lib/zen/public/admin/js/{mootools → vendor/mootools}/core.js +0 -1
  166. data/lib/zen/public/admin/js/{mootools → vendor/mootools}/more.js +100 -29
  167. data/lib/zen/public/admin/js/zen/index.js +48 -0
  168. data/lib/zen/public/admin/js/zen/lib/asset.js +111 -0
  169. data/lib/zen/public/admin/js/zen/{editor.js → lib/editor.js} +107 -127
  170. data/lib/zen/public/admin/js/zen/{editor → lib/editor}/markdown.js +7 -9
  171. data/lib/zen/public/admin/js/zen/{editor → lib/editor}/textile.js +7 -9
  172. data/lib/zen/public/admin/js/zen/lib/html_table.js +143 -0
  173. data/lib/zen/public/admin/js/zen/{tabs.js → lib/tabs.js} +40 -37
  174. data/lib/zen/public/admin/js/zen/{window.js → lib/window.js} +24 -20
  175. data/lib/zen/spec/bacon/color_output.rb +39 -0
  176. data/lib/zen/spec/helper.rb +152 -0
  177. data/lib/zen/spec/simplecov.rb +22 -0
  178. data/lib/zen/task/build.rake +20 -43
  179. data/lib/zen/task/clean.rake +2 -6
  180. data/lib/zen/task/db.rake +8 -12
  181. data/lib/zen/task/package.rake +4 -10
  182. data/lib/zen/task/plugin.rake +3 -9
  183. data/lib/zen/task/proto.rake +0 -62
  184. data/lib/zen/task/test.rake +6 -3
  185. data/lib/zen/task/theme.rake +4 -11
  186. data/lib/zen/theme.rb +22 -24
  187. data/lib/zen/validation.rb +34 -27
  188. data/lib/zen/version.rb +2 -8
  189. data/lib/zen/view/head.xhtml +7 -0
  190. data/lib/zen/view/main.xhtml +7 -22
  191. data/{proto/package/migrations → pkg}/.gitkeep +0 -0
  192. data/proto/app/app.rb +1 -0
  193. data/proto/app/config/config.rb +5 -4
  194. data/proto/app/config/database.rb +19 -41
  195. data/proto/app/config/middlewares.rb +32 -29
  196. data/proto/{package/lib/package/view/admin/package/index.xhtml → app/log/database/dev/.gitkeep} +0 -0
  197. data/proto/app/log/database/live/.gitkeep +0 -0
  198. data/spec/Rakefile +26 -0
  199. data/spec/fixtures/zen/asset.rb +18 -0
  200. data/spec/fixtures/zen/helper/acl.rb +39 -0
  201. data/spec/fixtures/zen/helper/message.rb +19 -0
  202. data/spec/fixtures/zen/language/en/spec.yml +10 -0
  203. data/spec/fixtures/zen/language/nl/spec.yml +7 -0
  204. data/spec/fixtures/zen/package.rb +17 -0
  205. data/spec/fixtures/zen/package/comments/controller/comments_form.rb +27 -0
  206. data/spec/fixtures/zen/package/settings/plugin/settings.rb +20 -0
  207. data/spec/fixtures/zen/plugin.rb +7 -0
  208. data/spec/fixtures/zen/theme/404.xhtml +1 -0
  209. data/spec/fixtures/zen/theme/default-section/index.xhtml +1 -0
  210. data/spec/fixtures/zen/theme/helper/404.xhtml +1 -0
  211. data/spec/fixtures/zen/theme/helper/partial.xhtml +1 -0
  212. data/spec/fixtures/zen/theme/helper/wrong_partial.xhtml +1 -0
  213. data/spec/fixtures/zen/theme/partials/partial.xhtml +1 -0
  214. data/spec/fixtures/zen/theme/theme.rb +11 -0
  215. data/spec/fixtures/zen/validation.rb +22 -0
  216. data/spec/helper.rb +41 -0
  217. data/spec/zen/all.rb +5 -0
  218. data/spec/zen/asset.rb +97 -0
  219. data/spec/zen/bin/create.rb +89 -0
  220. data/spec/zen/bin/runner.rb +47 -0
  221. data/spec/zen/controller/admin_controller.rb +26 -0
  222. data/spec/zen/controller/main_controller.rb +81 -0
  223. data/spec/zen/controller/preview.rb +33 -0
  224. data/spec/zen/helper/acl.rb +149 -0
  225. data/spec/zen/helper/breadcrumb.rb +38 -0
  226. data/spec/zen/helper/message.rb +31 -0
  227. data/spec/zen/helper/theme.rb +58 -0
  228. data/spec/zen/language.rb +55 -0
  229. data/spec/zen/package.rb +23 -0
  230. data/spec/zen/package/categories/controller/categories.rb +123 -0
  231. data/spec/zen/package/categories/controller/category_groups.rb +108 -0
  232. data/spec/zen/package/categories/helper/category.rb +75 -0
  233. data/spec/zen/package/categories/plugin/categories.rb +92 -0
  234. data/spec/zen/package/comments/controller/comments.rb +134 -0
  235. data/spec/zen/package/comments/controller/comments_form.rb +343 -0
  236. data/spec/zen/package/comments/helper/comment.rb +47 -0
  237. data/spec/zen/package/comments/plugin/anti_spam.rb +59 -0
  238. data/spec/zen/package/comments/plugin/comments.rb +107 -0
  239. data/spec/zen/package/custom_fields/blue_form_parameters.rb +183 -0
  240. data/spec/zen/package/custom_fields/controller/custom_field_groups.rb +120 -0
  241. data/spec/zen/package/custom_fields/controller/custom_field_types.rb +169 -0
  242. data/spec/zen/package/custom_fields/controller/custom_fields.rb +158 -0
  243. data/spec/zen/package/custom_fields/helper/custom_field.rb +86 -0
  244. data/spec/zen/package/menus/controller/menu_items.rb +110 -0
  245. data/spec/zen/package/menus/controller/menus.rb +110 -0
  246. data/spec/zen/package/menus/helper/menu.rb +75 -0
  247. data/spec/zen/package/menus/plugin/menus.rb +120 -0
  248. data/spec/zen/package/sections/controller/section_entries.rb +201 -0
  249. data/spec/zen/package/sections/controller/sections.rb +116 -0
  250. data/spec/zen/package/sections/helper/section.rb +74 -0
  251. data/spec/zen/package/sections/plugin/section_entries.rb +161 -0
  252. data/spec/zen/package/sections/plugin/sections.rb +75 -0
  253. data/spec/zen/package/settings/controller/settings.rb +36 -0
  254. data/spec/zen/package/settings/plugin/settings.rb +33 -0
  255. data/spec/zen/package/users/controller/access_rules.rb +90 -0
  256. data/spec/zen/package/users/controller/user_groups.rb +101 -0
  257. data/spec/zen/package/users/controller/users.rb +130 -0
  258. data/spec/zen/package/users/helper/users.rb +97 -0
  259. data/spec/zen/plugin.rb +64 -0
  260. data/spec/zen/plugin/helper.rb +11 -0
  261. data/spec/zen/plugin/markup.rb +44 -0
  262. data/spec/zen/theme.rb +41 -0
  263. data/spec/zen/validation.rb +63 -0
  264. data/zen.gemspec +36 -0
  265. metadata +159 -113
  266. data/MANIFEST +0 -266
  267. data/lib/zen/bin/app.rb +0 -40
  268. data/lib/zen/ext/string.rb +0 -185
  269. data/lib/zen/helper/common.rb +0 -106
  270. data/lib/zen/package/categories/lib/categories/view/admin/categories/edit.xhtml +0 -7
  271. data/lib/zen/package/categories/lib/categories/view/admin/categories/new.xhtml +0 -7
  272. data/lib/zen/package/categories/lib/categories/view/admin/category-groups/edit.xhtml +0 -7
  273. data/lib/zen/package/categories/lib/categories/view/admin/category-groups/new.xhtml +0 -7
  274. data/lib/zen/package/comments/lib/comments/view/admin/comments/edit.xhtml +0 -7
  275. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/edit.xhtml +0 -7
  276. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/new.xhtml +0 -7
  277. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/edit.xhtml +0 -7
  278. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/new.xhtml +0 -7
  279. data/lib/zen/package/menus/lib/menus/view/admin/menu-items/edit.xhtml +0 -7
  280. data/lib/zen/package/menus/lib/menus/view/admin/menu-items/new.xhtml +0 -7
  281. data/lib/zen/package/menus/lib/menus/view/admin/menus/edit.xhtml +0 -7
  282. data/lib/zen/package/menus/lib/menus/view/admin/menus/new.xhtml +0 -7
  283. data/lib/zen/package/sections/lib/sections/view/admin/edit.xhtml +0 -7
  284. data/lib/zen/package/sections/lib/sections/view/admin/new.xhtml +0 -7
  285. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/edit.xhtml +0 -7
  286. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/new.xhtml +0 -7
  287. data/lib/zen/package/users/lib/users/view/admin/access-rules/edit.xhtml +0 -7
  288. data/lib/zen/package/users/lib/users/view/admin/access-rules/new.xhtml +0 -7
  289. data/lib/zen/package/users/lib/users/view/admin/user-groups/edit.xhtml +0 -7
  290. data/lib/zen/package/users/lib/users/view/admin/user-groups/new.xhtml +0 -7
  291. data/lib/zen/package/users/lib/users/view/admin/users/edit.xhtml +0 -7
  292. data/lib/zen/package/users/lib/users/view/admin/users/new.xhtml +0 -7
  293. data/lib/zen/plugin/controller.rb +0 -59
  294. data/lib/zen/public/admin/css/zen/notifications.css +0 -84
  295. data/lib/zen/public/admin/images/zen/icons/large/error.png +0 -0
  296. data/lib/zen/public/admin/images/zen/icons/large/notice.png +0 -0
  297. data/lib/zen/public/admin/images/zen/icons/large/success.png +0 -0
  298. data/lib/zen/public/admin/js/zen/core.js +0 -73
  299. data/lib/zen/public/admin/js/zen/init.js +0 -80
  300. data/proto/package/lib/package.rb +0 -21
  301. data/proto/package/lib/package/controller/controllers.rb +0 -50
  302. data/proto/package/lib/package/language/en/languages.yml +0 -4
  303. data/proto/package/lib/package/model/model.rb +0 -12
@@ -0,0 +1,13 @@
1
+ module Sections
2
+ module Model
3
+ ##
4
+ # Model for managing the statuses of each section entry.
5
+ #
6
+ # @author Yorick Peterse
7
+ # @since 0.2.8
8
+ #
9
+ class SectionEntryStatus < Sequel::Model
10
+ many_to_one :section_entry, :class => 'Sections::Model::SectionEntryStatus'
11
+ end # SectionEntryStatus
12
+ end # Model
13
+ end # Sections
@@ -3,10 +3,10 @@ module Sections
3
3
  #:nodoc:
4
4
  module Plugin
5
5
  ##
6
- # The SectionEntries plugin can be used to retrieve section entries as well as the
7
- # associated comments and user data. This allows you to relatively easily build a list
8
- # of entries (e.g. blog articles) without having to retrieve and process the
9
- # associated data manually.
6
+ # The SectionEntries plugin can be used to retrieve section entries as well
7
+ # as the associated comments and user data. This allows you to relatively
8
+ # easily build a list of entries (e.g. blog articles) without having to
9
+ # retrieve and process the associated data manually.
10
10
  #
11
11
  # ## Usage
12
12
  #
@@ -17,9 +17,9 @@ module Sections
17
17
  # puts e[:title]
18
18
  # end
19
19
  #
20
- # The values of custom fields are stored under the key :fields. This key contains a
21
- # hash where the keys are the slugs of the custom fields and the values the values for
22
- # the current entry.
20
+ # The values of custom fields are stored under the key :fields. This key
21
+ # contains a hash where the keys are the slugs of the custom fields and the
22
+ # values the values for the current entry.
23
23
  #
24
24
  # entries.each do |e|
25
25
  # e[:fields][:thumbnail]
@@ -39,7 +39,8 @@ module Sections
39
39
  # end
40
40
  # end
41
41
  #
42
- # For a full list of available options see Sections::Plugin::SectionEntries.initialize.
42
+ # For a full list of available options see
43
+ # Sections::Plugin::SectionEntries.initialize.
43
44
  #
44
45
  # @author Yorick Peterse
45
46
  # @since 0.2.5
@@ -49,31 +50,32 @@ module Sections
49
50
  include ::Sections::Model
50
51
 
51
52
  ##
52
- # Creates a new instance of the plugin and validates/stores the given configuration
53
- # options. Please note that you always need to either specify a section from which
54
- # to retrieve all entries or a single entry in order to use this plugin. You can
55
- # retrieve a list of entries (or just a single one) by specifying the ID or the
56
- # slug:
53
+ # Creates a new instance of the plugin and validates/stores the given
54
+ # configuration options. Please note that you always need to either
55
+ # specify a section from which to retrieve all entries or a single entry
56
+ # in order to use this plugin. You can retrieve a list of entries (or just
57
+ # a single one) by specifying the ID or the slug:
57
58
  #
58
59
  # plugin(:section_entries, :section => 'blog')
59
60
  # plugin(:section_entries, :section => 10)
60
61
  #
61
62
  # @author Yorick Peterse
62
63
  # @since 0.2.5
63
- # @param [Hash] options Hash with a collection of custom configuration options that
64
- # determine how and what entries should be retrieved.
64
+ # @param [Hash] options Hash with a collection of custom configuration
65
+ # options that determine how and what entries should be retrieved.
65
66
  # @option options [Fixnum/Integer] :limit
66
67
  # @option options [Fixnum/Integer] :offset
67
68
  # @option options [NilClass/String/Integer/Fixnum] :section
68
69
  # @option options [NilClass/String/Integer/Fixnum] :entry
69
- # @option options [TrueClass] :markup When set to true the markup of all entries will
70
- # be converted to the desired output (usually this is HTML).
71
- # @option options [TrueClass] :comments When set to true all comments for each entry
72
- # will be retrieved.
73
- # @option options [TrueClass] :comment_markup When set to true the markup of comments
74
- # will be converted to the desired output.
75
- # @option options [TrueClass] :categories When set to true all categories for each
76
- # entry will be retrieved as well.
70
+ # @option options [TrueClass] :markup When set to true the markup of all
71
+ # entries will be converted to the desired output (usually this is HTML).
72
+ # @option options [TrueClass] :comments When set to true all comments for
73
+ # each entry will be retrieved. Set to false by default.
74
+ # @option options [TrueClass] :comment_markup When set to true the markup
75
+ # of comments will be converted to the desired output.
76
+ # @option options [TrueClass] :categories When set to true all categories
77
+ # for each entry will be retrieved as well. This is set to false by
78
+ # default.
77
79
  #
78
80
  def initialize(options = {})
79
81
  @options = {
@@ -82,29 +84,36 @@ module Sections
82
84
  :section => nil,
83
85
  :entry => nil,
84
86
  :markup => true,
85
- :comments => true,
87
+ :comments => false,
86
88
  :comment_markup => true,
87
- :categories => true
89
+ :categories => false
88
90
  }.merge(options)
89
91
 
90
92
  validate_type(@options[:limit] , :limit , [Fixnum, Integer])
91
93
  validate_type(@options[:offset] , :limit , [Fixnum, Integer])
92
- validate_type(@options[:section] , :section , [NilClass, String, Integer, Fixnum])
93
- validate_type(@options[:entry] , :entry , [NilClass, String, Integer, Fixnum])
94
+
95
+ validate_type(
96
+ @options[:section], :section, [NilClass, String, Integer, Fixnum]
97
+ )
98
+
99
+ validate_type(
100
+ @options[:entry], :entry, [NilClass, String, Integer, Fixnum]
101
+ )
102
+
94
103
  validate_type(@options[:markup] , :markup , [TrueClass, FalseClass])
95
104
  validate_type(@options[:comments], :comments, [TrueClass, FalseClass])
96
105
 
97
106
  if @options[:section].nil? and @options[:entry].nil?
98
107
  raise(
99
- ArgumentError,
108
+ ArgumentError,
100
109
  "You need to specify either an entry or a section to retrieve."
101
110
  )
102
111
  end
103
112
  end
104
113
 
105
114
  ##
106
- # Fetches all the data and converts everything to a hash. Once this is done either
107
- # an array of entries or a single entry hash will be returned.
115
+ # Fetches all the data and converts everything to a hash. Once this is
116
+ # done either an array of entries or a single entry hash will be returned.
108
117
  #
109
118
  # @author Yorick Peterse
110
119
  # @since 0.2.5
@@ -112,14 +121,18 @@ module Sections
112
121
  #
113
122
  def call
114
123
  # Create the list with models to load using eager()
115
- eager_models = [:custom_field_values, :categories, :section, :user]
124
+ eager_models = [:custom_field_values, :user]
116
125
  filter_hash = {}
117
126
 
118
127
  if @options[:comments] === true
119
128
  eager_models.push(:comments)
120
129
  end
130
+
131
+ if @options[:categories] === true
132
+ eager_models.push(:categories)
133
+ end
121
134
 
122
- # Retrieve multiple entries
135
+ # Get the section ID based on either the slug or ID.
123
136
  if !@options[:section].nil?
124
137
  # Retrieve the section by it's slug
125
138
  if @options[:section].class == String
@@ -142,6 +155,10 @@ module Sections
142
155
  end
143
156
  end
144
157
 
158
+ # Get the correct status to retrieve
159
+ filter_hash[:section_entry_status_id] = \
160
+ ::Sections::Model::SectionEntryStatus[:name => 'published'].id
161
+
145
162
  # Get the entries
146
163
  entries = SectionEntry.filter(filter_hash) \
147
164
  .eager(*eager_models) \
@@ -152,10 +169,6 @@ module Sections
152
169
 
153
170
  # Loop through all entries so we can process our custom field values
154
171
  entries.each_with_index do |entry, index|
155
- if comment_format.nil?
156
- comment_format = entry.section.comment_format
157
- end
158
-
159
172
  field_values = {}
160
173
  user = {}
161
174
  comments = []
@@ -176,6 +189,10 @@ module Sections
176
189
 
177
190
  # Get all the comments if the developer wants them
178
191
  if @options[:comments] === true
192
+ if comment_format.nil?
193
+ comment_format = entry.section.comment_format
194
+ end
195
+
179
196
  entry.comments.each do |c|
180
197
  comment = c.values
181
198
 
@@ -185,7 +202,9 @@ module Sections
185
202
 
186
203
  # Convert the comment's markup
187
204
  if @options[:comment_markup]
188
- comment[:comment] = plugin(:markup, comment_format, comment[:comment])
205
+ comment[:comment] = plugin(
206
+ :markup, comment_format, comment[:comment]
207
+ )
189
208
  end
190
209
 
191
210
  comments.push(comment)
@@ -198,8 +217,10 @@ module Sections
198
217
  end
199
218
 
200
219
  # Get all categories
201
- categories = entry.categories.map do |cat|
202
- cat.values
220
+ if @options[:categories] === true
221
+ categories = entry.categories.map do |cat|
222
+ cat.values
223
+ end
203
224
  end
204
225
 
205
226
  # Convert the entry to a hash and re-assign all data
@@ -3,8 +3,8 @@ module Sections
3
3
  #:nodoc:
4
4
  module Plugin
5
5
  ##
6
- # Plugin that can be used to display sections and their details. If you want to
7
- # display section entries instead you should use the plugin
6
+ # Plugin that can be used to display sections and their details. If you want
7
+ # to display section entries instead you should use the plugin
8
8
  # Sections::Plugin::SectionEntries.
9
9
  #
10
10
  # ## Usage
@@ -20,8 +20,8 @@ module Sections
20
20
  include ::Sections::Model
21
21
 
22
22
  ##
23
- # Creates a new instance of the plugin and saves/validates the given configuration
24
- # options.
23
+ # Creates a new instance of the plugin and saves/validates the given
24
+ # configuration options.
25
25
  #
26
26
  # @example
27
27
  # plugin = Sections::Plugin::Sections.new(:section => 10)
@@ -39,19 +39,22 @@ module Sections
39
39
 
40
40
  validate_type(@options[:limit] , :limit , [Fixnum, Integer])
41
41
  validate_type(@options[:offset] , :offset , [Fixnum, Integer])
42
- validate_type(@options[:section], :section, [NilClass, Integer, Fixnum, String])
42
+
43
+ validate_type(
44
+ @options[:section], :section, [NilClass, Integer, Fixnum, String]
45
+ )
43
46
  end
44
47
 
45
48
  ##
46
- # Retrieves the section(s) based on the given configuration options. When multiple
47
- # sections are retrieved they're returned as an array, otherwise a single instance
48
- # of Sections::Model::Sections will be returned.
49
+ # Retrieves the section(s) based on the given configuration options. When
50
+ # multiple sections are retrieved they're returned as an array, otherwise
51
+ # a single instance of Sections::Model::Sections will be returned.
49
52
  #
50
53
  # @author Yorick Peterse
51
54
  # @since 0.2.5
52
- # @return [Array/Sections::Model::Section] List of all sections that were retrieved
53
- # or an instance of Sections::Model::Section in case a specific section was retrieved
54
- # from the database.
55
+ # @return [Array/Sections::Model::Section] List of all sections that were
56
+ # retrieved or an instance of Sections::Model::Section in case a specific
57
+ # section was retrieved from the database.
55
58
  #
56
59
  def call
57
60
  # Retrieve a single section
@@ -1,107 +1,110 @@
1
- <div class="tabs">
2
- <ul>
3
- <li>
4
- <a href="#general" title="#{lang('sections.tabs.general')}">
5
- #{lang('sections.tabs.general')}
6
- </a>
7
- </li>
8
- <li>
9
- <a href="#comments" title="#{lang('sections.tabs.comment_settings')}">
10
- #{lang('sections.tabs.comment_settings')}
11
- </a>
12
- </li>
13
- <li>
14
- <a href="#groups" title="#{lang('sections.tabs.group_assignments')}">
15
- #{lang('sections.tabs.group_assignments')}
16
- </a>
17
- </li>
18
- </ul>
19
- </div>
20
-
21
- #{
22
- form_for(@section, :method => 'post', :action => @form_save_url, :id => :section_form) do |f|
1
+ <article>
2
+ <header>
3
+ <h1>#{get_breadcrumbs}</h1>
4
+ </header>
23
5
 
24
- f.input_hidden(:id, @section.id)
25
- f.input_hidden(:csrf_token, get_csrf_token)
26
-
27
- f.g.div(:id => 'general') do
6
+ <div class="tabs">
7
+ <ul>
8
+ <li>
9
+ <a href="#general" title="#{lang('sections.tabs.general')}">
10
+ #{lang('sections.tabs.general')}
11
+ </a>
12
+ </li>
13
+ <li>
14
+ <a href="#comments"
15
+ title="#{lang('sections.tabs.comment_settings')}">
16
+ #{lang('sections.tabs.comment_settings')}
17
+ </a>
18
+ </li>
19
+ <li>
20
+ <a href="#groups"
21
+ title="#{lang('sections.tabs.group_assignments')}">
22
+ #{lang('sections.tabs.group_assignments')}
23
+ </a>
24
+ </li>
25
+ </ul>
26
+ </div>
28
27
 
29
- f.input_text(
30
- lang('sections.labels.name'),
31
- :name
32
- )
28
+ #{
29
+ form_for(
30
+ @section,
31
+ :method => 'post',
32
+ :action => Sections::Controller::Sections.r(:save),
33
+ :id => :section_form
34
+ ) do |f|
35
+ f.input_hidden(:id , @section.id)
36
+ f.input_hidden(:csrf_token, get_csrf_token)
33
37
 
34
- f.input_text(
35
- lang('sections.labels.slug'),
36
- :slug
37
- )
38
+ f.g.div(:id => 'general') do
39
+ f.input_text(
40
+ lang('sections.labels.name'),
41
+ :name
42
+ )
38
43
 
39
- f.textarea(
40
- lang('sections.labels.description'),
41
- :description,
42
- :rows => 8
43
- )
44
+ f.input_text(
45
+ lang('sections.labels.slug'),
46
+ :slug
47
+ )
44
48
 
45
- end
46
-
47
- f.g.div(:id => 'comments') do
49
+ f.textarea(
50
+ lang('sections.labels.description'),
51
+ :description,
52
+ :rows => 8
53
+ )
54
+ end # f.g.div(:id => 'general')
48
55
 
49
- f.input_radio(
50
- lang('sections.labels.comment_allow'),
51
- :comment_allow,
52
- @section.comment_allow,
53
- :values => @boolean_hash
54
- )
55
-
56
- f.input_radio(
57
- lang('sections.labels.comment_require_account'),
58
- :comment_require_account,
59
- @section.comment_require_account,
60
- :values => @boolean_hash
61
- )
62
-
63
- f.input_radio(
64
- lang('sections.labels.comment_moderate'),
65
- :comment_moderate,
66
- @section.comment_moderate,
67
- :values => @boolean_hash
68
- )
69
-
70
- f.select(
71
- lang('sections.labels.comment_format'),
72
- :comment_format,
73
- :values => Zen::Plugin::Markup::Engines,
74
- :selected => @section.comment_format,
75
- :size => 1
76
- )
56
+ f.g.div(:id => 'comments') do
57
+ f.input_radio(
58
+ lang('sections.labels.comment_allow'),
59
+ :comment_allow,
60
+ @section.comment_allow,
61
+ :values => @boolean_hash.invert
62
+ )
77
63
 
78
- end
79
-
80
- f.g.div(:id => 'groups') do
64
+ f.input_radio(
65
+ lang('sections.labels.comment_require_account'),
66
+ :comment_require_account,
67
+ @section.comment_require_account,
68
+ :values => @boolean_hash.invert
69
+ )
81
70
 
82
- f.select(
83
- lang('sections.labels.custom_field_groups'),
84
- :custom_field_group_pks,
85
- :values => @custom_field_group_pk_hash,
86
- :multiple => :multiple,
87
- :selected => @section.custom_field_group_pks
88
- )
89
-
90
- f.select(
91
- lang('sections.labels.category_groups'),
92
- :category_group_pks,
93
- :values => @category_group_pk_hash,
94
- :multiple => :multiple,
95
- :selected => @section.category_group_pks
96
- )
71
+ f.input_radio(
72
+ lang('sections.labels.comment_moderate'),
73
+ :comment_moderate,
74
+ @section.comment_moderate,
75
+ :values => @boolean_hash.invert
76
+ )
97
77
 
98
- end
99
-
100
- f.g.div(:class => 'clearfix') do
101
- f.g.div(:class => 'button') do
102
- f.g.input(:type => 'submit', :value => lang('sections.buttons.save'))
103
- end
104
- end
78
+ f.select(
79
+ lang('sections.labels.comment_format'),
80
+ :comment_format,
81
+ :values => Zen::Plugin::Markup::Engines,
82
+ :selected => @section.comment_format,
83
+ :size => 1
84
+ )
85
+ end # f.g.div(:id => 'comments')
86
+
87
+ f.g.div(:id => 'groups') do
88
+ f.select(
89
+ lang('sections.labels.custom_field_groups'),
90
+ :custom_field_group_pks,
91
+ :values => @custom_field_group_pk_hash,
92
+ :multiple => :multiple,
93
+ :selected => @section.custom_field_group_pks
94
+ )
105
95
 
106
- end
107
- }
96
+ f.select(
97
+ lang('sections.labels.category_groups'),
98
+ :category_group_pks,
99
+ :values => @category_group_pk_hash,
100
+ :multiple => :multiple,
101
+ :selected => @section.category_group_pks
102
+ )
103
+ end # f.g.div(:id => 'groups')
104
+
105
+ f.g.div(:class => 'button') do
106
+ f.g.input(:type => 'submit', :value => lang('sections.buttons.save'))
107
+ end
108
+ end
109
+ }
110
+ </article>