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
data/lib/zen/theme.rb CHANGED
@@ -120,25 +120,81 @@ module Zen
120
120
  # theme using Rubygems. For example, if the theme is called "test" then the
121
121
  # file would be called "test.rb".
122
122
  #
123
- # When registering a theme you can set the following setters:
124
- #
125
- # * name (required): the name of the theme (should be a symbol)
126
- # * author (required): the name of the person who developed the theme.
127
- # * about (required): a short description of the theme.
128
- # * templates (required): a path to the directory containing the templates for
129
- # all sections.
130
- # * partials: a path to the directory containing all the partials that should
131
- # be rendered when calling ``partial()``.
132
- # * public: a path to an extra public directory to use, useful when you're
133
- # distributing your theme using Rubygems and want to ship it with a few CSS
134
- # files.
135
- # * migrations: path to a directory containing all Sequel migrations for the
136
- # theme. While not always needed this can be useful to automatically insert
137
- # data into the database.
138
- # * default_template_group: the name of the default template group to use in
139
- # case no custom one has been specified in the URI.
140
- # * env: an instance of ``OpenStruct`` that can be used to store custom data
141
- # such as an instance of ``Ramaze::Asset::Environment``.
123
+ # When registering a new theme you're required to set the following
124
+ # attributes:
125
+ #
126
+ # <table class="table full">
127
+ # <thead>
128
+ # <tr>
129
+ # <th>Attribute</th>
130
+ # <th>Description</th>
131
+ # </tr>
132
+ # </thead>
133
+ # <tbody>
134
+ # <tr>
135
+ # <td>name</td>
136
+ # <td>The name of the theme as a symbol.</td>
137
+ # </tr>
138
+ # <tr>
139
+ # <td>auhtor</td>
140
+ # <td>The name of the author of the theme.</td>
141
+ # </tr>
142
+ # <tr>
143
+ # <td>about</td>
144
+ # <td>A short description of the theme.</td>
145
+ # </tr>
146
+ # <tr>
147
+ # <td>templates</td>
148
+ # <td>
149
+ # Path to the directory containing the templates of the
150
+ # theme.
151
+ # </td>
152
+ # </tr>
153
+ # </tbody>
154
+ # </table>
155
+ #
156
+ # Optionally you can also specify the following attributes:
157
+ #
158
+ # <table class="table full">
159
+ # <thead>
160
+ # <tr>
161
+ # <th>Attribute</th>
162
+ # <th>Description</th>
163
+ # </tr>
164
+ # </thead>
165
+ # <tbody>
166
+ # <tr>
167
+ # <td>partials</td>
168
+ # <td>Path to a directory containing template partials.</td>
169
+ # </tr>
170
+ # <tr>
171
+ # <td>public</td>
172
+ # <td>
173
+ # Path to the public directory of the theme. This attribute is
174
+ # useful when you're distributing CSS and Javascript files (or
175
+ # other static files) with your theme.
176
+ # </td>
177
+ # </tr>
178
+ # <tr>
179
+ # <td>migrations</td>
180
+ # <td>Directory containing Sequel migrations for the theme.</td>
181
+ # </tr>
182
+ # <tr>
183
+ # <td>default_template_group</td>
184
+ # <td>
185
+ # The name of the default template group to use, set to
186
+ # "default" by default.
187
+ # </td>
188
+ # </tr>
189
+ # <tr>
190
+ # <td>env</td>
191
+ # <td>
192
+ # An instance of OpenStruct that can be used for storing
193
+ # arbitrary data (such as an asset manager).
194
+ # </td>
195
+ # </tr>
196
+ # </tbody>
197
+ # </table>
142
198
  #
143
199
  # An example call to ``Zen::Theme.add`` using these options:
144
200
  #
@@ -166,7 +222,7 @@ module Zen
166
222
  # Some examples:
167
223
  #
168
224
  # GET /pages/entry/hello-world => /pages/entry.xhtml
169
- # GET /pages/example => /404.xhtml (if "example" doesn't exist)
225
+ # GET /pages/example => /404.xhtml (if "example" doesn't exist)
170
226
  # GET /pages => /pages/index.xhtml
171
227
  #
172
228
  # Templates have access to the special instance variable ``@request_uri``.
@@ -175,7 +231,7 @@ module Zen
175
231
  # with the following values for this array:
176
232
  #
177
233
  # GET /pages/entry/hello-world => ['pages', 'entry', 'hello-world']
178
- # GET /pages/example => ['pages', 'example']
234
+ # GET /pages/example => ['pages', 'example']
179
235
  # GET /pages => ['pages', 'index']
180
236
  #
181
237
  # ## Retrieving Data
@@ -209,7 +265,7 @@ module Zen
209
265
  #
210
266
  # ## Template Partials
211
267
  #
212
- # Often you'll need to re-use an existing template multiple times. For
268
+ # Often you'll need to reuse an existing template multiple times. For
213
269
  # example, almost all templates will have some data inside the ``<head>`` tag
214
270
  # that will have pretty much the same markup and/or content in different
215
271
  # templates. Zen makes it possible this easy by using "partials". Partials are
@@ -301,7 +357,7 @@ module Zen
301
357
  end
302
358
 
303
359
  ##
304
- # Retrieves a single theme for hte given identifier.
360
+ # Retrieves a single theme for the given identifier.
305
361
  #
306
362
  # @since 0.2.4
307
363
  # @param [String/Symbol] name The name of the theme to retrieve.
@@ -338,7 +394,7 @@ module Zen
338
394
 
339
395
  ##
340
396
  # Returns the name of the theme as either plain text or an anchor tag if the
341
- # url attribute is set.
397
+ # URL attribute is set.
342
398
  #
343
399
  # @since 19-11-2011
344
400
  # @return [String]
@@ -123,7 +123,7 @@ module Zen
123
123
  end
124
124
 
125
125
  ##
126
- # Checks if the specified attribute contains a valid filepath.
126
+ # Checks if the specified attribute contains a valid file path.
127
127
  #
128
128
  # @example
129
129
  # validates_filepath(:directory)
data/lib/zen/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Zen
2
2
  # :nodoc:
3
- VERSION = '0.4'
3
+ VERSION = '0.4.1'
4
4
  end
@@ -5,14 +5,19 @@
5
5
  # Because this file is loaded using require() like any other file you're free to
6
6
  # add statements and custom code in this configuration file.
7
7
 
8
- # The root directory of your application. This directory will be used for
9
- # various settings by Zen and is therefor required.
10
- Zen.root = __DIR__('../')
11
-
12
8
  # The application mode to use. Based on different modes your application might
13
9
  # behave differently. For example, when set to :dev assets will not be minified.
10
+ #
11
+ # One thing to keep in mind is that the Ramaze mode **must** be set before
12
+ # defining Zen's root directory. Defining the mode after setting the root
13
+ # directory will prevent the various assets being used for the backend from
14
+ # being minified.
14
15
  Ramaze.options.mode = :dev
15
16
 
17
+ # The root directory of your application. This directory will be used for
18
+ # various settings by Zen and is therefor required.
19
+ Zen.root = __DIR__('../')
20
+
16
21
  # The name of your application. Its very important that this name is unique,
17
22
  # especially when a cache is shared among different Ramaze applications. If
18
23
  # these applications were to use the same name they might end up retrieving the
@@ -6,7 +6,7 @@
6
6
  # For development purposes we'll be loading various middlewares to make it
7
7
  # easier to detect errors, reloading the code and so on.
8
8
  #
9
- Ramaze.middleware!(:dev) do |m|
9
+ Ramaze.middleware! :dev do |m|
10
10
  # Rack::Lint is used to validate all code according to the Rack specification.
11
11
  # It's not recommended to use this middleware in a production environment as
12
12
  # it will slow your application down a bit.
@@ -17,7 +17,6 @@ Ramaze.middleware!(:dev) do |m|
17
17
  # details to the visitor.
18
18
  m.use Rack::ShowExceptions
19
19
 
20
- # Pretty much the same as Rack::ShowExceptions.
21
20
  m.use Rack::ShowStatus
22
21
 
23
22
  # Routes exceptions to different actions, can be useful for catching 404's and
data/spec/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Testing Zen
2
+
3
+ Zen comes with a wide variety of tests to ensure that the various parts of Zen
4
+ work as expected. These tests can be configured to use different databases
5
+ and/or features. Regardless of the configuration you should first migrate the
6
+ database and set up a test user, this can be done by running the following
7
+ commands:
8
+
9
+ $ cd spec
10
+ $ rake db:migrate
11
+ $ rake db:test_user
12
+
13
+ Once migrated you can run the tests as following:
14
+
15
+ $ ruby zen/all.rb
16
+
17
+ ## Requirements
18
+
19
+ * Ruby 1.9.2 or newer
20
+ * Firefox
21
+ * Selenium
22
+
23
+ Based on your configuration you may also need extra gems such as the sqlite3 gem
24
+ or the mysql2 gem.
25
+
26
+ ## Environment Variables
27
+
28
+ * ADAPTER: the database adapter to use. For SQLite3 this should be set to
29
+ "sqlite", for MySQL to "mysql2" and for PostgreSQL to "postgres".
30
+ * DATABASE: the name or file (in case of SQLite3) of the database.
31
+ * USERNAME: the username to use for connecting to a PostgreSQL or MySQL
32
+ database.
33
+ * PASSWORD: the password to use for connecting to a PostgreSQL or MySQL
34
+ database.
35
+ * LRU: when set to a non empty value the cache for sessions is set to
36
+ Ramaze::Cache::LRU.
37
+ * COVERAGE: when set to a non empty value code coverage will be generated using
38
+ SimpleCov.
39
+
40
+ ## Examples
41
+
42
+ Testing MySQL:
43
+
44
+ $ cd spec
45
+ $ export ADAPTER=mysql2 DATABASE=zen_dev USERNAME=root
46
+ $ rake db:migrate
47
+ $ rake db:test_user
48
+ $ ruby zen/all.rb
49
+
50
+ Testing PostgreSQL:
51
+
52
+ $ cd spec
53
+ $ export ADAPTER=postgres DATABASE=zen_dev USERNAME=postgres
54
+ $ rake db:migrate
55
+ $ rake db:test_user
56
+ $ ruby zen/all.rb
@@ -1,5 +1,4 @@
1
1
  require File.expand_path('../../../helper', __FILE__)
2
- require 'rdiscount'
3
2
 
4
3
  describe 'Zen::Controller::AdminController' do
5
4
  behaves_like :capybara
@@ -1,5 +1,4 @@
1
1
  require File.expand_path('../../../helper', __FILE__)
2
- require 'rdiscount'
3
2
 
4
3
  describe "Zen::Controller::Preview" do
5
4
  behaves_like :capybara
data/spec/zen/package.rb CHANGED
@@ -4,6 +4,12 @@ require File.join(Zen::FIXTURES, 'package')
4
4
  describe 'Zen::Package' do
5
5
  behaves_like :capybara
6
6
 
7
+ after do
8
+ admins = Users::Model::UserGroup[:slug => 'administrators']
9
+
10
+ admins.update(:super_group => true) unless admins.super_group
11
+ end
12
+
7
13
  it 'Add a new package' do
8
14
  Zen::Package.add do |p|
9
15
  p.name = :spec
@@ -59,4 +65,30 @@ describe 'Zen::Package' do
59
65
  menu.include?('<ul class="navigation">').should == true
60
66
  menu.include?(html).should == true
61
67
  end
68
+
69
+ # https://github.com/zen-cms/Zen-Core/issues/65
70
+ it 'Menu items that do not need permissions should be displayed' do
71
+ permission = Zen::Package[:spec].menu[0].options[:permission]
72
+ admins = Users::Model::UserGroup[:slug => 'administrators']
73
+ logout = Users::Controller::Users.r(:logout).to_s
74
+
75
+ Zen::Package[:spec].menu[0].options[:permission] = nil
76
+
77
+ # Change the user to a regular user for this test.
78
+ visit(logout)
79
+
80
+ admins.update(:super_group => false)
81
+
82
+ capybara_login
83
+
84
+ visit(Dashboard::Controller::Dashboard.r(:index).to_s)
85
+
86
+ within '#admin_navigation' do
87
+ page.has_content?('Spec').should == true
88
+ end
89
+
90
+ visit(logout)
91
+
92
+ Zen::Package[:spec].menu[0].options[:permission] = permission
93
+ end
62
94
  end
@@ -145,6 +145,13 @@ describe "Categories::Controller::Categories" do
145
145
  page.has_selector?('span.error').should == true
146
146
  end
147
147
 
148
+ it 'Non numeric category IDs should be handled gracefully' do
149
+ visit(Categories::Controller::Categories.r(:edit, group.id, 'a').to_s)
150
+
151
+ page.current_path.should == index_url
152
+ page.has_selector?('.message.error').should == true
153
+ end
154
+
148
155
  enable_javascript
149
156
 
150
157
  it 'Automatically save a category' do
@@ -152,6 +152,13 @@ describe "Categories::Controller::CategoryGroups" do
152
152
  page.has_selector?('span.error').should == true
153
153
  end
154
154
 
155
+ it 'Non numeric category group IDs should be handled gracefully' do
156
+ visit(Categories::Controller::CategoryGroups.r(:edit, 'a').to_s)
157
+
158
+ page.current_path.should == index_url
159
+ page.has_selector?('.message.error').should == true
160
+ end
161
+
155
162
  enable_javascript
156
163
 
157
164
  it 'Automatically save a category group' do
@@ -159,6 +159,13 @@ describe 'Comments::Controller::Comments' do
159
159
  page.has_selector?('span.error').should == true
160
160
  end
161
161
 
162
+ it 'Gracefully handle non numeric comment IDs' do
163
+ visit(Comments::Controller::Comments.r(:edit, 'a').to_s)
164
+
165
+ page.current_path.should == index_url
166
+ page.has_selector?('.message.error').should == true
167
+ end
168
+
162
169
  enable_javascript
163
170
 
164
171
  it 'Automatically save a comment' do
@@ -91,6 +91,13 @@ describe 'CustomFields::Controller::CustomFieldGroups' do
91
91
  page.find('input[name="name"]').value.should == 'Spec field group modified'
92
92
  end
93
93
 
94
+ it 'Gracefully handle non numeric custom field group IDs' do
95
+ visit(CustomFields::Controller::CustomFieldGroups.r(:edit, 'a').to_s)
96
+
97
+ page.current_path.should == index_url
98
+ page.has_selector?('.message.error').should == true
99
+ end
100
+
94
101
  enable_javascript
95
102
 
96
103
  it 'Automatically save a custom field group' do
@@ -139,6 +139,13 @@ describe 'CustomFields::Controller::CustomFieldTypes' do
139
139
  page.find_field('custom_field_method_id').value.should == method_id
140
140
  end
141
141
 
142
+ it 'Gracefully handle non numeric custom field type IDs' do
143
+ visit(CustomFields::Controller::CustomFieldTypes.r(:edit, 'a').to_s)
144
+
145
+ page.current_path.should == index_url
146
+ page.has_selector?('.message.error').should == true
147
+ end
148
+
142
149
  enable_javascript
143
150
 
144
151
  it 'Automatically save a custom field type' do
@@ -129,6 +129,13 @@ describe 'CustomFields::Controller::CustomFields' do
129
129
  .value.should == textarea_field.id.to_s
130
130
  end
131
131
 
132
+ it 'Gracefully handle non numeric custom field IDs' do
133
+ visit(CustomFields::Controller::CustomFields.r(:edit, group.id, 'a').to_s)
134
+
135
+ page.current_path.should == index_url
136
+ page.has_selector?('.message.error').should == true
137
+ end
138
+
132
139
  enable_javascript
133
140
 
134
141
  it 'Automatically save a custom field' do
@@ -57,6 +57,13 @@ describe "Menus::Controller::MenuItems" do
57
57
  page.find('input[name="name"]').value.should == 'Spec menu item modified'
58
58
  end
59
59
 
60
+ it 'Gracefully handle non numeric menu item IDs' do
61
+ visit(Menus::Controller::MenuItems.r(:edit, menu.id, 'a').to_s)
62
+
63
+ page.current_path.should == index_url
64
+ page.has_selector?('.message.error').should == true
65
+ end
66
+
60
67
  enable_javascript
61
68
 
62
69
  it 'Automatically save a menu item' do
@@ -89,6 +89,13 @@ describe "Menus::Controller::Menus" do
89
89
  page.find('input[name="name"]').value.should == 'Spec menu modified'
90
90
  end
91
91
 
92
+ it 'Gracefully handle non numeric menu IDs' do
93
+ visit(Menus::Controller::Menus.r(:edit, 'a').to_s)
94
+
95
+ page.current_path.should == index_url
96
+ page.has_selector?('.message.error').should == true
97
+ end
98
+
92
99
  enable_javascript
93
100
 
94
101
  it 'Automatically save a menu' do
@@ -52,7 +52,7 @@ describe 'Menus::Plugin::Menus' do
52
52
  end
53
53
 
54
54
  it "Retrieve a menu with only 1 item" do
55
- menu = render_menu(nav_menu.slug, :limit => 1).strip
55
+ menu = render_menu(nav_menu.slug, :limit => 1, :order => :asc).strip
56
56
 
57
57
  menu.include?('Spec').should == true
58
58
  menu.include?('Spec 2').should == false