zen 0.4 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -41,18 +41,58 @@ module Menus
41
41
  #
42
42
  # In this form you can use the following fields:
43
43
  #
44
- # * **Name** (required): the name of the menu.
45
- # * **Slug**: a URL friendly version of the name. If none is specified it
46
- # will be generated automatically based on the name of the menu.
47
- # * **HTML class**: a space separated list of classes to apply to the HTML
48
- # element. The format of this field should match the regular exresspion
49
- # ``^[a-zA-Z\-_0-9\s]*$``
50
- # * **HTML ID**: an ID to apply to the HTML element. This value should match
51
- # the regular expression ``^[a-zA-Z\-_0-9]*$``.
52
- # * **Description**: the description of the menu.
53
- #
54
- # Note that all fields except the description field have a maximum length of
55
- # 255 characters.
44
+ # <table class="table full">
45
+ # <thead>
46
+ # <tr>
47
+ # <th class="field_name">Field</th>
48
+ # <th>Required</th>
49
+ # <th>Maximum Length</th>
50
+ # <th>Description</th>
51
+ # </tr>
52
+ # </thead>
53
+ # <tbody>
54
+ # <tr>
55
+ # <td>Name</td>
56
+ # <td>Yes</td>
57
+ # <td>255</td>
58
+ # <td>The name of the menu.</td>
59
+ # </tr>
60
+ # <tr>
61
+ # <td>Slug</td>
62
+ # <td>No</td>
63
+ # <td>255</td>
64
+ # <td>
65
+ # A URL friendly version of the name. If no slug is
66
+ # specified one will be generated based on the name.
67
+ # </td>
68
+ # </tr>
69
+ # <tr>
70
+ # <td>HTML class</td>
71
+ # <td>No</td>
72
+ # <td>255</td>
73
+ # <td>
74
+ # A space separated string containing the class(es) to apply
75
+ # to the menu. This value should match the pattern
76
+ # <code>^[a-zA-Z\-_0-9\s]*$</code>.
77
+ # </td>
78
+ # </tr>
79
+ # <tr>
80
+ # <td>HTML ID</td>
81
+ # <td>No</td>
82
+ # <td>255</td>
83
+ # <td>
84
+ # A single ID to apply to the menu. This value should match
85
+ # the pattern <code>^[a-zA-Z\-_0-9]*$</code>.
86
+ # </td>
87
+ # </tr>
88
+ # <tr>
89
+ # <td>Description</td>
90
+ # <td>No</td>
91
+ # <td>Unlimited</td>
92
+ # <td>A description of the menu.</td>
93
+ # </tr>
94
+ # </tbody>
95
+ # </table>
56
96
  #
57
97
  # ## Used Permissions
58
98
  #
@@ -74,7 +114,7 @@ module Menus
74
114
  csrf_protection :save, :delete
75
115
 
76
116
  ##
77
- # Shows an overview of all exisitng menus and a few properties of these
117
+ # Shows an overview of all existing menus and a few properties of these
78
118
  # groups such as the name, slug and the amount of items in that group.
79
119
  #
80
120
  # @since 0.2a
@@ -18,11 +18,12 @@ module Ramaze
18
18
  # valid.
19
19
  #
20
20
  def validate_menu(menu_id)
21
+ redirect_invalid_menu unless menu_id =~ /\d+/
22
+
21
23
  menu = ::Menus::Model::Menu[menu_id]
22
24
 
23
25
  if menu.nil?
24
- message(:error, lang('menus.errors.invalid_menu'))
25
- redirect(::Menus::Controller::Menus.r(:index))
26
+ redirect_invalid_menu
26
27
  else
27
28
  return menu
28
29
  end
@@ -38,16 +39,41 @@ module Ramaze
38
39
  # @return [Menus::Model::MenuItem]
39
40
  #
40
41
  def validate_menu_item(menu_item_id, menu_id)
42
+ redirect_invalid_menu_item(menu_id) unless menu_item_id =~ /\d+/
43
+
41
44
  menu_item = ::Menus::Model::MenuItem[menu_item_id]
42
45
 
43
46
  if menu_item.nil?
44
- message(:error, lang('menu_items.errors.invalid_item'))
45
- redirect(::Menus::Controller::MenuItems.r(:index, menu_id))
47
+ redirect_invalid_menu_item(menu_id)
46
48
  else
47
49
  return menu_item
48
50
  end
49
51
  end
50
52
 
53
+ ##
54
+ # Redirects the user to the menus overview and informs him/her that the
55
+ # menu he/she tried to access is invalid.
56
+ #
57
+ # @since 05-04-2012
58
+ #
59
+ def redirect_invalid_menu
60
+ message(:error, lang('menus.errors.invalid_menu'))
61
+ redirect(::Menus::Controller::Menus.r(:index))
62
+ end
63
+
64
+ ##
65
+ # Redirects the user back to the overview of menu items for a specific
66
+ # menu and informs the user that the menu item he/she tried to access is
67
+ # invalid.
68
+ #
69
+ # @since 05-04-2012
70
+ # @param [Fixnum] menu_id The ID of the menu.
71
+ #
72
+ def redirect_invalid_menu_item(menu_id)
73
+ message(:error, lang('menu_items.errors.invalid_item'))
74
+ redirect(::Menus::Controller::MenuItems.r(:index, menu_id))
75
+ end
76
+
51
77
  ##
52
78
  # Builds the menu item tree that can be used by the user to edit the sort
53
79
  # order, create the menu item tree and edit individual menu items.
@@ -109,7 +109,9 @@ module Menus
109
109
  def menu_items_tree(order = :asc, limit = nil)
110
110
  nodes = []
111
111
  indexes = {}
112
- rows = MenuItem.filter(:menu_id => id).limit(limit).all
112
+ rows = MenuItem.filter(:menu_id => id) \
113
+ .order(:sort_order.send(order)) \
114
+ .limit(limit).all
113
115
 
114
116
  rows.sort! do |left, right|
115
117
  (left.parent_id || 0) <=> (right.parent_id || 0)
@@ -133,7 +135,7 @@ module Menus
133
135
  nodes.reverse.each do |node|
134
136
  # If there's a matching parent node the current node should be
135
137
  # assigned to that node and removed from the list. If there's no
136
- # parent item then the node is un-modified.
138
+ # parent item then the node is unmodified.
137
139
  if indexes[node[:node].parent_id]
138
140
  index = indexes[node[:node].parent_id]
139
141
 
@@ -33,15 +33,54 @@ module Sections
33
33
  # Regardless of what field groups and categories you have assigned you can
34
34
  # always specify the following fields:
35
35
  #
36
- # * **Title** (required): the title of your entry.
37
- # * **Slug**: a URL friendly version of the title. If no slug is specified
38
- # one will be generated manually.
39
- # * **Created at**: The date on which the entry was created. This field is
40
- # filled in automatically when an entry is created.
41
- # * **Author** (required): the name of the person who wrote the entry.
42
- # * **Status** (required): the status of an entry. If an entry has a status
43
- # other than "Published" it will not be displayed when using the
44
- # sectio_entries plugin.
36
+ # <table class="table full">
37
+ # <thead>
38
+ # <tr>
39
+ # <th class="field_name">Field</th>
40
+ # <th>Required</th>
41
+ # <th>Maximum Length</th>
42
+ # <th>Description</th>
43
+ # </tr>
44
+ # </thead>
45
+ # <tbody>
46
+ # <tr>
47
+ # <td>Title</td>
48
+ # <td>Yes</td>
49
+ # <td>255</td>
50
+ # <td>The title of the section entry.</td>
51
+ # </tr>
52
+ # <tr>
53
+ # <td>Slug</td>
54
+ # <td>No</td>
55
+ # <td>255</td>
56
+ # <td>
57
+ # A URL friendly version of the title. If no value is specified
58
+ # one will be generated automatically.
59
+ # </td>
60
+ # </tr>
61
+ # <tr>
62
+ # <td>Creatd at</td>
63
+ # <td>No</td>
64
+ # <td></td>
65
+ # <td>
66
+ # The date on which the article was created. If no date is
67
+ # specified one will be set automatically.
68
+ # </td>
69
+ # </tr>
70
+ # <tr>
71
+ # <td>Author</td>
72
+ # <td>Yes</td>
73
+ # <td></td>
74
+ # <td>The name of the author of the entry.</td>
75
+ # </tr>
76
+ # <tr>
77
+ # <td>Status</td>
78
+ # <td>Yes</td>
79
+ # <td></td>
80
+ # <td>The status of the section entry.</td>
81
+ # </tr>
82
+ # </tbody>
83
+ # </table>
45
84
  #
46
85
  # Depending on whether or not you have category and field groups assigned
47
86
  # you can also use these fields. In the images above there's a "Body" field
@@ -47,27 +47,83 @@ module Sections
47
47
  #
48
48
  # In this form you can specify the following fields:
49
49
  #
50
- # * **Name** (required): the name of the section.
51
- # * **Slug**: a URL friendly version of the section name. If no slug is
52
- # specified one will be generated automatically.
53
- # * **Description**: a description of the section to help clarify it's
54
- # purpose.
55
- # * **Allow comments** (required): whether or not users can submit comments
56
- # for entries assigned to the section.
57
- # * **Comments require an account** (required): when set to "Yes" a user has
58
- # to be logged in in order to post a comment.
59
- # * **Moderate comments** (required): when enabled a comment first has to be
60
- # approved before it's displayed. This option is disabled by default.
61
- # * **Comment format** (required): the format comments are posted in such as
62
- # Markdown or plain text.
63
- # * **Custom field groups**: all the custom field groups to assign to the
64
- # section. These groups can then be used by all the entries in the
65
- # section.
66
- # * **Category groups**: all the category groups that should be available to
67
- # the section entries of this section.
68
- #
69
- # Note that the name and the slug of a section can not be longer than 255
70
- # characters.
50
+ # <table class="table full">
51
+ # <thead>
52
+ # <tr>
53
+ # <th class="field_name">Field</th>
54
+ # <th>Required</th>
55
+ # <th>Maximum Length</th>
56
+ # <th>Description</th>
57
+ # </tr>
58
+ # </thead>
59
+ # <tbody>
60
+ # <tr>
61
+ # <td>Name</td>
62
+ # <td>Yes</td>
63
+ # <td>255</td>
64
+ # <td>The name of the section.</td>
65
+ # </tr>
66
+ # <tr>
67
+ # <td>Slug</td>
68
+ # <td>No</td>
69
+ # <td>255</td>
70
+ # <td>
71
+ # A URL friendly version of the section name. If no value is
72
+ # specified one will be generated based on the section name.
73
+ # </td>
74
+ # </tr>
75
+ # <tr>
76
+ # <td>Description</td>
77
+ # <td>No</td>
78
+ # <td>Unlimited</td>
79
+ # <td>A description of the section.</td>
80
+ # </tr>
81
+ # <tr>
82
+ # <td>Allow comments</td>
83
+ # <td>Yes</td>
84
+ # <td></td>
85
+ # <td>
86
+ # Whether or not users can submit comments for this
87
+ # section's entries.
88
+ # </td>
89
+ # </tr>
90
+ # <tr>
91
+ # <td>Comments require an account</td>
92
+ # <td>Yes</td>
93
+ # <td></td>
94
+ # <td>
95
+ # When set users are required to be logged in in order to
96
+ # submit comments.
97
+ # </td>
98
+ # </tr>
99
+ # <tr>
100
+ # <td>Moderate comments</td>
101
+ # <td>Yes</td>
102
+ # <td></td>
103
+ # <td>
104
+ # Comments have to be approved before they'll be displayed.
105
+ # </td>
106
+ # </tr>
107
+ # <tr>
108
+ # <td>Comment format</td>
109
+ # <td>Yes</td>
110
+ # <td></td>
111
+ # <td>The markup format to use for comments.</td>
112
+ # </tr>
113
+ # <tr>
114
+ # <td>Custom field groups</td>
115
+ # <td></td>
116
+ # <td></td>
117
+ # <td>The custom field groups to assign to the section.</td>
118
+ # </tr>
119
+ # <tr>
120
+ # <td>Category groups</td>
121
+ # <td></td>
122
+ # <td></td>
123
+ # <td>The category groups to assign to the section.</td>
124
+ # </tr>
125
+ # </tbody>
126
+ # </table>
71
127
  #
72
128
  # ## Used Permissions
73
129
  #
@@ -14,11 +14,12 @@ module Ramaze
14
14
  # @return [Sections::Model::Section]
15
15
  #
16
16
  def validate_section(section_id)
17
+ redirect_invalid_section unless section_id =~ /\d+/
18
+
17
19
  section = Sections::Model::Section[section_id]
18
20
 
19
21
  if section.nil?
20
- message(:error, lang('sections.errors.invalid_section'))
21
- redirect(Sections::Controller::Sections.r(:index))
22
+ redirect_invalid_section
22
23
  else
23
24
  return section
24
25
  end
@@ -35,11 +36,14 @@ module Ramaze
35
36
  # @return [Sections::Model::SectionEntry]
36
37
  #
37
38
  def validate_section_entry(section_entry_id, section_id)
39
+ unless section_entry_id =~ /\d+/
40
+ redirect_invalid_section_entry(section_id)
41
+ end
42
+
38
43
  entry = Sections::Model::SectionEntry[section_entry_id]
39
44
 
40
45
  if entry.nil?
41
- message(:error, lang('section_entries.errors.invalid_entry'))
42
- redirect(Sections::Controller::SectionEntries.r(:index, section_id))
46
+ redirect_invalid_section_entry(section_id)
43
47
  else
44
48
  return entry
45
49
  end
@@ -88,6 +92,30 @@ module Ramaze
88
92
 
89
93
  return field_errors
90
94
  end
95
+
96
+ ##
97
+ # Redirects the user to the sections overview and shows a message
98
+ # informing the user that the section he/she tried to access is invalid.
99
+ #
100
+ # @since 09-04-2012
101
+ #
102
+ def redirect_invalid_section
103
+ message(:error, lang('sections.errors.invalid_section'))
104
+ redirect(Sections::Controller::Sections.r(:index))
105
+ end
106
+
107
+ ##
108
+ # Redirects the user to the overview of section entries for a given
109
+ # section and shows a message informing the user that the section entry
110
+ # he/she tried to access is invalid.
111
+ #
112
+ # @since 09-04-2012
113
+ # @param [Fixnum] section_id The ID of the section.
114
+ #
115
+ def redirect_invalid_section_entry(section_id)
116
+ message(:error, lang('section_entries.errors.invalid_entry'))
117
+ redirect(Sections::Controller::SectionEntries.r(:index, section_id))
118
+ end
91
119
  end # Section
92
120
  end # Helper
93
121
  end # Ramaze
@@ -149,7 +149,7 @@ module Sections
149
149
 
150
150
  ##
151
151
  # Retrieves all the possible categories for an entry and returns these as
152
- # a hash. This hash is a multi dimensional hash where the keys are the
152
+ # a hash. This hash is a multidimensional hash where the keys are the
153
153
  # names of all available category groups and the values hashes with the
154
154
  # IDs and names of all the categories for that group.
155
155
  #
@@ -41,7 +41,7 @@
41
41
  f.input_hidden(:section_id, @section_id)
42
42
  f.input_hidden(:id , @entry.id)
43
43
 
44
- f.g.div(:id => :basic) do
44
+ f.g.div(:id => :basic, :class => :tab_field) do
45
45
  f.input_text(
46
46
  lang('section_entries.labels.title'),
47
47
  :title,
@@ -74,7 +74,8 @@
74
74
  :user_id,
75
75
  :values => ::Users::Model::User.pk_hash(:name),
76
76
  :size => 1,
77
- :required => :required
77
+ :required => :required,
78
+ :selected => @entry.user_id
78
79
  )
79
80
 
80
81
  f.select(
@@ -86,7 +87,7 @@
86
87
  )
87
88
  end
88
89
 
89
- f.g.div(:id => :categories) do
90
+ f.g.div(:id => :categories, :class => :tab_field) do
90
91
  if !@possible_categories.empty?
91
92
  @possible_categories.each do |group, categories|
92
93
  f.input_checkbox(
@@ -103,7 +104,7 @@
103
104
 
104
105
  # Display all the custom fields for this entry
105
106
  @custom_fields_hash.each do |id, group|
106
- f.g.div(:id => "group_#{id}") do
107
+ f.g.div(:id => "group_#{id}", :class => :tab_field) do
107
108
  group[:fields].each do |field|
108
109
  f.send(*field)
109
110
  end
@@ -37,7 +37,7 @@
37
37
  f.input_hidden(:id , @section.id)
38
38
  f.input_hidden(:csrf_token, get_csrf_token)
39
39
 
40
- f.g.div(:id => 'general') do
40
+ f.g.div(:id => 'general', :class => :tab_field) do
41
41
  f.input_text(
42
42
  lang('sections.labels.name'),
43
43
  :name,
@@ -58,7 +58,7 @@
58
58
  )
59
59
  end # f.g.div(:id => 'general')
60
60
 
61
- f.g.div(:id => 'comments') do
61
+ f.g.div(:id => 'comments', :class => :tab_field) do
62
62
  f.input_radio(
63
63
  lang('sections.labels.comment_allow'),
64
64
  :comment_allow,
@@ -93,7 +93,7 @@
93
93
  )
94
94
  end # f.g.div(:id => 'comments')
95
95
 
96
- f.g.div(:id => 'groups') do
96
+ f.g.div(:id => 'groups', :class => :tab_field) do
97
97
  f.input_checkbox(
98
98
  lang('sections.labels.custom_field_groups'),
99
99
  :custom_field_group_pks,