zen 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gems +34 -0
- data/.travis.yml +7 -0
- data/AUTHORS +5 -0
- data/CHANGELOG +14 -0
- data/{license.txt → LICENSE} +0 -0
- data/MANIFEST +67 -51
- data/README.md +18 -25
- data/Rakefile +2 -3
- data/bin/zen +2 -2
- data/lib/zen.rb +93 -57
- data/lib/zen/asset.rb +7 -8
- data/lib/zen/bin/app.rb +0 -2
- data/lib/zen/controller/admin_controller.rb +4 -9
- data/lib/zen/controller/base_controller.rb +0 -25
- data/lib/zen/controller/main_controller.rb +5 -5
- data/lib/zen/controller/preview.rb +50 -0
- data/lib/zen/helper/common.rb +4 -68
- data/lib/zen/helper/message.rb +82 -0
- data/lib/zen/helper/theme.rb +2 -2
- data/lib/zen/language.rb +68 -38
- data/lib/zen/language/en/zen_general.yml +1 -4
- data/lib/zen/language/nl/zen_general.yml +28 -0
- data/lib/zen/language/nl/zen_models.yml +13 -0
- data/lib/zen/layout/admin.xhtml +1 -1
- data/lib/zen/layout/login.xhtml +1 -1
- data/lib/zen/model/settings.rb +2 -0
- data/lib/zen/package.rb +29 -25
- data/lib/zen/package/all.rb +1 -1
- data/lib/zen/package/categories/lib/categories/controller/categories.rb +51 -63
- data/lib/zen/package/categories/lib/categories/controller/category_groups.rb +45 -52
- data/lib/zen/package/categories/lib/categories/language/en/categories.yml +2 -2
- data/lib/zen/package/categories/lib/categories/language/nl/categories.yml +39 -0
- data/lib/zen/package/categories/lib/categories/language/nl/category_groups.yml +33 -0
- data/lib/zen/package/categories/lib/categories/plugin/categories.rb +2 -2
- data/lib/zen/package/comments/lib/comments.rb +31 -2
- data/lib/zen/package/comments/lib/comments/controller/comments.rb +42 -57
- data/lib/zen/package/comments/lib/comments/controller/comments_form.rb +36 -51
- data/lib/zen/package/comments/lib/comments/language/en/comments.yml +7 -3
- data/lib/zen/package/comments/lib/comments/language/nl/comments.yml +48 -0
- data/lib/zen/package/comments/lib/comments/model/comment.rb +45 -4
- data/lib/zen/package/comments/lib/comments/plugin/anti_spam.rb +152 -0
- data/lib/zen/package/comments/lib/comments/plugin/comments.rb +5 -6
- data/lib/zen/package/comments/lib/comments/view/admin/comments/index.xhtml +2 -2
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +43 -52
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_fields.rb +68 -67
- data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_fields.yml +1 -1
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_groups.yml +32 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_fields.yml +52 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field.rb +3 -3
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_group.rb +4 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb +3 -3
- data/lib/zen/package/menus/lib/menus/controller/menu_items.rb +37 -44
- data/lib/zen/package/menus/lib/menus/controller/menus.rb +33 -43
- data/lib/zen/package/menus/lib/menus/helper/menu_item.rb +5 -10
- data/lib/zen/package/menus/lib/menus/language/nl/menu_items.yml +41 -0
- data/lib/zen/package/menus/lib/menus/language/nl/menus.yml +39 -0
- data/lib/zen/package/menus/lib/menus/model/menu.rb +3 -3
- data/lib/zen/package/menus/lib/menus/model/menu_item.rb +3 -3
- data/lib/zen/package/menus/lib/menus/plugin/menus.rb +5 -6
- data/lib/zen/package/menus/migrations/1297184342_create_schema.rb +1 -1
- data/lib/zen/package/sections/lib/sections.rb +20 -0
- data/lib/zen/package/sections/lib/sections/controller/section_entries.rb +85 -79
- data/lib/zen/package/sections/lib/sections/controller/sections.rb +58 -66
- data/lib/zen/package/sections/lib/sections/language/en/sections.yml +0 -1
- data/lib/zen/package/sections/lib/sections/language/nl/section_entries.yml +43 -0
- data/lib/zen/package/sections/lib/sections/language/nl/sections.yml +47 -0
- data/lib/zen/package/sections/lib/sections/model/section.rb +11 -15
- data/lib/zen/package/sections/lib/sections/model/section_entry.rb +9 -5
- data/lib/zen/package/sections/lib/sections/plugin/section_entries.rb +7 -8
- data/lib/zen/package/sections/lib/sections/plugin/sections.rb +3 -4
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/form.xhtml +0 -4
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/index.xhtml +8 -2
- data/lib/zen/package/sections/migrations/1306772479_remove_unique_slug.rb +28 -0
- data/lib/zen/package/settings/lib/settings.rb +21 -34
- data/lib/zen/package/settings/lib/settings/controller/settings.rb +29 -22
- data/lib/zen/package/settings/lib/settings/language/en/settings.yml +7 -5
- data/lib/zen/package/settings/lib/settings/language/nl/settings.yml +39 -0
- data/lib/zen/package/settings/lib/settings/model/setting.rb +3 -5
- data/lib/zen/package/settings/lib/settings/plugin/group_base.rb +3 -4
- data/lib/zen/package/settings/lib/settings/plugin/setting_base.rb +3 -5
- data/lib/zen/package/settings/lib/settings/plugin/settings.rb +11 -4
- data/lib/zen/package/settings/lib/settings/view/admin/settings/index.xhtml +5 -5
- data/lib/zen/package/settings/migrations/1299538742_add_language_key.rb +8 -8
- data/lib/zen/package/settings/migrations/1303196915_settings_plugin.rb +2 -5
- data/lib/zen/package/users/lib/users/controller/access_rules.rb +54 -61
- data/lib/zen/package/users/lib/users/controller/user_groups.rb +49 -57
- data/lib/zen/package/users/lib/users/controller/users.rb +58 -73
- data/lib/zen/package/users/lib/users/language/en/users.yml +6 -0
- data/lib/zen/package/users/lib/users/language/nl/access_rules.yml +37 -0
- data/lib/zen/package/users/lib/users/language/nl/user_groups.yml +31 -0
- data/lib/zen/package/users/lib/users/language/nl/users.yml +56 -0
- data/lib/zen/package/users/lib/users/model/user.rb +16 -1
- data/lib/zen/package/users/lib/users/view/admin/users/form.xhtml +27 -2
- data/lib/zen/package/users/lib/users/view/admin/users/index.xhtml +15 -3
- data/lib/zen/package/users/migrations/1304939855_user_settings.rb +15 -0
- data/lib/zen/plugin.rb +7 -9
- data/lib/zen/public/admin/css/{buttons.css → zen/buttons.css} +11 -7
- data/lib/zen/public/admin/css/{datepicker.css → zen/datepicker.css} +0 -0
- data/lib/zen/public/admin/css/{editor.css → zen/editor.css} +10 -5
- data/lib/zen/public/admin/css/{forms.css → zen/forms.css} +1 -1
- data/lib/zen/public/admin/css/{general.css → zen/general.css} +7 -7
- data/lib/zen/public/admin/css/{grid.css → zen/grid.css} +0 -0
- data/lib/zen/public/admin/css/{layout.css → zen/layout.css} +4 -5
- data/lib/zen/public/admin/css/zen/messages.css +61 -0
- data/lib/zen/public/admin/css/{notifications.css → zen/notifications.css} +4 -4
- data/lib/zen/public/admin/css/{reset.css → zen/reset.css} +0 -0
- data/lib/zen/public/admin/css/{tables.css → zen/tables.css} +3 -3
- data/lib/zen/public/admin/css/{tabs.css → zen/tabs.css} +5 -5
- data/lib/zen/public/admin/css/zen/window.css +79 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/accept.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/add.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/back.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/bold.png +0 -0
- data/lib/zen/public/admin/images/zen/icons/close.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/delete.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/edit.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/error.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/help.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/info.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/italic.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/large/error.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/large/notice.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/large/success.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/link.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/logout.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/ol.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/pdf.png +0 -0
- data/lib/zen/public/admin/images/zen/icons/preview.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/ul.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/user.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/view.png +0 -0
- data/lib/zen/public/admin/js/zen/core.js +73 -0
- data/lib/zen/public/admin/js/zen/editor.js +527 -0
- data/lib/zen/public/admin/js/zen/editor/markdown.js +84 -0
- data/lib/zen/public/admin/js/zen/editor/textile.js +84 -0
- data/lib/zen/public/admin/js/zen/init.js +12 -66
- data/lib/zen/public/admin/js/zen/tabs.js +5 -0
- data/lib/zen/public/admin/js/zen/window.js +206 -0
- data/lib/zen/task/build.rake +23 -6
- data/lib/zen/task/clean.rake +6 -7
- data/lib/zen/task/db.rake +7 -9
- data/lib/zen/task/package.rake +6 -6
- data/lib/zen/task/test.rake +6 -0
- data/lib/zen/task/theme.rake +3 -3
- data/lib/zen/theme.rb +3 -4
- data/lib/zen/validation.rb +7 -9
- data/lib/zen/version.rb +3 -4
- data/lib/zen/view/bottom.xhtml +0 -5
- data/lib/zen/view/main.xhtml +2 -0
- data/proto/app/app.rb +6 -4
- data/proto/app/config/config.rb +1 -7
- data/proto/app/config/database.rb +47 -43
- data/proto/app/config/middlewares.rb +0 -40
- data/proto/app/start.rb +1 -6
- data/proto/app/{vendor → theme}/.gitkeep +0 -0
- data/proto/migration.rb +3 -3
- data/proto/package/lib/package.rb +0 -1
- data/proto/package/lib/package/controller/controllers.rb +7 -40
- data/proto/package/lib/package/model/model.rb +3 -3
- metadata +106 -79
- data/CHANGELOG.md +0 -27
- data/ROADMAP.md +0 -53
- data/lib/zen/database.rb +0 -112
- data/lib/zen/logger.rb +0 -56
- data/lib/zen/public/admin/css/modals.css +0 -63
- data/lib/zen/public/admin/images/icons/close.png +0 -0
- data/lib/zen/public/admin/js/vendor/yepnope.js +0 -1
- data/lib/zen/public/admin/js/zen/editor/base.js +0 -262
- data/lib/zen/public/admin/js/zen/editor/drivers/html.js +0 -89
- data/lib/zen/public/admin/js/zen/editor/drivers/markdown.js +0 -87
- data/lib/zen/public/admin/js/zen/editor/drivers/textile.js +0 -87
- data/lib/zen/public/admin/js/zen/modal.js +0 -146
- data/lib/zen/public/admin/js/zen/notification.js +0 -211
- data/proto/app/config/requires.rb +0 -10
- data/proto/app/vendor/theme/.gitkeep +0 -0
- data/proto/package/lib/package/view/admin/package/edit.xhtml +0 -0
- data/proto/package/lib/package/view/admin/package/form.xhtml +0 -0
- data/proto/package/lib/package/view/admin/package/new.xhtml +0 -0
@@ -14,6 +14,7 @@ errors:
|
|
14
14
|
website_offline : 'This website is currently offline.'
|
15
15
|
no_templates : 'No templates were found for the given action.'
|
16
16
|
no_theme : 'No theme has been specified.'
|
17
|
+
invalid_request : 'The request could not be executed as the specified data is incorrect.'
|
17
18
|
|
18
19
|
special:
|
19
20
|
format_hash:
|
@@ -25,7 +26,3 @@ special:
|
|
25
26
|
boolean_hash:
|
26
27
|
'true' : 'Yes'
|
27
28
|
'false' : 'No'
|
28
|
-
|
29
|
-
language_hash:
|
30
|
-
en : 'English'
|
31
|
-
|
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
labels:
|
3
|
+
zen_version : 'Deze website draait op Zen versie %s'
|
4
|
+
zen_website : 'Website'
|
5
|
+
zen_docs : 'Documentatie'
|
6
|
+
zen_github : 'GitHub account'
|
7
|
+
view_website: 'Bekijk website'
|
8
|
+
logout : 'Uitloggen'
|
9
|
+
profile : 'Profiel'
|
10
|
+
|
11
|
+
errors:
|
12
|
+
csrf : 'De actie kan niet worden uitgevoerd zonder een geldige CSRF token.'
|
13
|
+
not_authorized : 'U bent niet toegestaan om de huidige pagina te bekijken.'
|
14
|
+
website_offline: 'Deze website is momenteel offline.'
|
15
|
+
no_templates : 'Er konden geen sjablonen worden gevonden voor de huidige actie.'
|
16
|
+
no_theme : 'Er is geen thema ingesteld.'
|
17
|
+
invalid_request: 'De actie kon niet worden uitgevoerd omdat de data onjuist is.'
|
18
|
+
|
19
|
+
special:
|
20
|
+
format_hash:
|
21
|
+
html : 'HTML'
|
22
|
+
textile : 'Textile'
|
23
|
+
markdown: 'Markdown'
|
24
|
+
plain : 'Platte tekst'
|
25
|
+
|
26
|
+
boolean_hash:
|
27
|
+
'true' : 'Ja'
|
28
|
+
'false': 'Nee'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
exact_length: 'Dit veld bevat niet exact %s karakters.'
|
3
|
+
format : 'Het formaat van de waarde van dit veld is onjuist.'
|
4
|
+
includes : 'De waarde van dit veld is niet binnen het bereik van %s.'
|
5
|
+
integer : 'De waarde van dit veld is niet numeriek.'
|
6
|
+
length_range: 'De waarde van dit veld is te lang of te kort.'
|
7
|
+
max_length : 'De waarde van dit veld mag niet langer zijn dan %s karakters.'
|
8
|
+
min_length : 'De waarde van dit veld mag niet korter zijn dan %s karakters.'
|
9
|
+
not_string : 'De waarde van dit veld is geen tekst.'
|
10
|
+
numeric : 'De waarde van dit veld is niet numeriek.'
|
11
|
+
type : 'De waarde van dit veld is niet het type %s.'
|
12
|
+
presence : 'Dit veld is vereist.'
|
13
|
+
unique : 'De waarde van dit veld is al in gebruik.'
|
data/lib/zen/layout/admin.xhtml
CHANGED
data/lib/zen/layout/login.xhtml
CHANGED
data/lib/zen/model/settings.rb
CHANGED
data/lib/zen/package.rb
CHANGED
@@ -5,12 +5,12 @@ require __DIR__('package/base')
|
|
5
5
|
#:nodoc:
|
6
6
|
module Zen
|
7
7
|
##
|
8
|
-
# Module used for registering extensions and themes, setting their details and the
|
9
|
-
# whole shebang. Packages follow the same directory structure as Rubygems and can
|
10
|
-
# actually be installed using either Rubygems or by storing them in a custom directory.
|
8
|
+
# Module used for registering extensions and themes, setting their details and the
|
9
|
+
# whole shebang. Packages follow the same directory structure as Rubygems and can
|
10
|
+
# actually be installed using either Rubygems or by storing them in a custom directory.
|
11
11
|
# As long as you require the correct file you're good to go.
|
12
12
|
#
|
13
|
-
# Packages are added or "described" using a simple block and the add() method as
|
13
|
+
# Packages are added or "described" using a simple block and the add() method as
|
14
14
|
# following:
|
15
15
|
#
|
16
16
|
# Zen::Package.add do |ext|
|
@@ -24,7 +24,7 @@ module Zen
|
|
24
24
|
# * about: a small description of the package.
|
25
25
|
# * url: the URL to the package's website.
|
26
26
|
# * directory: the root directory of the package, set this using __DIR__('path').
|
27
|
-
#
|
27
|
+
#
|
28
28
|
# Optionally you can also specify the attribute "menu" (more on that later).
|
29
29
|
#
|
30
30
|
# ## ACL
|
@@ -72,12 +72,12 @@ module Zen
|
|
72
72
|
#
|
73
73
|
# If your package uses it's own database tables it's best to use migrations as these make
|
74
74
|
# it very easy to install/uninstall the extension. Migrations should be put in the root
|
75
|
-
# directory of your extension. For example, if your extension is in "foobar" the
|
76
|
-
# migrations should be located in "foobar/migrations", the lib directory in "foobar/lib",
|
75
|
+
# directory of your extension. For example, if your extension is in "foobar" the
|
76
|
+
# migrations should be located in "foobar/migrations", the lib directory in "foobar/lib",
|
77
77
|
# etc.
|
78
78
|
#
|
79
79
|
# Migrations can be executed using the Thor task "package:migrate" or "db:migrate",
|
80
|
-
# the latter will install all packages while the first one will only install the
|
80
|
+
# the latter will install all packages while the first one will only install the
|
81
81
|
# specified packages. For more information on these tasks execute the following command:
|
82
82
|
#
|
83
83
|
# $ rake -T
|
@@ -104,7 +104,7 @@ module Zen
|
|
104
104
|
Controllers = []
|
105
105
|
|
106
106
|
##
|
107
|
-
# Adds a new package along with all it's details such as the name, author, version
|
107
|
+
# Adds a new package along with all it's details such as the name, author, version
|
108
108
|
# and so on. Extensions can be added using a simple block as following:
|
109
109
|
#
|
110
110
|
# Zen::Package.add do |ext|
|
@@ -130,7 +130,7 @@ module Zen
|
|
130
130
|
#
|
131
131
|
def self.add
|
132
132
|
package = Zen::Package::Base.new
|
133
|
-
|
133
|
+
|
134
134
|
yield package
|
135
135
|
|
136
136
|
# Validate the package
|
@@ -154,8 +154,8 @@ module Zen
|
|
154
154
|
Controllers.push(controller)
|
155
155
|
end
|
156
156
|
end
|
157
|
-
|
158
|
-
Registered[package.name.to_sym] = package
|
157
|
+
|
158
|
+
Registered[package.name.to_sym] = package
|
159
159
|
end
|
160
160
|
|
161
161
|
##
|
@@ -194,7 +194,7 @@ module Zen
|
|
194
194
|
@g = Ramaze::Gestalt.new
|
195
195
|
@permissions = permissions
|
196
196
|
menu_items = []
|
197
|
-
|
197
|
+
|
198
198
|
Registered.each do |name, pkg|
|
199
199
|
# Got a menu for us?
|
200
200
|
if !pkg.menu.nil?
|
@@ -203,12 +203,12 @@ module Zen
|
|
203
203
|
end
|
204
204
|
end
|
205
205
|
end
|
206
|
-
|
206
|
+
|
207
207
|
# Sort the menu alphabetical
|
208
208
|
menu_items = menu_items.sort_by do |item|
|
209
209
|
item[:title]
|
210
210
|
end
|
211
|
-
|
211
|
+
|
212
212
|
@g.ul :class => css_class do
|
213
213
|
if !menu_items.empty?
|
214
214
|
menu_items.each do |m|
|
@@ -216,12 +216,12 @@ module Zen
|
|
216
216
|
end
|
217
217
|
end
|
218
218
|
end
|
219
|
-
|
219
|
+
|
220
220
|
return @g.to_s
|
221
221
|
end
|
222
|
-
|
222
|
+
|
223
223
|
private
|
224
|
-
|
224
|
+
|
225
225
|
##
|
226
226
|
# Method that's used to generate the list items for each
|
227
227
|
# navigation menu along with all sub elements.
|
@@ -231,13 +231,18 @@ module Zen
|
|
231
231
|
# @since 0.1
|
232
232
|
#
|
233
233
|
def self.nav_list(menu)
|
234
|
-
if menu[:url][0] != '/'
|
234
|
+
if menu[:url][0, 1] != '/'
|
235
235
|
menu[:url] = '/' + menu[:url]
|
236
236
|
end
|
237
237
|
|
238
238
|
# Get the controller for the current item
|
239
|
-
controller
|
240
|
-
|
239
|
+
controller = Ramaze::AppMap.at('/').url_map.at(menu[:url]).to_s
|
240
|
+
|
241
|
+
if @permissions[controller].nil?
|
242
|
+
read_access = false
|
243
|
+
else
|
244
|
+
read_access = @permissions[controller].include?(:read)
|
245
|
+
end
|
241
246
|
|
242
247
|
# Ignore the menu item alltogether
|
243
248
|
if !read_access and !menu.key?(:children)
|
@@ -253,7 +258,7 @@ module Zen
|
|
253
258
|
@g.a :href => menu[:url], :title => menu[:title] do
|
254
259
|
menu[:title]
|
255
260
|
end
|
256
|
-
|
261
|
+
|
257
262
|
if menu.key?(:children)
|
258
263
|
@g.ul do
|
259
264
|
menu[:children].each do |c|
|
@@ -263,6 +268,5 @@ module Zen
|
|
263
268
|
end
|
264
269
|
end
|
265
270
|
end
|
266
|
-
|
267
|
-
|
268
|
-
end
|
271
|
+
end # Package
|
272
|
+
end # Zen
|
data/lib/zen/package/all.rb
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
# not work.
|
5
5
|
#
|
6
6
|
require __DIR__('users/lib/users')
|
7
|
-
require __DIR__('sections/lib/sections')
|
8
7
|
require __DIR__('settings/lib/settings')
|
8
|
+
require __DIR__('sections/lib/sections')
|
9
9
|
require __DIR__('comments/lib/comments')
|
10
10
|
require __DIR__('categories/lib/categories')
|
11
11
|
require __DIR__('custom_fields/lib/custom_fields')
|
@@ -1,11 +1,11 @@
|
|
1
1
|
#:nodoc:
|
2
|
-
module Categories
|
2
|
+
module Categories
|
3
3
|
#:nodoc:
|
4
4
|
module Controller
|
5
5
|
##
|
6
6
|
# Categories can be seen as "tags" for your section entries. They describe the
|
7
7
|
# type of entry just like tags except that categories generally cover larger elements.
|
8
|
-
# When adding a new entry categories aren't required so you're free to ignore
|
8
|
+
# When adding a new entry categories aren't required so you're free to ignore
|
9
9
|
# them if you don't need them.
|
10
10
|
#
|
11
11
|
# @author Yorick Peterse
|
@@ -13,15 +13,15 @@ module Categories
|
|
13
13
|
#
|
14
14
|
class Categories < Zen::Controller::AdminController
|
15
15
|
include ::Categories::Model
|
16
|
-
|
16
|
+
|
17
17
|
map('/admin/categories')
|
18
|
-
|
18
|
+
|
19
19
|
before_all do
|
20
20
|
csrf_protection(:save, :delete) do
|
21
21
|
respond(lang('zen_general.errors.csrf'), 403)
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
##
|
26
26
|
# The constructor is used to set various options such as the form URLs and load
|
27
27
|
# the language pack for the categories module.
|
@@ -36,20 +36,20 @@ module Categories
|
|
36
36
|
#
|
37
37
|
def initialize
|
38
38
|
super
|
39
|
-
|
39
|
+
|
40
40
|
@form_save_url = Categories.r(:save)
|
41
41
|
@form_delete_url = Categories.r(:delete)
|
42
42
|
|
43
43
|
Zen::Language.load('categories')
|
44
44
|
Zen::Language.load('category_groups')
|
45
|
-
|
45
|
+
|
46
46
|
# Set the page title
|
47
47
|
if !action.method.nil?
|
48
48
|
method = action.method.to_s
|
49
49
|
@page_title = lang("categories.titles.#{method}") rescue nil
|
50
50
|
end
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
##
|
54
54
|
# Show an overview of all existing categories and allow the user
|
55
55
|
# to create and manage these categories.
|
@@ -67,16 +67,16 @@ module Categories
|
|
67
67
|
if !user_authorized?([:read])
|
68
68
|
respond(lang('zen_general.errors.not_authorized'), 403)
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
set_breadcrumbs(
|
72
72
|
anchor_to(lang('category_groups.titles.index'), CategoryGroups.r(:index)),
|
73
73
|
lang('categories.titles.index')
|
74
74
|
)
|
75
|
-
|
75
|
+
|
76
76
|
@category_group_id = category_group_id.to_i
|
77
77
|
@categories = CategoryGroup[@category_group_id].categories
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
##
|
81
81
|
# Edit an existing category based on the ID specified in the URL.
|
82
82
|
#
|
@@ -94,13 +94,13 @@ module Categories
|
|
94
94
|
if !user_authorized?([:read, :update])
|
95
95
|
respond(lang('zen_general.errors.not_authorized'), 403)
|
96
96
|
end
|
97
|
-
|
97
|
+
|
98
98
|
set_breadcrumbs(
|
99
99
|
anchor_to(lang('category_groups.titles.index'), CategoryGroups.r(:index)),
|
100
100
|
anchor_to(lang('categories.titles.index'), Categories.r(:index, category_group_id)),
|
101
101
|
lang('categories.titles.edit')
|
102
102
|
)
|
103
|
-
|
103
|
+
|
104
104
|
@category_group_id = category_group_id.to_i
|
105
105
|
|
106
106
|
if flash[:form_data]
|
@@ -109,7 +109,7 @@ module Categories
|
|
109
109
|
@category = Category[id.to_i]
|
110
110
|
end
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
113
|
##
|
114
114
|
# Create a new category.
|
115
115
|
#
|
@@ -126,13 +126,13 @@ module Categories
|
|
126
126
|
if !user_authorized?([:read, :create])
|
127
127
|
respond(lang('zen_general.errors.not_authorized'), 403)
|
128
128
|
end
|
129
|
-
|
129
|
+
|
130
130
|
set_breadcrumbs(
|
131
131
|
anchor_to(lang('category_groups.titles.index'), CategoryGroups.r(:index)),
|
132
132
|
anchor_to(lang('categories.titles.index'), Categories.r(:index, category_group_id)),
|
133
133
|
lang('categories.titles.new')
|
134
134
|
)
|
135
|
-
|
135
|
+
|
136
136
|
@category_group_id = category_group_id.to_i
|
137
137
|
@category = Category.new
|
138
138
|
end
|
@@ -148,48 +148,52 @@ module Categories
|
|
148
148
|
#
|
149
149
|
# @author Yorick Peterse
|
150
150
|
# @since 0.1
|
151
|
-
#
|
151
|
+
#
|
152
152
|
def save
|
153
153
|
if !user_authorized?([:create, :update])
|
154
154
|
respond(lang('zen_general.errors.not_authorized'), 403)
|
155
155
|
end
|
156
|
-
|
157
|
-
post
|
158
|
-
|
159
|
-
|
160
|
-
post.delete('slug') if post['slug'].empty?
|
156
|
+
|
157
|
+
post = request.subset(
|
158
|
+
:id, :parent_id, :name, :description, :slug, :category_group_id
|
159
|
+
)
|
161
160
|
|
162
161
|
# Retrieve the category and set the notifications based on if the ID has
|
163
162
|
# been specified or not.
|
164
163
|
if post['id'] and !post['id'].empty?
|
165
|
-
@category = Category[post['id']
|
164
|
+
@category = Category[post['id']]
|
166
165
|
save_action = :save
|
167
166
|
else
|
168
167
|
@category = Category.new
|
169
168
|
save_action = :new
|
170
169
|
end
|
171
|
-
|
170
|
+
|
171
|
+
# Remove various keys
|
172
|
+
post.delete('slug') if post['slug'].empty?
|
173
|
+
post.delete('id')
|
174
|
+
|
175
|
+
# Set the messages to display
|
172
176
|
flash_success = lang("categories.success.#{save_action}")
|
173
177
|
flash_error = lang("categories.errors.#{save_action}")
|
174
|
-
|
178
|
+
|
175
179
|
# Try to update the category
|
176
180
|
begin
|
177
181
|
@category.update(post)
|
178
|
-
|
182
|
+
message(:success, flash_success)
|
179
183
|
rescue
|
180
|
-
|
181
|
-
|
184
|
+
message(:error, flash_error)
|
185
|
+
|
182
186
|
flash[:form_errors] = @category.errors
|
183
187
|
flash[:form_data] = @category
|
184
188
|
end
|
185
|
-
|
189
|
+
|
186
190
|
if @category.id
|
187
|
-
redirect(Categories.r(:edit, category_group_id, @category.id))
|
188
|
-
else
|
189
|
-
redirect(Categories.r(:new, category_group_id))
|
191
|
+
redirect(Categories.r(:edit, post['category_group_id'], @category.id))
|
192
|
+
else
|
193
|
+
redirect(Categories.r(:new, post['category_group_id']))
|
190
194
|
end
|
191
195
|
end
|
192
|
-
|
196
|
+
|
193
197
|
##
|
194
198
|
# Delete all specified category groups and their categories. In
|
195
199
|
# order to delete a number of groups an array of fields, named "category_group_ids"
|
@@ -207,43 +211,27 @@ module Categories
|
|
207
211
|
if !user_authorized?([:delete])
|
208
212
|
respond(lang('zen_general.errors.not_authorized'), 403)
|
209
213
|
end
|
210
|
-
|
211
|
-
post
|
212
|
-
|
213
|
-
|
214
|
+
|
215
|
+
post = request.subset(:category_ids, :category_group_id)
|
216
|
+
|
214
217
|
# Obviously we'll require some IDs
|
215
218
|
if !request.params['category_ids'] or request.params['category_ids'].empty?
|
216
|
-
|
217
|
-
|
218
|
-
lang('categories.titles.index'),
|
219
|
-
lang('categorieserrors.no_delete')
|
220
|
-
)
|
221
|
-
|
222
|
-
redirect(Categories.r(:index, category_group_id))
|
219
|
+
message(:error, lang('categories.errors.no_delete'))
|
220
|
+
redirect(Categories.r(:index, post['category_group_id']))
|
223
221
|
end
|
224
|
-
|
222
|
+
|
225
223
|
# Delete each section
|
226
224
|
request.params['category_ids'].each do |id|
|
227
225
|
begin
|
228
|
-
Category[id
|
229
|
-
|
230
|
-
:success,
|
231
|
-
lang('categories.titles.index'),
|
232
|
-
lang('categories.success.delete')
|
233
|
-
)
|
234
|
-
|
226
|
+
Category[id].destroy
|
227
|
+
message(:success, lang('categories.success.delete'))
|
235
228
|
rescue
|
236
|
-
|
237
|
-
:error,
|
238
|
-
lang('categories.titles.index'),
|
239
|
-
lang('categories.errors.delete') % id
|
240
|
-
)
|
241
|
-
|
229
|
+
message(:error, lang('categories.errors.delete') % id)
|
242
230
|
end
|
243
231
|
end
|
244
|
-
|
245
|
-
redirect(Categories.r(:index, category_group_id))
|
232
|
+
|
233
|
+
redirect(Categories.r(:index, post['category_group_id']))
|
246
234
|
end
|
247
|
-
end
|
248
|
-
end
|
249
|
-
end
|
235
|
+
end # Categories
|
236
|
+
end # Controller
|
237
|
+
end # Categories
|