zen 0.4 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.aspell.en.pws +31 -0
- data/.gems +1 -1
- data/.mailmap +1 -0
- data/.travis.yml +13 -7
- data/.yardopts +1 -1
- data/Rakefile +2 -2
- data/guide/changelog.md +23 -5
- data/guide/css/common.css +48 -0
- data/guide/javascript.md +1 -0
- data/guide/javascript/zen_form.md +46 -0
- data/guide/zen_compared.md +104 -0
- data/lib/zen.rb +21 -12
- data/lib/zen/helper/breadcrumb.rb +1 -1
- data/lib/zen/helper/message.rb +4 -5
- data/lib/zen/language.rb +75 -10
- data/lib/zen/markup.rb +20 -8
- data/lib/zen/model/init.rb +14 -9
- data/lib/zen/model/plugin/events.rb +1 -1
- data/lib/zen/package.rb +71 -14
- data/lib/zen/package/categories/lib/categories/controller/categories.rb +39 -12
- data/lib/zen/package/categories/lib/categories/controller/category_groups.rb +26 -5
- data/lib/zen/package/categories/lib/categories/helper/category.rb +37 -6
- data/lib/zen/package/categories/lib/categories/helper/category_frontend.rb +2 -2
- data/lib/zen/package/categories/lib/categories/view/admin/categories/form.xhtml +26 -29
- data/lib/zen/package/comments/lib/comments.rb +9 -1
- data/lib/zen/package/comments/lib/comments/anti_spam.rb +1 -1
- data/lib/zen/package/comments/lib/comments/controller/comments.rb +59 -14
- data/lib/zen/package/comments/lib/comments/controller/comments_form.rb +49 -11
- data/lib/zen/package/comments/lib/comments/helper/comment.rb +14 -2
- data/lib/zen/package/comments/lib/comments/view/admin/comments/form.xhtml +3 -3
- data/lib/zen/package/comments/migrations/1308774099_comment_status.rb +1 -1
- data/lib/zen/package/custom_fields/lib/custom_fields/blue_form_parameters.rb +12 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +24 -6
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_types.rb +68 -20
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_fields.rb +106 -26
- data/lib/zen/package/custom_fields/lib/custom_fields/helper/custom_field.rb +50 -11
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/form.xhtml +2 -2
- data/lib/zen/package/dashboard/lib/dashboard/controller/dashboard.rb +1 -1
- data/lib/zen/package/menu.rb +6 -1
- data/lib/zen/package/menus/lib/menus/controller/menu_items.rb +44 -9
- data/lib/zen/package/menus/lib/menus/controller/menus.rb +53 -13
- data/lib/zen/package/menus/lib/menus/helper/menu.rb +30 -4
- data/lib/zen/package/menus/lib/menus/model/menu.rb +4 -2
- data/lib/zen/package/sections/lib/sections/controller/section_entries.rb +48 -9
- data/lib/zen/package/sections/lib/sections/controller/sections.rb +77 -21
- data/lib/zen/package/sections/lib/sections/helper/section.rb +32 -4
- data/lib/zen/package/sections/lib/sections/model/section_entry.rb +1 -1
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/form.xhtml +5 -4
- data/lib/zen/package/sections/lib/sections/view/admin/sections/form.xhtml +3 -3
- data/lib/zen/package/sections/migrations/1308813320_section_entry_statuses.rb +1 -1
- data/lib/zen/package/settings/lib/settings/blue_form_parameters.rb +2 -2
- data/lib/zen/package/settings/lib/settings/controller/settings.rb +60 -15
- data/lib/zen/package/settings/lib/settings/view/admin/settings/index.xhtml +1 -1
- data/lib/zen/package/users/lib/users/controller/user_groups.rb +42 -7
- data/lib/zen/package/users/lib/users/controller/users.rb +78 -16
- data/lib/zen/package/users/lib/users/helper/users.rb +29 -4
- data/lib/zen/package/users/lib/users/view/admin/user-groups/form.xhtml +2 -2
- data/lib/zen/package/users/lib/users/view/admin/users/form.xhtml +2 -2
- data/lib/zen/public/admin/zen/css/general.css +5 -0
- data/lib/zen/public/admin/zen/css/messages.css +1 -0
- data/lib/zen/public/admin/zen/css/tables.css +33 -0
- data/lib/zen/public/admin/zen/css/tabs.css +8 -0
- data/lib/zen/public/admin/zen/js/index.js +21 -2
- data/lib/zen/public/admin/zen/js/lib/events.js +45 -0
- data/lib/zen/public/admin/zen/js/lib/form.js +229 -0
- data/lib/zen/public/admin/zen/js/lib/hash.js +0 -27
- data/lib/zen/task/spelling.rake +97 -0
- data/lib/zen/task/test.rake +21 -0
- data/lib/zen/theme.rb +80 -24
- data/lib/zen/validation.rb +1 -1
- data/lib/zen/version.rb +1 -1
- data/proto/app/config/config.rb.erb +9 -4
- data/proto/app/config/middlewares.rb +1 -2
- data/spec/README.md +56 -0
- data/spec/zen/controller/admin_controller.rb +0 -1
- data/spec/zen/controller/preview.rb +0 -1
- data/spec/zen/package.rb +32 -0
- data/spec/zen/package/categories/controller/categories.rb +7 -0
- data/spec/zen/package/categories/controller/category_groups.rb +7 -0
- data/spec/zen/package/comments/controller/comments.rb +7 -0
- data/spec/zen/package/custom_fields/controller/custom_field_groups.rb +7 -0
- data/spec/zen/package/custom_fields/controller/custom_field_types.rb +7 -0
- data/spec/zen/package/custom_fields/controller/custom_fields.rb +7 -0
- data/spec/zen/package/menus/controller/menu_items.rb +7 -0
- data/spec/zen/package/menus/controller/menus.rb +7 -0
- data/spec/zen/package/menus/helper/menu_frontend.rb +1 -1
- data/spec/zen/package/sections/controller/section_entries.rb +39 -0
- data/spec/zen/package/sections/controller/sections.rb +14 -0
- data/spec/zen/package/users/controller/user_groups.rb +7 -0
- data/spec/zen/package/users/controller/users.rb +7 -0
- data/zen.gemspec +6 -5
- metadata +142 -40
@@ -53,11 +53,32 @@ module Categories
|
|
53
53
|
#
|
54
54
|
# In this form you can set the following fields:
|
55
55
|
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
56
|
+
# <table class="table full">
|
57
|
+
# <thead>
|
58
|
+
# <tr>
|
59
|
+
# <th class="field_name">Field</th>
|
60
|
+
# <th>Required</th>
|
61
|
+
# <th>Maximum Length</th>
|
62
|
+
# <th>Description</th>
|
63
|
+
# </tr>
|
64
|
+
# </thead>
|
65
|
+
# <tbody>
|
66
|
+
# <tr>
|
67
|
+
# <td>Name</td>
|
68
|
+
# <td>Yes</td>
|
69
|
+
# <td>255</td>
|
70
|
+
# <td>
|
71
|
+
# The name of the category group, the length of this name
|
72
|
+
# </td>
|
73
|
+
# </tr>
|
74
|
+
# <tr>
|
75
|
+
# <td>Description</td>
|
76
|
+
# <td>No</td>
|
77
|
+
# <td></td>
|
78
|
+
# <td>A short description of the category group.</td>
|
79
|
+
# </tr>
|
80
|
+
# </tbody>
|
81
|
+
# </table>
|
61
82
|
#
|
62
83
|
# ## Used Permissions
|
63
84
|
#
|
@@ -20,11 +20,14 @@ module Ramaze
|
|
20
20
|
# @return [Categories::Model::CategoryGroup]
|
21
21
|
#
|
22
22
|
def validate_category_group(category_group_id)
|
23
|
+
unless category_group_id =~ /\d+/
|
24
|
+
redirect_invalid_group
|
25
|
+
end
|
26
|
+
|
23
27
|
group = ::Categories::Model::CategoryGroup[category_group_id]
|
24
28
|
|
25
29
|
if group.nil?
|
26
|
-
|
27
|
-
redirect(::Categories::Controller::CategoryGroups.r(:index))
|
30
|
+
redirect_invalid_group
|
28
31
|
else
|
29
32
|
return group
|
30
33
|
end
|
@@ -43,13 +46,14 @@ module Ramaze
|
|
43
46
|
# @return [Categories::Model::Category]
|
44
47
|
#
|
45
48
|
def validate_category(category_id, category_group_id)
|
49
|
+
unless category_id =~ /\d+/
|
50
|
+
redirect_invalid_category(category_group_id)
|
51
|
+
end
|
52
|
+
|
46
53
|
category = ::Categories::Model::Category[category_id]
|
47
54
|
|
48
55
|
if category.nil?
|
49
|
-
|
50
|
-
redirect(
|
51
|
-
::Categories::Controller::Categories.r(:index, category_group_id)
|
52
|
-
)
|
56
|
+
redirect_invalid_category(category_group_id)
|
53
57
|
else
|
54
58
|
return category
|
55
59
|
end
|
@@ -78,6 +82,33 @@ module Ramaze
|
|
78
82
|
|
79
83
|
return parent_categories
|
80
84
|
end
|
85
|
+
|
86
|
+
##
|
87
|
+
# Redirects the user to the category groups overview and shows a message
|
88
|
+
# about an invalid group being specified.
|
89
|
+
#
|
90
|
+
# @since 03-04-2012
|
91
|
+
#
|
92
|
+
def redirect_invalid_group
|
93
|
+
message(:error, lang('category_groups.errors.invalid_group'))
|
94
|
+
redirect(::Categories::Controller::CategoryGroups.r(:index))
|
95
|
+
end
|
96
|
+
|
97
|
+
##
|
98
|
+
# Redirects the user to the overview of the categories of a given group
|
99
|
+
# and shows a message informing the user that the specified category was
|
100
|
+
# invalid.
|
101
|
+
#
|
102
|
+
# @since 03-04-2012
|
103
|
+
# @param [Fixnum] category_group_id The ID of the category group that the
|
104
|
+
# category belongs to.
|
105
|
+
#
|
106
|
+
def redirect_invalid_category(category_group_id)
|
107
|
+
message(:error, lang('categories.errors.invalid_category'))
|
108
|
+
redirect(
|
109
|
+
::Categories::Controller::Categories.r(:index, category_group_id)
|
110
|
+
)
|
111
|
+
end
|
81
112
|
end # Category
|
82
113
|
end # Helper
|
83
114
|
end # Ramaze
|
@@ -9,7 +9,7 @@ module Ramaze
|
|
9
9
|
module CategoryFrontend
|
10
10
|
##
|
11
11
|
# Gets a number of categories and optionally paginates them. Keep in mind
|
12
|
-
# that this method will either return a
|
12
|
+
# that this method will either return a data set or an instance of
|
13
13
|
# ``Ramaze::Helper::Paginate::Paginator``.
|
14
14
|
#
|
15
15
|
# When paginating the results and no custom ``:var`` or ``:limit`` options
|
@@ -66,7 +66,7 @@ module Ramaze
|
|
66
66
|
query = query.filter(:category_groups__id => group)
|
67
67
|
end
|
68
68
|
|
69
|
-
# Paginate the results or return the
|
69
|
+
# Paginate the results or return the data set directly.
|
70
70
|
if options[:paginate] == true and respond_to?(:paginate)
|
71
71
|
return paginate(
|
72
72
|
query,
|
@@ -9,43 +9,40 @@
|
|
9
9
|
:method => :post,
|
10
10
|
:action => Categories::Controller::Categories.r(:save),
|
11
11
|
:id => :category_form,
|
12
|
-
:'data-autosave-url' => Categories::Controller::Categories
|
13
|
-
.r(:autosave)
|
12
|
+
:'data-autosave-url' => Categories::Controller::Categories.r(:autosave)
|
14
13
|
) do |f|
|
15
14
|
f.input_hidden(:category_group_id, @category_group_id)
|
16
15
|
f.input_hidden(:id , @category.id)
|
17
16
|
f.input_hidden(:csrf_token , get_csrf_token)
|
18
17
|
|
19
|
-
f.
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
)
|
18
|
+
f.input_text(
|
19
|
+
lang('categories.labels.name'),
|
20
|
+
:name,
|
21
|
+
:title => lang('categories.descriptions.name'),
|
22
|
+
:required => :required,
|
23
|
+
:maxlength => 255
|
24
|
+
)
|
27
25
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
f.input_text(
|
27
|
+
lang('categories.labels.slug'),
|
28
|
+
:slug,
|
29
|
+
:title => lang('categories.descriptions.slug'),
|
30
|
+
:maxlength => 255
|
31
|
+
)
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
33
|
+
f.select(
|
34
|
+
lang('categories.labels.parent'),
|
35
|
+
:parent_id,
|
36
|
+
:values => parent_categories(@category.id, @category_group_id),
|
37
|
+
:size => 1,
|
38
|
+
:selected => @category.parent_id
|
39
|
+
)
|
42
40
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
41
|
+
f.textarea(
|
42
|
+
lang('categories.labels.description'),
|
43
|
+
:description,
|
44
|
+
:rows => 8
|
45
|
+
)
|
49
46
|
|
50
47
|
f.g.input(
|
51
48
|
:type => 'submit',
|
@@ -31,7 +31,15 @@ Settings::Setting.add do |setting|
|
|
31
31
|
setting.group = 'security'
|
32
32
|
setting.type = 'select'
|
33
33
|
setting.default = 'defensio'
|
34
|
-
setting.values = lambda
|
34
|
+
setting.values = lambda do
|
35
|
+
regged = {}
|
36
|
+
|
37
|
+
Comments::AntiSpam::REGISTERED.each do |name, translation|
|
38
|
+
regged[name] = lang(translation)
|
39
|
+
end
|
40
|
+
|
41
|
+
return regged
|
42
|
+
end
|
35
43
|
end
|
36
44
|
|
37
45
|
Settings::Setting.add do |setting|
|
@@ -60,7 +60,7 @@ module Comments
|
|
60
60
|
# Array containing the method names of the various supported engines and
|
61
61
|
# their labels to display in the admin interface.
|
62
62
|
REGISTERED = {
|
63
|
-
:defensio =>
|
63
|
+
:defensio => 'comments.labels.defensio'
|
64
64
|
}
|
65
65
|
|
66
66
|
class << self
|
@@ -53,20 +53,65 @@ module Comments
|
|
53
53
|
#
|
54
54
|
# When editing a comment you can specify/update the following fields:
|
55
55
|
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
56
|
+
# <table class="table full">
|
57
|
+
# <thead>
|
58
|
+
# <tr>
|
59
|
+
# <th class="field_name">Field</th>
|
60
|
+
# <th>Required</th>
|
61
|
+
# <th>Maximum Length</th>
|
62
|
+
# <th>Description</th>
|
63
|
+
# </tr>
|
64
|
+
# </thead>
|
65
|
+
# <tbody>
|
66
|
+
# <tr>
|
67
|
+
# <td>Name</td>
|
68
|
+
# <td>
|
69
|
+
# Only when the comment was submitted by a non logged in
|
70
|
+
# user.
|
71
|
+
# </td>
|
72
|
+
# <td>255</td>
|
73
|
+
# <td>
|
74
|
+
# The name of the author of the comment. This field can only
|
75
|
+
# be edited if the comment was submitted by a user that
|
76
|
+
# wasn't logged in.
|
77
|
+
# </td>
|
78
|
+
# </tr>
|
79
|
+
# <tr>
|
80
|
+
# <td>Website</td>
|
81
|
+
# <td>No</td>
|
82
|
+
# <td>255</td>
|
83
|
+
# <td>The website of the comment author.</td>
|
84
|
+
# </tr>
|
85
|
+
# <tr>
|
86
|
+
# <td>Email</td>
|
87
|
+
# <td>
|
88
|
+
# Only if the comment was submitted by a user that wasn't
|
89
|
+
# logged in.
|
90
|
+
# </td>
|
91
|
+
# <td>255</td>
|
92
|
+
# <td>
|
93
|
+
# The Email address of the comment author. Like the name
|
94
|
+
# field this field can only be edited if the comment was
|
95
|
+
# submitted by a user that wasn't logged in.
|
96
|
+
# </td>
|
97
|
+
# </tr>
|
98
|
+
# <tr>
|
99
|
+
# <td>Status</td>
|
100
|
+
# <td>No</td>
|
101
|
+
# <td></td>
|
102
|
+
# <td>
|
103
|
+
# The status of the comment. If a comment is created and no
|
104
|
+
# status is specified the status will be set to "closed".
|
105
|
+
# </td>
|
106
|
+
# </tr>
|
107
|
+
# <tr>
|
108
|
+
# <td>Comment</td>
|
109
|
+
# <td>Yes</td>
|
110
|
+
# <td>Unlimited</td>
|
111
|
+
# <td>The actual comment.</td>
|
112
|
+
# </tr>
|
113
|
+
# </tbody>
|
114
|
+
# </table>
|
70
115
|
#
|
71
116
|
# ## Used Permissions
|
72
117
|
#
|
@@ -7,16 +7,54 @@ module Comments
|
|
7
7
|
# you and thus you'll have to do this yourself. When creating such a form
|
8
8
|
# you must add the following fields to it:
|
9
9
|
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
10
|
+
# <table class="table full">
|
11
|
+
# <thead>
|
12
|
+
# <tr>
|
13
|
+
# <th class="field_name">Field</th>
|
14
|
+
# <th>Required</th>
|
15
|
+
# <th>Maximum Length</th>
|
16
|
+
# <th>Description</th>
|
17
|
+
# </tr>
|
18
|
+
# </thead>
|
19
|
+
# <tbody>
|
20
|
+
# <tr>
|
21
|
+
# <td>section_entry</td>
|
22
|
+
# <td>Yes</td>
|
23
|
+
# <td></td>
|
24
|
+
# <td>The ID of the section entry the comment belongs to.</td>
|
25
|
+
# </tr>
|
26
|
+
# <tr>
|
27
|
+
# <td>user_id</td>
|
28
|
+
# <td>No</td>
|
29
|
+
# <td></td>
|
30
|
+
# <td>A short description of the category group.</td>
|
31
|
+
# </tr>
|
32
|
+
# <tr>
|
33
|
+
# <td>comment</td>
|
34
|
+
# <td>Yes</td>
|
35
|
+
# <td>Unlimited</td>
|
36
|
+
# <td>The text of the comment.</td>
|
37
|
+
# </tr>
|
38
|
+
# <tr>
|
39
|
+
# <td>name</td>
|
40
|
+
# <td>Only when the user isn't logged in.</td>
|
41
|
+
# <td>255</td>
|
42
|
+
# <td>The name of the comment author.</td>
|
43
|
+
# </tr>
|
44
|
+
# <tr>
|
45
|
+
# <td>website</td>
|
46
|
+
# <td>No</td>
|
47
|
+
# <td>255</td>
|
48
|
+
# <td>The website of the comment author.</td>
|
49
|
+
# </tr>
|
50
|
+
# <tr>
|
51
|
+
# <td>email</td>
|
52
|
+
# <td>Only when the user isn't logged in.</td>
|
53
|
+
# <td>255</td>
|
54
|
+
# <td>The Email address of the user.</td>
|
55
|
+
# </tr>
|
56
|
+
# </tbody>
|
57
|
+
# </table>
|
20
58
|
#
|
21
59
|
# An example of such a form looks like the code below. Note that this block
|
22
60
|
# of code should be wrapped in a ``#{}`` tag.
|
@@ -161,7 +199,7 @@ module Comments
|
|
161
199
|
url = post['website']
|
162
200
|
end
|
163
201
|
|
164
|
-
# Require anti
|
202
|
+
# Require anti spam validation?
|
165
203
|
if get_setting(:enable_antispam).true?
|
166
204
|
engine = get_setting(:anti_spam_system).value
|
167
205
|
spam = ::Comments::AntiSpam.validate(
|
@@ -18,15 +18,27 @@ module Ramaze
|
|
18
18
|
# @return [Comments::Model::Comment]
|
19
19
|
#
|
20
20
|
def validate_comment(comment_id)
|
21
|
+
redirect_invalid_comment unless comment_id =~ /\d+/
|
22
|
+
|
21
23
|
comment = ::Comments::Model::Comment[comment_id]
|
22
24
|
|
23
25
|
if comment.nil?
|
24
|
-
|
25
|
-
redirect(::Comments::Controller::Comments.r(:index))
|
26
|
+
redirect_invalid_comment
|
26
27
|
else
|
27
28
|
return comment
|
28
29
|
end
|
29
30
|
end
|
31
|
+
|
32
|
+
##
|
33
|
+
# Redirects the user to the comments overview and shows a message
|
34
|
+
# informing the user that the comment he/she tried to access was invalid.
|
35
|
+
#
|
36
|
+
# @since 05-04-2012
|
37
|
+
#
|
38
|
+
def redirect_invalid_comment
|
39
|
+
message(:error, lang('comments.errors.invalid_comment'))
|
40
|
+
redirect(::Comments::Controller::Comments.r(:index))
|
41
|
+
end
|
30
42
|
end # Comment
|
31
43
|
end # Helper
|
32
44
|
end # Ramaze
|
@@ -6,9 +6,9 @@
|
|
6
6
|
<div class="body">
|
7
7
|
#{form_for(
|
8
8
|
@comment,
|
9
|
-
:method
|
10
|
-
:action
|
11
|
-
:id
|
9
|
+
:method => :post,
|
10
|
+
:action => Comments::Controller::Comments.r(:save),
|
11
|
+
:id => :comment_form,
|
12
12
|
:'data-autosave-url' => Comments::Controller::Comments.r(:autosave)
|
13
13
|
) do |f|
|
14
14
|
f.input_hidden(:csrf_token, get_csrf_token)
|
@@ -59,7 +59,7 @@ Sequel.migration do
|
|
59
59
|
|
60
60
|
# Put the old statuses back in place
|
61
61
|
comments.each do |comment|
|
62
|
-
Zen.database.filter(:id => comment[:id]) \
|
62
|
+
Zen.database[:comments].filter(:id => comment[:id]) \
|
63
63
|
.update(:status => statuses[comment[:comment_status_id]])
|
64
64
|
end
|
65
65
|
|
@@ -109,6 +109,10 @@ module CustomFields
|
|
109
109
|
params.last[:class] = type.html_class
|
110
110
|
end
|
111
111
|
|
112
|
+
if field.required
|
113
|
+
params.last[:required] = :required
|
114
|
+
end
|
115
|
+
|
112
116
|
return params
|
113
117
|
end
|
114
118
|
|
@@ -181,6 +185,10 @@ module CustomFields
|
|
181
185
|
end
|
182
186
|
end
|
183
187
|
|
188
|
+
if field.required
|
189
|
+
params.last[:required] = :required
|
190
|
+
end
|
191
|
+
|
184
192
|
return params
|
185
193
|
end
|
186
194
|
|
@@ -232,6 +240,10 @@ module CustomFields
|
|
232
240
|
end
|
233
241
|
end
|
234
242
|
|
243
|
+
if field.required
|
244
|
+
params.last[:required] = :required
|
245
|
+
end
|
246
|
+
|
235
247
|
return params
|
236
248
|
end
|
237
249
|
|