zen 0.2.8 → 0.3b
Sign up to get free protection for your applications and to get access to all the features.
- data/.gems +20 -0
- data/.mailmap +3 -2
- data/.rvmrc +1 -1
- data/.travis.yml +13 -2
- data/.yardopts +13 -0
- data/AUTHORS +1 -1
- data/README.md +115 -77
- data/Rakefile +6 -7
- data/bin/zen +12 -5
- data/guide/_static/categories/categories.png +0 -0
- data/guide/_static/categories/category_groups.png +0 -0
- data/guide/_static/categories/new_category.png +0 -0
- data/guide/_static/categories/new_category_group.png +0 -0
- data/guide/_static/comments/comments.png +0 -0
- data/guide/_static/comments/edit_comment.png +0 -0
- data/guide/_static/custom_fields/custom_field_groups.png +0 -0
- data/guide/_static/custom_fields/custom_field_types.png +0 -0
- data/guide/_static/custom_fields/custom_fields.png +0 -0
- data/guide/_static/custom_fields/edit_custom_field_general.png +0 -0
- data/guide/_static/custom_fields/edit_custom_field_group.png +0 -0
- data/guide/_static/custom_fields/edit_custom_field_settings.png +0 -0
- data/guide/_static/custom_fields/edit_custom_field_type.png +0 -0
- data/guide/_static/menus/edit_menu.png +0 -0
- data/guide/_static/menus/edit_menu_item.png +0 -0
- data/guide/_static/menus/menu_items.png +0 -0
- data/guide/_static/menus/menus.png +0 -0
- data/guide/_static/sections/edit_entry.png +0 -0
- data/guide/_static/sections/edit_entry_categories.png +0 -0
- data/guide/_static/sections/edit_entry_general.png +0 -0
- data/guide/_static/sections/edit_entry_meta.png +0 -0
- data/guide/_static/sections/edit_section_comments.png +0 -0
- data/guide/_static/sections/edit_section_general.png +0 -0
- data/guide/_static/sections/edit_section_groups.png +0 -0
- data/guide/_static/sections/entries.png +0 -0
- data/guide/_static/sections/sections.png +0 -0
- data/guide/_static/settings/overview_general.png +0 -0
- data/guide/_static/settings/overview_security.png +0 -0
- data/guide/_static/settings/overview_user.png +0 -0
- data/guide/_static/users/edit_user.png +0 -0
- data/guide/_static/users/edit_user_group.png +0 -0
- data/guide/_static/users/edit_user_group_permissions.png +0 -0
- data/guide/_static/users/edit_user_permissions.png +0 -0
- data/guide/_static/users/overview.png +0 -0
- data/guide/_static/users/user_groups_overview.png +0 -0
- data/guide/asset_management.md +117 -0
- data/{CHANGELOG.md → guide/changelog.md} +42 -0
- data/guide/css/common.css +20 -0
- data/guide/getting_started.md +61 -0
- data/guide/hacking.md +52 -0
- data/guide/installation.md +44 -0
- data/guide/javascript.md +352 -0
- data/lib/vendor/sequel_sluggable.rb +137 -0
- data/lib/yard/tags.rb +13 -0
- data/lib/zen.rb +148 -78
- data/lib/zen/asset_groups.rb +85 -0
- data/lib/zen/bin/create.rb +267 -56
- data/lib/zen/bin/default.rb +84 -0
- data/lib/zen/controller/admin_controller.rb +1 -82
- data/lib/zen/controller/base_controller.rb +9 -5
- data/lib/zen/controller/frontend_controller.rb +0 -1
- data/lib/zen/controller/main_controller.rb +30 -42
- data/lib/zen/controller/preview.rb +9 -8
- data/lib/zen/controller/translations.rb +49 -0
- data/lib/zen/error.rb +17 -0
- data/lib/zen/event.rb +118 -0
- data/lib/zen/helper/asset.rb +63 -0
- data/lib/zen/helper/breadcrumb.rb +1 -4
- data/lib/zen/helper/controller.rb +73 -0
- data/lib/zen/helper/locale.rb +42 -0
- data/lib/zen/helper/message.rb +0 -3
- data/lib/zen/helper/search.rb +54 -0
- data/lib/zen/helper/stacked_aspect.rb +249 -0
- data/lib/zen/helper/theme.rb +3 -10
- data/lib/zen/language.rb +356 -181
- data/lib/zen/language/en/zen_general.rb +52 -0
- data/lib/zen/language/en/zen_models.rb +19 -0
- data/lib/zen/language/nl/zen_general.rb +57 -0
- data/lib/zen/language/nl/zen_models.rb +22 -0
- data/lib/zen/language/translation.rb +132 -0
- data/lib/zen/languages.rb +9 -0
- data/lib/zen/layout/admin.xhtml +3 -3
- data/lib/zen/layout/login.xhtml +1 -1
- data/lib/zen/markup.rb +189 -0
- data/lib/zen/model/helper.rb +65 -0
- data/lib/zen/model/init.rb +62 -0
- data/lib/zen/model/methods.rb +6 -7
- data/lib/zen/package.rb +312 -201
- data/lib/zen/package/all.rb +4 -3
- data/lib/zen/package/categories/lib/categories.rb +29 -41
- data/lib/zen/package/categories/lib/categories/controller/categories.rb +185 -130
- data/lib/zen/package/categories/lib/categories/controller/category_groups.rb +172 -102
- data/lib/zen/package/categories/lib/categories/helper/category.rb +4 -9
- data/lib/zen/package/categories/lib/categories/helper/category_frontend.rb +86 -0
- data/lib/zen/package/categories/lib/categories/language/en/categories.rb +40 -0
- data/lib/zen/package/categories/lib/categories/language/en/category_groups.rb +39 -0
- data/lib/zen/package/categories/lib/categories/language/nl/categories.rb +42 -0
- data/lib/zen/package/categories/lib/categories/language/nl/category_groups.rb +42 -0
- data/lib/zen/package/categories/lib/categories/model/category.rb +21 -25
- data/lib/zen/package/categories/lib/categories/model/category_group.rb +21 -15
- data/lib/zen/package/categories/lib/categories/view/admin/categories/form.xhtml +25 -26
- data/lib/zen/package/categories/lib/categories/view/admin/categories/index.xhtml +24 -24
- data/lib/zen/package/categories/lib/categories/view/admin/category-groups/form.xhtml +18 -20
- data/lib/zen/package/categories/lib/categories/view/admin/category-groups/index.xhtml +21 -18
- data/lib/zen/package/comments/lib/comments.rb +30 -50
- data/lib/zen/package/comments/lib/comments/anti_spam.rb +138 -0
- data/lib/zen/package/comments/lib/comments/controller/comments.rb +159 -92
- data/lib/zen/package/comments/lib/comments/controller/comments_form.rb +122 -34
- data/lib/zen/package/comments/lib/comments/helper/comment.rb +0 -3
- data/lib/zen/package/comments/lib/comments/helper/comment_frontend.rb +90 -0
- data/lib/zen/package/comments/lib/comments/language/en/comments.rb +57 -0
- data/lib/zen/package/comments/lib/comments/language/nl/comments.rb +61 -0
- data/lib/zen/package/comments/lib/comments/model/comment.rb +147 -49
- data/lib/zen/package/comments/lib/comments/model/comment_status.rb +0 -2
- data/lib/zen/package/comments/lib/comments/view/admin/comments/form.xhtml +37 -40
- data/lib/zen/package/comments/lib/comments/view/admin/comments/index.xhtml +23 -42
- data/lib/zen/package/comments/migrations/1308774099_comment_status.rb +12 -4
- data/lib/zen/package/comments/migrations/1313851786_remove_defensio_signature.rb +11 -0
- data/lib/zen/package/custom_fields/lib/custom_fields.rb +40 -43
- data/lib/zen/package/custom_fields/lib/custom_fields/blue_form_parameters.rb +72 -17
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +154 -118
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_types.rb +147 -90
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_fields.rb +161 -131
- data/lib/zen/package/custom_fields/lib/custom_fields/helper/custom_field.rb +4 -9
- data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_field_groups.rb +42 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_field_types.rb +51 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_fields.rb +60 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_groups.rb +41 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_types.rb +49 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_fields.rb +61 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field.rb +18 -23
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_group.rb +20 -19
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_method.rb +1 -3
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_type.rb +19 -9
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb +18 -15
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/form.xhtml +18 -18
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/index.xhtml +30 -24
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-types/form.xhtml +15 -10
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-types/index.xhtml +24 -19
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/form.xhtml +18 -13
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/index.xhtml +30 -20
- data/lib/zen/package/extensions/lib/extensions.rb +20 -0
- data/lib/zen/package/extensions/lib/extensions/controller/extensions.rb +41 -0
- data/lib/zen/package/extensions/lib/extensions/language/en/extensions.rb +23 -0
- data/lib/zen/package/extensions/lib/extensions/language/nl/extensions.rb +25 -0
- data/lib/zen/package/extensions/lib/extensions/view/admin/extensions/index.xhtml +86 -0
- data/lib/zen/package/menu.rb +109 -0
- data/lib/zen/package/menus/lib/menus.rb +25 -34
- data/lib/zen/package/menus/lib/menus/controller/menu_items.rb +143 -107
- data/lib/zen/package/menus/lib/menus/controller/menus.rb +166 -115
- data/lib/zen/package/menus/lib/menus/helper/menu.rb +2 -8
- data/lib/zen/package/menus/lib/menus/helper/menu_frontend.rb +114 -0
- data/lib/zen/package/menus/lib/menus/language/en/menu_items.rb +48 -0
- data/lib/zen/package/menus/lib/menus/language/en/menus.rb +48 -0
- data/lib/zen/package/menus/lib/menus/language/nl/menu_items.rb +48 -0
- data/lib/zen/package/menus/lib/menus/language/nl/menus.rb +50 -0
- data/lib/zen/package/menus/lib/menus/model/menu.rb +24 -17
- data/lib/zen/package/menus/lib/menus/model/menu_item.rb +37 -13
- data/lib/zen/package/menus/lib/menus/view/admin/menu-items/form.xhtml +32 -25
- data/lib/zen/package/menus/lib/menus/view/admin/menu-items/index.xhtml +23 -17
- data/lib/zen/package/menus/lib/menus/view/admin/menus/form.xhtml +31 -26
- data/lib/zen/package/menus/lib/menus/view/admin/menus/index.xhtml +20 -22
- data/lib/zen/package/sections/lib/sections.rb +25 -68
- data/lib/zen/package/sections/lib/sections/controller/section_entries.rb +178 -138
- data/lib/zen/package/sections/lib/sections/controller/sections.rb +173 -140
- data/lib/zen/package/sections/lib/sections/helper/section.rb +3 -6
- data/lib/zen/package/sections/lib/sections/helper/section_frontend.rb +146 -0
- data/lib/zen/package/sections/lib/sections/language/en/section_entries.rb +50 -0
- data/lib/zen/package/sections/lib/sections/language/en/sections.rb +55 -0
- data/lib/zen/package/sections/lib/sections/language/nl/section_entries.rb +50 -0
- data/lib/zen/package/sections/lib/sections/language/nl/sections.rb +55 -0
- data/lib/zen/package/sections/lib/sections/model/section.rb +36 -36
- data/lib/zen/package/sections/lib/sections/model/section_entry.rb +52 -59
- data/lib/zen/package/sections/lib/sections/model/section_entry_status.rb +2 -2
- data/lib/zen/package/sections/lib/sections/view/admin/form.xhtml +24 -21
- data/lib/zen/package/sections/lib/sections/view/admin/index.xhtml +24 -26
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/form.xhtml +33 -31
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/index.xhtml +24 -25
- data/lib/zen/package/sections/migrations/1308672298_use_id_for_default_section.rb +14 -10
- data/lib/zen/package/sections/migrations/1308813320_section_entry_statuses.rb +12 -6
- data/lib/zen/package/settings/lib/settings.rb +25 -120
- data/lib/zen/package/settings/lib/settings/blue_form_parameters.rb +157 -0
- data/lib/zen/package/settings/lib/settings/controller/settings.rb +94 -69
- data/lib/zen/package/settings/lib/settings/language/en/settings.rb +41 -0
- data/lib/zen/package/settings/lib/settings/language/nl/settings.rb +41 -0
- data/lib/zen/package/settings/lib/settings/model/setting.rb +0 -2
- data/lib/zen/package/settings/lib/settings/setting.rb +379 -0
- data/lib/zen/package/settings/lib/settings/setting_groups.rb +11 -0
- data/lib/zen/package/settings/lib/settings/settings.rb +83 -0
- data/lib/zen/package/settings/lib/settings/settings_group.rb +84 -0
- data/lib/zen/package/settings/lib/settings/singleton_methods.rb +35 -0
- data/lib/zen/package/settings/lib/settings/view/admin/settings/index.xhtml +15 -57
- data/lib/zen/package/settings/migrations/1321197919_remove_unused_columns.rb +17 -0
- data/lib/zen/package/users/lib/users.rb +51 -36
- data/lib/zen/package/users/lib/users/controller/user_groups.rb +133 -98
- data/lib/zen/package/users/lib/users/controller/users.rb +253 -136
- data/lib/zen/package/users/lib/users/helper/access.rb +102 -0
- data/lib/zen/package/users/lib/users/helper/acl.rb +113 -0
- data/lib/zen/package/users/lib/users/helper/users.rb +41 -24
- data/lib/zen/package/users/lib/users/language/en/permissions.rb +16 -0
- data/lib/zen/package/users/lib/users/language/en/user_groups.rb +39 -0
- data/lib/zen/package/users/lib/users/language/en/users.rb +73 -0
- data/lib/zen/package/users/lib/users/language/nl/permissions.rb +16 -0
- data/lib/zen/package/users/lib/users/language/nl/user_groups.rb +41 -0
- data/lib/zen/package/users/lib/users/language/nl/users.rb +74 -0
- data/lib/zen/package/users/lib/users/model/permission.rb +28 -0
- data/lib/zen/package/users/lib/users/model/user.rb +104 -65
- data/lib/zen/package/users/lib/users/model/user_group.rb +28 -24
- data/lib/zen/package/users/lib/users/model/user_status.rb +27 -0
- data/lib/zen/package/users/lib/users/public/admin/css/users/permissions.css +22 -0
- data/lib/zen/package/users/lib/users/public/admin/js/users/permissions.js +33 -0
- data/lib/zen/package/users/lib/users/settings.rb +19 -0
- data/lib/zen/package/users/lib/users/view/admin/user-groups/form.xhtml +58 -28
- data/lib/zen/package/users/lib/users/view/admin/user-groups/index.xhtml +19 -15
- data/lib/zen/package/users/lib/users/view/admin/users/form.xhtml +93 -62
- data/lib/zen/package/users/lib/users/view/admin/users/index.xhtml +23 -36
- data/lib/zen/package/users/lib/users/view/admin/users/login.xhtml +13 -6
- data/lib/zen/package/users/lib/users/view/admin/users/permissions.xhtml +33 -0
- data/lib/zen/package/users/lib/users/view/admin/users/register.xhtml +52 -0
- data/lib/zen/package/users/migrations/1313786058_update_default_date.rb +41 -0
- data/lib/zen/package/users/migrations/1316432327_permissions.rb +36 -0
- data/lib/zen/package/users/migrations/1320272365_status_ids.rb +67 -0
- data/lib/zen/public/admin/css/zen/buttons.css +3 -11
- data/lib/zen/public/admin/css/zen/datepicker.css +23 -13
- data/lib/zen/public/admin/css/zen/editor.css +6 -14
- data/lib/zen/public/admin/css/zen/forms.css +19 -12
- data/lib/zen/public/admin/css/zen/general.css +22 -18
- data/lib/zen/public/admin/css/zen/grid.css +1 -20
- data/lib/zen/public/admin/css/zen/layout.css +26 -11
- data/lib/zen/public/admin/css/zen/messages.css +3 -10
- data/lib/zen/public/admin/css/zen/reset.css +13 -15
- data/lib/zen/public/admin/css/zen/tables.css +8 -10
- data/lib/zen/public/admin/css/zen/tabs.css +2 -10
- data/lib/zen/public/admin/css/zen/window.css +2 -8
- data/lib/zen/public/admin/js/vendor/datepicker.js +540 -240
- data/lib/zen/public/admin/js/vendor/mootools/core.js +273 -283
- data/lib/zen/public/admin/js/vendor/mootools/more.js +131 -136
- data/lib/zen/public/admin/js/zen/index.js +8 -14
- data/lib/zen/public/admin/js/zen/lib/editor.js +36 -33
- data/lib/zen/public/admin/js/zen/lib/editor/markdown.js +0 -6
- data/lib/zen/public/admin/js/zen/lib/editor/textile.js +0 -6
- data/lib/zen/public/admin/js/zen/lib/html_table.js +0 -5
- data/lib/zen/public/admin/js/zen/lib/tabs.js +22 -79
- data/lib/zen/public/admin/js/zen/lib/window.js +12 -22
- data/lib/zen/spec/bacon/color_output.rb +1 -1
- data/lib/zen/spec/helper.rb +6 -11
- data/lib/zen/spec/simplecov.rb +3 -3
- data/lib/zen/task.rb +0 -1
- data/lib/zen/task/build.rake +46 -26
- data/lib/zen/task/clean.rake +14 -7
- data/lib/zen/task/db.rake +31 -29
- data/lib/zen/task/package.rake +19 -23
- data/lib/zen/task/proto.rake +3 -5
- data/lib/zen/task/setup.rake +4 -0
- data/lib/zen/task/test.rake +31 -6
- data/lib/zen/task/theme.rake +13 -19
- data/lib/zen/theme.rb +377 -52
- data/lib/zen/validation.rb +22 -30
- data/lib/zen/version.rb +1 -2
- data/lib/zen/view/bottom.xhtml +9 -1
- data/lib/zen/view/head.xhtml +1 -1
- data/lib/zen/view/main.xhtml +1 -1
- data/lib/zen/view/search.xhtml +9 -0
- data/proto/app/Rakefile +0 -1
- data/proto/app/app.rb +21 -16
- data/proto/app/config/config.rb.erb +41 -0
- data/proto/app/config/{database.rb → database.rb.erb} +17 -14
- data/proto/app/config/middlewares.rb +1 -1
- data/proto/app/theme/default/index.xhtml +25 -0
- data/proto/app/theme/theme.rb +19 -0
- data/proto/app/{log/database/dev → tmp}/.gitkeep +0 -0
- data/proto/migration.rb +3 -5
- data/proto/rack/thin.yml +41 -0
- data/proto/rack/unicorn.rb +38 -0
- data/spec/Rakefile +15 -11
- data/spec/fixtures/zen/helper/controller.rb +13 -0
- data/spec/fixtures/zen/helper/locale.rb +7 -0
- data/spec/fixtures/zen/helper/message.rb +0 -4
- data/spec/fixtures/zen/language.rb +31 -0
- data/spec/fixtures/zen/language/en/spec.rb +11 -0
- data/spec/fixtures/zen/language/nl/spec.rb +11 -0
- data/spec/fixtures/zen/package.rb +0 -10
- data/spec/fixtures/zen/package/categories/helper/category_frontend.rb +16 -0
- data/spec/fixtures/zen/package/comments/helper/comment_frontend.rb +16 -0
- data/spec/fixtures/zen/package/sections/helper/section_frontend.rb +16 -0
- data/spec/fixtures/zen/package/settings/controller/settings.rb +17 -0
- data/spec/fixtures/zen/package/users/helper/access.rb +18 -0
- data/spec/fixtures/zen/package/users/helper/acl.rb +23 -0
- data/spec/fixtures/zen/theme/{default-section → default}/index.xhtml +0 -0
- data/spec/helper.rb +12 -27
- data/{proto/app/log/database/live → spec/public}/.gitkeep +0 -0
- data/spec/zen/controller/admin_controller.rb +5 -6
- data/spec/zen/controller/main_controller.rb +29 -35
- data/spec/zen/controller/preview.rb +9 -10
- data/spec/zen/event.rb +44 -0
- data/spec/zen/helper/breadcrumb.rb +4 -5
- data/spec/zen/helper/controller.rb +21 -0
- data/spec/zen/helper/locale.rb +25 -0
- data/spec/zen/helper/message.rb +4 -11
- data/spec/zen/helper/theme.rb +11 -14
- data/spec/zen/language.rb +48 -22
- data/spec/zen/markup.rb +39 -0
- data/spec/zen/package.rb +48 -11
- data/spec/zen/package/categories/controller/categories.rb +99 -45
- data/spec/zen/package/categories/controller/category_groups.rb +109 -33
- data/spec/zen/package/categories/helper/category.rb +19 -32
- data/spec/zen/package/categories/helper/category_frontend.rb +61 -0
- data/spec/zen/package/comments/anti_spam.rb +50 -0
- data/spec/zen/package/comments/controller/comments.rb +121 -61
- data/spec/zen/package/comments/controller/comments_form.rb +120 -94
- data/spec/zen/package/comments/helper/comment.rb +13 -13
- data/spec/zen/package/comments/helper/comment_frontend.rb +92 -0
- data/spec/zen/package/custom_fields/blue_form_parameters.rb +50 -50
- data/spec/zen/package/custom_fields/controller/custom_field_groups.rb +135 -43
- data/spec/zen/package/custom_fields/controller/custom_field_types.rb +153 -48
- data/spec/zen/package/custom_fields/controller/custom_fields.rb +130 -51
- data/spec/zen/package/custom_fields/helper/custom_field.rb +8 -8
- data/spec/zen/package/extensions/controller/extensions.rb +38 -0
- data/spec/zen/package/menus/controller/menu_items.rb +121 -42
- data/spec/zen/package/menus/controller/menus.rb +125 -38
- data/spec/zen/package/menus/helper/menu.rb +26 -26
- data/spec/zen/package/menus/helper/menu_frontend.rb +104 -0
- data/spec/zen/package/sections/controller/section_entries.rb +145 -89
- data/spec/zen/package/sections/controller/sections.rb +130 -35
- data/spec/zen/package/sections/helper/section.rb +27 -38
- data/spec/zen/package/sections/helper/section_frontend.rb +160 -0
- data/spec/zen/package/settings/controller/settings.rb +73 -8
- data/spec/zen/package/settings/settings.rb +119 -0
- data/spec/zen/package/users/controller/user_groups.rb +134 -34
- data/spec/zen/package/users/controller/users.rb +189 -44
- data/spec/zen/package/users/helper/access.rb +29 -0
- data/spec/zen/package/users/helper/acl.rb +46 -0
- data/spec/zen/package/users/helper/users.rb +20 -64
- data/spec/zen/theme.rb +7 -9
- data/spec/zen/validation.rb +1 -2
- data/zen.gemspec +25 -22
- metadata +303 -222
- data/lib/zen/asset.rb +0 -292
- data/lib/zen/bin/runner.rb +0 -118
- data/lib/zen/error/language_error.rb +0 -10
- data/lib/zen/error/package_error.rb +0 -10
- data/lib/zen/error/plugin_error.rb +0 -10
- data/lib/zen/error/theme_error.rb +0 -10
- data/lib/zen/error/validation_error.rb +0 -10
- data/lib/zen/helper/acl.rb +0 -182
- data/lib/zen/helper/blue_form_vendor.rb +0 -689
- data/lib/zen/language/en/zen_general.yml +0 -25
- data/lib/zen/language/en/zen_models.yml +0 -13
- data/lib/zen/language/nl/zen_general.yml +0 -25
- data/lib/zen/language/nl/zen_models.yml +0 -13
- data/lib/zen/model/settings.rb +0 -78
- data/lib/zen/package/base.rb +0 -62
- data/lib/zen/package/categories/lib/categories/language/en/categories.yml +0 -36
- data/lib/zen/package/categories/lib/categories/language/en/category_groups.yml +0 -34
- data/lib/zen/package/categories/lib/categories/language/nl/categories.yml +0 -40
- data/lib/zen/package/categories/lib/categories/language/nl/category_groups.yml +0 -34
- data/lib/zen/package/categories/lib/categories/plugin/categories.rb +0 -141
- data/lib/zen/package/comments/lib/comments/language/en/comments.yml +0 -48
- data/lib/zen/package/comments/lib/comments/language/nl/comments.yml +0 -50
- data/lib/zen/package/comments/lib/comments/plugin/anti_spam.rb +0 -156
- data/lib/zen/package/comments/lib/comments/plugin/comments.rb +0 -115
- data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_field_groups.yml +0 -33
- data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_field_types.yml +0 -40
- data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_fields.yml +0 -54
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_groups.yml +0 -33
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_types.yml +0 -40
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_fields.yml +0 -54
- data/lib/zen/package/menus/lib/menus/language/en/menu_items.yml +0 -41
- data/lib/zen/package/menus/lib/menus/language/en/menus.yml +0 -40
- data/lib/zen/package/menus/lib/menus/language/nl/menu_items.yml +0 -41
- data/lib/zen/package/menus/lib/menus/language/nl/menus.yml +0 -40
- data/lib/zen/package/menus/lib/menus/plugin/menus.rb +0 -152
- data/lib/zen/package/sections/lib/sections/language/en/section_entries.yml +0 -44
- data/lib/zen/package/sections/lib/sections/language/en/sections.yml +0 -48
- data/lib/zen/package/sections/lib/sections/language/nl/section_entries.yml +0 -44
- data/lib/zen/package/sections/lib/sections/language/nl/sections.yml +0 -48
- data/lib/zen/package/sections/lib/sections/plugin/section_entries.rb +0 -244
- data/lib/zen/package/sections/lib/sections/plugin/sections.rb +0 -87
- data/lib/zen/package/settings/lib/settings/language/en/settings.yml +0 -36
- data/lib/zen/package/settings/lib/settings/language/nl/settings.yml +0 -37
- data/lib/zen/package/settings/lib/settings/plugin/group_base.rb +0 -39
- data/lib/zen/package/settings/lib/settings/plugin/setting_base.rb +0 -133
- data/lib/zen/package/settings/lib/settings/plugin/settings.rb +0 -251
- data/lib/zen/package/users/lib/users/controller/access_rules.rb +0 -284
- data/lib/zen/package/users/lib/users/language/en/access_rules.yml +0 -38
- data/lib/zen/package/users/lib/users/language/en/user_groups.yml +0 -32
- data/lib/zen/package/users/lib/users/language/en/users.yml +0 -57
- data/lib/zen/package/users/lib/users/language/nl/access_rules.yml +0 -38
- data/lib/zen/package/users/lib/users/language/nl/user_groups.yml +0 -32
- data/lib/zen/package/users/lib/users/language/nl/users.yml +0 -57
- data/lib/zen/package/users/lib/users/model/access_rule.rb +0 -42
- data/lib/zen/package/users/lib/users/public/admin/js/users/access_rules.js +0 -65
- data/lib/zen/package/users/lib/users/public/admin/js/users/lib/access_rules.js +0 -49
- data/lib/zen/package/users/lib/users/view/admin/access-rules/form.xhtml +0 -120
- data/lib/zen/package/users/lib/users/view/admin/access-rules/index.xhtml +0 -102
- data/lib/zen/plugin.rb +0 -182
- data/lib/zen/plugin/base.rb +0 -46
- data/lib/zen/plugin/helper.rb +0 -47
- data/lib/zen/plugin/markup/lib/markup.rb +0 -14
- data/lib/zen/plugin/markup/lib/markup/language/en/markup.yml +0 -6
- data/lib/zen/plugin/markup/lib/markup/markup.rb +0 -165
- data/lib/zen/public/admin/js/zen/lib/asset.js +0 -111
- data/lib/zen/task/plugin.rake +0 -18
- data/lib/zen/theme/base.rb +0 -65
- data/proto/app/config/config.rb +0 -18
- data/spec/fixtures/zen/language/en/spec.yml +0 -10
- data/spec/fixtures/zen/language/nl/spec.yml +0 -7
- data/spec/fixtures/zen/package/settings/plugin/settings.rb +0 -20
- data/spec/zen/asset.rb +0 -97
- data/spec/zen/bin/create.rb +0 -89
- data/spec/zen/bin/runner.rb +0 -47
- data/spec/zen/helper/acl.rb +0 -149
- data/spec/zen/package/categories/plugin/categories.rb +0 -92
- data/spec/zen/package/comments/plugin/anti_spam.rb +0 -59
- data/spec/zen/package/comments/plugin/comments.rb +0 -107
- data/spec/zen/package/menus/plugin/menus.rb +0 -120
- data/spec/zen/package/sections/plugin/section_entries.rb +0 -161
- data/spec/zen/package/sections/plugin/sections.rb +0 -75
- data/spec/zen/package/settings/plugin/settings.rb +0 -33
- data/spec/zen/package/users/controller/access_rules.rb +0 -90
- data/spec/zen/plugin.rb +0 -64
- data/spec/zen/plugin/helper.rb +0 -11
- data/spec/zen/plugin/markup.rb +0 -44
@@ -1,36 +0,0 @@
|
|
1
|
-
---
|
2
|
-
titles:
|
3
|
-
index: 'Settings'
|
4
|
-
|
5
|
-
labels:
|
6
|
-
website_name : 'Website name'
|
7
|
-
website_description : 'Website description'
|
8
|
-
language : 'Language'
|
9
|
-
frontend_language : 'Frontend language'
|
10
|
-
default_section : 'Default section'
|
11
|
-
theme : 'Theme'
|
12
|
-
enable_antispam : 'Enable anti-spam'
|
13
|
-
date_format : 'Date format'
|
14
|
-
|
15
|
-
placeholders:
|
16
|
-
website_name : 'The name of the website.'
|
17
|
-
website_description : 'The description of the website.'
|
18
|
-
language : 'The language to use for the system.'
|
19
|
-
default_section : 'The default section to use on the homepage.'
|
20
|
-
theme : 'The frontend theme to use.'
|
21
|
-
enable_antispam : 'Whether or not anti-spam protection should be used for comments'
|
22
|
-
frontend_language : 'The language to use for the frontend of the website.'
|
23
|
-
date_format : 'A custom format used for all the dates displayed in the backend.'
|
24
|
-
|
25
|
-
tabs:
|
26
|
-
general : 'General'
|
27
|
-
security : 'Security'
|
28
|
-
|
29
|
-
buttons:
|
30
|
-
save: 'Save'
|
31
|
-
|
32
|
-
success:
|
33
|
-
save: 'The settings have been saved.'
|
34
|
-
|
35
|
-
errors:
|
36
|
-
save: 'The settings could not be saved.'
|
@@ -1,37 +0,0 @@
|
|
1
|
-
---
|
2
|
-
titles:
|
3
|
-
index: 'Instellingen'
|
4
|
-
|
5
|
-
labels:
|
6
|
-
website_name : 'Website naam'
|
7
|
-
website_description: 'Website beschrijving'
|
8
|
-
language : 'Taal'
|
9
|
-
frontend_langauge : 'Taal voor bezoekers'
|
10
|
-
default_section : 'Standaard sectie'
|
11
|
-
theme : 'Thema'
|
12
|
-
enable_antispam : 'Anti-spam inschakelen'
|
13
|
-
date_format : 'Datum formaat'
|
14
|
-
|
15
|
-
placeholders:
|
16
|
-
website_name : 'De naam van de website.'
|
17
|
-
website_description: 'De beschrijving van de website.'
|
18
|
-
language : 'De taal die gebruikt moet worden voor het admin gedeelte.'
|
19
|
-
default_section : 'De standaard sectie die moet worden gebruikt.'
|
20
|
-
theme : 'Het thema dat bezoekers zullen zien.'
|
21
|
-
enable_antispam : 'Waarde die aangeeft of het anti-spam systeem moet worden gebruikt
|
22
|
-
voor reacties.'
|
23
|
-
frontend_language : 'De taal die gebruikt moet worden voor bezoekers.'
|
24
|
-
date_format : 'Het formaat van de datum voor het admin gedeelte.'
|
25
|
-
|
26
|
-
tabs:
|
27
|
-
general : 'Algemeen'
|
28
|
-
security: 'Beveiliging'
|
29
|
-
|
30
|
-
buttons:
|
31
|
-
save: 'Opslaan'
|
32
|
-
|
33
|
-
success:
|
34
|
-
save: 'De instellingen zijn opgeslagen.'
|
35
|
-
|
36
|
-
errors:
|
37
|
-
save: 'De instellingen konden niet worden opgeslagen.'
|
@@ -1,39 +0,0 @@
|
|
1
|
-
#:nodoc:
|
2
|
-
module Settings
|
3
|
-
#:nodoc:
|
4
|
-
module Plugin
|
5
|
-
##
|
6
|
-
# Base class used for setting groups.
|
7
|
-
#
|
8
|
-
# @author Yorick Peterse
|
9
|
-
# @since 0.2.5
|
10
|
-
#
|
11
|
-
class GroupBase
|
12
|
-
include ::Zen::Validation
|
13
|
-
|
14
|
-
# The name of the group
|
15
|
-
attr_accessor :name
|
16
|
-
|
17
|
-
# The title of the group, displayed in the GUI
|
18
|
-
attr_accessor :title
|
19
|
-
|
20
|
-
##
|
21
|
-
# Validates all attributes of this class.
|
22
|
-
#
|
23
|
-
# @author Yorick Peterse
|
24
|
-
# @since 0.2.5
|
25
|
-
#
|
26
|
-
def validate
|
27
|
-
validates_presence([:name, :title])
|
28
|
-
validates_format(:name, /[a-z0-9_\-]+/)
|
29
|
-
|
30
|
-
if ::Settings::Plugin::Settings::Registered[:groups].key?(name)
|
31
|
-
raise(
|
32
|
-
::Zen::ValidationError,
|
33
|
-
"The setting group #{name} has already been registered."
|
34
|
-
)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end # GroupBase
|
38
|
-
end # Plugin
|
39
|
-
end # Settings
|
@@ -1,133 +0,0 @@
|
|
1
|
-
#:nodoc:
|
2
|
-
module Settings
|
3
|
-
#:nodoc:
|
4
|
-
module Plugin
|
5
|
-
##
|
6
|
-
# Base class used for individual settings.
|
7
|
-
#
|
8
|
-
# @author Yorick Peterse
|
9
|
-
# @since 0.2.5
|
10
|
-
#
|
11
|
-
class SettingBase
|
12
|
-
include ::Zen::Validation
|
13
|
-
|
14
|
-
##
|
15
|
-
# Array containing all possible setting types.
|
16
|
-
#
|
17
|
-
# @author Yorick Peterse
|
18
|
-
# @since 0.2.5
|
19
|
-
#
|
20
|
-
Types = [
|
21
|
-
'textbox', 'textarea', 'radio', 'checkbox', 'date', 'select', 'select_multiple'
|
22
|
-
]
|
23
|
-
|
24
|
-
# The name of the setting
|
25
|
-
attr_accessor :name
|
26
|
-
|
27
|
-
# The title of the setting, displayed in the GUI
|
28
|
-
attr_accessor :title
|
29
|
-
|
30
|
-
# A small description about the setting
|
31
|
-
attr_accessor :description
|
32
|
-
|
33
|
-
# The name of the settings group this setting belongs to
|
34
|
-
attr_accessor :group
|
35
|
-
|
36
|
-
# The type of setting (e.g. textbox)
|
37
|
-
attr_accessor :type
|
38
|
-
|
39
|
-
# The possible values for the setting
|
40
|
-
attr_writer :values
|
41
|
-
|
42
|
-
# The default value of the setting
|
43
|
-
attr_accessor :default
|
44
|
-
|
45
|
-
##
|
46
|
-
# Validates all attributes of this class.
|
47
|
-
#
|
48
|
-
# @author Yorick Peterse
|
49
|
-
# @since 0.2.5
|
50
|
-
#
|
51
|
-
def validate
|
52
|
-
validates_presence([:name, :title, :group, :type])
|
53
|
-
|
54
|
-
# Validate the setting type
|
55
|
-
if !Types.include?(type)
|
56
|
-
raise(::Zen::ValidationError, "The setting type #{type} is invalid.")
|
57
|
-
end
|
58
|
-
|
59
|
-
# Check if the setting hasn't been registered yet
|
60
|
-
if ::Settings::Plugin::Settings::Registered[:settings].key?(name)
|
61
|
-
raise(
|
62
|
-
::Zen::ValidationError,
|
63
|
-
"The setting #{name} has already been registered"
|
64
|
-
)
|
65
|
-
end
|
66
|
-
|
67
|
-
# Validate the group
|
68
|
-
if !::Settings::Plugin::Settings::Registered[:groups].key?(group)
|
69
|
-
raise(::Zen::ValidationError, "The settings group #{group} doesn't exist.")
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
##
|
74
|
-
# Updates the value of a setting both in the cache and the SQL database.
|
75
|
-
#
|
76
|
-
# @author Yorick Peterse
|
77
|
-
# @since 0.2.6.1
|
78
|
-
# @param [String] value The value to set the setting to.
|
79
|
-
#
|
80
|
-
def value=(value)
|
81
|
-
# First we'll update the SQL database
|
82
|
-
::Settings::Model::Setting[:name => name].update(:value => value)
|
83
|
-
|
84
|
-
# Sync the cache
|
85
|
-
::Ramaze::Cache.settings.store(name, value)
|
86
|
-
end
|
87
|
-
|
88
|
-
##
|
89
|
-
# Retrieves the setting. If it exists in the cache the cache's value is used,
|
90
|
-
# otherwise it will be retrieved from the SQL database and cached.
|
91
|
-
#
|
92
|
-
# @author Yorick Peterse
|
93
|
-
# @since 0.2.6.1
|
94
|
-
#
|
95
|
-
def value
|
96
|
-
val = ::Ramaze::Cache.settings.fetch(name)
|
97
|
-
|
98
|
-
# Get the setting from the database
|
99
|
-
if val.nil?
|
100
|
-
setting = ::Settings::Model::Setting[:name => name]
|
101
|
-
|
102
|
-
# If the value is also nil we'll use the default value
|
103
|
-
if setting.value.nil? or setting.value.empty?
|
104
|
-
val = setting.default
|
105
|
-
else
|
106
|
-
val = setting.value
|
107
|
-
end
|
108
|
-
|
109
|
-
::Ramaze::Cache.settings.store(name, val)
|
110
|
-
end
|
111
|
-
|
112
|
-
return val
|
113
|
-
end
|
114
|
-
|
115
|
-
##
|
116
|
-
# Retrieves the possible values for the setting. If the value is a Proc or Lambda
|
117
|
-
# (or anything else that responds to call()) it will be called and it's return
|
118
|
-
# value is used.
|
119
|
-
#
|
120
|
-
# @author Yorick Peterse
|
121
|
-
# @since 0.2.8
|
122
|
-
# @return [Mixed]
|
123
|
-
#
|
124
|
-
def values
|
125
|
-
if @values.respond_to?(:call)
|
126
|
-
return @values.call
|
127
|
-
else
|
128
|
-
return @values
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end # SettingBase
|
132
|
-
end # Plugin
|
133
|
-
end # Settings
|
@@ -1,251 +0,0 @@
|
|
1
|
-
require __DIR__('group_base')
|
2
|
-
require __DIR__('setting_base')
|
3
|
-
|
4
|
-
#:nodoc:
|
5
|
-
module Settings
|
6
|
-
#:nodoc:
|
7
|
-
module Plugin
|
8
|
-
##
|
9
|
-
# The settings plugin is a plugin that can be used to register and migrate settings
|
10
|
-
# without having to manually insert the data. Previously you'd have to manually insert
|
11
|
-
# the data into the settings table at some point and the process of loading
|
12
|
-
# translation keys and possible values was a pain. This this plugin was created to
|
13
|
-
# solve most of those problems.
|
14
|
-
#
|
15
|
-
# ## Adding Settings
|
16
|
-
#
|
17
|
-
# In order to add a setting you'll first need to ensure there's at least a single
|
18
|
-
# setting group available. These groups don't add any extra features or whatsoever but
|
19
|
-
# are used to display settings in different tabs in the backend interface. In order to
|
20
|
-
# register a new group you'd write the following code:
|
21
|
-
#
|
22
|
-
# plugin(:settings, :register_group) do |group|
|
23
|
-
# group.title = 'My Group'
|
24
|
-
# group.name = 'my_group'
|
25
|
-
# end
|
26
|
-
#
|
27
|
-
# When registering a group you only need to specify a title and a name. The name is
|
28
|
-
# used to associate a setting with it's group and thus should always be unique. The
|
29
|
-
# title is displayed in the tab for the specific settings group.
|
30
|
-
#
|
31
|
-
# Once a setting group has been added we can add a setting as following:
|
32
|
-
#
|
33
|
-
# plugin(:settings, :register) do |setting|
|
34
|
-
# setting.title = 'My Setting'
|
35
|
-
# setting.description = 'This is my setting!'
|
36
|
-
# setting.name = 'my_setting'
|
37
|
-
# setting.group = 'my_group'
|
38
|
-
# setting.type = 'select'
|
39
|
-
# setting.values = ['yorick', 'zen']
|
40
|
-
# setting.default = 'yorick'
|
41
|
-
# end
|
42
|
-
#
|
43
|
-
# Note that the values array (or hash) is used to determine the possible values for
|
44
|
-
# a field. These values will only be used for elements that only allow a user to
|
45
|
-
# choose a single value (e.g. a checkbox). For the type getter/setter you can use
|
46
|
-
# any of the following values:
|
47
|
-
#
|
48
|
-
# * textbox
|
49
|
-
# * textarea
|
50
|
-
# * radio
|
51
|
-
# * checkbox
|
52
|
-
# * date
|
53
|
-
# * select
|
54
|
-
# * select_multiple
|
55
|
-
#
|
56
|
-
# ## Migrating Settings
|
57
|
-
#
|
58
|
-
# Once a setting has been added you still have to migrate it. Zen takes care of this
|
59
|
-
# so usually you don't need to manually migrate your settings. If you do want to
|
60
|
-
# migrate them however you can simple execute the following code:
|
61
|
-
#
|
62
|
-
# plugin(:settings, :migrate)
|
63
|
-
#
|
64
|
-
# ## Removing Settings
|
65
|
-
#
|
66
|
-
# If you ever need to remove a setting both from the database and the system you can
|
67
|
-
# do so as following:
|
68
|
-
#
|
69
|
-
# plugin(:settings, :remove, ['name1', 'name2'])
|
70
|
-
#
|
71
|
-
# You don't have to specify an array of names, you can also specify the name of a
|
72
|
-
# single setting to delete.
|
73
|
-
#
|
74
|
-
# @author Yorick Peterse
|
75
|
-
# @since 0.2.5
|
76
|
-
#
|
77
|
-
class Settings
|
78
|
-
include ::Zen::Plugin::Helper
|
79
|
-
include ::Settings::Model
|
80
|
-
|
81
|
-
##
|
82
|
-
# Hash containing all registered settings and setting groups.
|
83
|
-
#
|
84
|
-
# @author Yorick Peterse
|
85
|
-
# @since 0.2.5
|
86
|
-
#
|
87
|
-
Registered = {
|
88
|
-
:groups => {},
|
89
|
-
:settings => {}
|
90
|
-
}
|
91
|
-
|
92
|
-
##
|
93
|
-
# Creates a new instance of the plugin and saves the given arguments as instance
|
94
|
-
# variables so they can be used by Settings::Plugin::Settings.call.
|
95
|
-
#
|
96
|
-
# @author Yorick Peterse
|
97
|
-
# @since 0.2.5
|
98
|
-
# @param [Symbol/String] action The action (method) to execute.
|
99
|
-
# @param [Array] args Array containing all additional arguments.
|
100
|
-
# @param [Proc] block An optional block containing extra details.
|
101
|
-
# a setting.
|
102
|
-
#
|
103
|
-
def initialize(action, *args, &block)
|
104
|
-
# Validate the given action
|
105
|
-
if !respond_to?(action)
|
106
|
-
raise(ArgumentError, "The action #{action} does not exist.")
|
107
|
-
end
|
108
|
-
|
109
|
-
validate_type(action, :action, [Symbol, String])
|
110
|
-
|
111
|
-
@action, @args, @block = action, args, block
|
112
|
-
end
|
113
|
-
|
114
|
-
##
|
115
|
-
# Executes the action set in the construct and returns the results.
|
116
|
-
#
|
117
|
-
# @author Yorick Peterse
|
118
|
-
# @since 0.2.5
|
119
|
-
# @return [Mixed]
|
120
|
-
#
|
121
|
-
def call
|
122
|
-
return send(@action, *@args, &@block)
|
123
|
-
end
|
124
|
-
|
125
|
-
##
|
126
|
-
# Registers a new setting group using the specified block.
|
127
|
-
#
|
128
|
-
# @example
|
129
|
-
# plugin(:settings, :register_group) do |group|
|
130
|
-
# group.name = 'example'
|
131
|
-
# group.title = 'Example group'
|
132
|
-
# end
|
133
|
-
#
|
134
|
-
# @author Yorick Peterse
|
135
|
-
# @since 0.2.5
|
136
|
-
#
|
137
|
-
def register_group
|
138
|
-
group = GroupBase.new
|
139
|
-
|
140
|
-
yield group
|
141
|
-
|
142
|
-
# Validate the group
|
143
|
-
group.validate
|
144
|
-
|
145
|
-
# Store the group
|
146
|
-
Registered[:groups][group.name] = group
|
147
|
-
end
|
148
|
-
|
149
|
-
##
|
150
|
-
# Registers a new setting using the specified block.
|
151
|
-
#
|
152
|
-
# @example
|
153
|
-
# plugin(:settings, :register) do |setting|
|
154
|
-
# setting.name = 'example'
|
155
|
-
# setting.title = 'Example setting'
|
156
|
-
# setting.group = 'example'
|
157
|
-
# setting.type = 'select'
|
158
|
-
# setting.value = ['yorick', 'chuck']
|
159
|
-
# end
|
160
|
-
#
|
161
|
-
# @author Yorick Peterse
|
162
|
-
# @since 0.2.5
|
163
|
-
#
|
164
|
-
def register
|
165
|
-
setting = SettingBase.new
|
166
|
-
|
167
|
-
yield setting
|
168
|
-
|
169
|
-
# Validate all attributes
|
170
|
-
setting.validate
|
171
|
-
|
172
|
-
Registered[:settings][setting.name] = setting
|
173
|
-
end
|
174
|
-
|
175
|
-
##
|
176
|
-
# Gets the setting for the given name.
|
177
|
-
#
|
178
|
-
# @author Yorick Peterse
|
179
|
-
# @since 0.2.5
|
180
|
-
# @param [String] name The name of the setting to retrieve.
|
181
|
-
# @return [Zen::StrictStruct]
|
182
|
-
#
|
183
|
-
def get(name)
|
184
|
-
validate_type(name, :name, [String, Symbol])
|
185
|
-
|
186
|
-
name = name.to_s
|
187
|
-
|
188
|
-
if !Registered[:settings].key?(name)
|
189
|
-
raise(ArgumentError, "The setting #{name} doesn't exist.")
|
190
|
-
end
|
191
|
-
|
192
|
-
return Registered[:settings][name]
|
193
|
-
end
|
194
|
-
|
195
|
-
##
|
196
|
-
# Inserts all settings into the database. This method will ignore the settings that
|
197
|
-
# have already been inserted into the database.
|
198
|
-
#
|
199
|
-
# @author Yorick Peterse
|
200
|
-
# @since 0.2.5
|
201
|
-
#
|
202
|
-
def migrate
|
203
|
-
settings = Setting.all.map { |s| s.name }
|
204
|
-
|
205
|
-
Registered[:settings].each do |name, setting|
|
206
|
-
name = name.to_s
|
207
|
-
|
208
|
-
if !settings.include?(name)
|
209
|
-
# For some reason using the Settings model generates nil errors
|
210
|
-
# when this method is called from a migration so we'll insert them
|
211
|
-
# the non-model way.
|
212
|
-
Zen.database[:settings].insert(
|
213
|
-
:name => setting.name,
|
214
|
-
:group => setting.group,
|
215
|
-
:default => setting.default,
|
216
|
-
:type => setting.type
|
217
|
-
)
|
218
|
-
|
219
|
-
# Update everything but the value
|
220
|
-
else
|
221
|
-
Zen.database[:settings].filter[:name => setting.name].update(
|
222
|
-
:group => setting.group,
|
223
|
-
:default => setting.default,
|
224
|
-
:type => setting.type
|
225
|
-
)
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
##
|
231
|
-
# Removes the settings who's names match those specified in the array. The values
|
232
|
-
# of these settings will also be removed from the database.
|
233
|
-
#
|
234
|
-
# @author Yorick Peterse
|
235
|
-
# @since 0.2.5
|
236
|
-
# @param [Array] namese An array with setting names to remove.
|
237
|
-
#
|
238
|
-
def remove(names)
|
239
|
-
if names.class != Array
|
240
|
-
names = [names]
|
241
|
-
end
|
242
|
-
|
243
|
-
names.each do |i|
|
244
|
-
Registered[:settings].delete(i)
|
245
|
-
end
|
246
|
-
|
247
|
-
Setting.filter(:name => names).delete
|
248
|
-
end
|
249
|
-
end # Settings
|
250
|
-
end # Plugin
|
251
|
-
end # Settings
|