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
@@ -0,0 +1,13 @@
|
|
1
|
+
module Sections
|
2
|
+
module Model
|
3
|
+
##
|
4
|
+
# Model for managing the statuses of each section entry.
|
5
|
+
#
|
6
|
+
# @author Yorick Peterse
|
7
|
+
# @since 0.2.8
|
8
|
+
#
|
9
|
+
class SectionEntryStatus < Sequel::Model
|
10
|
+
many_to_one :section_entry, :class => 'Sections::Model::SectionEntryStatus'
|
11
|
+
end # SectionEntryStatus
|
12
|
+
end # Model
|
13
|
+
end # Sections
|
@@ -3,10 +3,10 @@ module Sections
|
|
3
3
|
#:nodoc:
|
4
4
|
module Plugin
|
5
5
|
##
|
6
|
-
# The SectionEntries plugin can be used to retrieve section entries as well
|
7
|
-
# associated comments and user data. This allows you to relatively
|
8
|
-
# of entries (e.g. blog articles) without having to
|
9
|
-
# associated data manually.
|
6
|
+
# The SectionEntries plugin can be used to retrieve section entries as well
|
7
|
+
# as the associated comments and user data. This allows you to relatively
|
8
|
+
# easily build a list of entries (e.g. blog articles) without having to
|
9
|
+
# retrieve and process the associated data manually.
|
10
10
|
#
|
11
11
|
# ## Usage
|
12
12
|
#
|
@@ -17,9 +17,9 @@ module Sections
|
|
17
17
|
# puts e[:title]
|
18
18
|
# end
|
19
19
|
#
|
20
|
-
# The values of custom fields are stored under the key :fields. This key
|
21
|
-
# hash where the keys are the slugs of the custom fields and the
|
22
|
-
# the current entry.
|
20
|
+
# The values of custom fields are stored under the key :fields. This key
|
21
|
+
# contains a hash where the keys are the slugs of the custom fields and the
|
22
|
+
# values the values for the current entry.
|
23
23
|
#
|
24
24
|
# entries.each do |e|
|
25
25
|
# e[:fields][:thumbnail]
|
@@ -39,7 +39,8 @@ module Sections
|
|
39
39
|
# end
|
40
40
|
# end
|
41
41
|
#
|
42
|
-
# For a full list of available options see
|
42
|
+
# For a full list of available options see
|
43
|
+
# Sections::Plugin::SectionEntries.initialize.
|
43
44
|
#
|
44
45
|
# @author Yorick Peterse
|
45
46
|
# @since 0.2.5
|
@@ -49,31 +50,32 @@ module Sections
|
|
49
50
|
include ::Sections::Model
|
50
51
|
|
51
52
|
##
|
52
|
-
# Creates a new instance of the plugin and validates/stores the given
|
53
|
-
# options. Please note that you always need to either
|
54
|
-
# to retrieve all entries or a single entry
|
55
|
-
#
|
56
|
-
# slug:
|
53
|
+
# Creates a new instance of the plugin and validates/stores the given
|
54
|
+
# configuration options. Please note that you always need to either
|
55
|
+
# specify a section from which to retrieve all entries or a single entry
|
56
|
+
# in order to use this plugin. You can retrieve a list of entries (or just
|
57
|
+
# a single one) by specifying the ID or the slug:
|
57
58
|
#
|
58
59
|
# plugin(:section_entries, :section => 'blog')
|
59
60
|
# plugin(:section_entries, :section => 10)
|
60
61
|
#
|
61
62
|
# @author Yorick Peterse
|
62
63
|
# @since 0.2.5
|
63
|
-
# @param [Hash] options Hash with a collection of custom configuration
|
64
|
-
# determine how and what entries should be retrieved.
|
64
|
+
# @param [Hash] options Hash with a collection of custom configuration
|
65
|
+
# options that determine how and what entries should be retrieved.
|
65
66
|
# @option options [Fixnum/Integer] :limit
|
66
67
|
# @option options [Fixnum/Integer] :offset
|
67
68
|
# @option options [NilClass/String/Integer/Fixnum] :section
|
68
69
|
# @option options [NilClass/String/Integer/Fixnum] :entry
|
69
|
-
# @option options [TrueClass] :markup When set to true the markup of all
|
70
|
-
# be converted to the desired output (usually this is HTML).
|
71
|
-
# @option options [TrueClass] :comments When set to true all comments for
|
72
|
-
# will be retrieved.
|
73
|
-
# @option options [TrueClass] :comment_markup When set to true the markup
|
74
|
-
# will be converted to the desired output.
|
75
|
-
# @option options [TrueClass] :categories When set to true all categories
|
76
|
-
# entry will be retrieved as well.
|
70
|
+
# @option options [TrueClass] :markup When set to true the markup of all
|
71
|
+
# entries will be converted to the desired output (usually this is HTML).
|
72
|
+
# @option options [TrueClass] :comments When set to true all comments for
|
73
|
+
# each entry will be retrieved. Set to false by default.
|
74
|
+
# @option options [TrueClass] :comment_markup When set to true the markup
|
75
|
+
# of comments will be converted to the desired output.
|
76
|
+
# @option options [TrueClass] :categories When set to true all categories
|
77
|
+
# for each entry will be retrieved as well. This is set to false by
|
78
|
+
# default.
|
77
79
|
#
|
78
80
|
def initialize(options = {})
|
79
81
|
@options = {
|
@@ -82,29 +84,36 @@ module Sections
|
|
82
84
|
:section => nil,
|
83
85
|
:entry => nil,
|
84
86
|
:markup => true,
|
85
|
-
:comments =>
|
87
|
+
:comments => false,
|
86
88
|
:comment_markup => true,
|
87
|
-
:categories =>
|
89
|
+
:categories => false
|
88
90
|
}.merge(options)
|
89
91
|
|
90
92
|
validate_type(@options[:limit] , :limit , [Fixnum, Integer])
|
91
93
|
validate_type(@options[:offset] , :limit , [Fixnum, Integer])
|
92
|
-
|
93
|
-
validate_type(
|
94
|
+
|
95
|
+
validate_type(
|
96
|
+
@options[:section], :section, [NilClass, String, Integer, Fixnum]
|
97
|
+
)
|
98
|
+
|
99
|
+
validate_type(
|
100
|
+
@options[:entry], :entry, [NilClass, String, Integer, Fixnum]
|
101
|
+
)
|
102
|
+
|
94
103
|
validate_type(@options[:markup] , :markup , [TrueClass, FalseClass])
|
95
104
|
validate_type(@options[:comments], :comments, [TrueClass, FalseClass])
|
96
105
|
|
97
106
|
if @options[:section].nil? and @options[:entry].nil?
|
98
107
|
raise(
|
99
|
-
ArgumentError,
|
108
|
+
ArgumentError,
|
100
109
|
"You need to specify either an entry or a section to retrieve."
|
101
110
|
)
|
102
111
|
end
|
103
112
|
end
|
104
113
|
|
105
114
|
##
|
106
|
-
# Fetches all the data and converts everything to a hash. Once this is
|
107
|
-
# an array of entries or a single entry hash will be returned.
|
115
|
+
# Fetches all the data and converts everything to a hash. Once this is
|
116
|
+
# done either an array of entries or a single entry hash will be returned.
|
108
117
|
#
|
109
118
|
# @author Yorick Peterse
|
110
119
|
# @since 0.2.5
|
@@ -112,14 +121,18 @@ module Sections
|
|
112
121
|
#
|
113
122
|
def call
|
114
123
|
# Create the list with models to load using eager()
|
115
|
-
eager_models = [:custom_field_values, :
|
124
|
+
eager_models = [:custom_field_values, :user]
|
116
125
|
filter_hash = {}
|
117
126
|
|
118
127
|
if @options[:comments] === true
|
119
128
|
eager_models.push(:comments)
|
120
129
|
end
|
130
|
+
|
131
|
+
if @options[:categories] === true
|
132
|
+
eager_models.push(:categories)
|
133
|
+
end
|
121
134
|
|
122
|
-
#
|
135
|
+
# Get the section ID based on either the slug or ID.
|
123
136
|
if !@options[:section].nil?
|
124
137
|
# Retrieve the section by it's slug
|
125
138
|
if @options[:section].class == String
|
@@ -142,6 +155,10 @@ module Sections
|
|
142
155
|
end
|
143
156
|
end
|
144
157
|
|
158
|
+
# Get the correct status to retrieve
|
159
|
+
filter_hash[:section_entry_status_id] = \
|
160
|
+
::Sections::Model::SectionEntryStatus[:name => 'published'].id
|
161
|
+
|
145
162
|
# Get the entries
|
146
163
|
entries = SectionEntry.filter(filter_hash) \
|
147
164
|
.eager(*eager_models) \
|
@@ -152,10 +169,6 @@ module Sections
|
|
152
169
|
|
153
170
|
# Loop through all entries so we can process our custom field values
|
154
171
|
entries.each_with_index do |entry, index|
|
155
|
-
if comment_format.nil?
|
156
|
-
comment_format = entry.section.comment_format
|
157
|
-
end
|
158
|
-
|
159
172
|
field_values = {}
|
160
173
|
user = {}
|
161
174
|
comments = []
|
@@ -176,6 +189,10 @@ module Sections
|
|
176
189
|
|
177
190
|
# Get all the comments if the developer wants them
|
178
191
|
if @options[:comments] === true
|
192
|
+
if comment_format.nil?
|
193
|
+
comment_format = entry.section.comment_format
|
194
|
+
end
|
195
|
+
|
179
196
|
entry.comments.each do |c|
|
180
197
|
comment = c.values
|
181
198
|
|
@@ -185,7 +202,9 @@ module Sections
|
|
185
202
|
|
186
203
|
# Convert the comment's markup
|
187
204
|
if @options[:comment_markup]
|
188
|
-
comment[:comment] = plugin(
|
205
|
+
comment[:comment] = plugin(
|
206
|
+
:markup, comment_format, comment[:comment]
|
207
|
+
)
|
189
208
|
end
|
190
209
|
|
191
210
|
comments.push(comment)
|
@@ -198,8 +217,10 @@ module Sections
|
|
198
217
|
end
|
199
218
|
|
200
219
|
# Get all categories
|
201
|
-
|
202
|
-
cat
|
220
|
+
if @options[:categories] === true
|
221
|
+
categories = entry.categories.map do |cat|
|
222
|
+
cat.values
|
223
|
+
end
|
203
224
|
end
|
204
225
|
|
205
226
|
# Convert the entry to a hash and re-assign all data
|
@@ -3,8 +3,8 @@ module Sections
|
|
3
3
|
#:nodoc:
|
4
4
|
module Plugin
|
5
5
|
##
|
6
|
-
# Plugin that can be used to display sections and their details. If you want
|
7
|
-
# display section entries instead you should use the plugin
|
6
|
+
# Plugin that can be used to display sections and their details. If you want
|
7
|
+
# to display section entries instead you should use the plugin
|
8
8
|
# Sections::Plugin::SectionEntries.
|
9
9
|
#
|
10
10
|
# ## Usage
|
@@ -20,8 +20,8 @@ module Sections
|
|
20
20
|
include ::Sections::Model
|
21
21
|
|
22
22
|
##
|
23
|
-
# Creates a new instance of the plugin and saves/validates the given
|
24
|
-
# options.
|
23
|
+
# Creates a new instance of the plugin and saves/validates the given
|
24
|
+
# configuration options.
|
25
25
|
#
|
26
26
|
# @example
|
27
27
|
# plugin = Sections::Plugin::Sections.new(:section => 10)
|
@@ -39,19 +39,22 @@ module Sections
|
|
39
39
|
|
40
40
|
validate_type(@options[:limit] , :limit , [Fixnum, Integer])
|
41
41
|
validate_type(@options[:offset] , :offset , [Fixnum, Integer])
|
42
|
-
|
42
|
+
|
43
|
+
validate_type(
|
44
|
+
@options[:section], :section, [NilClass, Integer, Fixnum, String]
|
45
|
+
)
|
43
46
|
end
|
44
47
|
|
45
48
|
##
|
46
|
-
# Retrieves the section(s) based on the given configuration options. When
|
47
|
-
# sections are retrieved they're returned as an array, otherwise
|
48
|
-
# of Sections::Model::Sections will be returned.
|
49
|
+
# Retrieves the section(s) based on the given configuration options. When
|
50
|
+
# multiple sections are retrieved they're returned as an array, otherwise
|
51
|
+
# a single instance of Sections::Model::Sections will be returned.
|
49
52
|
#
|
50
53
|
# @author Yorick Peterse
|
51
54
|
# @since 0.2.5
|
52
|
-
# @return [Array/Sections::Model::Section] List of all sections that were
|
53
|
-
# or an instance of Sections::Model::Section in case a specific
|
54
|
-
# from the database.
|
55
|
+
# @return [Array/Sections::Model::Section] List of all sections that were
|
56
|
+
# retrieved or an instance of Sections::Model::Section in case a specific
|
57
|
+
# section was retrieved from the database.
|
55
58
|
#
|
56
59
|
def call
|
57
60
|
# Retrieve a single section
|
@@ -1,107 +1,110 @@
|
|
1
|
-
<
|
2
|
-
<
|
3
|
-
<
|
4
|
-
|
5
|
-
#{lang('sections.tabs.general')}
|
6
|
-
</a>
|
7
|
-
</li>
|
8
|
-
<li>
|
9
|
-
<a href="#comments" title="#{lang('sections.tabs.comment_settings')}">
|
10
|
-
#{lang('sections.tabs.comment_settings')}
|
11
|
-
</a>
|
12
|
-
</li>
|
13
|
-
<li>
|
14
|
-
<a href="#groups" title="#{lang('sections.tabs.group_assignments')}">
|
15
|
-
#{lang('sections.tabs.group_assignments')}
|
16
|
-
</a>
|
17
|
-
</li>
|
18
|
-
</ul>
|
19
|
-
</div>
|
20
|
-
|
21
|
-
#{
|
22
|
-
form_for(@section, :method => 'post', :action => @form_save_url, :id => :section_form) do |f|
|
1
|
+
<article>
|
2
|
+
<header>
|
3
|
+
<h1>#{get_breadcrumbs}</h1>
|
4
|
+
</header>
|
23
5
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
6
|
+
<div class="tabs">
|
7
|
+
<ul>
|
8
|
+
<li>
|
9
|
+
<a href="#general" title="#{lang('sections.tabs.general')}">
|
10
|
+
#{lang('sections.tabs.general')}
|
11
|
+
</a>
|
12
|
+
</li>
|
13
|
+
<li>
|
14
|
+
<a href="#comments"
|
15
|
+
title="#{lang('sections.tabs.comment_settings')}">
|
16
|
+
#{lang('sections.tabs.comment_settings')}
|
17
|
+
</a>
|
18
|
+
</li>
|
19
|
+
<li>
|
20
|
+
<a href="#groups"
|
21
|
+
title="#{lang('sections.tabs.group_assignments')}">
|
22
|
+
#{lang('sections.tabs.group_assignments')}
|
23
|
+
</a>
|
24
|
+
</li>
|
25
|
+
</ul>
|
26
|
+
</div>
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
#{
|
29
|
+
form_for(
|
30
|
+
@section,
|
31
|
+
:method => 'post',
|
32
|
+
:action => Sections::Controller::Sections.r(:save),
|
33
|
+
:id => :section_form
|
34
|
+
) do |f|
|
35
|
+
f.input_hidden(:id , @section.id)
|
36
|
+
f.input_hidden(:csrf_token, get_csrf_token)
|
33
37
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
+
f.g.div(:id => 'general') do
|
39
|
+
f.input_text(
|
40
|
+
lang('sections.labels.name'),
|
41
|
+
:name
|
42
|
+
)
|
38
43
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
)
|
44
|
+
f.input_text(
|
45
|
+
lang('sections.labels.slug'),
|
46
|
+
:slug
|
47
|
+
)
|
44
48
|
|
45
|
-
|
46
|
-
|
47
|
-
|
49
|
+
f.textarea(
|
50
|
+
lang('sections.labels.description'),
|
51
|
+
:description,
|
52
|
+
:rows => 8
|
53
|
+
)
|
54
|
+
end # f.g.div(:id => 'general')
|
48
55
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
f.input_radio(
|
57
|
-
lang('sections.labels.comment_require_account'),
|
58
|
-
:comment_require_account,
|
59
|
-
@section.comment_require_account,
|
60
|
-
:values => @boolean_hash
|
61
|
-
)
|
62
|
-
|
63
|
-
f.input_radio(
|
64
|
-
lang('sections.labels.comment_moderate'),
|
65
|
-
:comment_moderate,
|
66
|
-
@section.comment_moderate,
|
67
|
-
:values => @boolean_hash
|
68
|
-
)
|
69
|
-
|
70
|
-
f.select(
|
71
|
-
lang('sections.labels.comment_format'),
|
72
|
-
:comment_format,
|
73
|
-
:values => Zen::Plugin::Markup::Engines,
|
74
|
-
:selected => @section.comment_format,
|
75
|
-
:size => 1
|
76
|
-
)
|
56
|
+
f.g.div(:id => 'comments') do
|
57
|
+
f.input_radio(
|
58
|
+
lang('sections.labels.comment_allow'),
|
59
|
+
:comment_allow,
|
60
|
+
@section.comment_allow,
|
61
|
+
:values => @boolean_hash.invert
|
62
|
+
)
|
77
63
|
|
78
|
-
|
79
|
-
|
80
|
-
|
64
|
+
f.input_radio(
|
65
|
+
lang('sections.labels.comment_require_account'),
|
66
|
+
:comment_require_account,
|
67
|
+
@section.comment_require_account,
|
68
|
+
:values => @boolean_hash.invert
|
69
|
+
)
|
81
70
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
)
|
89
|
-
|
90
|
-
f.select(
|
91
|
-
lang('sections.labels.category_groups'),
|
92
|
-
:category_group_pks,
|
93
|
-
:values => @category_group_pk_hash,
|
94
|
-
:multiple => :multiple,
|
95
|
-
:selected => @section.category_group_pks
|
96
|
-
)
|
71
|
+
f.input_radio(
|
72
|
+
lang('sections.labels.comment_moderate'),
|
73
|
+
:comment_moderate,
|
74
|
+
@section.comment_moderate,
|
75
|
+
:values => @boolean_hash.invert
|
76
|
+
)
|
97
77
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
78
|
+
f.select(
|
79
|
+
lang('sections.labels.comment_format'),
|
80
|
+
:comment_format,
|
81
|
+
:values => Zen::Plugin::Markup::Engines,
|
82
|
+
:selected => @section.comment_format,
|
83
|
+
:size => 1
|
84
|
+
)
|
85
|
+
end # f.g.div(:id => 'comments')
|
86
|
+
|
87
|
+
f.g.div(:id => 'groups') do
|
88
|
+
f.select(
|
89
|
+
lang('sections.labels.custom_field_groups'),
|
90
|
+
:custom_field_group_pks,
|
91
|
+
:values => @custom_field_group_pk_hash,
|
92
|
+
:multiple => :multiple,
|
93
|
+
:selected => @section.custom_field_group_pks
|
94
|
+
)
|
105
95
|
|
106
|
-
|
107
|
-
|
96
|
+
f.select(
|
97
|
+
lang('sections.labels.category_groups'),
|
98
|
+
:category_group_pks,
|
99
|
+
:values => @category_group_pk_hash,
|
100
|
+
:multiple => :multiple,
|
101
|
+
:selected => @section.category_group_pks
|
102
|
+
)
|
103
|
+
end # f.g.div(:id => 'groups')
|
104
|
+
|
105
|
+
f.g.div(:class => 'button') do
|
106
|
+
f.g.input(:type => 'submit', :value => lang('sections.buttons.save'))
|
107
|
+
end
|
108
|
+
end
|
109
|
+
}
|
110
|
+
</article>
|