zen 0.4 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. data/.aspell.en.pws +31 -0
  2. data/.gems +1 -1
  3. data/.mailmap +1 -0
  4. data/.travis.yml +13 -7
  5. data/.yardopts +1 -1
  6. data/Rakefile +2 -2
  7. data/guide/changelog.md +23 -5
  8. data/guide/css/common.css +48 -0
  9. data/guide/javascript.md +1 -0
  10. data/guide/javascript/zen_form.md +46 -0
  11. data/guide/zen_compared.md +104 -0
  12. data/lib/zen.rb +21 -12
  13. data/lib/zen/helper/breadcrumb.rb +1 -1
  14. data/lib/zen/helper/message.rb +4 -5
  15. data/lib/zen/language.rb +75 -10
  16. data/lib/zen/markup.rb +20 -8
  17. data/lib/zen/model/init.rb +14 -9
  18. data/lib/zen/model/plugin/events.rb +1 -1
  19. data/lib/zen/package.rb +71 -14
  20. data/lib/zen/package/categories/lib/categories/controller/categories.rb +39 -12
  21. data/lib/zen/package/categories/lib/categories/controller/category_groups.rb +26 -5
  22. data/lib/zen/package/categories/lib/categories/helper/category.rb +37 -6
  23. data/lib/zen/package/categories/lib/categories/helper/category_frontend.rb +2 -2
  24. data/lib/zen/package/categories/lib/categories/view/admin/categories/form.xhtml +26 -29
  25. data/lib/zen/package/comments/lib/comments.rb +9 -1
  26. data/lib/zen/package/comments/lib/comments/anti_spam.rb +1 -1
  27. data/lib/zen/package/comments/lib/comments/controller/comments.rb +59 -14
  28. data/lib/zen/package/comments/lib/comments/controller/comments_form.rb +49 -11
  29. data/lib/zen/package/comments/lib/comments/helper/comment.rb +14 -2
  30. data/lib/zen/package/comments/lib/comments/view/admin/comments/form.xhtml +3 -3
  31. data/lib/zen/package/comments/migrations/1308774099_comment_status.rb +1 -1
  32. data/lib/zen/package/custom_fields/lib/custom_fields/blue_form_parameters.rb +12 -0
  33. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +24 -6
  34. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_types.rb +68 -20
  35. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_fields.rb +106 -26
  36. data/lib/zen/package/custom_fields/lib/custom_fields/helper/custom_field.rb +50 -11
  37. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/form.xhtml +2 -2
  38. data/lib/zen/package/dashboard/lib/dashboard/controller/dashboard.rb +1 -1
  39. data/lib/zen/package/menu.rb +6 -1
  40. data/lib/zen/package/menus/lib/menus/controller/menu_items.rb +44 -9
  41. data/lib/zen/package/menus/lib/menus/controller/menus.rb +53 -13
  42. data/lib/zen/package/menus/lib/menus/helper/menu.rb +30 -4
  43. data/lib/zen/package/menus/lib/menus/model/menu.rb +4 -2
  44. data/lib/zen/package/sections/lib/sections/controller/section_entries.rb +48 -9
  45. data/lib/zen/package/sections/lib/sections/controller/sections.rb +77 -21
  46. data/lib/zen/package/sections/lib/sections/helper/section.rb +32 -4
  47. data/lib/zen/package/sections/lib/sections/model/section_entry.rb +1 -1
  48. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/form.xhtml +5 -4
  49. data/lib/zen/package/sections/lib/sections/view/admin/sections/form.xhtml +3 -3
  50. data/lib/zen/package/sections/migrations/1308813320_section_entry_statuses.rb +1 -1
  51. data/lib/zen/package/settings/lib/settings/blue_form_parameters.rb +2 -2
  52. data/lib/zen/package/settings/lib/settings/controller/settings.rb +60 -15
  53. data/lib/zen/package/settings/lib/settings/view/admin/settings/index.xhtml +1 -1
  54. data/lib/zen/package/users/lib/users/controller/user_groups.rb +42 -7
  55. data/lib/zen/package/users/lib/users/controller/users.rb +78 -16
  56. data/lib/zen/package/users/lib/users/helper/users.rb +29 -4
  57. data/lib/zen/package/users/lib/users/view/admin/user-groups/form.xhtml +2 -2
  58. data/lib/zen/package/users/lib/users/view/admin/users/form.xhtml +2 -2
  59. data/lib/zen/public/admin/zen/css/general.css +5 -0
  60. data/lib/zen/public/admin/zen/css/messages.css +1 -0
  61. data/lib/zen/public/admin/zen/css/tables.css +33 -0
  62. data/lib/zen/public/admin/zen/css/tabs.css +8 -0
  63. data/lib/zen/public/admin/zen/js/index.js +21 -2
  64. data/lib/zen/public/admin/zen/js/lib/events.js +45 -0
  65. data/lib/zen/public/admin/zen/js/lib/form.js +229 -0
  66. data/lib/zen/public/admin/zen/js/lib/hash.js +0 -27
  67. data/lib/zen/task/spelling.rake +97 -0
  68. data/lib/zen/task/test.rake +21 -0
  69. data/lib/zen/theme.rb +80 -24
  70. data/lib/zen/validation.rb +1 -1
  71. data/lib/zen/version.rb +1 -1
  72. data/proto/app/config/config.rb.erb +9 -4
  73. data/proto/app/config/middlewares.rb +1 -2
  74. data/spec/README.md +56 -0
  75. data/spec/zen/controller/admin_controller.rb +0 -1
  76. data/spec/zen/controller/preview.rb +0 -1
  77. data/spec/zen/package.rb +32 -0
  78. data/spec/zen/package/categories/controller/categories.rb +7 -0
  79. data/spec/zen/package/categories/controller/category_groups.rb +7 -0
  80. data/spec/zen/package/comments/controller/comments.rb +7 -0
  81. data/spec/zen/package/custom_fields/controller/custom_field_groups.rb +7 -0
  82. data/spec/zen/package/custom_fields/controller/custom_field_types.rb +7 -0
  83. data/spec/zen/package/custom_fields/controller/custom_fields.rb +7 -0
  84. data/spec/zen/package/menus/controller/menu_items.rb +7 -0
  85. data/spec/zen/package/menus/controller/menus.rb +7 -0
  86. data/spec/zen/package/menus/helper/menu_frontend.rb +1 -1
  87. data/spec/zen/package/sections/controller/section_entries.rb +39 -0
  88. data/spec/zen/package/sections/controller/sections.rb +14 -0
  89. data/spec/zen/package/users/controller/user_groups.rb +7 -0
  90. data/spec/zen/package/users/controller/users.rb +7 -0
  91. data/zen.gemspec +6 -5
  92. 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
- # * **Name**: the name of the category group. It can be any name in any
57
- # format as long as it's not longer than 255 characters.
58
- # * **Description**: the description of the category group. While not
59
- # required it can be used to make it easier to remember that purpose a
60
- # category group has.
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
- message(:error, lang('category_groups.errors.invalid_group'))
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
- message(:error, lang('categories.errors.invalid_category'))
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 dataset or an instance of
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 dataset directly.
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.g.div(:id => 'general') do
20
- f.input_text(
21
- lang('categories.labels.name'),
22
- :name,
23
- :title => lang('categories.descriptions.name'),
24
- :required => :required,
25
- :maxlength => 255
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
- f.input_text(
29
- lang('categories.labels.slug'),
30
- :slug,
31
- :title => lang('categories.descriptions.slug'),
32
- :maxlength => 255
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
- f.select(
36
- lang('categories.labels.parent'),
37
- :parent_id,
38
- :values => parent_categories(@category.id, @category_group_id),
39
- :size => 1,
40
- :selected => @category.parent_id
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
- f.textarea(
44
- lang('categories.labels.description'),
45
- :description,
46
- :rows => 8
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 { Comments::AntiSpam::REGISTERED }
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 => lang('comments.labels.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
- # * **Name**: the name of the author. This field can only be changed if the
57
- # comment was posted by somebody that wasn't logged in.
58
- # * **Website**: the website of the author that posted the comment.
59
- # * **Email**: the Email address of the author. If the comment was posted by
60
- # a user that wasn't logged in then this field is required.
61
- # * **Status**: the status of a comment, can be "Open", "Closed" or "Spam".
62
- # If the status is something other than "Open" it will be hidden when the
63
- # comments plugin is used.
64
- # * **Comment** (required): the actual comment. Based on a section's
65
- # settings these are formatted using Markdown, Textile or any of the other
66
- # available markup processors.
67
- #
68
- # Note that if a comment was posted by a user that was logged in you won't
69
- # be able to change the name of the author.
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
- # * **section_entry** (required): an ID of a section entry where the
11
- # comments belong to.
12
- # * **user_id**: the ID of the currently logged in user (if any). If this ID
13
- # isn't specified the "name" and "Email" fields are required.
14
- # * **comment**: the text of the comment.
15
- # * **name**: the name of the author, required when the "user_id" field is
16
- # empty.
17
- # * **website**: the website of the user, if any.
18
- # * **email**: the Email address of the user, required if the "user_id"
19
- # field is empty.
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-spam validation?
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
- message(:error, lang('comments.errors.invalid_comment'))
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 => :post,
10
- :action => Comments::Controller::Comments.r(:save),
11
- :id => :comment_form,
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