zen 0.2.5 → 0.2.6
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.
- 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
data/lib/zen/asset.rb
CHANGED
|
@@ -37,7 +37,7 @@ module Zen
|
|
|
37
37
|
#
|
|
38
38
|
# ## Building Assets
|
|
39
39
|
#
|
|
40
|
-
# Building assets shouldn't be required as Zen already does this but if you happen to
|
|
40
|
+
# Building assets shouldn't be required as Zen already does this but if you happen to
|
|
41
41
|
# need it you can build the files as following:
|
|
42
42
|
#
|
|
43
43
|
# Zen::Asset.build(:stylesheet)
|
|
@@ -45,8 +45,8 @@ module Zen
|
|
|
45
45
|
#
|
|
46
46
|
# ## Controller Usage
|
|
47
47
|
#
|
|
48
|
-
# While this module can be called by any other piece of code the class
|
|
49
|
-
# Zen::Controller::AdminController provides shortcuts to Zen::Asset.javascript and
|
|
48
|
+
# While this module can be called by any other piece of code the class
|
|
49
|
+
# Zen::Controller::AdminController provides shortcuts to Zen::Asset.javascript and
|
|
50
50
|
# Zen::Asset.stylesheet. These shortcuts work identical but are defined as class methods
|
|
51
51
|
# and thus can be used inside your class declaration:
|
|
52
52
|
#
|
|
@@ -137,7 +137,7 @@ module Zen
|
|
|
137
137
|
# @option options [TrueClass] :global When set to true all the specified stylesheets
|
|
138
138
|
# will be loaded globally rather than just for the current action.
|
|
139
139
|
# @option options [String/Symbol] controller The name of the controller for which
|
|
140
|
-
# the specified files should be loaded.
|
|
140
|
+
# the specified files should be loaded.
|
|
141
141
|
#
|
|
142
142
|
def self.stylesheet(files, options = {})
|
|
143
143
|
options = {
|
|
@@ -163,7 +163,7 @@ module Zen
|
|
|
163
163
|
# @since 0.2.5
|
|
164
164
|
# @param [Symbol] type The type of assets to build.
|
|
165
165
|
# @return [String] The HTML tags for all the assets.
|
|
166
|
-
#
|
|
166
|
+
#
|
|
167
167
|
def self.build(type)
|
|
168
168
|
type = type.to_sym
|
|
169
169
|
attrs = {}
|
|
@@ -253,6 +253,5 @@ module Zen
|
|
|
253
253
|
end
|
|
254
254
|
end
|
|
255
255
|
end
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
end
|
|
256
|
+
end # Asset
|
|
257
|
+
end # Zen
|
data/lib/zen/bin/app.rb
CHANGED
|
@@ -7,7 +7,6 @@ require 'fileutils'
|
|
|
7
7
|
# @since 0.2.5
|
|
8
8
|
#
|
|
9
9
|
command :app do |cmd|
|
|
10
|
-
|
|
11
10
|
# Set a few details of the command
|
|
12
11
|
cmd.syntax = '$ zen app [NAME]'
|
|
13
12
|
cmd.description = 'Creates a new application powered by Zen.'
|
|
@@ -38,5 +37,4 @@ command :app do |cmd|
|
|
|
38
37
|
abort "Failed to generate the application: #{e.message}"
|
|
39
38
|
end
|
|
40
39
|
end
|
|
41
|
-
|
|
42
40
|
end
|
|
@@ -21,7 +21,7 @@ module Zen
|
|
|
21
21
|
class AdminController < Zen::Controller::BaseController
|
|
22
22
|
layout :admin
|
|
23
23
|
engine :etanni
|
|
24
|
-
helper :blue_form, :common, :breadcrumb, :user, :acl
|
|
24
|
+
helper :blue_form, :common, :breadcrumb, :user, :acl, :message
|
|
25
25
|
|
|
26
26
|
##
|
|
27
27
|
# The initialize method is called upon class initalization and is used to process several
|
|
@@ -77,21 +77,16 @@ module Zen
|
|
|
77
77
|
# Load all stylesheets globally
|
|
78
78
|
stylesheet(
|
|
79
79
|
[
|
|
80
|
-
'reset', 'grid', 'layout', 'general', 'forms', 'tables',
|
|
81
|
-
'
|
|
80
|
+
'zen/reset', 'zen/grid', 'zen/layout', 'zen/general', 'zen/forms', 'zen/tables',
|
|
81
|
+
'zen/buttons', 'zen/messages'
|
|
82
82
|
],
|
|
83
83
|
:global => true
|
|
84
84
|
)
|
|
85
85
|
|
|
86
86
|
# Load all global javascript files
|
|
87
87
|
javascript(
|
|
88
|
-
[
|
|
89
|
-
'mootools/core', 'mootools/more', 'vendor/yepnope', 'zen/notification',
|
|
90
|
-
'zen/init',
|
|
91
|
-
],
|
|
92
|
-
:global => true
|
|
88
|
+
['mootools/core', 'mootools/more', 'zen/core', 'zen/init'], :global => true
|
|
93
89
|
)
|
|
94
|
-
|
|
95
90
|
end
|
|
96
91
|
end
|
|
97
92
|
end
|
|
@@ -14,31 +14,6 @@ module Zen
|
|
|
14
14
|
include ::Zen::Language
|
|
15
15
|
|
|
16
16
|
helper :csrf, :cgi
|
|
17
|
-
|
|
18
|
-
##
|
|
19
|
-
# The initialize method is called upon class initalization and is used to
|
|
20
|
-
# process several items before loading the controller(s) for the current module.
|
|
21
|
-
#
|
|
22
|
-
# @author Yorick Peterse
|
|
23
|
-
# @since 1.0
|
|
24
|
-
#
|
|
25
|
-
def initialize
|
|
26
|
-
super
|
|
27
|
-
|
|
28
|
-
# Store the settings data if this is the first time we're loading the controller
|
|
29
|
-
if ::Zen::Settings.empty?
|
|
30
|
-
::Settings::Model::Setting.get_settings.each do |k, v|
|
|
31
|
-
::Zen::Settings[k] = v
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# Override the language
|
|
36
|
-
if ::Zen::Settings[:language] != ::Zen::Language.options.language
|
|
37
|
-
# Reload the language pack
|
|
38
|
-
::Zen::Language.options.language = ::Zen::Settings[:language]
|
|
39
|
-
::Zen::Language.load('zen_general')
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
17
|
end
|
|
43
18
|
end
|
|
44
19
|
end
|
|
@@ -31,7 +31,7 @@ module Zen
|
|
|
31
31
|
uri.each { |v| @request_uri.push(h(v)) }
|
|
32
32
|
|
|
33
33
|
if !@request_uri[0] or @request_uri[0].empty?
|
|
34
|
-
@request_uri[0] = ::Zen
|
|
34
|
+
@request_uri[0] = ::Zen.settings[:default_section]
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
if !@request_uri[1] or @request_uri[1].empty?
|
|
@@ -39,11 +39,11 @@ module Zen
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
# A theme is always required
|
|
42
|
-
if ::Zen
|
|
42
|
+
if ::Zen.settings[:theme].nil? or ::Zen.settings[:theme].empty?
|
|
43
43
|
respond(lang('zen_general.errors.no_theme'))
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
theme = ::Zen::Theme[::Zen
|
|
46
|
+
theme = ::Zen::Theme[::Zen.settings[:theme]]
|
|
47
47
|
group = @request_uri[0]
|
|
48
48
|
template = @request_uri[1]
|
|
49
49
|
|
|
@@ -53,7 +53,7 @@ module Zen
|
|
|
53
53
|
template_path = File.join(theme_path, group, "#{template}.xhtml")
|
|
54
54
|
|
|
55
55
|
# Is the website down?
|
|
56
|
-
if ::Zen
|
|
56
|
+
if ::Zen.settings[:website_enabled] == '0'
|
|
57
57
|
offline_path = File.join(theme_path, 'offline.xhtml')
|
|
58
58
|
|
|
59
59
|
if File.exist?(offline_path)
|
|
@@ -69,7 +69,7 @@ module Zen
|
|
|
69
69
|
not_found = File.join(theme_path, '404.xhtml')
|
|
70
70
|
|
|
71
71
|
if File.exist?(not_found)
|
|
72
|
-
render_file(not_found)
|
|
72
|
+
respond(render_file(not_found), 404)
|
|
73
73
|
else
|
|
74
74
|
respond(lang('zen_general.errors.no_templates'), 404)
|
|
75
75
|
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#:nodoc
|
|
2
|
+
module Zen
|
|
3
|
+
#:nodoc
|
|
4
|
+
module Controller
|
|
5
|
+
##
|
|
6
|
+
# Controller that can be used to render a block of markup based on the POST data. This
|
|
7
|
+
# controller is useful for generating previews when using the text editor for example.
|
|
8
|
+
#
|
|
9
|
+
# In order to render a preview you'll have to send a POST request with the following
|
|
10
|
+
# data in it:
|
|
11
|
+
#
|
|
12
|
+
# * engine: The markup engine to use (Markdown, Textile, etc).
|
|
13
|
+
# * markup: The markup to convert to HTML.
|
|
14
|
+
#
|
|
15
|
+
# An example of such a request would look like the following:
|
|
16
|
+
#
|
|
17
|
+
# POST /admin/preview
|
|
18
|
+
# engine: "markdown"
|
|
19
|
+
# markup: "Hello **world**!"
|
|
20
|
+
#
|
|
21
|
+
# The return data is an HTTP status code and the HTML as the body. The HTTP status
|
|
22
|
+
# code will be 200 whenever the data was converted and or 400 in case of an error
|
|
23
|
+
# (e.g. an incorrect markup engine was specified).
|
|
24
|
+
#
|
|
25
|
+
# @author Yorick Peterse
|
|
26
|
+
# @since 0.2.6
|
|
27
|
+
#
|
|
28
|
+
class Preview < Zen::Controller::AdminController
|
|
29
|
+
map '/admin/preview'
|
|
30
|
+
|
|
31
|
+
##
|
|
32
|
+
# Converts the markup set in the POST data and returns the HTML.
|
|
33
|
+
#
|
|
34
|
+
# @author Yorick Peterse
|
|
35
|
+
# @since 0.2.6
|
|
36
|
+
#
|
|
37
|
+
def index
|
|
38
|
+
if !request.params['engine'] or !request.params['markup']
|
|
39
|
+
respond(lang('zen_general.errors.invalid_request'), 400)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
begin
|
|
43
|
+
respond(plugin(:markup, request.params['engine'], request.params['markup']), 200)
|
|
44
|
+
rescue
|
|
45
|
+
respond(lang('zen_general.errors.invalid_request'), 400)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
data/lib/zen/helper/common.rb
CHANGED
|
@@ -9,42 +9,11 @@ module Ramaze
|
|
|
9
9
|
# @author Yorick Peterse
|
|
10
10
|
# @since 0.1
|
|
11
11
|
#
|
|
12
|
-
module Common
|
|
12
|
+
module Common
|
|
13
13
|
##
|
|
14
|
-
# Generate
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
# @author Yorick Peterse
|
|
19
|
-
# @param [Symbol] type The type of notification to generate (error, notice, etc).
|
|
20
|
-
# @param [String] title The title of the notification.
|
|
21
|
-
# @param [String] message The message to display in the notification.
|
|
22
|
-
# @param [String] image An optional path to a custom image to use. If no image
|
|
23
|
-
# is specified the type of notification will be used for the image. For example,
|
|
24
|
-
# an error message would result in an image named "error.png" (.png is used for
|
|
25
|
-
# all default icons).
|
|
26
|
-
# @param [Boolean] sticky Boolean that indicates that the notification shouldn't
|
|
27
|
-
# be automatically removed after a certain period of time.
|
|
28
|
-
# @since 0.1
|
|
29
|
-
#
|
|
30
|
-
def notification(type, title, message, image = nil, sticky = false)
|
|
31
|
-
if image.nil?
|
|
32
|
-
image = "/admin/images/icons/large/#{type.to_s}.png"
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
sticky = true if type === :error
|
|
36
|
-
|
|
37
|
-
flash[:notification] = {
|
|
38
|
-
:title => title,
|
|
39
|
-
:content => message,
|
|
40
|
-
:image => image,
|
|
41
|
-
:sticky => sticky
|
|
42
|
-
}
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
##
|
|
46
|
-
# Generate an anchor tag inspired by the way Rails does this.
|
|
47
|
-
# The first parameter is the text to display, the second parameter is the URL.
|
|
14
|
+
# Generate an anchor tag similar as to how Ramaze does it with the
|
|
15
|
+
# Ramaze::Controller.a() method. The first parameter is the text to display,
|
|
16
|
+
# the second parameter is the URL.
|
|
48
17
|
#
|
|
49
18
|
# The anchor_to tag supports both query string parameters just like the link helper
|
|
50
19
|
# that ships with Ramaze but it also supports the possibility of adding HTML
|
|
@@ -78,7 +47,6 @@ module Ramaze
|
|
|
78
47
|
# @return [String]
|
|
79
48
|
#
|
|
80
49
|
def anchor_to(text, url, *attributes)
|
|
81
|
-
|
|
82
50
|
# Sanitize the text and URL
|
|
83
51
|
text = Rack::Utils.escape_html(text)
|
|
84
52
|
url = url.to_s
|
|
@@ -133,38 +101,6 @@ module Ramaze
|
|
|
133
101
|
# Return the tag
|
|
134
102
|
return "<a #{html_attributes}>#{text}</a>"
|
|
135
103
|
end
|
|
136
|
-
|
|
137
|
-
##
|
|
138
|
-
# The cycle method cycles through a specified list of words. This helper can be
|
|
139
|
-
# used to generate "zebra" tables, meaning that every odd row has a different color.
|
|
140
|
-
#
|
|
141
|
-
# The amount of words you want to cycle through is completely customizable,
|
|
142
|
-
# however you should atleast have two words otherwise this method will be
|
|
143
|
-
# completely useless.
|
|
144
|
-
#
|
|
145
|
-
# @author Yorick Peterse
|
|
146
|
-
# @since 0.1
|
|
147
|
-
# @param [Array] args All words to cycle through.
|
|
148
|
-
# @return [String]
|
|
149
|
-
#
|
|
150
|
-
def cycle(*args)
|
|
151
|
-
@@cycle_counter ||= 0
|
|
152
|
-
|
|
153
|
-
# Check the current counter and reset it if it matches the total amount of arguments
|
|
154
|
-
if @@cycle_counter >= args.count
|
|
155
|
-
# Reset the counter
|
|
156
|
-
@@cycle_counter = 0
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
# Get the element based on the current index
|
|
160
|
-
cycle_element = args[@@cycle_counter]
|
|
161
|
-
|
|
162
|
-
# Increment the counter
|
|
163
|
-
@@cycle_counter += 1
|
|
164
|
-
|
|
165
|
-
# Return the cycle element
|
|
166
|
-
return cycle_element
|
|
167
|
-
end
|
|
168
104
|
end
|
|
169
105
|
end
|
|
170
106
|
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
require 'ramaze/gestalt'
|
|
2
|
+
|
|
3
|
+
#:nodoc:
|
|
4
|
+
module Ramaze
|
|
5
|
+
#:nodoc:
|
|
6
|
+
module Helper
|
|
7
|
+
##
|
|
8
|
+
# The Mesage helper is a Ruby implementation of the Codeigniter library "Message"
|
|
9
|
+
# (located here: https://github.com/isset/codeigniter-message). This helper was taken
|
|
10
|
+
# from another project of mine which can be found here:
|
|
11
|
+
# https://github.com/yorickpeterse/stumpert/
|
|
12
|
+
#
|
|
13
|
+
# ## Usage
|
|
14
|
+
#
|
|
15
|
+
# Basic usage is as following:
|
|
16
|
+
#
|
|
17
|
+
# message(:error, "Bummer, something went wrong!")
|
|
18
|
+
#
|
|
19
|
+
# In your layout you'd do the following:
|
|
20
|
+
#
|
|
21
|
+
# display_messages
|
|
22
|
+
#
|
|
23
|
+
# This will create and return the HTML for all the messages.
|
|
24
|
+
#
|
|
25
|
+
# @author Yorick Peterse
|
|
26
|
+
# @since 26-05-2011
|
|
27
|
+
#
|
|
28
|
+
module Message
|
|
29
|
+
##
|
|
30
|
+
# Adds a new message to the list for the given type.
|
|
31
|
+
#
|
|
32
|
+
# @author Yorick Peterse
|
|
33
|
+
# @since 26-05-2011
|
|
34
|
+
# @param [Symbol/String] type The type of message to store (e.g. "error").
|
|
35
|
+
# @param [String] message The message to display.
|
|
36
|
+
#
|
|
37
|
+
def message(type, message)
|
|
38
|
+
if type.respond_to?(:to_sym)
|
|
39
|
+
type = type.to_sym
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
flash[:messages] ||= {}
|
|
43
|
+
flash[:messages][type] ||= []
|
|
44
|
+
flash[:messages][type].push(message)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
##
|
|
48
|
+
# Renders all the messages for the specified types.
|
|
49
|
+
#
|
|
50
|
+
# @author Yorick Peterse
|
|
51
|
+
# @since 26-05-2011
|
|
52
|
+
# @param [Array] types Array containing all the messages to render.
|
|
53
|
+
#
|
|
54
|
+
def display_messages(types = [:info, :error, :success])
|
|
55
|
+
gestalt = ::Ramaze::Gestalt.new
|
|
56
|
+
|
|
57
|
+
return if flash[:messages].nil?
|
|
58
|
+
|
|
59
|
+
gestalt.div(:id => 'message_container', :class => 'container') do
|
|
60
|
+
# Render each individual group
|
|
61
|
+
types.each do |type|
|
|
62
|
+
if type.respond_to?(:to_sym)
|
|
63
|
+
type = type.to_sym
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
if flash[:messages].key?(type)
|
|
67
|
+
gestalt.div(:class => "message #{type}") do
|
|
68
|
+
# Render all the messages
|
|
69
|
+
flash[:messages][type].each_with_index do |message, index|
|
|
70
|
+
flash[:messages][type].delete_at(index)
|
|
71
|
+
gestalt.p { message }
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
return gestalt.to_s
|
|
79
|
+
end
|
|
80
|
+
end # Message
|
|
81
|
+
end # Helper
|
|
82
|
+
end # Ramaze
|
data/lib/zen/helper/theme.rb
CHANGED
|
@@ -29,7 +29,7 @@ module Ramaze
|
|
|
29
29
|
# the partial.
|
|
30
30
|
#
|
|
31
31
|
def partial(file, variables = {})
|
|
32
|
-
theme = ::Zen::Theme[::Zen
|
|
32
|
+
theme = ::Zen::Theme[::Zen.settings[:theme]]
|
|
33
33
|
|
|
34
34
|
if !theme.respond_to?(:partial_dir) or theme.partial_dir.nil?
|
|
35
35
|
raise(::Zen::ThemeError, "The theme #{theme.name} has no partial directory set.")
|
|
@@ -59,7 +59,7 @@ module Ramaze
|
|
|
59
59
|
# @param [Hash] variables Hash with variables to pass to the 404 template.
|
|
60
60
|
#
|
|
61
61
|
def show_404(variables = {})
|
|
62
|
-
theme = ::Zen::Theme[::Zen
|
|
62
|
+
theme = ::Zen::Theme[::Zen.settings[:theme]]
|
|
63
63
|
template = "#{theme.template_dir}/404.xhtml"
|
|
64
64
|
|
|
65
65
|
# Render the template and replace the current buffer with it's output
|
data/lib/zen/language.rb
CHANGED
|
@@ -59,11 +59,15 @@ module Zen
|
|
|
59
59
|
# itself.
|
|
60
60
|
#
|
|
61
61
|
# @author Yorick Peterse
|
|
62
|
-
# @since 0.2
|
|
62
|
+
# @since 0.2
|
|
63
63
|
#
|
|
64
64
|
module Language
|
|
65
65
|
include Ramaze::Optioned
|
|
66
66
|
|
|
67
|
+
class << self
|
|
68
|
+
include Innate::Trinity
|
|
69
|
+
end
|
|
70
|
+
|
|
67
71
|
##
|
|
68
72
|
# Hash containing all loaded translation files.
|
|
69
73
|
#
|
|
@@ -72,49 +76,67 @@ module Zen
|
|
|
72
76
|
#
|
|
73
77
|
Registered = {}
|
|
74
78
|
|
|
79
|
+
##
|
|
80
|
+
# Hash containing all the available languages.
|
|
81
|
+
#
|
|
82
|
+
# @author Yorick Peterse
|
|
83
|
+
# @since 0.2.6
|
|
84
|
+
#
|
|
85
|
+
Languages = {
|
|
86
|
+
'en' => 'English',
|
|
87
|
+
'nl' => 'Nederlands'
|
|
88
|
+
}
|
|
89
|
+
|
|
75
90
|
options.dsl do
|
|
76
91
|
o 'Small string that defines the current language (e.g. "en").', :language, 'en'
|
|
77
|
-
o 'Array of paths to look for the language files' , :paths , []
|
|
92
|
+
o 'Array of paths to look for the language files' , :paths , []
|
|
78
93
|
end
|
|
79
|
-
|
|
94
|
+
|
|
80
95
|
##
|
|
81
96
|
# Tries to load a language file for the given name. If no language files were found
|
|
82
|
-
# based on the name and the current language an exception will be raised.
|
|
97
|
+
# based on the name and the current language an exception will be raised.
|
|
98
|
+
#
|
|
99
|
+
# Note that this method will load the language pack for *all* languages.
|
|
83
100
|
#
|
|
84
101
|
# @example
|
|
85
102
|
# Zen::Language.load('user')
|
|
86
103
|
#
|
|
87
104
|
# @author Yorick Peterse
|
|
88
105
|
# @since 0.1
|
|
89
|
-
# @param [String] lang_name The name of the language file to load.
|
|
90
|
-
#
|
|
106
|
+
# @param [String] lang_name The name of the language file to load.
|
|
107
|
+
#
|
|
91
108
|
def self.load(lang_name)
|
|
92
|
-
|
|
109
|
+
file_found = false
|
|
93
110
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
end
|
|
111
|
+
Languages.each do |language, label|
|
|
112
|
+
Registered[language] ||= {}
|
|
97
113
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
# Abort of the file has already been loaded
|
|
115
|
+
if Registered[language][lang_name]
|
|
116
|
+
file_found = true
|
|
117
|
+
next
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
self.options.paths.each do |path|
|
|
121
|
+
path += "/language/#{language}/#{lang_name}.yml"
|
|
122
|
+
|
|
123
|
+
# Load the file and save it
|
|
124
|
+
if File.exist?(path)
|
|
125
|
+
file_found = true
|
|
126
|
+
translation = YAML.load_file(path)
|
|
127
|
+
|
|
128
|
+
# Conver the hash to a dot based hash. This means that {:person => {:age => 18}}
|
|
129
|
+
# would result in {'person.age' => 18}.
|
|
130
|
+
translation = self.to_dotted_hash({lang_name.to_s => translation})
|
|
131
|
+
|
|
132
|
+
Registered[language].merge!(translation)
|
|
133
|
+
end
|
|
134
|
+
end
|
|
115
135
|
end
|
|
116
136
|
|
|
117
|
-
|
|
137
|
+
if file_found === false
|
|
138
|
+
raise(Zen::LanguageError, "No language file could be found for \"#{lang_name}\"")
|
|
139
|
+
end
|
|
118
140
|
end
|
|
119
141
|
|
|
120
142
|
private
|
|
@@ -165,7 +187,7 @@ module Zen
|
|
|
165
187
|
end
|
|
166
188
|
when Array
|
|
167
189
|
source.each_with_index do |v, i|
|
|
168
|
-
self.to_dotted_hash(v, target, "#{prefix}#{i}")
|
|
190
|
+
self.to_dotted_hash(v, target, "#{prefix}#{i}")
|
|
169
191
|
end
|
|
170
192
|
else
|
|
171
193
|
if !namespace.nil?
|
|
@@ -202,16 +224,25 @@ module Zen
|
|
|
202
224
|
# @author Yorick Peterse
|
|
203
225
|
# @since 0.2
|
|
204
226
|
# @param [String] key The language key to select.
|
|
227
|
+
# @param [String] lang The language for which to retrieve the key, overwrites the
|
|
228
|
+
# language set in the session.
|
|
205
229
|
# @return [Mixed]
|
|
206
230
|
#
|
|
207
|
-
def lang(key)
|
|
208
|
-
lang
|
|
209
|
-
|
|
210
|
-
|
|
231
|
+
def lang(key, lang = nil)
|
|
232
|
+
if lang.nil?
|
|
233
|
+
begin
|
|
234
|
+
lang = action.node.session[:user].language
|
|
235
|
+
rescue
|
|
236
|
+
lang = ::Zen::Language.options.language
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
groups = []
|
|
241
|
+
translations = ::Zen::Language::Registered
|
|
211
242
|
|
|
212
243
|
if !translations or !translations.key?(lang)
|
|
213
244
|
raise(
|
|
214
|
-
Zen::LanguageError,
|
|
245
|
+
Zen::LanguageError,
|
|
215
246
|
"No translation files have been added for the language code \"#{lang}\""
|
|
216
247
|
)
|
|
217
248
|
end
|
|
@@ -219,13 +250,12 @@ module Zen
|
|
|
219
250
|
if translations[lang][key]
|
|
220
251
|
return translations[lang][key]
|
|
221
252
|
end
|
|
222
|
-
|
|
253
|
+
|
|
223
254
|
raise(
|
|
224
255
|
Zen::LanguageError,
|
|
225
256
|
"The specified language item \"#{key}\" does not exist"
|
|
226
257
|
)
|
|
227
258
|
end
|
|
228
259
|
end
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
end
|
|
260
|
+
end # Language
|
|
261
|
+
end # Zen
|