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/task/build.rake
CHANGED
|
@@ -10,9 +10,7 @@ namespace :build do
|
|
|
10
10
|
task :doc do
|
|
11
11
|
zen_path = File.expand_path('../../../../', __FILE__)
|
|
12
12
|
command = "yard doc #{zen_path}/lib -m markdown -M rdiscount -o #{zen_path}/doc "
|
|
13
|
-
command += "-r #{zen_path}/README.md --private --protected
|
|
14
|
-
command += "--files #{zen_path}/license.txt,#{zen_path}/CHANGELOG.md,"
|
|
15
|
-
command += "#{zen_path}/ROADMAP.md"
|
|
13
|
+
command += "-r #{zen_path}/README.md --private --protected"
|
|
16
14
|
|
|
17
15
|
sh(command)
|
|
18
16
|
end
|
|
@@ -30,8 +28,8 @@ namespace :build do
|
|
|
30
28
|
desc 'Builds the MANIFEST file'
|
|
31
29
|
task :manifest do
|
|
32
30
|
zen_path = File.expand_path('../../../../', __FILE__)
|
|
33
|
-
ignore_exts = ['.gem', '.gemspec']
|
|
34
|
-
ignore_files = ['.DS_Store', '.gitignore']
|
|
31
|
+
ignore_exts = ['.gem', '.gemspec', '.swp']
|
|
32
|
+
ignore_files = ['.DS_Store', '.gitignore', '.rvmrc']
|
|
35
33
|
ignore_dirs = ['.git', '.yardoc', 'spec', 'pkg', 'doc']
|
|
36
34
|
files = ''
|
|
37
35
|
|
|
@@ -40,7 +38,8 @@ namespace :build do
|
|
|
40
38
|
f.gsub!(/^\//, '')
|
|
41
39
|
|
|
42
40
|
# Ignore directories
|
|
43
|
-
if !File.directory?(f) and !ignore_exts.include?(File.extname(f))
|
|
41
|
+
if !File.directory?(f) and !ignore_exts.include?(File.extname(f)) \
|
|
42
|
+
and !ignore_files.include?(File.basename(f))
|
|
44
43
|
files += "#{f}\n"
|
|
45
44
|
else
|
|
46
45
|
Find.prune if ignore_dirs.include?(f)
|
|
@@ -57,4 +56,22 @@ namespace :build do
|
|
|
57
56
|
end
|
|
58
57
|
end
|
|
59
58
|
|
|
59
|
+
# Shamelessly stolen from Ramaze
|
|
60
|
+
desc 'Builds a list of all the people that have contributed to Zen'
|
|
61
|
+
task :authors do
|
|
62
|
+
authors = Hash.new(0)
|
|
63
|
+
|
|
64
|
+
`git shortlog -nse`.scan(/(\d+)\s(.+)\s<(.*)>$/) do |count, name, email|
|
|
65
|
+
authors[[name, email]] += count.to_i
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
File.open('AUTHORS', 'w+') do |io|
|
|
69
|
+
io.puts "Following persons have contributed to Zen."
|
|
70
|
+
io.puts '(Sorted by number of submitted patches, then alphabetically)'
|
|
71
|
+
io.puts ''
|
|
72
|
+
authors.sort_by{|(n,e),c| [-c, n.downcase] }.each do |(name, email), count|
|
|
73
|
+
io.puts("%6d %s <%s>" % [count, name, email])
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
60
77
|
end
|
data/lib/zen/task/clean.rake
CHANGED
|
@@ -7,13 +7,13 @@ require 'fileutils'
|
|
|
7
7
|
# @since 0.2.5
|
|
8
8
|
#
|
|
9
9
|
namespace :clean do
|
|
10
|
+
desc 'Removes all the gems located in pkg/'
|
|
11
|
+
task :gem do
|
|
12
|
+
glob_pattern = File.expand_path('../../../../pkg/*.gem', __FILE__)
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
log_files = Dir.glob("#{zen_path}/spec/log/**/*.log")
|
|
16
|
-
log_files.each { |file| File.unlink(file) }
|
|
14
|
+
Dir.glob(glob_pattern).each do |gem|
|
|
15
|
+
File.unlink(gem)
|
|
16
|
+
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
desc 'Removes all YARD files'
|
|
@@ -23,5 +23,4 @@ namespace :clean do
|
|
|
23
23
|
FileUtils.rm_rf("#{zen_path}/doc")
|
|
24
24
|
FileUtils.rm_rf("#{zen_path}/.yardoc")
|
|
25
25
|
end
|
|
26
|
-
|
|
27
26
|
end
|
data/lib/zen/task/db.rake
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
Sequel.extension(:migration)
|
|
2
|
-
|
|
3
1
|
##
|
|
4
2
|
# Task group for database related tasks such as migrating and removing the database.
|
|
5
3
|
#
|
|
@@ -30,9 +28,9 @@ namespace :db do
|
|
|
30
28
|
table = 'migrations_package_' + pkg.name.to_s
|
|
31
29
|
|
|
32
30
|
# Migration time
|
|
33
|
-
Zen
|
|
34
|
-
Sequel::Migrator.run(Zen
|
|
35
|
-
|
|
31
|
+
Zen.database.transaction do
|
|
32
|
+
Sequel::Migrator.run(Zen.database, dir, :table => table)
|
|
33
|
+
Ramaze::Log.info("Successfully migrated \"#{pkg.name}\"")
|
|
36
34
|
end
|
|
37
35
|
end
|
|
38
36
|
end
|
|
@@ -61,11 +59,11 @@ namespace :db do
|
|
|
61
59
|
table = 'migrations_package_' + pkg.name.to_s
|
|
62
60
|
|
|
63
61
|
# Migration time
|
|
64
|
-
Zen
|
|
65
|
-
Sequel::Migrator.run(Zen
|
|
66
|
-
Zen
|
|
62
|
+
Zen.database.transaction do
|
|
63
|
+
Sequel::Migrator.run(Zen.database, dir, :table => table, :target => 0)
|
|
64
|
+
Zen.database.drop_table(table)
|
|
67
65
|
|
|
68
|
-
|
|
66
|
+
Ramaze::Log.info("Successfully uninstalled \"#{pkg.name}\"")
|
|
69
67
|
end
|
|
70
68
|
end
|
|
71
69
|
end
|
data/lib/zen/task/package.rake
CHANGED
|
@@ -34,11 +34,11 @@ MSG
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
# Validate the package name
|
|
37
|
-
if !Zen::
|
|
37
|
+
if !Zen::Package::Registered[args[:name].to_sym]
|
|
38
38
|
abort "The package name \"#{args[:name]}\" is invalid."
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
package = Zen::
|
|
41
|
+
package = Zen::Package::Registered[args[:name].to_sym]
|
|
42
42
|
|
|
43
43
|
# Get the migrations directory
|
|
44
44
|
if package.respond_to?(:migration_dir) and !package.migration_dir.nil?
|
|
@@ -54,12 +54,12 @@ MSG
|
|
|
54
54
|
|
|
55
55
|
table = 'migrations_package_' + package.name.to_s
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
Ramaze::Log.info('Migrating package...')
|
|
58
58
|
|
|
59
59
|
# Run all migrations
|
|
60
|
-
Zen
|
|
61
|
-
Sequel.
|
|
62
|
-
Zen
|
|
60
|
+
Zen.database.transaction do
|
|
61
|
+
Sequel::Migrator.run(
|
|
62
|
+
Zen.database, dir, :table => table, :target => version
|
|
63
63
|
)
|
|
64
64
|
end
|
|
65
65
|
end
|
data/lib/zen/task/theme.rake
CHANGED
|
@@ -56,11 +56,11 @@ MSG
|
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
# Time to migrate the theme
|
|
59
|
-
|
|
59
|
+
Ramaze::Log.info('Migrating package...')
|
|
60
60
|
|
|
61
|
-
Zen
|
|
61
|
+
Zen.database.transaction do
|
|
62
62
|
Sequel::Migrator.run(
|
|
63
|
-
Zen
|
|
63
|
+
Zen.database, dir, :table => table, :target => version
|
|
64
64
|
)
|
|
65
65
|
end
|
|
66
66
|
end
|
data/lib/zen/theme.rb
CHANGED
|
@@ -64,7 +64,7 @@ module Zen
|
|
|
64
64
|
if !Ramaze.options.publics.include?(theme.public_dir)
|
|
65
65
|
# Generate a relative path from ROOT to the theme
|
|
66
66
|
to = Pathname.new(theme.public_dir)
|
|
67
|
-
from = Pathname.new(Zen.
|
|
67
|
+
from = Pathname.new(Zen.root)
|
|
68
68
|
dir = to.relative_path_from(from.realpath).to_s
|
|
69
69
|
|
|
70
70
|
Ramaze.options.publics.push(dir)
|
|
@@ -97,6 +97,5 @@ module Zen
|
|
|
97
97
|
|
|
98
98
|
return Registered[name]
|
|
99
99
|
end
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
end
|
|
100
|
+
end # Theme
|
|
101
|
+
end # Zen
|
data/lib/zen/validation.rb
CHANGED
|
@@ -8,9 +8,9 @@ module Zen
|
|
|
8
8
|
#
|
|
9
9
|
# ## Usage
|
|
10
10
|
#
|
|
11
|
-
# Using the module is pretty simple. Include it, specify the validation rules in a
|
|
11
|
+
# Using the module is pretty simple. Include it, specify the validation rules in a
|
|
12
12
|
# method and call it. All official modules and classes use a method called "validate"
|
|
13
|
-
# but you're free to name it whatever you want. A basic example looks like the
|
|
13
|
+
# but you're free to name it whatever you want. A basic example looks like the
|
|
14
14
|
# following:
|
|
15
15
|
#
|
|
16
16
|
# class Something
|
|
@@ -27,7 +27,6 @@ module Zen
|
|
|
27
27
|
# @since 0.2.5
|
|
28
28
|
#
|
|
29
29
|
module Validation
|
|
30
|
-
|
|
31
30
|
##
|
|
32
31
|
# Checks if the specified attributes exist and aren't set to nil.
|
|
33
32
|
#
|
|
@@ -74,7 +73,7 @@ module Zen
|
|
|
74
73
|
|
|
75
74
|
if !value.respond_to?(:length)
|
|
76
75
|
raise(
|
|
77
|
-
ValidationError,
|
|
76
|
+
ValidationError,
|
|
78
77
|
"The length of \"#{attribute}\" can't be checked as the method \"length\" " +
|
|
79
78
|
"doesn't exist."
|
|
80
79
|
)
|
|
@@ -107,7 +106,7 @@ module Zen
|
|
|
107
106
|
# containing all the attributes and their regular expressions.
|
|
108
107
|
# @param [Regexp] regexp The regular expression to use when validating a single
|
|
109
108
|
# attribute.
|
|
110
|
-
# @raise [ValidationError] Raised when one of the attributes doesn't matches the
|
|
109
|
+
# @raise [ValidationError] Raised when one of the attributes doesn't matches the
|
|
111
110
|
# regular expression.
|
|
112
111
|
#
|
|
113
112
|
def validates_format(attribute, regexp = nil)
|
|
@@ -139,11 +138,10 @@ module Zen
|
|
|
139
138
|
#
|
|
140
139
|
def validates_filepath(attribute)
|
|
141
140
|
path = send(attribute)
|
|
142
|
-
|
|
141
|
+
|
|
143
142
|
if !File.exist?(path)
|
|
144
143
|
raise(ValidationError, "The path #{path} in \"#{attribute}\" doesn't exist.")
|
|
145
144
|
end
|
|
146
145
|
end
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
end
|
|
146
|
+
end # Validation
|
|
147
|
+
end # Zen
|
data/lib/zen/version.rb
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
#:nodoc:
|
|
2
2
|
module Zen
|
|
3
3
|
##
|
|
4
|
-
# Defines the current version of Zen as a string. This constant
|
|
5
|
-
#
|
|
6
|
-
# package.
|
|
4
|
+
# Defines the current version of Zen as a string. This constant is used to set the Gem
|
|
5
|
+
# version when generating a new Rubygems package.
|
|
7
6
|
#
|
|
8
7
|
# @author Yorick Peterse
|
|
9
8
|
# @since 0.1
|
|
10
9
|
#
|
|
11
|
-
Version = '0.2.
|
|
10
|
+
Version = '0.2.6'
|
|
12
11
|
end
|
data/lib/zen/view/bottom.xhtml
CHANGED
data/lib/zen/view/main.xhtml
CHANGED
data/proto/app/app.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# Load the Zen gem
|
|
2
1
|
require 'zen'
|
|
3
2
|
|
|
4
3
|
# Load the configuration files
|
|
@@ -11,10 +10,13 @@ require __DIR__('config/middlewares')
|
|
|
11
10
|
require __DIR__('config/database')
|
|
12
11
|
|
|
13
12
|
# Make sure that Ramaze knows where you are
|
|
14
|
-
Ramaze.options.roots.push(Zen.
|
|
13
|
+
Ramaze.options.roots.push(Zen.root)
|
|
15
14
|
|
|
16
15
|
# Load the database
|
|
17
16
|
Zen.init
|
|
18
17
|
|
|
19
|
-
#
|
|
20
|
-
require
|
|
18
|
+
# Load all the packages
|
|
19
|
+
require 'zen/package/all'
|
|
20
|
+
|
|
21
|
+
# Almost done!
|
|
22
|
+
Zen.post_init
|
data/proto/app/config/config.rb
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
# Specify the root directory. This is required since there are multiple directories
|
|
2
2
|
# to load resources from. This directory will be used for the database logger, modes, etc.
|
|
3
|
-
Zen.
|
|
4
|
-
|
|
5
|
-
# UTF-8 bitches.
|
|
6
|
-
Zen.options.encoding = 'utf8'
|
|
7
|
-
|
|
8
|
-
# Sets the language to use in the event of the database settings not being set correctly.
|
|
9
|
-
Zen.options.language = 'en'
|
|
3
|
+
Zen.root = __DIR__('../')
|
|
10
4
|
|
|
11
5
|
# Set the application's mode. Available modes are "dev" and "live"
|
|
12
6
|
Ramaze.options.mode = :dev
|
|
@@ -1,54 +1,58 @@
|
|
|
1
1
|
##
|
|
2
2
|
# Database group to use for developing the website.
|
|
3
3
|
#
|
|
4
|
-
#
|
|
4
|
+
# IMPORTANT: it's recommended to create a separate database user for your Zen application
|
|
5
|
+
# and prevent it from being able to access other databases. Zen is new and may allow
|
|
6
|
+
# hackers to exploit the system.
|
|
5
7
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
# *
|
|
9
|
-
#
|
|
10
|
-
# *
|
|
8
|
+
# The following items can be set:
|
|
9
|
+
#
|
|
10
|
+
# * adapter: the adapter to use. When using MySQL it's best to use the mysql2 gem as it's
|
|
11
|
+
# a lot faster than the mysql gem.
|
|
12
|
+
# * host: the hostname where the database is located.
|
|
13
|
+
# * username: the username to use for connecting to the database.
|
|
14
|
+
# * password: the password to use for connecting to the database.
|
|
11
15
|
# * database: the name of the database to use.
|
|
16
|
+
# * test: whether or not the connection should be verified.
|
|
17
|
+
# * encoding: the encoding type to use.
|
|
18
|
+
# * logger: the logger used for logging queries and such.
|
|
12
19
|
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
# to exploit the system. Using an isolated user would prevent hackers from destroying
|
|
16
|
-
# all databases.
|
|
20
|
+
# Fore more information see the Sequel documentation:
|
|
21
|
+
# http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html
|
|
17
22
|
#
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
# Sets the connection for the development mode
|
|
24
|
+
if Ramaze.options.mode === :dev
|
|
25
|
+
Zen.database = Sequel.connect(
|
|
26
|
+
:adapter => '',
|
|
27
|
+
:host => 'localhost',
|
|
28
|
+
:username => '',
|
|
29
|
+
:password => '',
|
|
30
|
+
:database => '',
|
|
31
|
+
:test => true,
|
|
32
|
+
:encoding => 'utf8',
|
|
33
|
+
:logger => Ramaze::Logger::RotatingInformer.new(
|
|
34
|
+
__DIR__("../log/database/dev"), '%d-%m-%Y.log'
|
|
35
|
+
)
|
|
36
|
+
)
|
|
24
37
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
# Does the same but for the live mode
|
|
39
|
+
elsif Ramaze.options.mode === :live
|
|
40
|
+
Zen.database = Sequel.connect(
|
|
41
|
+
:adapter => 'mysql2',
|
|
42
|
+
:host => '',
|
|
43
|
+
:username => '',
|
|
44
|
+
:password => '',
|
|
45
|
+
:database => '',
|
|
46
|
+
:test => true,
|
|
47
|
+
:encoding => 'utf8',
|
|
48
|
+
:logger => Ramaze::Logger::RotatingInformer.new(
|
|
49
|
+
__DIR__("../log/database/live"), '%d-%m-%Y.log'
|
|
50
|
+
)
|
|
51
|
+
)
|
|
33
52
|
end
|
|
34
53
|
|
|
35
|
-
|
|
36
|
-
#
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
Zen::Database.mode :live do |db|
|
|
40
|
-
# Example: mysql2
|
|
41
|
-
db.adapter = ''
|
|
42
|
-
|
|
43
|
-
# Example: localhost
|
|
44
|
-
db.host = ''
|
|
45
|
-
|
|
46
|
-
# Example: zen-app
|
|
47
|
-
db.username = ''
|
|
48
|
-
|
|
49
|
-
# Example: 23x190jj38123x
|
|
50
|
-
db.password = ''
|
|
51
|
-
|
|
52
|
-
# Example: blog
|
|
53
|
-
db.database = ''
|
|
54
|
+
# IMPORTANT, when running MySQL the engine should be set to InnoDB in order for foreign
|
|
55
|
+
# keys to work properly.
|
|
56
|
+
if Zen.database.adapter_scheme.to_s.include?('mysql')
|
|
57
|
+
Sequel::MySQL.default_engine = 'InnoDB'
|
|
54
58
|
end
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
##
|
|
2
1
|
# All Rack middlewares should go in a block like the one below. Different combinations
|
|
3
2
|
# can be used for different versions by setting the first argument of the middleware!
|
|
4
3
|
# method to a symbol containing the name of the environment (e.g. :live).
|
|
@@ -7,82 +6,43 @@
|
|
|
7
6
|
# detect errors, reloading the code and so on.
|
|
8
7
|
#
|
|
9
8
|
Ramaze.middleware! :dev do |m|
|
|
10
|
-
##
|
|
11
9
|
# Rack::Lint is used to validate all code according to the Rack specification.
|
|
12
10
|
# It's not recommended to use this middleware in a production environment as it will
|
|
13
11
|
# slow your application down a bit.
|
|
14
|
-
#
|
|
15
12
|
m.use Rack::Lint
|
|
16
13
|
|
|
17
|
-
##
|
|
18
|
-
# Rack::CommonLogger is used to log requests in an Apache like format. Zen ships with
|
|
19
|
-
# a small extension of Ramaze::Log::RotatingInformer that automatically creates the
|
|
20
|
-
# required directories for each mode and group (database, server, etc) but any Rack
|
|
21
|
-
# compatible logger will do.
|
|
22
|
-
#
|
|
23
|
-
m.use Rack::CommonLogger, Zen::Logger.new("#{Zen.options.root}/log/server")
|
|
24
|
-
|
|
25
|
-
##
|
|
26
14
|
# Shows an error page whenever an exception was raised. It's not recommended to use
|
|
27
15
|
# this middleware on a production server as it may reveal sensitive details to the
|
|
28
16
|
# visitor.
|
|
29
|
-
#
|
|
30
17
|
m.use Rack::ShowExceptions
|
|
31
18
|
|
|
32
|
-
##
|
|
33
19
|
# Pretty much the same as Rack::ShowExceptions.
|
|
34
|
-
#
|
|
35
20
|
m.use Rack::ShowStatus
|
|
36
21
|
|
|
37
|
-
##
|
|
38
22
|
# Routes exceptions to different actions, can be useful for catching 404's and such.
|
|
39
|
-
#
|
|
40
23
|
# m.use Rack::RouteExceptions
|
|
41
24
|
|
|
42
|
-
##
|
|
43
25
|
# Middleware that enables conditional GET using If-None-Match and If-Modified-Since.
|
|
44
26
|
# Currently Zen doesn't respond to conditional GET requests so it's fairly useless
|
|
45
27
|
# out of the box, it can be useful for custom extensions and such.
|
|
46
|
-
#
|
|
47
28
|
# m.use Rack::ConditionalGet
|
|
48
29
|
|
|
49
|
-
##
|
|
50
30
|
# Automatically sets the ETag header on all string bodies. Etags can be useful for
|
|
51
31
|
# checking if a certain page has been modified or not.
|
|
52
32
|
#
|
|
53
33
|
# IMPORTANT: Prior to Rack 1.2.2 Rack::ETag required the second argument of use() to
|
|
54
34
|
# be set to 'public'. Newer versions no longer require this.
|
|
55
|
-
#
|
|
56
35
|
m.use Rack::ETag
|
|
57
36
|
|
|
58
|
-
##
|
|
59
37
|
# Allows HEAD requests. HEAD requests are identical to GET requests but shouldn't
|
|
60
38
|
# return the body.
|
|
61
|
-
#
|
|
62
39
|
m.use Rack::Head
|
|
63
40
|
|
|
64
|
-
##
|
|
65
41
|
# Automatically reloads your application whenever it detects changes. Note that this
|
|
66
42
|
# middleware isn't always as accurate so there may be times when you have to manually
|
|
67
43
|
# restart your server.
|
|
68
|
-
#
|
|
69
44
|
m.use Ramaze::Reloader
|
|
70
45
|
|
|
71
|
-
##
|
|
72
46
|
# Runs Ramaze based on all mappings and such.
|
|
73
|
-
#
|
|
74
|
-
m.run Ramaze::AppMap
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
##
|
|
78
|
-
# Middlewares to use for a production environment.
|
|
79
|
-
#
|
|
80
|
-
Ramaze.middleware! :live do |m|
|
|
81
|
-
m.use Rack::CommonLogger, Zen::Logger.new("#{Zen.options.root}/log/server")
|
|
82
|
-
m.use Rack::RouteExceptions
|
|
83
|
-
m.use Rack::ShowStatus
|
|
84
|
-
m.use Rack::ConditionalGet
|
|
85
|
-
m.use Rack::ETag
|
|
86
|
-
m.use Rack::Head
|
|
87
47
|
m.run Ramaze::AppMap
|
|
88
48
|
end
|