zen 0.1a
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/MANIFEST +337 -0
- data/README.textile +42 -0
- data/Rakefile +6 -0
- data/bin/zen +9 -0
- data/doc/Categories.html +93 -0
- data/doc/Categories/Controllers.html +93 -0
- data/doc/Categories/Controllers/Categories.html +995 -0
- data/doc/Categories/Controllers/CategoryGroups.html +878 -0
- data/doc/Categories/Models.html +97 -0
- data/doc/Categories/Models/Category.html +269 -0
- data/doc/Categories/Models/CategoryGroup.html +231 -0
- data/doc/Comments.html +93 -0
- data/doc/Comments/Controllers.html +93 -0
- data/doc/Comments/Controllers/Comments.html +797 -0
- data/doc/Comments/Controllers/CommentsForm.html +487 -0
- data/doc/Comments/Liquid.html +93 -0
- data/doc/Comments/Liquid/CommentForm.html +522 -0
- data/doc/Comments/Liquid/Comments.html +543 -0
- data/doc/Comments/Models.html +95 -0
- data/doc/Comments/Models/Comment.html +260 -0
- data/doc/CustomFields.html +93 -0
- data/doc/CustomFields/Controllers.html +93 -0
- data/doc/CustomFields/Controllers/CustomFieldGroups.html +902 -0
- data/doc/CustomFields/Controllers/CustomFields.html +974 -0
- data/doc/CustomFields/Models.html +97 -0
- data/doc/CustomFields/Models/CustomField.html +272 -0
- data/doc/CustomFields/Models/CustomFieldGroup.html +259 -0
- data/doc/CustomFields/Models/CustomFieldValue.html +154 -0
- data/doc/Ramaze.html +93 -0
- data/doc/Ramaze/Helper.html +93 -0
- data/doc/Ramaze/Helper/ACL.html +531 -0
- data/doc/Ramaze/Helper/Asset.html +617 -0
- data/doc/Ramaze/Helper/Breadcrumb.html +411 -0
- data/doc/Ramaze/Helper/Common.html +738 -0
- data/doc/Sections.html +93 -0
- data/doc/Sections/Controllers.html +93 -0
- data/doc/Sections/Controllers/SectionEntries.html +1100 -0
- data/doc/Sections/Controllers/Sections.html +953 -0
- data/doc/Sections/Liquid.html +93 -0
- data/doc/Sections/Liquid/SectionEntries.html +674 -0
- data/doc/Sections/Liquid/Sections.html +494 -0
- data/doc/Sections/Models.html +97 -0
- data/doc/Sections/Models/Section.html +272 -0
- data/doc/Sections/Models/SectionEntry.html +264 -0
- data/doc/Sequel.html +91 -0
- data/doc/Sequel/Model.html +243 -0
- data/doc/Settings.html +93 -0
- data/doc/Settings/Controllers.html +91 -0
- data/doc/Settings/Controllers/Settings.html +565 -0
- data/doc/Settings/Liquid.html +91 -0
- data/doc/Settings/Liquid/Setting.html +426 -0
- data/doc/Settings/Models.html +95 -0
- data/doc/Settings/Models/Setting.html +293 -0
- data/doc/Users.html +93 -0
- data/doc/Users/Controllers.html +93 -0
- data/doc/Users/Controllers/AccessRules.html +904 -0
- data/doc/Users/Controllers/UserGroups.html +879 -0
- data/doc/Users/Controllers/Users.html +1124 -0
- data/doc/Users/Liquid.html +93 -0
- data/doc/Users/Liquid/User.html +480 -0
- data/doc/Users/Liquid/Users.html +495 -0
- data/doc/Users/Models.html +97 -0
- data/doc/Users/Models/AccessRule.html +257 -0
- data/doc/Users/Models/User.html +649 -0
- data/doc/Users/Models/UserGroup.html +267 -0
- data/doc/Zen.html +391 -0
- data/doc/Zen/Bin.html +113 -0
- data/doc/Zen/Bin/Base.html +727 -0
- data/doc/Zen/Controllers.html +115 -0
- data/doc/Zen/Controllers/AdminController.html +298 -0
- data/doc/Zen/Controllers/BaseController.html +272 -0
- data/doc/Zen/Controllers/FrontendController.html +164 -0
- data/doc/Zen/Controllers/MainController.html +421 -0
- data/doc/Zen/Database.html +498 -0
- data/doc/Zen/Language.html +660 -0
- data/doc/Zen/Liquid.html +117 -0
- data/doc/Zen/Liquid/ControllerBehavior.html +448 -0
- data/doc/Zen/Liquid/General.html +444 -0
- data/doc/Zen/Liquid/Redirect.html +435 -0
- data/doc/Zen/Liquid/Strip.html +447 -0
- data/doc/Zen/Logger.html +393 -0
- data/doc/Zen/Package.html +909 -0
- data/doc/_index.html +724 -0
- data/doc/class_list.html +36 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +53 -0
- data/doc/css/style.css +310 -0
- data/doc/file.README.html +86 -0
- data/doc/file_list.html +38 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +86 -0
- data/doc/js/app.js +203 -0
- data/doc/js/full_list.js +149 -0
- data/doc/js/jquery.js +154 -0
- data/doc/method_list.html +1139 -0
- data/doc/top-level-namespace.html +88 -0
- data/lib/zen.rb +77 -0
- data/lib/zen/base/database.rb +105 -0
- data/lib/zen/base/language.rb +132 -0
- data/lib/zen/base/logger.rb +54 -0
- data/lib/zen/base/package.rb +233 -0
- data/lib/zen/base/version.rb +11 -0
- data/lib/zen/bin/zen_binary.rb +173 -0
- data/lib/zen/controller/admin_controller.rb +60 -0
- data/lib/zen/controller/base_controller.rb +39 -0
- data/lib/zen/controller/frontend_controller.rb +16 -0
- data/lib/zen/controller/main_controller.rb +93 -0
- data/lib/zen/helper/acl.rb +124 -0
- data/lib/zen/helper/asset.rb +104 -0
- data/lib/zen/helper/breadcrumb.rb +71 -0
- data/lib/zen/helper/common.rb +157 -0
- data/lib/zen/language/en/zen_general.rb +21 -0
- data/lib/zen/language/en/zen_models.rb +39 -0
- data/lib/zen/layout/admin.xhtml +72 -0
- data/lib/zen/layout/login.xhtml +44 -0
- data/lib/zen/liquid/controller_behavior.rb +55 -0
- data/lib/zen/liquid/general.rb +69 -0
- data/lib/zen/liquid/redirect.rb +47 -0
- data/lib/zen/liquid/strip.rb +58 -0
- data/lib/zen/model/methods.rb +26 -0
- data/lib/zen/model/settings.rb +27 -0
- data/lib/zen/packages/categories/LICENSE +19 -0
- data/lib/zen/packages/categories/README.textile +0 -0
- data/lib/zen/packages/categories/lib/categories.rb +24 -0
- data/lib/zen/packages/categories/lib/categories/controller/categories.rb +202 -0
- data/lib/zen/packages/categories/lib/categories/controller/category_groups.rb +173 -0
- data/lib/zen/packages/categories/lib/categories/language/en/categories.rb +38 -0
- data/lib/zen/packages/categories/lib/categories/language/en/category_groups.rb +37 -0
- data/lib/zen/packages/categories/lib/categories/model/category.rb +42 -0
- data/lib/zen/packages/categories/lib/categories/model/category_group.rb +29 -0
- data/lib/zen/packages/categories/lib/categories/view/admin/categories/edit.xhtml +7 -0
- data/lib/zen/packages/categories/lib/categories/view/admin/categories/form.xhtml +36 -0
- data/lib/zen/packages/categories/lib/categories/view/admin/categories/index.xhtml +70 -0
- data/lib/zen/packages/categories/lib/categories/view/admin/categories/new.xhtml +7 -0
- data/lib/zen/packages/categories/lib/categories/view/admin/category_groups/edit.xhtml +7 -0
- data/lib/zen/packages/categories/lib/categories/view/admin/category_groups/form.xhtml +18 -0
- data/lib/zen/packages/categories/lib/categories/view/admin/category_groups/index.xhtml +72 -0
- data/lib/zen/packages/categories/lib/categories/view/admin/category_groups/new.xhtml +7 -0
- data/lib/zen/packages/categories/migrations/.gitkeep +0 -0
- data/lib/zen/packages/categories/migrations/1295282303_create_schema.rb +40 -0
- data/lib/zen/packages/comments/LICENSE +19 -0
- data/lib/zen/packages/comments/README.textile +0 -0
- data/lib/zen/packages/comments/lib/comments.rb +26 -0
- data/lib/zen/packages/comments/lib/comments/controller/comments.rb +157 -0
- data/lib/zen/packages/comments/lib/comments/controller/comments_form.rb +135 -0
- data/lib/zen/packages/comments/lib/comments/language/en/comments.rb +52 -0
- data/lib/zen/packages/comments/lib/comments/liquid/comment_form.rb +97 -0
- data/lib/zen/packages/comments/lib/comments/liquid/comments.rb +115 -0
- data/lib/zen/packages/comments/lib/comments/model/comment.rb +34 -0
- data/lib/zen/packages/comments/lib/comments/view/admin/comments/edit.xhtml +7 -0
- data/lib/zen/packages/comments/lib/comments/view/admin/comments/form.xhtml +31 -0
- data/lib/zen/packages/comments/lib/comments/view/admin/comments/index.xhtml +74 -0
- data/lib/zen/packages/comments/migrations/.gitkeep +0 -0
- data/lib/zen/packages/comments/migrations/1295282202_create_schema.rb +24 -0
- data/lib/zen/packages/comments/migrations/1296949631_add_defensio_signature.rb +11 -0
- data/lib/zen/packages/custom_fields/LICENSE +19 -0
- data/lib/zen/packages/custom_fields/README.textile +0 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields.rb +24 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +179 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/controller/custom_fields.rb +194 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/language/en/custom_field_groups.rb +45 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/language/en/custom_fields.rb +64 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/model/custom_field.rb +41 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/model/custom_field_group.rb +32 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/model/custom_field_value.rb +20 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/view/admin/custom_field_groups/edit.xhtml +7 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/view/admin/custom_field_groups/form.xhtml +18 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/view/admin/custom_field_groups/index.xhtml +88 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/view/admin/custom_field_groups/new.xhtml +7 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/view/admin/custom_fields/edit.xhtml +7 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/view/admin/custom_fields/form.xhtml +50 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/view/admin/custom_fields/index.xhtml +75 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/view/admin/custom_fields/new.xhtml +7 -0
- data/lib/zen/packages/custom_fields/migrations/.gitkeep +0 -0
- data/lib/zen/packages/custom_fields/migrations/1295255665_create_schema.rb +53 -0
- data/lib/zen/packages/sections/LICENSE +19 -0
- data/lib/zen/packages/sections/README.textile +43 -0
- data/lib/zen/packages/sections/lib/sections.rb +33 -0
- data/lib/zen/packages/sections/lib/sections/controller/section_entries.rb +251 -0
- data/lib/zen/packages/sections/lib/sections/controller/sections.rb +205 -0
- data/lib/zen/packages/sections/lib/sections/language/en/section_entries.rb +58 -0
- data/lib/zen/packages/sections/lib/sections/language/en/sections.rb +63 -0
- data/lib/zen/packages/sections/lib/sections/liquid/section_entries.rb +209 -0
- data/lib/zen/packages/sections/lib/sections/liquid/sections.rb +76 -0
- data/lib/zen/packages/sections/lib/sections/model/section.rb +43 -0
- data/lib/zen/packages/sections/lib/sections/model/section_entry.rb +43 -0
- data/lib/zen/packages/sections/lib/sections/view/admin/edit.xhtml +7 -0
- data/lib/zen/packages/sections/lib/sections/view/admin/form.xhtml +54 -0
- data/lib/zen/packages/sections/lib/sections/view/admin/index.xhtml +77 -0
- data/lib/zen/packages/sections/lib/sections/view/admin/new.xhtml +7 -0
- data/lib/zen/packages/sections/lib/sections/view/admin/section_entries/edit.xhtml +7 -0
- data/lib/zen/packages/sections/lib/sections/view/admin/section_entries/form.xhtml +147 -0
- data/lib/zen/packages/sections/lib/sections/view/admin/section_entries/index.xhtml +74 -0
- data/lib/zen/packages/sections/lib/sections/view/admin/section_entries/new.xhtml +7 -0
- data/lib/zen/packages/sections/migrations/.gitkeep +0 -0
- data/lib/zen/packages/sections/migrations/1295251836_create_schema.rb +35 -0
- data/lib/zen/packages/sections/migrations/1296335671_userdata_section_entries.rb +18 -0
- data/lib/zen/packages/sections/migrations/1296936110_drop_comment_antispam.rb +11 -0
- data/lib/zen/packages/settings/LICENSE +0 -0
- data/lib/zen/packages/settings/README.textile +0 -0
- data/lib/zen/packages/settings/lib/settings.rb +22 -0
- data/lib/zen/packages/settings/lib/settings/controller/settings.rb +113 -0
- data/lib/zen/packages/settings/lib/settings/language/en/settings.rb +56 -0
- data/lib/zen/packages/settings/lib/settings/liquid/setting.rb +56 -0
- data/lib/zen/packages/settings/lib/settings/model/setting.rb +38 -0
- data/lib/zen/packages/settings/lib/settings/view/admin/settings/index.xhtml +79 -0
- data/lib/zen/packages/settings/migrations/.gitkeep +0 -0
- data/lib/zen/packages/settings/migrations/1295597111_create_schema.rb +31 -0
- data/lib/zen/packages/users/LICENSE +19 -0
- data/lib/zen/packages/users/README.textile +0 -0
- data/lib/zen/packages/users/lib/users.rb +35 -0
- data/lib/zen/packages/users/lib/users/controller/access_rules.rb +186 -0
- data/lib/zen/packages/users/lib/users/controller/user_groups.rb +171 -0
- data/lib/zen/packages/users/lib/users/controller/users.rb +240 -0
- data/lib/zen/packages/users/lib/users/language/en/access_rules.rb +49 -0
- data/lib/zen/packages/users/lib/users/language/en/user_groups.rb +42 -0
- data/lib/zen/packages/users/lib/users/language/en/users.rb +63 -0
- data/lib/zen/packages/users/lib/users/liquid/user.rb +75 -0
- data/lib/zen/packages/users/lib/users/liquid/users.rb +80 -0
- data/lib/zen/packages/users/lib/users/model/access_rule.rb +29 -0
- data/lib/zen/packages/users/lib/users/model/user.rb +96 -0
- data/lib/zen/packages/users/lib/users/model/user_group.rb +38 -0
- data/lib/zen/packages/users/lib/users/public/admin/js/users/access_rules.js +43 -0
- data/lib/zen/packages/users/lib/users/view/admin/access_rules/edit.xhtml +7 -0
- data/lib/zen/packages/users/lib/users/view/admin/access_rules/form.xhtml +68 -0
- data/lib/zen/packages/users/lib/users/view/admin/access_rules/index.xhtml +85 -0
- data/lib/zen/packages/users/lib/users/view/admin/access_rules/new.xhtml +7 -0
- data/lib/zen/packages/users/lib/users/view/admin/user_groups/edit.xhtml +7 -0
- data/lib/zen/packages/users/lib/users/view/admin/user_groups/form.xhtml +19 -0
- data/lib/zen/packages/users/lib/users/view/admin/user_groups/index.xhtml +69 -0
- data/lib/zen/packages/users/lib/users/view/admin/user_groups/new.xhtml +7 -0
- data/lib/zen/packages/users/lib/users/view/admin/users/edit.xhtml +7 -0
- data/lib/zen/packages/users/lib/users/view/admin/users/form.xhtml +25 -0
- data/lib/zen/packages/users/lib/users/view/admin/users/index.xhtml +73 -0
- data/lib/zen/packages/users/lib/users/view/admin/users/login.xhtml +22 -0
- data/lib/zen/packages/users/lib/users/view/admin/users/new.xhtml +7 -0
- data/lib/zen/packages/users/migrations/.gitkeep +0 -0
- data/lib/zen/packages/users/migrations/1295281013_create_schema.rb +54 -0
- data/lib/zen/public/admin/css/boilerplate.css +174 -0
- data/lib/zen/public/admin/css/general.css +485 -0
- data/lib/zen/public/admin/css/grid.css +119 -0
- data/lib/zen/public/admin/css/layout.css +111 -0
- data/lib/zen/public/admin/images/general/noise.jpg +0 -0
- data/lib/zen/public/admin/images/icons/accept.png +0 -0
- data/lib/zen/public/admin/images/icons/add.png +0 -0
- data/lib/zen/public/admin/images/icons/back.png +0 -0
- data/lib/zen/public/admin/images/icons/bold.png +0 -0
- data/lib/zen/public/admin/images/icons/close.png +0 -0
- data/lib/zen/public/admin/images/icons/delete.png +0 -0
- data/lib/zen/public/admin/images/icons/edit.png +0 -0
- data/lib/zen/public/admin/images/icons/error.png +0 -0
- data/lib/zen/public/admin/images/icons/help.png +0 -0
- data/lib/zen/public/admin/images/icons/info.png +0 -0
- data/lib/zen/public/admin/images/icons/italic.png +0 -0
- data/lib/zen/public/admin/images/icons/large/error.png +0 -0
- data/lib/zen/public/admin/images/icons/large/notice.png +0 -0
- data/lib/zen/public/admin/images/icons/large/success.png +0 -0
- data/lib/zen/public/admin/images/icons/link.png +0 -0
- data/lib/zen/public/admin/images/icons/logout.png +0 -0
- data/lib/zen/public/admin/images/icons/ol.png +0 -0
- data/lib/zen/public/admin/images/icons/pdf.png +0 -0
- data/lib/zen/public/admin/images/icons/ul.png +0 -0
- data/lib/zen/public/admin/images/icons/user.png +0 -0
- data/lib/zen/public/admin/images/icons/view.png +0 -0
- data/lib/zen/public/admin/js/mootools/core.js +436 -0
- data/lib/zen/public/admin/js/mootools/more.js +288 -0
- data/lib/zen/public/admin/js/zen/editor/base.js +265 -0
- data/lib/zen/public/admin/js/zen/editor/drivers/html.js +104 -0
- data/lib/zen/public/admin/js/zen/editor/drivers/markdown.js +102 -0
- data/lib/zen/public/admin/js/zen/editor/drivers/textile.js +102 -0
- data/lib/zen/public/admin/js/zen/init.js +57 -0
- data/lib/zen/public/admin/js/zen/modal.js +159 -0
- data/lib/zen/public/admin/js/zen/notification.js +213 -0
- data/lib/zen/public/admin/js/zen/tabs.js +263 -0
- data/lib/zen/tasks.rb +6 -0
- data/pkg/.gitkeep +0 -0
- data/proto/app/Rakefile +2 -0
- data/proto/app/app.rb +20 -0
- data/proto/app/config.ru +18 -0
- data/proto/app/config/config.rb +17 -0
- data/proto/app/config/database.rb +18 -0
- data/proto/app/config/middlewares.rb +23 -0
- data/proto/app/config/requires.rb +8 -0
- data/proto/app/logs/.gitkeep +0 -0
- data/proto/app/public/.gitkeep +0 -0
- data/proto/app/start.rb +22 -0
- data/proto/app/vendor/.gitkeep +0 -0
- data/proto/app/vendor/themes/.gitkeep +0 -0
- data/proto/migration.rb +11 -0
- data/proto/module/LICENSE +0 -0
- data/proto/module/README.textile +0 -0
- data/proto/module/lib/module.rb +15 -0
- data/proto/module/lib/module/controller/controllers.rb +86 -0
- data/proto/module/lib/module/language/en/languages.rb +3 -0
- data/proto/module/lib/module/model/model.rb +12 -0
- data/proto/module/lib/module/view/admin/edit.xhtml +0 -0
- data/proto/module/lib/module/view/admin/form.xhtml +0 -0
- data/proto/module/lib/module/view/admin/index.xhtml +0 -0
- data/proto/module/lib/module/view/admin/new.xhtml +0 -0
- data/proto/module/migrations/.gitkeep +0 -0
- data/spec/javascript/css/base.css +177 -0
- data/spec/javascript/css/style.css +204 -0
- data/spec/javascript/css/typography.css +70 -0
- data/spec/javascript/editor/index.html +65 -0
- data/spec/javascript/images/close.png +0 -0
- data/spec/javascript/images/info.png +0 -0
- data/spec/javascript/js/editor.js +16 -0
- data/spec/javascript/js/modal.js +12 -0
- data/spec/javascript/js/namespace.js +2 -0
- data/spec/javascript/js/notification.js +43 -0
- data/spec/javascript/js/tabs.js +8 -0
- data/spec/javascript/modal/index.html +45 -0
- data/spec/javascript/notification/index.html +48 -0
- data/spec/javascript/tabs/index.html +73 -0
- data/spec/javascript/tabs/tab_1.html +1 -0
- data/spec/javascript/tabs/tab_2.html +1 -0
- data/spec/zen/base/language.rb +31 -0
- data/spec/zen/base/logger.rb +34 -0
- data/spec/zen/base/package.rb +47 -0
- data/spec/zen/config/database.rb +8 -0
- data/spec/zen/helper/asset.rb +26 -0
- data/spec/zen/helper/breadcrumb.rb +24 -0
- data/spec/zen/language/en/general.rb +4 -0
- data/spec/zen/language/nl/general.rb +4 -0
- data/spec/zen/liquid/general.rb +42 -0
- data/spec/zen/logs/.gitkeep +0 -0
- data/spec/zen/spec.rb +9 -0
- data/spec/zen/spec_database.db +0 -0
- data/tasks/bacon.rake +99 -0
- data/tasks/build.rake +72 -0
- data/tasks/clean.rake +18 -0
- data/tasks/db.rake +81 -0
- data/tasks/doc.rake +5 -0
- data/tasks/extension.rake +65 -0
- data/tasks/proto.rake +37 -0
- data/tasks/theme.rake +63 -0
- metadata +512 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
module Zen
|
2
|
+
module Controllers
|
3
|
+
##
|
4
|
+
# The BaseController is extended by both the FrontendController and the BackendController.
|
5
|
+
# This controller is mostly used to set and retrieve data that's used in both the
|
6
|
+
# backend and the frontend.
|
7
|
+
#
|
8
|
+
# @author Yorick Peterse
|
9
|
+
# @since 0.1
|
10
|
+
#
|
11
|
+
class BaseController < Ramaze::Controller
|
12
|
+
helper :csrf, :cgi
|
13
|
+
|
14
|
+
##
|
15
|
+
# The initialize method is called upon class initalization and is used to process several
|
16
|
+
# items before loading the controller(s) for the current module.
|
17
|
+
#
|
18
|
+
# @author Yorick Peterse
|
19
|
+
# @since 1.0
|
20
|
+
#
|
21
|
+
def initialize
|
22
|
+
super
|
23
|
+
|
24
|
+
# The trait for the User helper has to be specified in the constructor as
|
25
|
+
# our user model is loaded after this class is loaded (but before it's initialized)
|
26
|
+
self.trait :user_model => ::Users::Models::User
|
27
|
+
|
28
|
+
# Get all settings
|
29
|
+
if !session[:settings]
|
30
|
+
session[:settings] = ::Settings::Models::Setting.get_settings
|
31
|
+
end
|
32
|
+
|
33
|
+
# Override the language
|
34
|
+
Zen.options.language = session[:settings][:language]
|
35
|
+
@zen_general_lang = Zen::Language.load('zen_general')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Zen
|
2
|
+
module Controllers
|
3
|
+
##
|
4
|
+
# Controller that should be extended by other controllers that can be accessed from
|
5
|
+
# the web without having to log in. Frontend controllers don't have a layout and
|
6
|
+
# use the Liquid template engine for all views.
|
7
|
+
#
|
8
|
+
# @author Yorick Peterse
|
9
|
+
# @since 0.1
|
10
|
+
#
|
11
|
+
class FrontendController < Zen::Controllers::BaseController
|
12
|
+
engine :liquid
|
13
|
+
layout :none
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module Zen
|
2
|
+
module Controllers
|
3
|
+
##
|
4
|
+
# The MainController controller is used to load the correct template files based
|
5
|
+
# on the current URI. If no section is specified the default section will be retrieved
|
6
|
+
# from the settings table.
|
7
|
+
#
|
8
|
+
# @author Yorick Peterse
|
9
|
+
# @since 0.1
|
10
|
+
#
|
11
|
+
class MainController < Zen::Controllers::FrontendController
|
12
|
+
map '/'
|
13
|
+
|
14
|
+
##
|
15
|
+
# The index method acts as a catch-all method. Based on the requested URI
|
16
|
+
# the correct template group/file will be loaded. If no templates are found
|
17
|
+
# a 404 template will be loaded. If that's not found either a default error
|
18
|
+
# will be shown. If the website is offline we'll try to load the template
|
19
|
+
# "offline", if it isn't there a regular message will be displayed.
|
20
|
+
#
|
21
|
+
# @author Yorick Peterse
|
22
|
+
# @since 0.1
|
23
|
+
# @param [Array] uri Array containing all arguments (thus the URI).
|
24
|
+
#
|
25
|
+
def index(*uri)
|
26
|
+
settings = session[:settings]
|
27
|
+
@uri = []
|
28
|
+
|
29
|
+
# Clean the URI of nasty input
|
30
|
+
uri.each { |v| @uri.push(h(v)) }
|
31
|
+
|
32
|
+
if !@uri[0] or @uri[0].empty?
|
33
|
+
@uri[0] = settings[:default_section]
|
34
|
+
end
|
35
|
+
|
36
|
+
if !@uri[1] or @uri[1].empty?
|
37
|
+
@uri[1] = 'index'
|
38
|
+
end
|
39
|
+
|
40
|
+
# A theme is always required
|
41
|
+
if settings[:theme].nil?
|
42
|
+
respond(@zen_general_lang.errors[:no_theme])
|
43
|
+
end
|
44
|
+
|
45
|
+
theme = ::Zen::Package[settings[:theme]]
|
46
|
+
group = @uri[0]
|
47
|
+
template = @uri[1]
|
48
|
+
|
49
|
+
# Pre-create a few Liquid variables
|
50
|
+
@flash = {}
|
51
|
+
@current_user = {}
|
52
|
+
flash.each { |k, v| @flash[k.to_s] = v }
|
53
|
+
|
54
|
+
if !session[:user].nil?
|
55
|
+
session[:user].values.each { |k, v| @current_user[k.to_s] = v }
|
56
|
+
end
|
57
|
+
|
58
|
+
# Create the group, template and partial paths
|
59
|
+
theme_path = theme.directory + '/templates'
|
60
|
+
group_path = theme_path + "/#{group}"
|
61
|
+
template_path = theme_path + "/#{group}/#{template}.liquid"
|
62
|
+
|
63
|
+
# Register our partial path
|
64
|
+
partial_path = theme_path + "/partials"
|
65
|
+
::Liquid::Template.file_system = ::Liquid::LocalFileSystem.new(partial_path)
|
66
|
+
|
67
|
+
# Is the website down?
|
68
|
+
if settings[:website_enabled] == '0'
|
69
|
+
offline_path = theme_path + "/offline.liquid"
|
70
|
+
|
71
|
+
if File.exist?(offline_path)
|
72
|
+
render_file offline_path
|
73
|
+
else
|
74
|
+
respond(@zen_general_lang.errors[:website_offline])
|
75
|
+
end
|
76
|
+
else
|
77
|
+
# Check if the group exists
|
78
|
+
if File.directory?(group_path) and File.exists?(template_path)
|
79
|
+
render_file template_path
|
80
|
+
else
|
81
|
+
not_found = theme_path + "/404.liquid"
|
82
|
+
|
83
|
+
if File.exist?(not_found)
|
84
|
+
render_file not_found
|
85
|
+
else
|
86
|
+
respond(@zen_general_lang.errors[:no_templates], 404)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
module Ramaze
|
2
|
+
module Helper
|
3
|
+
##
|
4
|
+
# This helper provides an easy way of working with the ACL system that
|
5
|
+
# ships with Zen. Using this helper you can restrict access to methods,
|
6
|
+
# view elements and pretty much everything else based on the user's
|
7
|
+
# permissions.
|
8
|
+
#
|
9
|
+
# In order to use the ACL helper you'll need to define a trait named
|
10
|
+
# "extension_identifier" in your classes. Once this trait have been set you
|
11
|
+
# can use the "user_authorized?" method to verify the permissions of the current user.
|
12
|
+
# The first parameter is an array of required permissions,
|
13
|
+
# the second a boolean that indicates if either all or just a single permission must be set.
|
14
|
+
#
|
15
|
+
# For more information about the ACL system you should read the documentation
|
16
|
+
# in the ACL controller, Users::Controllers::AccessRules().
|
17
|
+
#
|
18
|
+
# @author Yorick Peterse
|
19
|
+
# @since 0.1
|
20
|
+
# @see Users::Controllers::AccessRules()
|
21
|
+
#
|
22
|
+
module ACL
|
23
|
+
##
|
24
|
+
# Retrieves all permissions for the current user
|
25
|
+
# along with the permissions set for all groups the user
|
26
|
+
# belongs to. Rather than loading a new instance of the User model
|
27
|
+
# we'll retrieve the model from the session variable set by the
|
28
|
+
# User helper provided by Ramaze. Doing this saves us a few queries.
|
29
|
+
#
|
30
|
+
# @author Yorick Peterse
|
31
|
+
# @since 0.1
|
32
|
+
# @return [Mixed] returns a hash containing all rules per identifier along
|
33
|
+
# with a boolean that indicates if the user is in a super group.
|
34
|
+
#
|
35
|
+
def extension_permissions
|
36
|
+
m = session[:user]
|
37
|
+
user_groups = m.user_groups
|
38
|
+
super_group = false
|
39
|
+
rules = []
|
40
|
+
ordered_rules = {}
|
41
|
+
|
42
|
+
user_groups.each do |group|
|
43
|
+
rules += group.access_rules
|
44
|
+
|
45
|
+
if group.super_group == true
|
46
|
+
super_group = true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
m.access_rules.each do |rule|
|
51
|
+
rules.push(rule)
|
52
|
+
end
|
53
|
+
|
54
|
+
rules.each do |rule|
|
55
|
+
if !ordered_rules.key?(rule.extension)
|
56
|
+
ordered_rules[rule.extension] = []
|
57
|
+
end
|
58
|
+
|
59
|
+
[:create_access, :read_access, :update_access, :delete_access].each do |perm|
|
60
|
+
if rule.send(perm) === true or super_group == true
|
61
|
+
perm = perm.to_s.gsub!('_access', '').to_sym
|
62
|
+
|
63
|
+
if !ordered_rules[rule.extension].include?(perm)
|
64
|
+
ordered_rules[rule.extension].push(perm)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
return ordered_rules, super_group
|
71
|
+
end
|
72
|
+
|
73
|
+
##
|
74
|
+
# Checks if the user has the specified permissions for the current
|
75
|
+
# extension that was called. Returns true if this is the case and false
|
76
|
+
# otherwise.
|
77
|
+
#
|
78
|
+
# @author Yorick Peterse
|
79
|
+
# @param [Array] reqs Array of permissions that are required.
|
80
|
+
# @param [Boolean] require_all Boolean that specifies that the user
|
81
|
+
# should have ALL specified permissios. Setting this to false causes
|
82
|
+
# this method to return true if any of the permissions are set for the
|
83
|
+
# current user.
|
84
|
+
# @return [Boolean]
|
85
|
+
#
|
86
|
+
def user_authorized?(reqs, require_all = true)
|
87
|
+
identifier = ancestral_trait.values_at(:extension_identifier)
|
88
|
+
identifier = identifier[0]
|
89
|
+
|
90
|
+
if identifier.nil?
|
91
|
+
raise "You need to specify an extension identifier"
|
92
|
+
end
|
93
|
+
|
94
|
+
# Get the ACL list
|
95
|
+
rules = self.extension_permissions
|
96
|
+
super_group = rules[1]
|
97
|
+
rules = rules[0]
|
98
|
+
|
99
|
+
# Super groups have full access
|
100
|
+
if super_group == true
|
101
|
+
return true
|
102
|
+
end
|
103
|
+
|
104
|
+
# Deny access if the identifier is not found
|
105
|
+
if !rules.key?(identifier)
|
106
|
+
return false
|
107
|
+
end
|
108
|
+
|
109
|
+
# Verify the permissions
|
110
|
+
perms = rules[identifier]
|
111
|
+
|
112
|
+
reqs.each do |req|
|
113
|
+
if require_all == false and perms.include?(req)
|
114
|
+
return true
|
115
|
+
elsif !perms.include?(req)
|
116
|
+
return false
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
return true
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'ramaze/gestalt'
|
2
|
+
|
3
|
+
module Ramaze
|
4
|
+
module Helper
|
5
|
+
##
|
6
|
+
# The Asset helper can be used to load Javascript and CSS files without
|
7
|
+
# having to embedd them in your views. In order to tell the helper that
|
8
|
+
# a CSS or Javascript file has to be loaded you'll have to call the
|
9
|
+
# require_* method. For example, if we want to require a CSS file named
|
10
|
+
# "reset" we'd do the following:
|
11
|
+
#
|
12
|
+
# bc. register_css :reset
|
13
|
+
#
|
14
|
+
# Once you have your files required you can build the HTML by either calling
|
15
|
+
# build_css or build_js.
|
16
|
+
#
|
17
|
+
# @author Yorick Peterse
|
18
|
+
# @since 0.1
|
19
|
+
# @todo Add support for compressing Javascript and CSS files.
|
20
|
+
#
|
21
|
+
module Asset
|
22
|
+
@css = []
|
23
|
+
@js = []
|
24
|
+
|
25
|
+
##
|
26
|
+
# Requires a new CSS file.
|
27
|
+
#
|
28
|
+
# @author Yorick Peterse
|
29
|
+
# @param [Symbol] files Paths to the CSS files to require.
|
30
|
+
# @since 0.1
|
31
|
+
#
|
32
|
+
def require_css *files
|
33
|
+
if @css.nil?
|
34
|
+
@css = []
|
35
|
+
end
|
36
|
+
|
37
|
+
files.each do |file|
|
38
|
+
file = file.to_sym
|
39
|
+
|
40
|
+
if !@css.include?(file)
|
41
|
+
@css.push(file)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
##
|
47
|
+
# Requires a new Javascript file.
|
48
|
+
#
|
49
|
+
# @author Yorick Peterse
|
50
|
+
# @param [Symbol] files Paths to the Javascript files to require.
|
51
|
+
# @since 0.1
|
52
|
+
#
|
53
|
+
def require_js *files
|
54
|
+
if @js.nil?
|
55
|
+
@js = []
|
56
|
+
end
|
57
|
+
|
58
|
+
files.each do |file|
|
59
|
+
file = file.to_sym
|
60
|
+
|
61
|
+
if !@js.include?(file)
|
62
|
+
@js.push(file)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
##
|
68
|
+
# Builds the HTML for all CSS tags using Gestalt.
|
69
|
+
#
|
70
|
+
# @author Yorick Peterse
|
71
|
+
# @since 0.1
|
72
|
+
# @return [String]
|
73
|
+
#
|
74
|
+
def build_css
|
75
|
+
g = Ramaze::Gestalt.new
|
76
|
+
|
77
|
+
@css.each do |css|
|
78
|
+
css = "/admin/css/#{css}.css"
|
79
|
+
g.link :rel => "stylesheet", :href => css, :media => "all", :type => "text/css"
|
80
|
+
end
|
81
|
+
|
82
|
+
return g.to_s
|
83
|
+
end
|
84
|
+
|
85
|
+
##
|
86
|
+
# Builds the HTML for all Javascript tags using Gestalt.
|
87
|
+
#
|
88
|
+
# @author Yorick Peterse
|
89
|
+
# @since 0.1
|
90
|
+
# @return [String]
|
91
|
+
#
|
92
|
+
def build_js
|
93
|
+
g = Ramaze::Gestalt.new
|
94
|
+
|
95
|
+
@js.each do |js|
|
96
|
+
js = "/admin/js/#{js}.js"
|
97
|
+
g.script(:src => js) {}
|
98
|
+
end
|
99
|
+
|
100
|
+
return g.to_s
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Ramaze
|
2
|
+
module Helper
|
3
|
+
##
|
4
|
+
# Helper that can be used to quickly generate breadcrumbs without having
|
5
|
+
# to manually write the HTML separators and formatting the output correctly.
|
6
|
+
# In order to create a set of breadcrumbs we first need to call the set_breadcrumbs
|
7
|
+
# method:
|
8
|
+
#
|
9
|
+
# bc. set_breadcrumbs segment1, segment2, segment3, etc
|
10
|
+
#
|
11
|
+
# Each argument will be a segment of the breadcrumbs, separated by a custom character.
|
12
|
+
# Retrieving the breadcrumbs is super easy:
|
13
|
+
#
|
14
|
+
# bc. get_breadcrumbs
|
15
|
+
#
|
16
|
+
# This will generate the correct HTML and return it, all you have to do is output it.
|
17
|
+
#
|
18
|
+
# @author Yorick Peterse
|
19
|
+
# @since 0.1
|
20
|
+
#
|
21
|
+
module Breadcrumb
|
22
|
+
@breadcrumbs = []
|
23
|
+
|
24
|
+
##
|
25
|
+
# Appends each element to the list of breadcrumb segments.
|
26
|
+
#
|
27
|
+
# @example
|
28
|
+
# set_breadcrumbs "Articles", "Edit"
|
29
|
+
#
|
30
|
+
# Note that you'll have to manually specify anchor tags, this method won't automatically
|
31
|
+
# generate URLs.
|
32
|
+
#
|
33
|
+
# @author Yorick Peterse
|
34
|
+
# @param [Array] args Array of segments for the breadcrumbs.
|
35
|
+
# @since 0.1
|
36
|
+
#
|
37
|
+
def set_breadcrumbs *args
|
38
|
+
@breadcrumbs = args
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# Retrieves all breacrumbs and separates them either by "»" or a custom element
|
43
|
+
# set as the first argument of this method.
|
44
|
+
#
|
45
|
+
# @example
|
46
|
+
# get_breadcrumbs # => "Articles » Edit"
|
47
|
+
#
|
48
|
+
# @example
|
49
|
+
# get_breadcrumbs ">" # => "Articles > Edit"
|
50
|
+
#
|
51
|
+
# @author Yorick Peterse
|
52
|
+
# @param [String] separator The HTML character to use for separating each segment.
|
53
|
+
# @return [String]
|
54
|
+
#
|
55
|
+
def get_breadcrumbs separator = "»"
|
56
|
+
if !@breadcrumbs or @breadcrumbs.empty?
|
57
|
+
return
|
58
|
+
end
|
59
|
+
|
60
|
+
html = ''
|
61
|
+
separator = " #{separator} "
|
62
|
+
|
63
|
+
@breadcrumbs.each do |segment|
|
64
|
+
html += segment + separator
|
65
|
+
end
|
66
|
+
|
67
|
+
return html.chomp(separator)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|