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
@@ -55,7 +55,7 @@ Sequel.migration do
55
55
  end
56
56
 
57
57
  entries.each do |entry|
58
- Zen.database.filter(:id => entry[:id]) \
58
+ Zen.database[:section_entries].filter(:id => entry[:id]) \
59
59
  .update(:status => statuses[entry[:section_entry_status_id]])
60
60
  end
61
61
 
@@ -7,7 +7,7 @@ module Settings
7
7
  #
8
8
  # Similar to the custom fields module mentioned above adding methods to this
9
9
  # module is relatively easy (though you usually don't need to add your own
10
- # methods). This can be done by simply re-opening the module and adding a
10
+ # methods). This can be done by simply reopening the module and adding a
11
11
  # class method to it:
12
12
  #
13
13
  # module Settings
@@ -27,7 +27,7 @@ module Settings
27
27
  module BlueFormParameters
28
28
  class << self
29
29
  ##
30
- # Generates the required parameters for a textbox (``input type="text"``).
30
+ # Generates the required parameters for a text box (``input type="text"``).
31
31
  #
32
32
  # @since 0.3
33
33
  # @param [Settings::Setting] setting The setting for which to generate the
@@ -20,7 +20,7 @@ module Settings
20
20
  module Controller
21
21
  ##
22
22
  # Controller for managing settings. Settings are used to store the name of
23
- # the website, what anti-spam system to use and so on. These settings can be
23
+ # the website, what anti spam system to use and so on. These settings can be
24
24
  # managed via the admin interface rather than having to edit configuration
25
25
  # files. Settings can be managed by going to ``/admin/settings``. This page
26
26
  # shows an overview of all the available settings organized in a number of
@@ -33,20 +33,65 @@ module Settings
33
33
  #
34
34
  # Out of the box Zen ships with the following settings:
35
35
  #
36
- # * **Website name**: the name of the website.
37
- # * **Website description**: a short description of the website.
38
- # * **Language**: the default language to use for the admin interface.
39
- # * **Frontend Language**: the default language to use for the frontend of
40
- # your website.
41
- # * **Theme**: the theme to use for the frontend.
42
- # * **Date format**: the default date format to use in the backend.
43
- # * **Enable anti-spam**: whether or not comments should be verified to see
44
- # if they're spam or ham.
45
- # * **Anti-spam system**: the anti-spam system to use. Zen by default only
46
- # comes with Defensio support.
47
- # * **Defensio key**: the API key for the Defensio anti-spam system.
48
- # * **Allow Registration**: defines whether or not visitors are allowed to
49
- # register a user account.
36
+ # <table class="table full">
37
+ # <thead>
38
+ # <tr>
39
+ # <th class="field_name">Field</th>
40
+ # <th>Description</th>
41
+ # </tr>
42
+ # </thead>
43
+ # <tbody>
44
+ # <tr>
45
+ # <td>Website name</td>
46
+ # <td>The name of the website.</td>
47
+ # </tr>
48
+ # <tr>
49
+ # <td>Website description</td>
50
+ # <td>A description of the website.</td>
51
+ # </tr>
52
+ # <tr>
53
+ # <td>Language</td>
54
+ # <td>The language to use for the backend.</td>
55
+ # </tr>
56
+ # <tr>
57
+ # <td>Frontend Language</td>
58
+ # <td>The language to use for the frontend of the website.</td>
59
+ # </tr>
60
+ # <tr>
61
+ # <td>Theme</td>
62
+ # <td>The theme to use for the website.</td>
63
+ # </tr>
64
+ # <tr>
65
+ # <td>Date format</td>
66
+ # <td>
67
+ # The date format to use for dates displayed in the backend.
68
+ # </td>
69
+ # </tr>
70
+ # <tr>
71
+ # <td>Enable anti-spam</td>
72
+ # <td>
73
+ # When set comments will be validated before they're saved.
74
+ # </td>
75
+ # </tr>
76
+ # <tr>
77
+ # <td>Anti-spam system</td>
78
+ # <td>
79
+ # The system to use for validating comments. Out of the box
80
+ # Zen only supports Defensio.
81
+ # </td>
82
+ # </tr>
83
+ # <tr>
84
+ # <td>Defensio key</td>
85
+ # <td>The API key to use for the Defensio API.</td>
86
+ # </tr>
87
+ # <tr>
88
+ # <td>Allow Registration</td>
89
+ # <td>
90
+ # When set users are allowed to register user accounts.
91
+ # </td>
92
+ # </tr>
93
+ # </tbody>
94
+ # </table>
50
95
  #
51
96
  # ## Used Permissions
52
97
  #
@@ -23,7 +23,7 @@
23
23
  f.input_hidden(:csrf_token, get_csrf_token)
24
24
 
25
25
  @settings_ordered.each do |group, items|
26
- f.g.div(:id => "group_#{group}") do
26
+ f.g.div(:id => "group_#{group}", :class => :tab_field) do
27
27
  items.each do |s|
28
28
  f.send(*get_setting(s.name).form_parameters)
29
29
  end
@@ -22,13 +22,48 @@ module Users
22
22
  #
23
23
  # In this form you can fill in the following fields:
24
24
  #
25
- # * **Name** (required): the name of the user group.
26
- # * **Slug**: a URL friendly version of the name. If no name is specified
27
- # one will be generated automatically.
28
- # * **Super group** (required): when set to "Yes" all users that are
29
- # assigned to this group will have access to *everything* regardless of
30
- # their individual settings.
31
- # * **Description**: a description of the user group.
25
+ # <table class="table full">
26
+ # <thead>
27
+ # <tr>
28
+ # <th class="field_name">Field</th>
29
+ # <th>Required</th>
30
+ # <th>Maximum Length</th>
31
+ # <th>Description</th>
32
+ # </tr>
33
+ # </thead>
34
+ # <tbody>
35
+ # <tr>
36
+ # <td>Name</td>
37
+ # <td>Yes</td>
38
+ # <td>255</td>
39
+ # <td>The name of the user group.</td>
40
+ # </tr>
41
+ # <tr>
42
+ # <td>Slug</td>
43
+ # <td>No</td>
44
+ # <td>255</td>
45
+ # <td>
46
+ # A URL friendly version of the user group. If no value is
47
+ # specified one will be generated automatically based on the name
48
+ # of the user group.
49
+ # </td>
50
+ # </tr>
51
+ # <tr>
52
+ # <td>Super group</td>
53
+ # <td>Yes</td>
54
+ # <td></td>
55
+ # <td>
56
+ # When set users of this group have full access to the backend.
57
+ # </td>
58
+ # </tr>
59
+ # <tr>
60
+ # <td>Description</td>
61
+ # <td>No</td>
62
+ # <td>Unlimited</td>
63
+ # <td>A description of the user group.</td>
64
+ # </tr>
65
+ # </tbody>
66
+ # </table>
32
67
  #
33
68
  # Besides these fields you can also specify all the permissions o the user
34
69
  # group similar to how they're managed for individual users. Note that user
@@ -48,22 +48,84 @@ module Users
48
48
  #
49
49
  # In this form the following fields can be filled:
50
50
  #
51
- # * **Name** (required): the full name of the user.
52
- # * **Email** (required): the Email address of the user, used for logging
53
- # in.
54
- # * **Website**: the website of the user (if he/she has any).
55
- # * **Password** (required for new users): the raw password the user will
56
- # use in order to log in.
57
- # * **Confirm password** (required for new users): an extra field to confirm
58
- # that the specified password is the right one. This field should match
59
- # the password specified in the "Password" field.
60
- # * **Status**: field that indicates if a user is active or not. If the
61
- # status is set to "Closed" the user will not be able to log in.
62
- # * **User Groups**: all the user groups the user belongs to.
63
- # * **Language**: the language to use for the admin interface.
64
- # * **Frontend language**: the language to use for the frontend of the
65
- # application.
66
- # * **Date format**: the date format to use in the admin interface.
51
+ # <table class="table full">
52
+ # <thead>
53
+ # <tr>
54
+ # <th class="field_name">Field</th>
55
+ # <th>Required</th>
56
+ # <th>Maximum Length</th>
57
+ # <th>Description</th>
58
+ # </tr>
59
+ # </thead>
60
+ # <tbody>
61
+ # <tr>
62
+ # <td>Name</td>
63
+ # <td>Yes</td>
64
+ # <td>255</td>
65
+ # <td>The full name of the user.</td>
66
+ # </tr>
67
+ # <tr>
68
+ # <td>Email</td>
69
+ # <td>Yes</td>
70
+ # <td>255</td>
71
+ # <td>The Email address of the user.</td>
72
+ # </tr>
73
+ # <tr>
74
+ # <td>Website</td>
75
+ # <td>No</td>
76
+ # <td>255</td>
77
+ # <td>The website of the user.</td>
78
+ # </tr>
79
+ # <tr>
80
+ # <td>Password</td>
81
+ # <td>No</td>
82
+ # <td>255</td>
83
+ # <td>The password for the user.</td>
84
+ # </tr>
85
+ # <tr>
86
+ # <td>Confirm Password</td>
87
+ # <td>
88
+ # Only when a password has been specified in the "Password"
89
+ # field.
90
+ # </td>
91
+ # <td>255</td>
92
+ # <td>
93
+ # Field used to confirm the password in case of setting a
94
+ # new one.
95
+ # </td>
96
+ # </tr>
97
+ # <tr>
98
+ # <td>Status</td>
99
+ # <td>No</td>
100
+ # <td></td>
101
+ # <td>The status of the user, set to closed by default.</td>
102
+ # </tr>
103
+ # <tr>
104
+ # <td>User groups</td>
105
+ # <td>No</td>
106
+ # <td></td>
107
+ # <td>A selection of groups to add the user to.</td>
108
+ # </tr>
109
+ # <tr>
110
+ # <td>Language</td>
111
+ # <td>No</td>
112
+ # <td></td>
113
+ # <td>The language to use for the backend of the website.</td>
114
+ # </tr>
115
+ # <tr>
116
+ # <td>Frontend Language</td>
117
+ # <td>No</td>
118
+ # <td></td>
119
+ # <td>The language to use for the frontend of the website.</td>
120
+ # </tr>
121
+ # <tr>
122
+ # <td>Date format</td>
123
+ # <td>No</td>
124
+ # <td></td>
125
+ # <td>The date format to use for the backend.</td>
126
+ # </tr>
127
+ # </tbody>
128
+ # </table>
67
129
  #
68
130
  # Besides these fields there's also the tab "Permissions". This tab contains
69
131
  # a collection of all installed packages and their permissions. This makes
@@ -16,11 +16,12 @@ module Ramaze
16
16
  # @return [Users::Model::UserGroup]
17
17
  #
18
18
  def validate_user_group(user_group_id)
19
+ redirect_invalid_user_group unless user_group_id =~ /\d+/
20
+
19
21
  group = ::Users::Model::UserGroup[user_group_id]
20
22
 
21
23
  if group.nil?
22
- message(:error, lang('user_groups.errors.invalid_group'))
23
- redirect(::Users::Controller::UserGroups.r(:index))
24
+ redirect_invalid_user_group
24
25
  else
25
26
  return group
26
27
  end
@@ -34,11 +35,12 @@ module Ramaze
34
35
  # @return [Users::Model::User]
35
36
  #
36
37
  def validate_user(user_id)
38
+ redirect_invalid_user unless user_id =~ /\d+/
39
+
37
40
  user = ::Users::Model::User[user_id]
38
41
 
39
42
  if user.nil?
40
- message(:error, lang('users.errors.invalid_user'))
41
- redirect(::Users::Controller::Users.r(:index))
43
+ redirect_invalid_user
42
44
  else
43
45
  return user
44
46
  end
@@ -84,6 +86,29 @@ module Ramaze
84
86
  session[:super_group] = nil
85
87
  session[:permissions] = nil
86
88
  end
89
+
90
+ ##
91
+ # Redirects the user back to the users overview and shows a message
92
+ # informing the current user that the user he/she tried to access is
93
+ # invalid.
94
+ #
95
+ # @since 09-04-2012
96
+ #
97
+ def redirect_invalid_user
98
+ message(:error, lang('users.errors.invalid_user'))
99
+ redirect(::Users::Controller::Users.r(:index))
100
+ end
101
+
102
+ ##
103
+ # Redirects the user back to the user groups overview and informs the user
104
+ # that the group he/she tried to access is invalid.
105
+ #
106
+ # @since 09-04-2012
107
+ #
108
+ def redirect_invalid_user_group
109
+ message(:error, lang('user_groups.errors.invalid_group'))
110
+ redirect(::Users::Controller::UserGroups.r(:index))
111
+ end
87
112
  end # Users
88
113
  end # Helper
89
114
  end # Ramaze
@@ -36,7 +36,7 @@
36
36
  f.input_hidden(:id, @user_group.id)
37
37
  f.input_hidden(:csrf_token, get_csrf_token)
38
38
 
39
- f.g.div(:id => 'user_group_tab') do
39
+ f.g.div(:id => 'user_group_tab', :class => :tab_field) do
40
40
  f.input_text(
41
41
  lang('user_groups.labels.name'),
42
42
  :name,
@@ -66,7 +66,7 @@
66
66
  end
67
67
 
68
68
  if user_authorized?(:show_permission) and @user_group.exists?
69
- f.g.div(:id => 'permissions') do
69
+ f.g.div(:id => 'permissions', :class => :tab_field) do
70
70
  render_file(__DIR__('../users/permissions.xhtml'))
71
71
  end
72
72
  end
@@ -36,7 +36,7 @@
36
36
  f.input_hidden(:csrf_token, get_csrf_token)
37
37
  f.input_hidden(:id, @user.id)
38
38
 
39
- f.g.div(:id => 'user_tab') do
39
+ f.g.div(:id => 'user_tab', :class => :tab_field) do
40
40
  f.input_text(
41
41
  lang('users.labels.name'),
42
42
  :name,
@@ -113,7 +113,7 @@
113
113
  end
114
114
 
115
115
  if user_authorized?(:show_permission) and @user.exists?
116
- f.g.div(:id => 'permissions') do
116
+ f.g.div(:id => 'permissions', :class => :tab_field) do
117
117
  render_view(:permissions)
118
118
  end
119
119
  end
@@ -157,6 +157,11 @@ pre
157
157
  background-image: url('/admin/zen/images/icons/categories.png');
158
158
  }
159
159
 
160
+ .icon.error
161
+ {
162
+ background-image: url('/admin/zen/images/icons/error.png');
163
+ }
164
+
160
165
  .label
161
166
  {
162
167
  color: #fff;
@@ -2,6 +2,7 @@
2
2
  {
3
3
  border-bottom: 1px solid #000;
4
4
  color: #fff;
5
+ cursor: pointer;
5
6
  padding: 8px 10px 10px 10px;
6
7
  text-align: center;
7
8
  text-shadow: 1px 1px #000;
@@ -55,3 +55,36 @@ table
55
55
  {
56
56
  background: #fff;
57
57
  }
58
+
59
+ /* Styles for the pager. */
60
+ .pager
61
+ {
62
+ float: right;
63
+ margin-bottom: 20px;
64
+ }
65
+
66
+ .pager .grey
67
+ {
68
+ display: none;
69
+ }
70
+
71
+ .pager span, .pager a
72
+ {
73
+ border: 1px solid #ccc;
74
+ color: #000;
75
+ display: inline-block;
76
+ min-width: 20px;
77
+ margin-right: 8px;
78
+ padding: 5px;
79
+ text-align: center;
80
+
81
+ border-radius: 3px;
82
+ -webkit-border-radius: 3px;
83
+ -moz-border-radius: 3px;
84
+ }
85
+
86
+ .pager a:hover, .pager .current
87
+ {
88
+ background: #eee;
89
+ text-decoration: none;
90
+ }
@@ -56,6 +56,14 @@
56
56
  padding-left: 23px;
57
57
  }
58
58
 
59
+ .tabs ul li .tab_error
60
+ {
61
+ height: 16px;
62
+ margin: -5px 0px 0px -5px;
63
+ position: absolute;
64
+ width: 16px;
65
+ }
66
+
59
67
  .tabs ul li.active
60
68
  {
61
69
  background: #fff;