zen 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +15 -0
- data/.mailmap +2 -0
- data/.rvmrc +2 -0
- data/.travis.yml +8 -3
- data/AUTHORS +1 -2
- data/CHANGELOG.md +48 -17
- data/README.md +44 -39
- data/Rakefile +4 -0
- data/bin/zen +5 -30
- data/lib/zen.rb +13 -19
- data/lib/zen/asset.rb +99 -64
- data/lib/zen/bin/create.rb +94 -0
- data/lib/zen/bin/runner.rb +118 -0
- data/lib/zen/controller/admin_controller.rb +52 -36
- data/lib/zen/controller/base_controller.rb +5 -5
- data/lib/zen/controller/frontend_controller.rb +7 -7
- data/lib/zen/controller/main_controller.rb +12 -10
- data/lib/zen/controller/preview.rb +15 -11
- data/lib/zen/helper/acl.rb +73 -53
- data/lib/zen/helper/blue_form_vendor.rb +689 -0
- data/lib/zen/helper/breadcrumb.rb +23 -19
- data/lib/zen/helper/message.rb +3 -3
- data/lib/zen/helper/theme.rb +18 -13
- data/lib/zen/language.rb +62 -58
- data/lib/zen/language/en/zen_general.yml +2 -4
- data/lib/zen/language/nl/zen_general.yml +2 -4
- data/lib/zen/layout/admin.xhtml +3 -12
- data/lib/zen/layout/login.xhtml +1 -6
- data/lib/zen/model/methods.rb +6 -6
- data/lib/zen/model/settings.rb +5 -4
- data/lib/zen/package.rb +47 -38
- data/lib/zen/package/all.rb +3 -5
- data/lib/zen/package/base.rb +7 -7
- data/lib/zen/package/categories/lib/categories.rb +8 -3
- data/lib/zen/package/categories/lib/categories/controller/categories.rb +81 -55
- data/lib/zen/package/categories/lib/categories/controller/category_groups.rb +45 -44
- data/lib/zen/package/categories/lib/categories/helper/category.rb +88 -0
- data/lib/zen/package/categories/lib/categories/language/en/categories.yml +5 -4
- data/lib/zen/package/categories/lib/categories/language/en/category_groups.yml +5 -4
- data/lib/zen/package/categories/lib/categories/language/nl/categories.yml +5 -4
- data/lib/zen/package/categories/lib/categories/language/nl/category_groups.yml +5 -4
- data/lib/zen/package/categories/lib/categories/model/category.rb +15 -13
- data/lib/zen/package/categories/lib/categories/model/category_group.rb +3 -3
- data/lib/zen/package/categories/lib/categories/plugin/categories.rb +36 -25
- data/lib/zen/package/categories/lib/categories/view/admin/categories/form.xhtml +49 -56
- data/lib/zen/package/categories/lib/categories/view/admin/categories/index.xhtml +48 -35
- data/lib/zen/package/categories/lib/categories/view/admin/category-groups/form.xhtml +36 -29
- data/lib/zen/package/categories/lib/categories/view/admin/category-groups/index.xhtml +42 -37
- data/lib/zen/package/comments/lib/comments.rb +4 -1
- data/lib/zen/package/comments/lib/comments/controller/comments.rb +39 -32
- data/lib/zen/package/comments/lib/comments/controller/comments_form.rb +45 -26
- data/lib/zen/package/comments/lib/comments/helper/comment.rb +35 -0
- data/lib/zen/package/comments/lib/comments/language/en/comments.yml +9 -7
- data/lib/zen/package/comments/lib/comments/language/nl/comments.yml +10 -8
- data/lib/zen/package/comments/lib/comments/model/comment.rb +31 -17
- data/lib/zen/package/comments/lib/comments/model/comment_status.rb +15 -0
- data/lib/zen/package/comments/lib/comments/plugin/anti_spam.rb +27 -18
- data/lib/zen/package/comments/lib/comments/plugin/comments.rb +25 -20
- data/lib/zen/package/comments/lib/comments/view/admin/comments/form.xhtml +61 -54
- data/lib/zen/package/comments/lib/comments/view/admin/comments/index.xhtml +38 -23
- data/lib/zen/package/comments/migrations/1308774099_comment_status.rb +60 -0
- data/lib/zen/package/custom_fields/lib/custom_fields.rb +33 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/blue_form_parameters.rb +209 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +50 -47
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_types.rb +215 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_fields.rb +111 -73
- data/lib/zen/package/custom_fields/lib/custom_fields/helper/custom_field.rb +79 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_field_groups.yml +20 -19
- data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_field_types.yml +40 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_fields.yml +34 -32
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_groups.yml +5 -4
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_types.yml +40 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_fields.yml +18 -16
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field.rb +31 -11
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_method.rb +15 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_type.rb +50 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb +28 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/form.xhtml +33 -28
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/index.xhtml +48 -46
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-types/form.xhtml +61 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-types/index.xhtml +93 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/form.xhtml +105 -99
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/index.xhtml +43 -39
- data/lib/zen/package/custom_fields/migrations/1295255665_create_schema.rb +47 -16
- data/lib/zen/package/custom_fields/migrations/1310659580_custom_field_types.rb +148 -0
- data/lib/zen/package/custom_fields/migrations/1311694920_rename_css_class.rb +11 -0
- data/lib/zen/package/menus/lib/menus/controller/menu_items.rb +40 -35
- data/lib/zen/package/menus/lib/menus/controller/menus.rb +47 -43
- data/lib/zen/package/menus/lib/menus/helper/{menu_item.rb → menu.rb} +42 -15
- data/lib/zen/package/menus/lib/menus/language/en/menu_items.yml +5 -5
- data/lib/zen/package/menus/lib/menus/language/en/menus.yml +9 -8
- data/lib/zen/package/menus/lib/menus/language/nl/menu_items.yml +8 -8
- data/lib/zen/package/menus/lib/menus/language/nl/menus.yml +11 -10
- data/lib/zen/package/menus/lib/menus/model/menu.rb +5 -5
- data/lib/zen/package/menus/lib/menus/model/menu_item.rb +6 -5
- data/lib/zen/package/menus/lib/menus/plugin/menus.rb +41 -43
- data/lib/zen/package/menus/lib/menus/view/admin/menu-items/form.xhtml +59 -63
- data/lib/zen/package/menus/lib/menus/view/admin/menu-items/index.xhtml +35 -30
- data/lib/zen/package/menus/lib/menus/view/admin/menus/form.xhtml +46 -37
- data/lib/zen/package/menus/lib/menus/view/admin/menus/index.xhtml +37 -37
- data/lib/zen/package/menus/migrations/1297184342_create_schema.rb +5 -5
- data/lib/zen/package/menus/migrations/1308671733_rename_order_column.rb +11 -0
- data/lib/zen/package/menus/migrations/1311695030_rename_css_class.rb +17 -0
- data/lib/zen/package/sections/lib/sections.rb +18 -11
- data/lib/zen/package/sections/lib/sections/controller/section_entries.rb +115 -109
- data/lib/zen/package/sections/lib/sections/controller/sections.rb +72 -50
- data/lib/zen/package/sections/lib/sections/helper/section.rb +53 -0
- data/lib/zen/package/sections/lib/sections/language/en/section_entries.yml +5 -4
- data/lib/zen/package/sections/lib/sections/language/en/sections.yml +5 -4
- data/lib/zen/package/sections/lib/sections/language/nl/section_entries.yml +5 -4
- data/lib/zen/package/sections/lib/sections/language/nl/sections.yml +5 -4
- data/lib/zen/package/sections/lib/sections/model/section.rb +17 -9
- data/lib/zen/package/sections/lib/sections/model/section_entry.rb +192 -13
- data/lib/zen/package/sections/lib/sections/model/section_entry_status.rb +13 -0
- data/lib/zen/package/sections/lib/sections/plugin/section_entries.rb +60 -39
- data/lib/zen/package/sections/lib/sections/plugin/sections.rb +14 -11
- data/lib/zen/package/sections/lib/sections/view/admin/form.xhtml +100 -97
- data/lib/zen/package/sections/lib/sections/view/admin/index.xhtml +41 -39
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/form.xhtml +95 -215
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/index.xhtml +48 -40
- data/lib/zen/package/sections/migrations/1308672298_use_id_for_default_section.rb +40 -0
- data/lib/zen/package/sections/migrations/1308813320_section_entry_statuses.rb +58 -0
- data/lib/zen/package/settings/lib/settings/controller/settings.rb +5 -8
- data/lib/zen/package/settings/lib/settings/model/setting.rb +2 -37
- data/lib/zen/package/settings/lib/settings/plugin/setting_base.rb +18 -1
- data/lib/zen/package/settings/lib/settings/plugin/settings.rb +13 -7
- data/lib/zen/package/settings/lib/settings/view/admin/settings/index.xhtml +2 -1
- data/lib/zen/package/users/lib/users.rb +3 -1
- data/lib/zen/package/users/lib/users/controller/access_rules.rb +77 -60
- data/lib/zen/package/users/lib/users/controller/user_groups.rb +41 -36
- data/lib/zen/package/users/lib/users/controller/users.rb +48 -42
- data/lib/zen/package/users/lib/users/helper/users.rb +72 -0
- data/lib/zen/package/users/lib/users/language/en/access_rules.yml +6 -5
- data/lib/zen/package/users/lib/users/language/en/user_groups.yml +5 -4
- data/lib/zen/package/users/lib/users/language/en/users.yml +1 -0
- data/lib/zen/package/users/lib/users/language/nl/access_rules.yml +5 -4
- data/lib/zen/package/users/lib/users/language/nl/user_groups.yml +5 -4
- data/lib/zen/package/users/lib/users/language/nl/users.yml +1 -0
- data/lib/zen/package/users/lib/users/model/access_rule.rb +5 -1
- data/lib/zen/package/users/lib/users/model/user.rb +17 -10
- data/lib/zen/package/users/lib/users/public/admin/js/users/access_rules.js +10 -37
- data/lib/zen/package/users/lib/users/public/admin/js/users/lib/access_rules.js +49 -0
- data/lib/zen/package/users/lib/users/view/admin/access-rules/form.xhtml +105 -96
- data/lib/zen/package/users/lib/users/view/admin/access-rules/index.xhtml +48 -41
- data/lib/zen/package/users/lib/users/view/admin/user-groups/form.xhtml +42 -32
- data/lib/zen/package/users/lib/users/view/admin/user-groups/index.xhtml +43 -38
- data/lib/zen/package/users/lib/users/view/admin/users/form.xhtml +76 -67
- data/lib/zen/package/users/lib/users/view/admin/users/index.xhtml +43 -41
- data/lib/zen/package/users/lib/users/view/admin/users/login.xhtml +12 -9
- data/lib/zen/package/users/migrations/1295281013_create_schema.rb +2 -2
- data/lib/zen/plugin.rb +56 -50
- data/lib/zen/plugin/markup/lib/markup/markup.rb +33 -21
- data/lib/zen/public/admin/css/zen/buttons.css +11 -7
- data/lib/zen/public/admin/css/zen/datepicker.css +6 -6
- data/lib/zen/public/admin/css/zen/forms.css +2 -1
- data/lib/zen/public/admin/css/zen/general.css +15 -10
- data/lib/zen/public/admin/css/zen/layout.css +51 -20
- data/lib/zen/public/admin/css/zen/tables.css +39 -11
- data/lib/zen/public/admin/css/zen/tabs.css +6 -4
- data/lib/zen/public/admin/css/zen/window.css +11 -11
- data/lib/zen/public/{favicon.ico → admin/favicon.ico} +0 -0
- data/lib/zen/public/admin/images/zen/icons/asc.png +0 -0
- data/lib/zen/public/admin/images/zen/icons/desc.png +0 -0
- data/lib/zen/public/admin/js/vendor/datepicker.js +0 -11
- data/lib/zen/public/admin/js/{mootools → vendor/mootools}/core.js +0 -1
- data/lib/zen/public/admin/js/{mootools → vendor/mootools}/more.js +100 -29
- data/lib/zen/public/admin/js/zen/index.js +48 -0
- data/lib/zen/public/admin/js/zen/lib/asset.js +111 -0
- data/lib/zen/public/admin/js/zen/{editor.js → lib/editor.js} +107 -127
- data/lib/zen/public/admin/js/zen/{editor → lib/editor}/markdown.js +7 -9
- data/lib/zen/public/admin/js/zen/{editor → lib/editor}/textile.js +7 -9
- data/lib/zen/public/admin/js/zen/lib/html_table.js +143 -0
- data/lib/zen/public/admin/js/zen/{tabs.js → lib/tabs.js} +40 -37
- data/lib/zen/public/admin/js/zen/{window.js → lib/window.js} +24 -20
- data/lib/zen/spec/bacon/color_output.rb +39 -0
- data/lib/zen/spec/helper.rb +152 -0
- data/lib/zen/spec/simplecov.rb +22 -0
- data/lib/zen/task/build.rake +20 -43
- data/lib/zen/task/clean.rake +2 -6
- data/lib/zen/task/db.rake +8 -12
- data/lib/zen/task/package.rake +4 -10
- data/lib/zen/task/plugin.rake +3 -9
- data/lib/zen/task/proto.rake +0 -62
- data/lib/zen/task/test.rake +6 -3
- data/lib/zen/task/theme.rake +4 -11
- data/lib/zen/theme.rb +22 -24
- data/lib/zen/validation.rb +34 -27
- data/lib/zen/version.rb +2 -8
- data/lib/zen/view/head.xhtml +7 -0
- data/lib/zen/view/main.xhtml +7 -22
- data/{proto/package/migrations → pkg}/.gitkeep +0 -0
- data/proto/app/app.rb +1 -0
- data/proto/app/config/config.rb +5 -4
- data/proto/app/config/database.rb +19 -41
- data/proto/app/config/middlewares.rb +32 -29
- data/proto/{package/lib/package/view/admin/package/index.xhtml → app/log/database/dev/.gitkeep} +0 -0
- data/proto/app/log/database/live/.gitkeep +0 -0
- data/spec/Rakefile +26 -0
- data/spec/fixtures/zen/asset.rb +18 -0
- data/spec/fixtures/zen/helper/acl.rb +39 -0
- data/spec/fixtures/zen/helper/message.rb +19 -0
- data/spec/fixtures/zen/language/en/spec.yml +10 -0
- data/spec/fixtures/zen/language/nl/spec.yml +7 -0
- data/spec/fixtures/zen/package.rb +17 -0
- data/spec/fixtures/zen/package/comments/controller/comments_form.rb +27 -0
- data/spec/fixtures/zen/package/settings/plugin/settings.rb +20 -0
- data/spec/fixtures/zen/plugin.rb +7 -0
- data/spec/fixtures/zen/theme/404.xhtml +1 -0
- data/spec/fixtures/zen/theme/default-section/index.xhtml +1 -0
- data/spec/fixtures/zen/theme/helper/404.xhtml +1 -0
- data/spec/fixtures/zen/theme/helper/partial.xhtml +1 -0
- data/spec/fixtures/zen/theme/helper/wrong_partial.xhtml +1 -0
- data/spec/fixtures/zen/theme/partials/partial.xhtml +1 -0
- data/spec/fixtures/zen/theme/theme.rb +11 -0
- data/spec/fixtures/zen/validation.rb +22 -0
- data/spec/helper.rb +41 -0
- data/spec/zen/all.rb +5 -0
- data/spec/zen/asset.rb +97 -0
- data/spec/zen/bin/create.rb +89 -0
- data/spec/zen/bin/runner.rb +47 -0
- data/spec/zen/controller/admin_controller.rb +26 -0
- data/spec/zen/controller/main_controller.rb +81 -0
- data/spec/zen/controller/preview.rb +33 -0
- data/spec/zen/helper/acl.rb +149 -0
- data/spec/zen/helper/breadcrumb.rb +38 -0
- data/spec/zen/helper/message.rb +31 -0
- data/spec/zen/helper/theme.rb +58 -0
- data/spec/zen/language.rb +55 -0
- data/spec/zen/package.rb +23 -0
- data/spec/zen/package/categories/controller/categories.rb +123 -0
- data/spec/zen/package/categories/controller/category_groups.rb +108 -0
- data/spec/zen/package/categories/helper/category.rb +75 -0
- data/spec/zen/package/categories/plugin/categories.rb +92 -0
- data/spec/zen/package/comments/controller/comments.rb +134 -0
- data/spec/zen/package/comments/controller/comments_form.rb +343 -0
- data/spec/zen/package/comments/helper/comment.rb +47 -0
- data/spec/zen/package/comments/plugin/anti_spam.rb +59 -0
- data/spec/zen/package/comments/plugin/comments.rb +107 -0
- data/spec/zen/package/custom_fields/blue_form_parameters.rb +183 -0
- data/spec/zen/package/custom_fields/controller/custom_field_groups.rb +120 -0
- data/spec/zen/package/custom_fields/controller/custom_field_types.rb +169 -0
- data/spec/zen/package/custom_fields/controller/custom_fields.rb +158 -0
- data/spec/zen/package/custom_fields/helper/custom_field.rb +86 -0
- data/spec/zen/package/menus/controller/menu_items.rb +110 -0
- data/spec/zen/package/menus/controller/menus.rb +110 -0
- data/spec/zen/package/menus/helper/menu.rb +75 -0
- data/spec/zen/package/menus/plugin/menus.rb +120 -0
- data/spec/zen/package/sections/controller/section_entries.rb +201 -0
- data/spec/zen/package/sections/controller/sections.rb +116 -0
- data/spec/zen/package/sections/helper/section.rb +74 -0
- data/spec/zen/package/sections/plugin/section_entries.rb +161 -0
- data/spec/zen/package/sections/plugin/sections.rb +75 -0
- data/spec/zen/package/settings/controller/settings.rb +36 -0
- data/spec/zen/package/settings/plugin/settings.rb +33 -0
- data/spec/zen/package/users/controller/access_rules.rb +90 -0
- data/spec/zen/package/users/controller/user_groups.rb +101 -0
- data/spec/zen/package/users/controller/users.rb +130 -0
- data/spec/zen/package/users/helper/users.rb +97 -0
- data/spec/zen/plugin.rb +64 -0
- data/spec/zen/plugin/helper.rb +11 -0
- data/spec/zen/plugin/markup.rb +44 -0
- data/spec/zen/theme.rb +41 -0
- data/spec/zen/validation.rb +63 -0
- data/zen.gemspec +36 -0
- metadata +159 -113
- data/MANIFEST +0 -266
- data/lib/zen/bin/app.rb +0 -40
- data/lib/zen/ext/string.rb +0 -185
- data/lib/zen/helper/common.rb +0 -106
- data/lib/zen/package/categories/lib/categories/view/admin/categories/edit.xhtml +0 -7
- data/lib/zen/package/categories/lib/categories/view/admin/categories/new.xhtml +0 -7
- data/lib/zen/package/categories/lib/categories/view/admin/category-groups/edit.xhtml +0 -7
- data/lib/zen/package/categories/lib/categories/view/admin/category-groups/new.xhtml +0 -7
- data/lib/zen/package/comments/lib/comments/view/admin/comments/edit.xhtml +0 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/edit.xhtml +0 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/new.xhtml +0 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/edit.xhtml +0 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/new.xhtml +0 -7
- data/lib/zen/package/menus/lib/menus/view/admin/menu-items/edit.xhtml +0 -7
- data/lib/zen/package/menus/lib/menus/view/admin/menu-items/new.xhtml +0 -7
- data/lib/zen/package/menus/lib/menus/view/admin/menus/edit.xhtml +0 -7
- data/lib/zen/package/menus/lib/menus/view/admin/menus/new.xhtml +0 -7
- data/lib/zen/package/sections/lib/sections/view/admin/edit.xhtml +0 -7
- data/lib/zen/package/sections/lib/sections/view/admin/new.xhtml +0 -7
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/edit.xhtml +0 -7
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/new.xhtml +0 -7
- data/lib/zen/package/users/lib/users/view/admin/access-rules/edit.xhtml +0 -7
- data/lib/zen/package/users/lib/users/view/admin/access-rules/new.xhtml +0 -7
- data/lib/zen/package/users/lib/users/view/admin/user-groups/edit.xhtml +0 -7
- data/lib/zen/package/users/lib/users/view/admin/user-groups/new.xhtml +0 -7
- data/lib/zen/package/users/lib/users/view/admin/users/edit.xhtml +0 -7
- data/lib/zen/package/users/lib/users/view/admin/users/new.xhtml +0 -7
- data/lib/zen/plugin/controller.rb +0 -59
- data/lib/zen/public/admin/css/zen/notifications.css +0 -84
- data/lib/zen/public/admin/images/zen/icons/large/error.png +0 -0
- data/lib/zen/public/admin/images/zen/icons/large/notice.png +0 -0
- data/lib/zen/public/admin/images/zen/icons/large/success.png +0 -0
- data/lib/zen/public/admin/js/zen/core.js +0 -73
- data/lib/zen/public/admin/js/zen/init.js +0 -80
- data/proto/package/lib/package.rb +0 -21
- data/proto/package/lib/package/controller/controllers.rb +0 -50
- data/proto/package/lib/package/language/en/languages.yml +0 -4
- data/proto/package/lib/package/model/model.rb +0 -12
@@ -1,10 +1,12 @@
|
|
1
|
+
#:nodoc:
|
1
2
|
module Categories
|
3
|
+
#:nodoc:
|
2
4
|
module Controller
|
3
5
|
##
|
4
|
-
# Category groups can be used to group a number of categories into a single
|
5
|
-
# These groups are assigned to a section (rather than individual
|
6
|
-
# important to remember that a section entry can't use a
|
7
|
-
# been added to a section.
|
6
|
+
# Category groups can be used to group a number of categories into a single
|
7
|
+
# container. These groups are assigned to a section (rather than individual
|
8
|
+
# categories). It's important to remember that a section entry can't use a
|
9
|
+
# category group until it has been added to a section.
|
8
10
|
#
|
9
11
|
# @author Yorick Peterse
|
10
12
|
# @since 0.1
|
@@ -12,7 +14,8 @@ module Categories
|
|
12
14
|
class CategoryGroups < Zen::Controller::AdminController
|
13
15
|
include ::Categories::Model
|
14
16
|
|
15
|
-
|
17
|
+
helper :category
|
18
|
+
map '/admin/category-groups'
|
16
19
|
|
17
20
|
before_all do
|
18
21
|
csrf_protection(:save, :delete) do
|
@@ -21,8 +24,8 @@ module Categories
|
|
21
24
|
end
|
22
25
|
|
23
26
|
##
|
24
|
-
# The constructor is used to set various options such as the form URLs and
|
25
|
-
# the language pack for the categories module.
|
27
|
+
# The constructor is used to set various options such as the form URLs and
|
28
|
+
# load the language pack for the categories module.
|
26
29
|
#
|
27
30
|
# The following language files are loaded:
|
28
31
|
#
|
@@ -34,9 +37,6 @@ module Categories
|
|
34
37
|
def initialize
|
35
38
|
super
|
36
39
|
|
37
|
-
@form_save_url = CategoryGroups.r(:save)
|
38
|
-
@form_delete_url = CategoryGroups.r(:delete)
|
39
|
-
|
40
40
|
Zen::Language.load('category_groups')
|
41
41
|
|
42
42
|
# Set the page title
|
@@ -58,13 +58,11 @@ module Categories
|
|
58
58
|
# @since 0.1
|
59
59
|
#
|
60
60
|
def index
|
61
|
-
|
62
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
63
|
-
end
|
61
|
+
require_permissions(:read)
|
64
62
|
|
65
63
|
set_breadcrumbs(lang('category_groups.titles.index'))
|
66
64
|
|
67
|
-
@category_groups = CategoryGroup
|
65
|
+
@category_groups = paginate(CategoryGroup)
|
68
66
|
end
|
69
67
|
|
70
68
|
##
|
@@ -77,25 +75,26 @@ module Categories
|
|
77
75
|
# @author Yorick Peterse
|
78
76
|
# @since 0.1
|
79
77
|
#
|
80
|
-
def edit
|
81
|
-
|
82
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
83
|
-
end
|
78
|
+
def edit(id)
|
79
|
+
require_permissions(:read, :update)
|
84
80
|
|
85
81
|
set_breadcrumbs(
|
86
|
-
|
82
|
+
CategoryGroups.a(lang('category_groups.titles.index'), :index),
|
87
83
|
lang('category_groups.titles.edit')
|
88
84
|
)
|
89
85
|
|
90
86
|
if flash[:form_data]
|
91
87
|
@category_group = flash[:form_data]
|
92
88
|
else
|
93
|
-
@category_group =
|
89
|
+
@category_group = validate_category_group(id)
|
94
90
|
end
|
91
|
+
|
92
|
+
render_view(:form)
|
95
93
|
end
|
96
94
|
|
97
95
|
##
|
98
|
-
# Create a new category group. This method requires the following
|
96
|
+
# Create a new category group. This method requires the following
|
97
|
+
# permissions:
|
99
98
|
#
|
100
99
|
# * create
|
101
100
|
# * read
|
@@ -104,16 +103,16 @@ module Categories
|
|
104
103
|
# @since 0.1
|
105
104
|
#
|
106
105
|
def new
|
107
|
-
|
108
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
109
|
-
end
|
106
|
+
require_permissions(:create, :read)
|
110
107
|
|
111
108
|
set_breadcrumbs(
|
112
|
-
|
109
|
+
CategoryGroups.a(lang('category_groups.titles.index'), :index),
|
113
110
|
lang('category_groups.titles.new')
|
114
111
|
)
|
115
112
|
|
116
113
|
@category_group = CategoryGroup.new
|
114
|
+
|
115
|
+
render_view(:form)
|
117
116
|
end
|
118
117
|
|
119
118
|
##
|
@@ -127,18 +126,18 @@ module Categories
|
|
127
126
|
# @since 0.1
|
128
127
|
#
|
129
128
|
def save
|
130
|
-
if !user_authorized?([:create, :update])
|
131
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
132
|
-
end
|
133
|
-
|
134
129
|
post = request.subset(:id, :name, :description)
|
135
130
|
|
136
131
|
if post['id'] and !post['id'].empty?
|
137
|
-
|
138
|
-
|
132
|
+
require_permissions(:update)
|
133
|
+
|
134
|
+
category_group = validate_category_group(post['id'])
|
135
|
+
save_action = :save
|
139
136
|
else
|
140
|
-
|
141
|
-
|
137
|
+
require_permissions(:create)
|
138
|
+
|
139
|
+
category_group = CategoryGroup.new
|
140
|
+
save_action = :new
|
142
141
|
end
|
143
142
|
|
144
143
|
# Set the messages
|
@@ -149,18 +148,20 @@ module Categories
|
|
149
148
|
|
150
149
|
# Try to run the query
|
151
150
|
begin
|
152
|
-
|
151
|
+
category_group.update(post)
|
153
152
|
message(:success, flash_success)
|
154
153
|
rescue => e
|
155
154
|
message(:error, flash_error)
|
156
155
|
Ramaze::Log.error(e.inspect)
|
157
156
|
|
158
|
-
flash[:form_data] =
|
159
|
-
flash[:form_errors] =
|
157
|
+
flash[:form_data] = category_group
|
158
|
+
flash[:form_errors] = category_group.errors
|
159
|
+
|
160
|
+
redirect_referrer
|
160
161
|
end
|
161
162
|
|
162
|
-
if
|
163
|
-
redirect(CategoryGroups.r(:edit,
|
163
|
+
if !category_group.nil? and category_group.id
|
164
|
+
redirect(CategoryGroups.r(:edit, category_group.id))
|
164
165
|
else
|
165
166
|
redirect(CategoryGroups.r(:new))
|
166
167
|
end
|
@@ -168,9 +169,9 @@ module Categories
|
|
168
169
|
|
169
170
|
##
|
170
171
|
# Delete all specified category groups and their categories. In
|
171
|
-
# order to delete a number of groups an array of fields, named
|
172
|
-
# is required. This array will contain all the
|
173
|
-
# has to be deleted.
|
172
|
+
# order to delete a number of groups an array of fields, named
|
173
|
+
# "category_group_ids" is required. This array will contain all the
|
174
|
+
# primary values of each group that has to be deleted.
|
174
175
|
#
|
175
176
|
# This method requires the following permissions:
|
176
177
|
#
|
@@ -180,9 +181,7 @@ module Categories
|
|
180
181
|
# @since 0.1
|
181
182
|
#
|
182
183
|
def delete
|
183
|
-
|
184
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
185
|
-
end
|
184
|
+
require_permissions(:delete)
|
186
185
|
|
187
186
|
post = request.subset(:category_group_ids)
|
188
187
|
|
@@ -198,6 +197,8 @@ module Categories
|
|
198
197
|
rescue => e
|
199
198
|
Ramaze::Log.error(e.inspect)
|
200
199
|
message(:error, lang('category_groups.errors.delete') % id)
|
200
|
+
|
201
|
+
redirect_referrer
|
201
202
|
end
|
202
203
|
end
|
203
204
|
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#:nodoc:
|
2
|
+
module Ramaze
|
3
|
+
#:nodoc:
|
4
|
+
module Helper
|
5
|
+
##
|
6
|
+
# Helper for the Categories package. Note that this helper requires the
|
7
|
+
# helper Ramaze::Helper::Message to be loaded.
|
8
|
+
#
|
9
|
+
# @author Yorick Peterse
|
10
|
+
# @since 0.2.8
|
11
|
+
#
|
12
|
+
module Category
|
13
|
+
##
|
14
|
+
# Checks if the specified category group ID results in a valid instance of
|
15
|
+
# Categories::Model::CategoryGroup. If this is the case the object is
|
16
|
+
# returned, otherwise the user is redirected back to the overview of all
|
17
|
+
# category groups and is informed about the group being invalid.
|
18
|
+
#
|
19
|
+
# @author Yorick Peterse
|
20
|
+
# @since 0.2.8
|
21
|
+
# @param [Fixnum] category_group_id The ID of the category group to
|
22
|
+
# validate.
|
23
|
+
# @return [Categories::Model::CategoryGroup]
|
24
|
+
#
|
25
|
+
def validate_category_group(category_group_id)
|
26
|
+
group = ::Categories::Model::CategoryGroup[category_group_id]
|
27
|
+
|
28
|
+
if group.nil?
|
29
|
+
message(:error, lang('category_groups.errors.invalid_group'))
|
30
|
+
redirect(::Categories::Controller::CategoryGroups.r(:index))
|
31
|
+
else
|
32
|
+
return group
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
##
|
37
|
+
# Similar to validate_category_group this method checks if a category is
|
38
|
+
# valid or not. If it's valid the object is returned, otherwise an error
|
39
|
+
# is displayed and the user is redirected back to the overview of
|
40
|
+
# categories.
|
41
|
+
#
|
42
|
+
# @author Yorick Peterse
|
43
|
+
# @since 0.2.8
|
44
|
+
# @param [Fixnum] category_id The ID of the category.
|
45
|
+
# @param [Fixnum] category_group_id The ID of the category group, used
|
46
|
+
# when redirecting the user.
|
47
|
+
# @return [Categories::Model::Category]
|
48
|
+
#
|
49
|
+
def validate_category(category_id, category_group_id)
|
50
|
+
category = ::Categories::Model::Category[category_id]
|
51
|
+
|
52
|
+
if category.nil?
|
53
|
+
message(:error, lang('categories.errors.invalid_category'))
|
54
|
+
redirect(
|
55
|
+
::Categories::Controller::Categories.r(:index, category_group_id)
|
56
|
+
)
|
57
|
+
else
|
58
|
+
return category
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Method that extracts all the possible parent categories for a given
|
64
|
+
# category group ID.
|
65
|
+
#
|
66
|
+
# @author Yorick Peterse
|
67
|
+
# @since 0.2.8
|
68
|
+
# @param [Fixnum[ category_id The ID of the category, this one will be
|
69
|
+
# excluded from the hash.
|
70
|
+
# @param [Fixnum] category_group_id The ID of a category group for which
|
71
|
+
# to retrieve all the possible parent items.
|
72
|
+
# @return [Hash]
|
73
|
+
#
|
74
|
+
def parent_categories(category_id, category_group_id)
|
75
|
+
parent_categories = {}
|
76
|
+
|
77
|
+
Categories::Model::CategoryGroup[category_group_id].categories \
|
78
|
+
.each do |c|
|
79
|
+
parent_categories[c.id] = c.name if c.id != category_id
|
80
|
+
end
|
81
|
+
|
82
|
+
parent_categories[nil] = '--'
|
83
|
+
|
84
|
+
return parent_categories
|
85
|
+
end
|
86
|
+
end # Category
|
87
|
+
end # Helper
|
88
|
+
end # Ramaze
|
@@ -24,10 +24,11 @@ success:
|
|
24
24
|
delete : 'The selected categories have been deleted.'
|
25
25
|
|
26
26
|
errors:
|
27
|
-
new
|
28
|
-
save
|
29
|
-
delete
|
30
|
-
no_delete
|
27
|
+
new : 'Failed to add a new category.'
|
28
|
+
save : 'Failed to save the category.'
|
29
|
+
delete : 'Failed to delete the category with ID #%s.'
|
30
|
+
no_delete : "You haven't specified any categories to delete."
|
31
|
+
invalid_category: 'The specified category is invalid.'
|
31
32
|
|
32
33
|
buttons:
|
33
34
|
new : 'Add Category'
|
@@ -22,10 +22,11 @@ success:
|
|
22
22
|
delete : 'The category group has been deleted.'
|
23
23
|
|
24
24
|
errors:
|
25
|
-
new
|
26
|
-
save
|
27
|
-
delete
|
28
|
-
no_delete: 'You need to specify at least one group to delete.'
|
25
|
+
new : 'Failed to add a new category group.'
|
26
|
+
save : 'Failed to modify the category group.'
|
27
|
+
delete : 'Failed to delete the category group with ID #%s.'
|
28
|
+
no_delete : 'You need to specify at least one group to delete.'
|
29
|
+
invalid_group: 'The specified category group is invalid.'
|
29
30
|
|
30
31
|
buttons:
|
31
32
|
new : 'Add group'
|
@@ -28,10 +28,11 @@ success:
|
|
28
28
|
delete: 'De categorie is verwijderd.'
|
29
29
|
|
30
30
|
errors:
|
31
|
-
new
|
32
|
-
save
|
33
|
-
delete
|
34
|
-
no_delete: 'U moet ten minste 1 categorie specificeren om te verwijderen.'
|
31
|
+
new : 'De categorie kon niet worden aangemaakt.'
|
32
|
+
save : 'De categorie kon niet worden aangepast.'
|
33
|
+
delete : 'De categorie met ID #%s kon niet worden verwijderd.'
|
34
|
+
no_delete : 'U moet ten minste 1 categorie specificeren om te verwijderen.'
|
35
|
+
invalid_category: 'De opgegeven categorie is ongeldig.'
|
35
36
|
|
36
37
|
buttons:
|
37
38
|
new : 'Categorie aanmaken'
|
@@ -22,10 +22,11 @@ success:
|
|
22
22
|
delete: 'De categorie groep is verwijderd.'
|
23
23
|
|
24
24
|
errors:
|
25
|
-
new
|
26
|
-
save
|
27
|
-
delete
|
28
|
-
no_delete: 'U moet ten minste 1 groep specificeren om te verwijderen.'
|
25
|
+
new : 'De categorie groep kon niet worden aangemaakt.'
|
26
|
+
save : 'De categorie groep kon niet worden aangepast.'
|
27
|
+
delete : 'De categorie groep met ID #%s kon niet worden verwijderd.'
|
28
|
+
no_delete : 'U moet ten minste 1 groep specificeren om te verwijderen.'
|
29
|
+
invalid_group: 'De opgegeven categorie groep is ongeldig.'
|
29
30
|
|
30
31
|
buttons:
|
31
32
|
new : 'Groep aanmaken'
|
@@ -3,7 +3,8 @@ module Categories
|
|
3
3
|
#:nodoc:
|
4
4
|
module Model
|
5
5
|
##
|
6
|
-
# Model that represents a single category. This model has the following
|
6
|
+
# Model that represents a single category. This model has the following
|
7
|
+
# relations:
|
7
8
|
#
|
8
9
|
# * category groups (one to one)
|
9
10
|
# * self (many to one)
|
@@ -12,17 +13,18 @@ module Categories
|
|
12
13
|
#
|
13
14
|
# * sluggable (source: "name")
|
14
15
|
#
|
15
|
-
# When creating or saving a category the fields "name" and "slug" are
|
16
|
-
# The latter is only needed when saving an existing category as a
|
17
|
-
# generated whenever the field is empty. It's also important to
|
18
|
-
# that slugs have to be unique. For more info see the validate()
|
16
|
+
# When creating or saving a category the fields "name" and "slug" are
|
17
|
+
# required. The latter is only needed when saving an existing category as a
|
18
|
+
# slug will be generated whenever the field is empty. It's also important to
|
19
|
+
# remember that slugs have to be unique. For more info see the validate()
|
20
|
+
# method.
|
19
21
|
#
|
20
22
|
# @author Yorick Peterse
|
21
23
|
# @since 0.1
|
22
24
|
#
|
23
25
|
class Category < Sequel::Model
|
24
|
-
many_to_one :category_group
|
25
|
-
many_to_one :parent
|
26
|
+
many_to_one :category_group, :class => "Categories::Model::CategoryGroup"
|
27
|
+
many_to_one :parent , :class => self
|
26
28
|
|
27
29
|
plugin :sluggable, :source => :name, :frozen => false
|
28
30
|
|
@@ -33,10 +35,10 @@ module Categories
|
|
33
35
|
# @since 0.1
|
34
36
|
#
|
35
37
|
def validate
|
36
|
-
validates_presence
|
37
|
-
validates_max_length
|
38
|
-
validates_unique
|
38
|
+
validates_presence :name
|
39
|
+
validates_max_length 255, [:name, :slug]
|
40
|
+
validates_unique :slug
|
39
41
|
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
42
|
+
end # Category
|
43
|
+
end # Model
|
44
|
+
end # Categories
|
@@ -13,7 +13,7 @@ module Categories
|
|
13
13
|
# puts category[:name]
|
14
14
|
# end
|
15
15
|
#
|
16
|
-
# For more information about the available options see
|
16
|
+
# For more information about the available options see
|
17
17
|
# Zen::Plugin::Categories#initialize().
|
18
18
|
#
|
19
19
|
# @author Yorick Peterse
|
@@ -24,19 +24,23 @@ module Categories
|
|
24
24
|
include ::Zen::Plugin::Helper
|
25
25
|
|
26
26
|
##
|
27
|
-
# Creates a new instance of the plugin and stores the configuration
|
27
|
+
# Creates a new instance of the plugin and stores the configuration
|
28
|
+
# options.
|
28
29
|
#
|
29
30
|
# @author Yorick Peterse
|
30
31
|
# @since 0.2.5
|
31
|
-
# @param [Hash] options Hash containing a set of options used to
|
32
|
-
# categories should be retrieved and which one should
|
33
|
-
#
|
34
|
-
# @option options [Integer] :
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
32
|
+
# @param [Hash] options Hash containing a set of options used to
|
33
|
+
# determine how the categories should be retrieved and which one should
|
34
|
+
# be retrieved.
|
35
|
+
# @option options [Integer] :limit The maximum amount of categories to
|
36
|
+
# retrieve.
|
37
|
+
# @option options [Integer] :offset The row offset, useful for pagination
|
38
|
+
# systems.
|
39
|
+
# @option options [String/Integer] :group The name or ID of the category
|
40
|
+
# group for which to retrieve all categories.
|
41
|
+
# @option options [String/Integer] :category The slug or ID of the
|
42
|
+
# category to retrieve. Setting this option will cause the plugin to
|
43
|
+
# ignore the offset and limit options.
|
40
44
|
#
|
41
45
|
def initialize(options = {})
|
42
46
|
@options = {
|
@@ -48,11 +52,17 @@ module Categories
|
|
48
52
|
|
49
53
|
# Validate the specified options
|
50
54
|
if @options[:group].nil? and @options[:category].nil?
|
51
|
-
raise(
|
55
|
+
raise(
|
56
|
+
ArgumentError,
|
57
|
+
"You need to specify either a category or category group."
|
58
|
+
)
|
52
59
|
end
|
53
60
|
|
54
61
|
if !@options[:group].nil? and !@options[:category].nil?
|
55
|
-
raise(
|
62
|
+
raise(
|
63
|
+
ArgumentError,
|
64
|
+
"You can't specify both a category and a category group."
|
65
|
+
)
|
56
66
|
end
|
57
67
|
|
58
68
|
group_class = @options[:group].class
|
@@ -85,28 +95,30 @@ module Categories
|
|
85
95
|
# Retrieve the categories for a given group]]
|
86
96
|
if !@options[:group].nil?
|
87
97
|
# Get the group for an ID or a name
|
88
|
-
if @options[:group].class == Integer
|
98
|
+
if @options[:group].class == Integer \
|
99
|
+
or @options[:group].class == Fixnum
|
89
100
|
category_group = CategoryGroup[@options[:group]]
|
90
101
|
else
|
91
102
|
category_group = CategoryGroup[:name => @options[:group]]
|
92
103
|
end
|
93
104
|
|
94
|
-
# Since we require a group in this case we'll raise an error if the
|
95
|
-
# doesn't exist. If we were to return an empty value this may
|
96
|
-
# developer.
|
105
|
+
# Since we require a group in this case we'll raise an error if the
|
106
|
+
# group doesn't exist. If we were to return an empty value this may
|
107
|
+
# confuse the developer.
|
97
108
|
if category_group.nil?
|
98
109
|
raise("No category group could be found for \"#{@options[:group]}\"")
|
99
110
|
end
|
100
111
|
|
101
|
-
# Get all the categories according to our specified configuration
|
102
|
-
# and the category group that was retrieved earlier on.
|
112
|
+
# Get all the categories according to our specified configuration
|
113
|
+
# options and the category group that was retrieved earlier on.
|
103
114
|
categories = Category.filter(:category_group_id => category_group.id) \
|
104
115
|
.limit(@options[:limit], @options[:offset]) \
|
105
116
|
.all
|
106
|
-
|
117
|
+
|
107
118
|
# Retrieve the category for the specified ID or slug
|
108
119
|
else
|
109
|
-
if @options[:category].class == Integer
|
120
|
+
if @options[:category].class == Integer \
|
121
|
+
or @options[:category].class == Fixnum
|
110
122
|
categories = Category[@options[:category]]
|
111
123
|
else
|
112
124
|
categories = Category[:slug => @options[:category]]
|
@@ -124,7 +136,6 @@ module Categories
|
|
124
136
|
|
125
137
|
return categories
|
126
138
|
end
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
end
|
139
|
+
end # Categories
|
140
|
+
end # Plugin
|
141
|
+
end # Categories
|