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,39 @@
1
+ #:nodoc:
2
+ module Bacon
3
+ #:nodoc:
4
+ module ColorOutput
5
+ #:nodoc:
6
+ def handle_specification(name)
7
+ puts spaces + name
8
+ yield
9
+ puts if Counter[:context_depth] == 1
10
+ end
11
+
12
+ #:nodoc:
13
+ def handle_requirement(description)
14
+ error = yield
15
+
16
+ if !error.empty?
17
+ puts "#{spaces} \e[31m- #{description} [FAILED]\e[0m"
18
+ else
19
+ puts "#{spaces} \e[32m- #{description}\e[0m"
20
+ end
21
+ end
22
+
23
+ #:nodoc:
24
+ def handle_summary
25
+ print ErrorLog if Backtraces
26
+ puts "%d specifications (%d requirements), %d failures, %d errors" %
27
+ Counter.values_at(:specifications, :requirements, :failed, :errors)
28
+ end
29
+
30
+ #:nodoc:
31
+ def spaces
32
+ if Counter[:context_depth] === 0
33
+ Counter[:context_depth] = 1
34
+ end
35
+
36
+ return ' ' * (Counter[:context_depth] - 1)
37
+ end
38
+ end # ColorOutput
39
+ end # Bacon
@@ -0,0 +1,152 @@
1
+ require 'ramaze'
2
+ require 'stringio'
3
+
4
+ Ramaze.setup(:verobse => false) do
5
+ gem 'capybara', ['~> 1.0.0']
6
+ gem 'bacon' , ['~> 1.1.0']
7
+ gem 'webmock' , ['~> 1.6.4']
8
+ end
9
+
10
+ require 'capybara/dsl'
11
+ require 'ramaze/spec/bacon'
12
+ require __DIR__('bacon/color_output')
13
+
14
+ Bacon.extend(Bacon::ColorOutput)
15
+
16
+ # Configure Capybara
17
+ Capybara.configure do |config|
18
+ config.default_driver = :rack_test
19
+ config.app = Ramaze.middleware
20
+ end
21
+
22
+ ##
23
+ # Logs the user in using the spec user.
24
+ #
25
+ # @author Yorick Peterse
26
+ # @since 0.2.8
27
+ #
28
+ def capybara_login
29
+ # Log the user in
30
+ login_url = ::Users::Controller::Users.r(:login).to_s
31
+ dashboard_url = ::Sections::Controller::Sections.r(:index).to_s
32
+
33
+ visit(login_url)
34
+ ::Ramaze::Log.loggers.clear
35
+
36
+ within('#login_form') do
37
+ fill_in('Email' , :with => 'spec@domain.tld')
38
+ fill_in('Password', :with => 'spec')
39
+ click_button('Login')
40
+ end
41
+ end
42
+
43
+ ##
44
+ # Runs the block in a new thread and redirects $stdout and $stderr. The output
45
+ # normally stored in these variables is stored in an instance of StringIO which
46
+ # is returned as a hash.
47
+ #
48
+ # @example
49
+ # out = catch_output do
50
+ # puts 'hello'
51
+ # end
52
+ #
53
+ # puts out # => {:stdout => "hello\n", :stderr => ""}
54
+ #
55
+ # @author Yorick Peterse
56
+ # @since 0.2.8
57
+ # @return [Hash]
58
+ #
59
+ def catch_output
60
+ data = {
61
+ :stdout => nil,
62
+ :stderr => nil
63
+ }
64
+
65
+ Thread.new do
66
+ $stdout, $stderr = StringIO.new, StringIO.new
67
+
68
+ yield
69
+
70
+ $stdout.rewind
71
+ $stderr.rewind
72
+
73
+ data[:stdout], data[:stderr] = $stdout.read, $stderr.read
74
+
75
+ $stdout, $stderr = STDOUT, STDERR
76
+ end.join
77
+
78
+ return data
79
+ end
80
+
81
+ ##
82
+ # Allows developers to create stubbed objects similar to Mocha's stub() method.
83
+ #
84
+ # @example
85
+ # obj = stub(:language => 'Ruby')
86
+ # puts obj.language # => "Ruby"
87
+ #
88
+ # @author Yorick Peterse
89
+ # @since 0.2.8
90
+ # @param [Hash] attributes A hash containing all the attributes to set and
91
+ # their values.
92
+ # @return [Class]
93
+ #
94
+ def stub(attributes)
95
+ obj = Struct.new(*attributes.keys).new
96
+
97
+ attributes.each do |k, v|
98
+ obj.send("#{k}=", v)
99
+ end
100
+
101
+ return obj
102
+ end
103
+
104
+ ##
105
+ # Returns a hash with a stubbed custom field and a stubbed custom field value.
106
+ #
107
+ # @author Yorick Peterse
108
+ # @since 0.2.8
109
+ # @param [String] field_type_name The name of the field type.
110
+ # @param [Hash] options Additional options to pass to the stub() call for the
111
+ # custom field.
112
+ # @return [Hash]
113
+ #
114
+ def stub_custom_field(field_type_name, options = {})
115
+ custom_field_type = CustomFields::Model::CustomFieldType[
116
+ :name => field_type_name
117
+ ]
118
+
119
+ options = {
120
+ :id => 1,
121
+ :name => 'Field',
122
+ :slug => 'field',
123
+ :description => 'A stubbed field',
124
+ :sort_order => 0,
125
+ :format => 'markdown',
126
+ :required => false,
127
+ :text_editor => false,
128
+ :textarea_rows => nil,
129
+ :text_limit => 100,
130
+ :custom_field_group_id => 1,
131
+ :custom_field_type_id => custom_field_type.id,
132
+ :custom_field_type => custom_field_type
133
+ }.merge(options)
134
+
135
+ return {
136
+ :custom_field => stub(options),
137
+ :custom_field_value => stub(
138
+ :id => 1,
139
+ :value => 'Ruby',
140
+ :custom_field_id => 1,
141
+ :section_entry_id => 1
142
+ )
143
+ }
144
+ end
145
+
146
+ shared :capybara do
147
+ Ramaze.setup_dependencies
148
+ extend Capybara::DSL
149
+ extend WebMock::API
150
+
151
+ capybara_login
152
+ end
@@ -0,0 +1,22 @@
1
+ require 'ramaze'
2
+
3
+ Ramaze.setup(:verbose => false) do
4
+ gem 'simplecov', ['~> 0.4.2']
5
+ end
6
+
7
+ SimpleCov.configure do
8
+ root __DIR__('../../../')
9
+ command_name 'bacon'
10
+ project_name 'Zen'
11
+
12
+ add_group 'Packages' , 'zen/package'
13
+ add_group 'Plugins' , 'zen/plugin'
14
+ add_group 'Helpers' , 'zen/helper'
15
+ add_group 'Controllers', 'zen/controller'
16
+
17
+ # Don't actually test the coverage of the tests themselves
18
+ add_filter 'spec'
19
+ add_filter 'lib/zen/model/settings'
20
+ end
21
+
22
+ SimpleCov.start
@@ -1,11 +1,8 @@
1
- ##
2
- # Task group used for building various elements such as the Gem and the documentation.
3
- #
4
- # @author Yorick Peterse
5
- # @since 0.2.5
6
- #
7
- namespace :build do
1
+ require 'open3'
8
2
 
3
+ # Task group used for building various elements such as the Gem and the
4
+ # documentation.
5
+ namespace :build do
9
6
  desc 'Builds the documentation using YARD'
10
7
  task :doc do
11
8
  zen_path = File.expand_path('../../../../', __FILE__)
@@ -17,46 +14,26 @@ namespace :build do
17
14
 
18
15
  desc 'Builds a new Gem'
19
16
  task :gem do
20
- zen_path = File.expand_path('../../../../', __FILE__)
17
+ zen_path = __DIR__('../../../')
18
+ gemspec_path = File.join(
19
+ zen_path,
20
+ "#{Zen::Gemspec.name}-#{Zen::Gemspec.version.version}.gem"
21
+ )
22
+
23
+ pkg_path = File.join(
24
+ zen_path,
25
+ 'pkg',
26
+ "#{Zen::Gemspec.name}-#{Zen::Gemspec.version.version}.gem"
27
+ )
21
28
 
22
29
  # Build and install the gem
23
- sh("gem build #{zen_path}/zen.gemspec")
24
- sh("mv #{zen_path}/zen-#{Zen::Version}.gem #{zen_path}/pkg")
25
- sh("gem install #{zen_path}/pkg/zen-#{Zen::Version}.gem")
26
- end
27
30
 
28
- desc 'Builds the MANIFEST file'
29
- task :manifest do
30
- zen_path = File.expand_path('../../../../', __FILE__)
31
- ignore_exts = ['.gem', '.gemspec', '.swp']
32
- ignore_files = ['.DS_Store', '.gitignore', '.rvmrc']
33
- ignore_dirs = ['.git', '.yardoc', 'spec', 'pkg', 'doc']
34
- files = ''
35
-
36
- Find.find(zen_path) do |f|
37
- f[zen_path] = ''
38
- f.gsub!(/^\//, '')
39
-
40
- # Ignore directories
41
- if !File.directory?(f) and !ignore_exts.include?(File.extname(f)) \
42
- and !ignore_files.include?(File.basename(f))
43
- files += "#{f}\n"
44
- else
45
- Find.prune if ignore_dirs.include?(f)
46
- end
47
- end
48
-
49
- # Time to write the MANIFEST file
50
- begin
51
- handle = File.open 'MANIFEST', 'w'
52
- handle.write files.strip
53
- puts "The MANIFEST file has been updated."
54
- rescue
55
- abort "The MANIFEST file could not be written."
56
- end
31
+ sh('gem', 'build' , File.join(zen_path, 'zen.gemspec'))
32
+ sh('mv' , gemspec_path, pkg_path)
33
+ sh('gem', 'install' , pkg_path)
57
34
  end
58
35
 
59
- # Shamelessly stolen from Ramaze
36
+ # Stolen from Ramaze
60
37
  desc 'Builds a list of all the people that have contributed to Zen'
61
38
  task :authors do
62
39
  authors = Hash.new(0)
@@ -74,4 +51,4 @@ namespace :build do
74
51
  end
75
52
  end
76
53
  end
77
- end
54
+ end # namespace :build
@@ -1,11 +1,7 @@
1
1
  require 'fileutils'
2
2
 
3
- ##
4
- # Task group used to remove various files that aren't needed when releasing gems and such.
5
- #
6
- # @author Yorick Peterse
7
- # @since 0.2.5
8
- #
3
+ # Task group used to remove various files that aren't needed when releasing gems
4
+ # and such.
9
5
  namespace :clean do
10
6
  desc 'Removes all the gems located in pkg/'
11
7
  task :gem do
data/lib/zen/task/db.rake CHANGED
@@ -1,9 +1,5 @@
1
- ##
2
- # Task group for database related tasks such as migrating and removing the database.
3
- #
4
- # @author Yorick Peterse
5
- # @since 0.2.5
6
- #
1
+ # Task group for database related tasks such as migrating and removing the
2
+ # database.
7
3
  namespace :db do
8
4
 
9
5
  desc 'Migrates the database to the newest version'
@@ -75,29 +71,29 @@ namespace :db do
75
71
  number = (0..9).to_a[rand(26)]
76
72
  letter + number.to_s
77
73
  end.join
78
-
74
+
79
75
  # Only insert the user if it isn't there yet.
80
76
  user = Users::Model::User[:email => 'admin@website.tld']
81
77
  group = Users::Model::UserGroup[:slug => 'administrators']
82
-
78
+
83
79
  if group.nil?
84
80
  group = Users::Model::UserGroup.new(
85
81
  :name => 'Administrators',
86
82
  :slug => 'administrators', :super_group => true
87
83
  ).save
88
84
  end
89
-
85
+
90
86
  if !user.nil?
91
87
  abort "The default user has already been inserted."
92
88
  end
93
-
89
+
94
90
  user = Users::Model::User.new(
95
91
  :email => 'admin@website.tld', :name => 'Administrator',
96
92
  :password => password, :status => 'open'
97
93
  ).save
98
-
94
+
99
95
  user.user_group_pks = [group.id]
100
-
96
+
101
97
  puts "Default administrator account has been created.
102
98
 
103
99
  Email: admin@website.tld
@@ -1,20 +1,14 @@
1
- ##
2
1
  # Task group for managing packages.
3
- #
4
- # @author Yorick Peterse
5
- # @since 0.2.5
6
- #
7
2
  namespace :package do
8
-
3
+
9
4
  desc 'Lists all installed packages'
10
5
  task :list do
11
6
  Zen::Package::Registered.each do |name, pkg|
12
7
  message = <<-MSG
13
- --------------------------
14
- Name: #{name}
15
- Author: #{pkg.author}
16
-
8
+ #{name}
9
+ --------------------
17
10
  #{pkg.about}
11
+
18
12
  MSG
19
13
 
20
14
  puts message
@@ -1,20 +1,14 @@
1
- ##
2
1
  # Task group for managing plugins.
3
- #
4
- # @author Yorick Peterse
5
- # @since 0.2.5
6
- #
7
2
  namespace :plugin do
8
3
 
9
4
  desc 'Lists all installed plugins'
10
5
  task :list do
11
6
  Zen::Plugin::Registered.each do |name, pkg|
12
7
  message = <<-MSG
13
- --------------------------
14
- Name: #{name}
15
- Author: #{pkg.author}
16
-
8
+ #{name}
9
+ --------------------
17
10
  #{pkg.about}
11
+
18
12
  MSG
19
13
 
20
14
  puts message
@@ -1,12 +1,6 @@
1
1
  require 'fileutils'
2
- require __DIR__('../ext/string')
3
2
 
4
- ##
5
3
  # Task group used for creating various prototypes.
6
- #
7
- # @author Yorick Peterse
8
- # @since 0.2.5
9
- #
10
4
  namespace :proto do
11
5
 
12
6
  desc 'Creates a new migration'
@@ -36,60 +30,4 @@ namespace :proto do
36
30
  end
37
31
  end
38
32
 
39
- desc 'Creates a new package'
40
- task :package, :directory, :name do |task, args|
41
- # Validate the input
42
- if !args[:name]
43
- abort 'You need to specify the name of your package.'
44
- end
45
-
46
- if !args[:directory]
47
- abort 'You need to specify a directory where the package should be saved.'
48
- end
49
-
50
- name = args[:name]
51
- proto = File.expand_path('../../../../proto/package', __FILE__)
52
- klass = name.camel_case
53
- extension_path = File.join(args[:directory], name)
54
-
55
- FileUtils.rm_rf(extension_path)
56
-
57
- # Rename all files and folders
58
- begin
59
- FileUtils.cp_r(proto, extension_path)
60
-
61
- lib_path = "#{extension_path}/lib/#{name}"
62
-
63
- # Rename the base file and directory
64
- FileUtils.mv("#{extension_path}/lib/package" , lib_path)
65
- FileUtils.mv("#{extension_path}/lib/package.rb", "#{extension_path}/lib/#{name}.rb")
66
-
67
- controller_filename = klass.snake_case.pluralize
68
- model_filename = klass.snake_case.singularize
69
-
70
- # Generate the controller
71
- controller = File.open("#{lib_path}/controller/controllers.rb", 'r').read
72
- controller.gsub!('CONTROLLER', klass.pluralize)
73
- controller.gsub!('EXTENSION' , klass.pluralize)
74
-
75
- FileUtils.mv("#{lib_path}/controller/controllers.rb", "#{lib_path}/controller/#{controller_filename}.rb")
76
- File.open("#{lib_path}/controller/#{controller_filename}.rb", 'w').write(controller)
77
-
78
- # Move the view directory
79
- FileUtils.mv("#{lib_path}/view/admin/package", "#{lib_path}/view/admin/#{controller_filename}")
80
-
81
- # Generate the model
82
- model = File.open("#{lib_path}/model/model.rb", 'r').read
83
- model.gsub!('MODEL' , klass.singularize)
84
- model.gsub!('EXTENSION' , klass.pluralize)
85
-
86
- FileUtils.mv("#{lib_path}/model/model.rb", "#{lib_path}/model/#{model_filename}.rb")
87
- File.open("#{lib_path}/model/#{model_filename}.rb", 'w').write(model)
88
-
89
- puts "Done! Don't forget to rename the controllers/models/etc"
90
- rescue => e
91
- abort "Failed to generate the package: #{e}"
92
- end
93
- end
94
-
95
33
  end