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
@@ -5,33 +5,34 @@ module Ramaze
5
5
  ##
6
6
  # Helper that can be used to quickly generate breadcrumbs without having
7
7
  # to manually write the HTML separators and formatting the output correctly.
8
- # In order to create a set of breadcrumbs we first need to call the set_breadcrumbs
9
- # method:
8
+ # In order to create a set of breadcrumbs we first need to call the
9
+ # set_breadcrumbs method:
10
10
  #
11
11
  # set_breadcrumbs(segment1, segment2, segment3, etc)
12
12
  #
13
- # Each argument will be a segment of the breadcrumbs, separated by a custom character.
14
- # Retrieving the breadcrumbs is super easy:
13
+ # Each argument will be a segment of the breadcrumbs, separated by a custom
14
+ # character. Retrieving the breadcrumbs is super easy:
15
15
  #
16
16
  # get_breadcrumbs
17
17
  #
18
- # This will generate the correct HTML and return it, all you have to do is output it.
18
+ # This will generate the correct HTML and return it, all you have to do is
19
+ # output it.
19
20
  #
20
21
  # @author Yorick Peterse
21
22
  # @since 0.1
22
23
  #
23
24
  module Breadcrumb
24
25
  @breadcrumbs = []
25
-
26
+
26
27
  ##
27
28
  # Appends each element to the list of breadcrumb segments.
28
29
  #
29
30
  # @example
30
31
  # set_breadcrumbs "Articles", "Edit"
31
32
  #
32
- # Note that you'll have to manually specify anchor tags, this method won't
33
+ # Note that you'll have to manually specify anchor tags, this method won't
33
34
  # automatically generate URLs.
34
- #
35
+ #
35
36
  # @author Yorick Peterse
36
37
  # @param [Array] args Array of segments for the breadcrumbs.
37
38
  # @since 0.1
@@ -39,10 +40,10 @@ module Ramaze
39
40
  def set_breadcrumbs(*args)
40
41
  @breadcrumbs = args
41
42
  end
42
-
43
+
43
44
  ##
44
- # Retrieves all breacrumbs and separates them either by "»" or a custom
45
- # element set as the first argument of this method.
45
+ # Retrieves all breacrumbs and separates them either by "»" or a
46
+ # custom element set as the first argument of this method.
46
47
  #
47
48
  # @example
48
49
  # get_breadcrumbs # => "Articles » Edit"
@@ -51,23 +52,26 @@ module Ramaze
51
52
  # get_breadcrumbs ">" # => "Articles > Edit"
52
53
  #
53
54
  # @author Yorick Peterse
54
- # @param [String] separator The HTML character to use for separating each segment.
55
+ # @param [String] separator The HTML character to use for separating each
56
+ # segment.
55
57
  # @return [String]
56
- #
58
+ #
57
59
  def get_breadcrumbs(separator = "»")
58
60
  if !@breadcrumbs or @breadcrumbs.empty?
59
61
  return
60
62
  end
61
-
63
+
62
64
  html = ''
63
65
  separator = " #{separator} "
64
-
66
+
65
67
  @breadcrumbs.each do |segment|
66
68
  html += segment + separator
67
69
  end
68
-
70
+
71
+ @breadcrumbs = nil
72
+
69
73
  return html.chomp(separator)
70
74
  end
71
- end
72
- end
73
- end
75
+ end # Breadcrumb
76
+ end # Helper
77
+ end # Ramaze
@@ -5,9 +5,9 @@ module Ramaze
5
5
  #:nodoc:
6
6
  module Helper
7
7
  ##
8
- # The Mesage helper is a Ruby implementation of the Codeigniter library "Message"
9
- # (located here: https://github.com/isset/codeigniter-message). This helper was taken
10
- # from another project of mine which can be found here:
8
+ # The Mesage helper is a Ruby implementation of the Codeigniter library
9
+ # "Message" (located here: https://github.com/isset/codeigniter-message).
10
+ # This helper was taken from another project of mine which can be found here:
11
11
  # https://github.com/yorickpeterse/stumpert/
12
12
  #
13
13
  # ## Usage
@@ -5,17 +5,18 @@ module Ramaze
5
5
  #:nodoc:
6
6
  module Helper
7
7
  ##
8
- # Helper that provides a few methods that make certain tasks easier when creating
9
- # themes and templates.
8
+ # Helper that provides a few methods that make certain tasks easier when
9
+ # creating themes and templates.
10
10
  #
11
11
  # @author Yorick Peterse
12
12
  # @since 0.2.5
13
13
  #
14
14
  module Theme
15
15
  ##
16
- # Renders a partial from the current theme's partial directory. The first argument
17
- # is the name of the partial (without an extension) to render. The second argument
18
- # is a hash with variables that should be made available to the partial.
16
+ # Renders a partial from the current theme's partial directory. The first
17
+ # argument is the name of the partial (without an extension) to render.
18
+ # The second argument is a hash with variables that should be made
19
+ # available to the partial.
19
20
  #
20
21
  # @example
21
22
  # partial(:header) # => partials/header.xhtml
@@ -24,18 +25,21 @@ module Ramaze
24
25
  # @author Yorick Peterse
25
26
  # @since 0.2.5
26
27
  # @param [Symbol] file The name of the partial to render.
27
- # @param [Hash] variables A hash with variables that should be made available for
28
- # the partial.
28
+ # @param [Hash] variables A hash with variables that should be made
29
+ # available for the partial.
29
30
  #
30
31
  def partial(file, variables = {})
31
32
  theme = plugin(:settings, :get, :theme).value
32
33
  theme = Zen::Theme[theme]
33
34
 
34
35
  if !theme.respond_to?(:partial_dir) or theme.partial_dir.nil?
35
- raise(::Zen::ThemeError, "The theme #{theme.name} has no partial directory set.")
36
+ raise(
37
+ ::Zen::ThemeError,
38
+ "The theme #{theme.name} has no partial directory set."
39
+ )
36
40
  end
37
41
 
38
- template = "#{theme.partial_dir}/#{file}.xhtml"
42
+ template = File.join(theme.partial_dir, "#{file}.xhtml")
39
43
 
40
44
  if !File.exist?(template)
41
45
  raise(::Zen::ThemeError, "The template #{template} doesn't exist.")
@@ -46,9 +50,10 @@ module Ramaze
46
50
  end
47
51
 
48
52
  ##
49
- # Renders the 404 template for the current theme (clearing the current buffer) and
50
- # sets the HTTP response code to 404. Optionally you can pass a set of variables to
51
- # the 404 template by setting this method's first argument to a hash.
53
+ # Renders the 404 template for the current theme (clearing the current
54
+ # buffer) and sets the HTTP response code to 404. Optionally you can pass
55
+ # a set of variables to the 404 template by setting this method's first
56
+ # argument to a hash.
52
57
  #
53
58
  # @example
54
59
  # show_404
@@ -60,7 +65,7 @@ module Ramaze
60
65
  #
61
66
  def show_404(variables = {})
62
67
  theme = ::Zen::Theme[plugin(:settings, :get, :theme).value]
63
- template = "#{theme.template_dir}/404.xhtml"
68
+ template = File.join(theme.template_dir, '404.xhtml')
64
69
 
65
70
  # Render the template and replace the current buffer with it's output
66
71
  template = render_file(template, variables)
data/lib/zen/language.rb CHANGED
@@ -3,37 +3,39 @@ require __DIR__('error/language_error')
3
3
  #:nodoc:
4
4
  module Zen
5
5
  ##
6
- # The language module is used for writing and using text translations. Translations are
7
- # stored in a simple YAML file inside a directory called "language" followed by a directory
8
- # who's name matches the language code for which it's translations should be used.
9
- # Say we wanted to translate "Login" and "Register" into different languages our YAML
10
- # file would look like the following:
6
+ # The language module is used for writing and using text translations.
7
+ # Translations are stored in a simple YAML file inside a directory called
8
+ # "language" followed by a directory who's name matches the language code for
9
+ # which it's translations should be used. Say we wanted to translate "Login"
10
+ # and "Register" into different languages our YAML file would look like the
11
+ # following:
11
12
  #
12
13
  # ---
13
14
  # login: "Login"
14
15
  # register: "Register"
15
16
  #
16
- # If we save this file under parent_directory/language/en/tutorial.yml we could then
17
- # load that file as following:
17
+ # If we save this file under parent_directory/language/en/tutorial.yml we
18
+ # could then load that file as following:
18
19
  #
19
20
  # Zen::Language.load('tutorial')
20
21
  #
21
22
  # ## Loading Translations
22
23
  #
23
- # The load() method will look for a YAML file of which the name matches the given string
24
- # and can be found in the directory for the current language. This means that if we were
25
- # to switch our language without creating a translation file for that language we wouldn't
26
- # be able to use it (makes sense right?).
24
+ # The load() method will look for a YAML file of which the name matches the
25
+ # given string and can be found in the directory for the current language.
26
+ # This means that if we were to switch our language without creating a
27
+ # translation file for that language we wouldn't be able to use it
28
+ # (makes sense right?).
27
29
  #
28
- # Once your translation file is in place and it's loaded it can be used using the lang()
29
- # method. Example:
30
+ # Once your translation file is in place and it's loaded it can be used using
31
+ # the lang() method. Example:
30
32
  #
31
33
  # lang('tutorial.login') # => "Login"
32
34
  #
33
35
  # ## Directory Structure
34
36
  #
35
- # As mentioned earlier language files are saved in a certain directory. The structure
36
- # of this directory looks like the following:
37
+ # As mentioned earlier language files are saved in a certain directory. The
38
+ # structure of this directory looks like the following:
37
39
  #
38
40
  # parent directory
39
41
  # |
@@ -43,20 +45,21 @@ module Zen
43
45
  # |
44
46
  # |__ filename.yml
45
47
  #
46
- # When loading a language file this module will loop through a certain number of paths.
47
- # The array containing all base directories to loop through can be updated as following:
48
+ # When loading a language file this module will loop through a certain number
49
+ # of paths. The array containing all base directories to loop through can be
50
+ # updated as following:
48
51
  #
49
52
  # Zen::Language.options.paths.push('/path/to/directory')
50
53
  #
51
- # It's important that you _don't_ add a /language segment to the path, this will be done
52
- # automatically.
54
+ # It's important that you _don't_ add a /language segment to the path, this
55
+ # will be done automatically.
53
56
  #
54
57
  # ## Options
55
58
  #
56
59
  # * language: Small string that defines the current language (e.g. "en").
57
- # * paths: Array of paths to look for a language directory. Note that this should be
58
- # the parent directory of the directory called "language", not the actual directory
59
- # itself.
60
+ # * paths: Array of paths to look for a language directory. Note that this
61
+ # should be the parent directory of the directory called "language", not the
62
+ # actual directory itself.
60
63
  #
61
64
  # @author Yorick Peterse
62
65
  # @since 0.2
@@ -68,20 +71,13 @@ module Zen
68
71
  include Innate::Trinity
69
72
  end
70
73
 
71
- ##
72
- # Hash containing all loaded translation files.
73
- #
74
- # @author Yorick Peterse
75
- # @since 0.2.5
76
- #
77
- Registered = {}
74
+ # Hash containing all the translations.
75
+ Translations = {}
76
+
77
+ # Hash containing all the loaded language files for a language.
78
+ Loaded = {}
78
79
 
79
- ##
80
80
  # Hash containing all the available languages.
81
- #
82
- # @author Yorick Peterse
83
- # @since 0.2.6
84
- #
85
81
  Languages = {
86
82
  'en' => 'English',
87
83
  'nl' => 'Nederlands'
@@ -93,8 +89,9 @@ module Zen
93
89
  end
94
90
 
95
91
  ##
96
- # Tries to load a language file for the given name. If no language files were found
97
- # based on the name and the current language an exception will be raised.
92
+ # Tries to load a language file for the given name. If no language files
93
+ # were found based on the name and the current language an exception will
94
+ # be raised.
98
95
  #
99
96
  # Note that this method will load the language pack for *all* languages.
100
97
  #
@@ -106,15 +103,17 @@ module Zen
106
103
  # @param [String] lang_name The name of the language file to load.
107
104
  #
108
105
  def self.load(lang_name)
106
+ lang_name = lang_name.to_s
109
107
  file_found = false
110
108
 
111
109
  Languages.each do |language, label|
112
- Registered[language] ||= {}
110
+ Loaded[language] ||= []
111
+ Translations[language] ||= {}
113
112
 
114
113
  # Abort of the file has already been loaded
115
- if Registered[language][lang_name]
114
+ if Loaded.key?(language) and Loaded[language].include?(lang_name)
116
115
  file_found = true
117
- next
116
+ break
118
117
  end
119
118
 
120
119
  self.options.paths.each do |path|
@@ -125,25 +124,30 @@ module Zen
125
124
  file_found = true
126
125
  translation = YAML.load_file(path)
127
126
 
128
- # Conver the hash to a dot based hash. This means that {:person => {:age => 18}}
129
- # would result in {'person.age' => 18}.
127
+ Loaded[language].push(lang_name)
128
+
129
+ # Conver the hash to a dot based hash. This means that
130
+ # {:person => {:age => 18}} would result in {'person.age' => 18}.
130
131
  translation = self.to_dotted_hash({lang_name.to_s => translation})
131
132
 
132
- Registered[language].merge!(translation)
133
+ Translations[language].merge!(translation)
133
134
  end
134
135
  end
135
136
  end
136
137
 
137
138
  if file_found === false
138
- raise(Zen::LanguageError, "No language file could be found for \"#{lang_name}\"")
139
+ raise(
140
+ Zen::LanguageError,
141
+ "No language file could be found for \"#{lang_name}\""
142
+ )
139
143
  end
140
144
  end
141
145
 
142
146
  private
143
147
 
144
148
  ##
145
- # Method that takes a hash or an array and converts it to a dot-based hash. For example,
146
- # the following hash:
149
+ # Method that takes a hash or an array and converts it to a dot-based hash.
150
+ # For example, the following hash:
147
151
  #
148
152
  # {:name => 'Name', :location => {:street => 'Street', :address => 'Address'}}
149
153
  #
@@ -170,8 +174,8 @@ module Zen
170
174
  # @param [Hash/Array] source The hash or array to conver to a dot-based hash.
171
175
  # @param [Hash] target The hash to store the new key/values in.
172
176
  # @param [String] namespace The namespace for the key (e.g. "user.location").
173
- # @return [Hash] The converted hash where the keys are dot-based strings instead of
174
- # regular strings/symbols with sub hashes.
177
+ # @return [Hash] The converted hash where the keys are dot-based strings
178
+ # instead of regular strings/symbols with sub hashes.
175
179
  #
176
180
  def self.to_dotted_hash(source, target = {}, namespace = nil)
177
181
  if namespace and !namespace.nil?
@@ -180,12 +184,11 @@ module Zen
180
184
  prefix = ""
181
185
  end
182
186
 
183
- case source
184
- when Hash
187
+ if source.class == Hash
185
188
  source.each do |k, v|
186
189
  self.to_dotted_hash(v, target, "#{prefix}#{k}")
187
190
  end
188
- when Array
191
+ elsif source.class == Array
189
192
  source.each_with_index do |v, i|
190
193
  self.to_dotted_hash(v, target, "#{prefix}#{i}")
191
194
  end
@@ -203,8 +206,9 @@ module Zen
203
206
  #:nodoc:
204
207
  module SingletonMethods
205
208
  ##
206
- # Method for retrieving the correct language item based on the given string.
207
- # If you want to retrieve sub-items you can separate each level with a dot:
209
+ # Method for retrieving the correct language item based on the given
210
+ # string. If you want to retrieve sub-items you can separate each level
211
+ # with a dot:
208
212
  #
209
213
  # lang('tutorial.main.sub')
210
214
  #
@@ -214,9 +218,9 @@ module Zen
214
218
  # main:
215
219
  # sub: "Something!"
216
220
  #
217
- # It's important to remember that your key should always include the name of the
218
- # language file since once a file is loaded it will be kept in memory to reduce
219
- # disk usage.
221
+ # It's important to remember that your key should always include the name
222
+ # of the language file since once a file is loaded it will be kept in
223
+ # memory to reduce disk usage.
220
224
  #
221
225
  # @example
222
226
  # lang('username')
@@ -224,8 +228,8 @@ module Zen
224
228
  # @author Yorick Peterse
225
229
  # @since 0.2
226
230
  # @param [String] key The language key to select.
227
- # @param [String] lang The language for which to retrieve the key, overwrites the
228
- # language set in the session.
231
+ # @param [String] lang The language for which to retrieve the key,
232
+ # overwrites the language set in the session.
229
233
  # @return [Mixed]
230
234
  #
231
235
  def lang(key, lang = nil)
@@ -238,7 +242,7 @@ module Zen
238
242
  end
239
243
 
240
244
  groups = []
241
- translations = ::Zen::Language::Registered
245
+ translations = ::Zen::Language::Translations
242
246
 
243
247
  if !translations or !translations.key?(lang)
244
248
  raise(
@@ -1,9 +1,6 @@
1
1
  ---
2
2
  labels:
3
- zen_version : 'Powered by Zen version %s'
4
- zen_website : 'Website'
5
- zen_docs : 'Documentation'
6
- zen_github : 'GitHub Account'
3
+ powered_by : 'Powered by'
7
4
  view_website : 'View Website'
8
5
  logout : 'Logout'
9
6
  profile : 'Profile'
@@ -14,6 +11,7 @@ errors:
14
11
  no_templates : 'No templates were found for the given action.'
15
12
  no_theme : 'No theme has been specified.'
16
13
  invalid_request : 'The request could not be executed as the specified data is incorrect.'
14
+ require_login : 'You need to be logged in in order to view this page.'
17
15
 
18
16
  special:
19
17
  format_hash:
@@ -1,9 +1,6 @@
1
1
  ---
2
2
  labels:
3
- zen_version : 'Deze website draait op Zen versie %s'
4
- zen_website : 'Website'
5
- zen_docs : 'Documentatie'
6
- zen_github : 'GitHub account'
3
+ powered_by : 'Aangedreven door'
7
4
  view_website: 'Bekijk website'
8
5
  logout : 'Uitloggen'
9
6
  profile : 'Profiel'
@@ -14,6 +11,7 @@ errors:
14
11
  no_templates : 'Er konden geen sjablonen worden gevonden voor de huidige actie.'
15
12
  no_theme : 'Er is geen thema ingesteld.'
16
13
  invalid_request: 'De actie kon niet worden uitgevoerd omdat de data onjuist is.'
14
+ require_login : 'U moet ingelogd zijn om deze pagina te kunnen bekijken.'
17
15
 
18
16
  special:
19
17
  format_hash: