zen 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gems +17 -15
- data/.gitignore +1 -1
- data/.travis.yml +1 -1
- data/MANIFEST +470 -0
- data/README.md +5 -3
- data/Rakefile +8 -6
- data/bin/zen +2 -7
- data/guide/asset_management.md +1 -0
- data/guide/autosaving_forms.md +1 -0
- data/guide/changelog.md +22 -0
- data/guide/faq.md +1 -0
- data/guide/getting_started.md +1 -0
- data/guide/hacking.md +1 -0
- data/guide/images/sections/revisions.png +0 -0
- data/guide/images/sections/revisions_diff.png +0 -0
- data/guide/images/sections/revisions_diff_multiple.png +0 -0
- data/guide/installation.md +4 -3
- data/guide/javascript.md +1 -0
- data/guide/javascript/zen_autosave.md +1 -0
- data/guide/javascript/zen_editor.md +1 -0
- data/guide/javascript/zen_form.md +1 -0
- data/guide/javascript/zen_hash.md +1 -0
- data/guide/javascript/zen_htmltable.md +1 -0
- data/guide/javascript/zen_tabs.md +1 -0
- data/guide/javascript/zen_window.md +1 -0
- data/guide/zen_compared.md +1 -0
- data/lib/zen.rb +10 -12
- data/lib/zen/event.rb +2 -2
- data/lib/zen/helper/controller.rb +13 -13
- data/lib/zen/helper/message.rb +3 -3
- data/lib/zen/helper/search.rb +4 -4
- data/lib/zen/helper/stacked_aspect.rb +9 -9
- data/lib/zen/html_diff.rb +151 -0
- data/lib/zen/language.rb +9 -7
- data/lib/zen/language/translation.rb +8 -8
- data/lib/zen/markup.rb +1 -1
- data/lib/zen/migrator.rb +2 -2
- data/lib/zen/model/helper.rb +4 -4
- data/lib/zen/model/plugin/events.rb +16 -16
- data/lib/zen/package.rb +2 -2
- data/lib/zen/package/all.rb +1 -1
- data/lib/zen/package/categories/lib/categories/controller/categories.rb +4 -4
- data/lib/zen/package/categories/lib/categories/controller/category_groups.rb +4 -4
- data/lib/zen/package/categories/lib/categories/helper/category.rb +3 -3
- data/lib/zen/package/categories/lib/categories/model/category.rb +9 -9
- data/lib/zen/package/categories/lib/categories/model/category_group.rb +9 -9
- data/lib/zen/package/comments/lib/comments/controller/comments.rb +4 -4
- data/lib/zen/package/comments/lib/comments/controller/comments_form.rb +2 -2
- data/lib/zen/package/comments/lib/comments/helper/comment.rb +1 -1
- data/lib/zen/package/comments/lib/comments/model/comment.rb +13 -13
- data/lib/zen/package/custom_fields/lib/custom_fields/blue_form_parameters.rb +1 -1
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +4 -4
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_types.rb +6 -6
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_fields.rb +5 -5
- data/lib/zen/package/custom_fields/lib/custom_fields/helper/custom_field.rb +3 -3
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field.rb +9 -9
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_group.rb +9 -9
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_type.rb +9 -9
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb +8 -3
- data/lib/zen/package/custom_fields/migrations/1336171490_revisions.rb +41 -0
- data/lib/zen/package/dashboard/lib/dashboard/controller/dashboard.rb +6 -6
- data/lib/zen/package/dashboard/lib/dashboard/model/widget.rb +3 -3
- data/lib/zen/package/dashboard/lib/dashboard/widget.rb +12 -12
- data/lib/zen/package/extensions/lib/extensions/controller/extensions.rb +3 -3
- data/lib/zen/package/menus/lib/menus/controller/menu_items.rb +5 -5
- data/lib/zen/package/menus/lib/menus/controller/menus.rb +4 -4
- data/lib/zen/package/menus/lib/menus/helper/menu.rb +4 -4
- data/lib/zen/package/menus/lib/menus/model/menu.rb +11 -11
- data/lib/zen/package/menus/lib/menus/model/menu_item.rb +10 -10
- data/lib/zen/package/menus/lib/menus/public/admin/menus/js/lib/nested_sortables.js +13 -13
- data/lib/zen/package/menus/lib/menus/public/admin/menus/js/menu_items.js +1 -1
- data/lib/zen/package/sections/lib/sections.rb +19 -0
- data/lib/zen/package/sections/lib/sections/controller/revisions.rb +184 -0
- data/lib/zen/package/sections/lib/sections/controller/section_entries.rb +5 -5
- data/lib/zen/package/sections/lib/sections/controller/sections.rb +9 -6
- data/lib/zen/package/sections/lib/sections/helper/revision.rb +124 -0
- data/lib/zen/package/sections/lib/sections/helper/section.rb +17 -15
- data/lib/zen/package/sections/lib/sections/helper/section_frontend.rb +104 -6
- data/lib/zen/package/sections/lib/sections/language/en/revisions.rb +34 -0
- data/lib/zen/package/sections/lib/sections/language/en/sections.rb +1 -0
- data/lib/zen/package/sections/lib/sections/language/nl/revisions.rb +35 -0
- data/lib/zen/package/sections/lib/sections/language/nl/sections.rb +1 -0
- data/lib/zen/package/sections/lib/sections/model/revision.rb +76 -0
- data/lib/zen/package/sections/lib/sections/model/section.rb +9 -9
- data/lib/zen/package/sections/lib/sections/model/section_entry.rb +47 -12
- data/lib/zen/package/sections/lib/sections/view/admin/revisions/index.xhtml +89 -0
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/form.xhtml +1 -1
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/index.xhtml +14 -0
- data/lib/zen/package/sections/migrations/1335711557_revisions.rb +40 -0
- data/lib/zen/package/settings/lib/settings/controller/settings.rb +12 -4
- data/lib/zen/package/settings/lib/settings/setting.rb +6 -6
- data/lib/zen/package/users/lib/users/controller/user_groups.rb +4 -4
- data/lib/zen/package/users/lib/users/controller/users.rb +12 -12
- data/lib/zen/package/users/lib/users/helper/access.rb +1 -1
- data/lib/zen/package/users/lib/users/helper/acl.rb +4 -4
- data/lib/zen/package/users/lib/users/helper/users.rb +2 -2
- data/lib/zen/package/users/lib/users/model/permission.rb +1 -1
- data/lib/zen/package/users/lib/users/model/user.rb +11 -11
- data/lib/zen/package/users/lib/users/model/user_group.rb +9 -9
- data/lib/zen/package/users/lib/users/model/user_status.rb +2 -2
- data/lib/zen/public/admin/zen/css/general.css +54 -0
- data/lib/zen/public/admin/zen/css/messages.css +6 -3
- data/lib/zen/public/admin/zen/css/tables.css +10 -0
- data/lib/zen/public/admin/zen/images/icons/undo.png +0 -0
- data/lib/zen/public/admin/zen/js/lib/autosave.js +8 -8
- data/lib/zen/public/admin/zen/js/lib/base.js +2 -2
- data/lib/zen/public/admin/zen/js/lib/events.js +2 -2
- data/lib/zen/public/admin/zen/js/lib/form.js +7 -7
- data/lib/zen/public/admin/zen/js/lib/hash.js +7 -7
- data/lib/zen/public/admin/zen/js/lib/tabs.js +3 -3
- data/lib/zen/public/admin/zen/js/lib/window.js +1 -1
- data/lib/zen/security.rb +2 -2
- data/lib/zen/spec/helper.rb +3 -9
- data/lib/zen/spec/helper/capybara.rb +4 -4
- data/lib/zen/spec/helper/general.rb +1 -1
- data/lib/zen/spec/simplecov.rb +1 -5
- data/lib/zen/task/build.rake +22 -16
- data/lib/zen/task/db.rake +3 -2
- data/lib/zen/task/spelling.rake +10 -10
- data/lib/zen/task/test.rake +27 -19
- data/lib/zen/theme.rb +6 -6
- data/lib/zen/version.rb +1 -1
- data/spec/zen/all.rb +4 -0
- data/spec/zen/package/sections/controller/revisions.rb +235 -0
- data/spec/zen/package/sections/model/revision.rb +76 -0
- data/zen.gemspec +23 -21
- metadata +88 -29
- data/lib/zen/model/methods.rb +0 -27
- data/lib/zen/task/clean.rake +0 -20
- data/lib/zen/task/setup.rake +0 -4
- data/pkg/.gitkeep +0 -0
@@ -37,7 +37,7 @@ module Ramaze
|
|
37
37
|
# In this example both methods (``validate_ip`` and ``validate_user``) would
|
38
38
|
# be executed before calling ``#index()``.
|
39
39
|
#
|
40
|
-
# @since
|
40
|
+
# @since 2011-11-06
|
41
41
|
#
|
42
42
|
module StackedAspect
|
43
43
|
# Hash that will contain all the STACKED_AOP actions.
|
@@ -46,7 +46,7 @@ module Ramaze
|
|
46
46
|
##
|
47
47
|
# Called whenever this module is included into a class.
|
48
48
|
#
|
49
|
-
# @since
|
49
|
+
# @since 2011-11-06
|
50
50
|
# @param [Class] into The class that included this module.
|
51
51
|
#
|
52
52
|
def self.included(into)
|
@@ -68,7 +68,7 @@ module Ramaze
|
|
68
68
|
##
|
69
69
|
# Calls a certain AOP action for the specified position and method name.
|
70
70
|
#
|
71
|
-
# @since
|
71
|
+
# @since 2011-11-06
|
72
72
|
# @param [Symbol] position The position of the AOP action (e.g. :after).
|
73
73
|
# @param [String] name The name of the method for which to call the
|
74
74
|
# action.
|
@@ -118,7 +118,7 @@ module Ramaze
|
|
118
118
|
##
|
119
119
|
# Module who's methods become available as class methods.
|
120
120
|
#
|
121
|
-
# @since
|
121
|
+
# @since 2011-11-06
|
122
122
|
#
|
123
123
|
module ClassMethods
|
124
124
|
include Traited
|
@@ -135,7 +135,7 @@ module Ramaze
|
|
135
135
|
# validate_username
|
136
136
|
# end
|
137
137
|
#
|
138
|
-
# @since
|
138
|
+
# @since 2011-11-06
|
139
139
|
# @param [#to_sym] name The unique name of the block.
|
140
140
|
# @param [Proc] block The block to execute.
|
141
141
|
#
|
@@ -153,7 +153,7 @@ module Ramaze
|
|
153
153
|
# validate_ip
|
154
154
|
# end
|
155
155
|
#
|
156
|
-
# @since
|
156
|
+
# @since 2011-11-06
|
157
157
|
# @param [#to_sym] name A unique name for the block.
|
158
158
|
# @param [Array] methods An array of methods for which to run the block.
|
159
159
|
# @param [Proc] block The block to run.
|
@@ -172,7 +172,7 @@ module Ramaze
|
|
172
172
|
##
|
173
173
|
# Runs a block after all the actions in a controller.
|
174
174
|
#
|
175
|
-
# @since
|
175
|
+
# @since 2011-11-06
|
176
176
|
# @see Ramaze::Helper::StackedAspect::ClassMethods#stacked_before_all
|
177
177
|
#
|
178
178
|
def stacked_after_all(name, &block)
|
@@ -182,7 +182,7 @@ module Ramaze
|
|
182
182
|
##
|
183
183
|
# Runs a block after a specific list of methods.
|
184
184
|
#
|
185
|
-
# @since
|
185
|
+
# @since 2011-11-06
|
186
186
|
# @see Ramaze::Helper::StackedAspect::ClassMethods#stacked_before
|
187
187
|
#
|
188
188
|
def stacked_after(name, names, &block)
|
@@ -199,7 +199,7 @@ module Ramaze
|
|
199
199
|
##
|
200
200
|
# Wraps the block around the list of methods.
|
201
201
|
#
|
202
|
-
# @since
|
202
|
+
# @since 2011-11-06
|
203
203
|
# @see Ramaze::Helper::StackedAspect::ClassMethods#stacked_before
|
204
204
|
# @see Ramaze::Helper::StackedAspect::ClassMethods#stacked_after
|
205
205
|
#
|
@@ -0,0 +1,151 @@
|
|
1
|
+
module Zen
|
2
|
+
##
|
3
|
+
# Module for generating HTML diffs using Diff::LCS and a custom callback
|
4
|
+
# class. See {Zen::HTMLDiff.diff} and {Zen::HTMLDiff::Callback} for more
|
5
|
+
# information on the usage and the returned HTML.
|
6
|
+
#
|
7
|
+
# @since 2012-05-02
|
8
|
+
#
|
9
|
+
module HTMLDiff
|
10
|
+
##
|
11
|
+
# Gets the difference between the two given strings and returns a string
|
12
|
+
# containing these differences formatted using HTML.
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# old = 'hello world'
|
16
|
+
# new = 'Hello, world!'
|
17
|
+
# diff = Zen::HTMLDiff.diff(old, new)
|
18
|
+
#
|
19
|
+
# puts diff # => "<div class=\"diff\">...</div>"
|
20
|
+
#
|
21
|
+
# @since 2012-05-02
|
22
|
+
# @param [String] old The old version of the string.
|
23
|
+
# @param [String] new The new version of the string.
|
24
|
+
# @return [String]
|
25
|
+
#
|
26
|
+
def self.diff(old, new)
|
27
|
+
callback = Callback.new
|
28
|
+
|
29
|
+
old = old.join("\n") if old.is_a?(Array)
|
30
|
+
new = new.join("\n") if new.is_a?(Array)
|
31
|
+
|
32
|
+
Diff::LCS.traverse_sequences(
|
33
|
+
old.to_s.split(/\r\n|\n/),
|
34
|
+
new.to_s.split(/\r\n|\n/),
|
35
|
+
callback
|
36
|
+
)
|
37
|
+
|
38
|
+
return callback.to_s
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# Callback class for Diff::LCS that is used to format a diff using HTML. An
|
43
|
+
# example of the resulting markup is the following:
|
44
|
+
#
|
45
|
+
# <div class="diff">
|
46
|
+
# <table>
|
47
|
+
# <tbody>
|
48
|
+
# <tr>
|
49
|
+
# <td class="line">1</td>
|
50
|
+
# <td class="line"></td>
|
51
|
+
# <td class="line del">-Hello world</td>
|
52
|
+
# </tr>
|
53
|
+
# <tr>
|
54
|
+
# <td class="line"></td>
|
55
|
+
# <td class="line">1</td>
|
56
|
+
# <td class="line ins">+Hello World</td>
|
57
|
+
# </tr>
|
58
|
+
# </tbody>
|
59
|
+
# </table>
|
60
|
+
# </div>
|
61
|
+
#
|
62
|
+
# Example usage:
|
63
|
+
#
|
64
|
+
# old = '...'
|
65
|
+
# new = '...'
|
66
|
+
# callback Zen::HTMLDiff::Callback.new
|
67
|
+
#
|
68
|
+
# Diff::LCS.traverse_sequence(old, new, callback)
|
69
|
+
#
|
70
|
+
# puts callback # => "<div class=...>"
|
71
|
+
#
|
72
|
+
# @since 2012-05-02
|
73
|
+
#
|
74
|
+
class Callback
|
75
|
+
##
|
76
|
+
# Creates a new instance of the callback class.
|
77
|
+
#
|
78
|
+
# @since 2012-05-02
|
79
|
+
#
|
80
|
+
def initialize
|
81
|
+
@output = ''
|
82
|
+
end
|
83
|
+
|
84
|
+
##
|
85
|
+
# Called when there's a line in A but not in B.
|
86
|
+
#
|
87
|
+
# @since 2012-05-02
|
88
|
+
# @param [Diff::LCS::ContextChange] change
|
89
|
+
#
|
90
|
+
def discard_a(change)
|
91
|
+
@output << %Q{
|
92
|
+
<tr>
|
93
|
+
<td class="line_number">#{change.old_position + 1}</td>
|
94
|
+
<td class="line_number"></td>
|
95
|
+
<td class="line del">-#{change.old_element}</td>
|
96
|
+
</tr>
|
97
|
+
}
|
98
|
+
end
|
99
|
+
|
100
|
+
##
|
101
|
+
# Called when there's a line in B but not in A.
|
102
|
+
#
|
103
|
+
# @since 2012-05-02
|
104
|
+
# @param [Diff::LCS::ContextChange] change
|
105
|
+
#
|
106
|
+
def discard_b(change)
|
107
|
+
@output << %Q{
|
108
|
+
<tr>
|
109
|
+
<td class="line_number"></td>
|
110
|
+
<td class="line_number">#{change.new_position + 1}</td>
|
111
|
+
<td class="line ins">+#{change.new_element}</td>
|
112
|
+
</tr>
|
113
|
+
}
|
114
|
+
end
|
115
|
+
|
116
|
+
##
|
117
|
+
# Called when both lines are identical.
|
118
|
+
#
|
119
|
+
# @since 2012-05-02
|
120
|
+
# @param [Diff::LCS::ContextChange] change
|
121
|
+
#
|
122
|
+
def match(change)
|
123
|
+
@output << %Q{
|
124
|
+
<tr>
|
125
|
+
<td class="line_number">#{change.old_position + 1}</td>
|
126
|
+
<td class="line_number">#{change.new_position + 1}</td>
|
127
|
+
<td class="line"> #{change.old_element}</td>
|
128
|
+
</tr>
|
129
|
+
}
|
130
|
+
end
|
131
|
+
|
132
|
+
##
|
133
|
+
# Returns the full HTML for the diff.
|
134
|
+
#
|
135
|
+
# @since 2012-05-02
|
136
|
+
# @return [String]
|
137
|
+
#
|
138
|
+
def to_s
|
139
|
+
return %Q{
|
140
|
+
<div class="diff">
|
141
|
+
<table class="no_sort">
|
142
|
+
<tbody>
|
143
|
+
#{@output}
|
144
|
+
</tbody>
|
145
|
+
</table>
|
146
|
+
</div>
|
147
|
+
}
|
148
|
+
end
|
149
|
+
end # Callback
|
150
|
+
end # HTMLDiff
|
151
|
+
end # Zen
|
data/lib/zen/language.rb
CHANGED
@@ -178,6 +178,7 @@ module Zen
|
|
178
178
|
#
|
179
179
|
# <div class="note todo">
|
180
180
|
# <p>
|
181
|
+
# <strong>Note:</strong>
|
181
182
|
# This can't be stressed enough: always load language files using the
|
182
183
|
# post_start event.
|
183
184
|
# </p>
|
@@ -206,6 +207,7 @@ module Zen
|
|
206
207
|
#
|
207
208
|
# <div class="note todo">
|
208
209
|
# <p>
|
210
|
+
# <strong>Note:</strong>
|
209
211
|
# Because language files aren't loaded until Zen.start is called you
|
210
212
|
# should never use or rely on translations before the application has
|
211
213
|
# started. Most of the core code works around this by loading
|
@@ -263,7 +265,7 @@ module Zen
|
|
263
265
|
# lang.rtl = true
|
264
266
|
# end
|
265
267
|
#
|
266
|
-
# @since
|
268
|
+
# @since 2011-11-14
|
267
269
|
# @yield Zen::Language
|
268
270
|
#
|
269
271
|
def add
|
@@ -362,7 +364,7 @@ module Zen
|
|
362
364
|
# Returns a hash where the keys are the language codes and the values the
|
363
365
|
# titles.
|
364
366
|
#
|
365
|
-
# @since
|
367
|
+
# @since 2011-11-14
|
366
368
|
# @return [Hash]
|
367
369
|
#
|
368
370
|
def to_hash
|
@@ -377,7 +379,7 @@ module Zen
|
|
377
379
|
# Returns a string containing the text direction if the current language
|
378
380
|
# is an rtl language.
|
379
381
|
#
|
380
|
-
# @since
|
382
|
+
# @since 2011-11-14
|
381
383
|
# @return [String]
|
382
384
|
#
|
383
385
|
def html_text_direction
|
@@ -390,7 +392,7 @@ module Zen
|
|
390
392
|
##
|
391
393
|
# Creates a new instance of the class.
|
392
394
|
#
|
393
|
-
# @since
|
395
|
+
# @since 2011-11-14
|
394
396
|
#
|
395
397
|
def initialize
|
396
398
|
@loaded = []
|
@@ -400,7 +402,7 @@ module Zen
|
|
400
402
|
##
|
401
403
|
# Sets the name of the language and converts it to a string.
|
402
404
|
#
|
403
|
-
# @since
|
405
|
+
# @since 2011-11-14
|
404
406
|
# @param [#to_s] name The name of the language.
|
405
407
|
#
|
406
408
|
def name=(name)
|
@@ -411,7 +413,7 @@ module Zen
|
|
411
413
|
# Returns a boolean that indicates whether or not the language reads from
|
412
414
|
# right to left.
|
413
415
|
#
|
414
|
-
# @since
|
416
|
+
# @since 2011-11-14
|
415
417
|
# @return [TrueClass|FalseClass]
|
416
418
|
#
|
417
419
|
def rtl
|
@@ -421,7 +423,7 @@ module Zen
|
|
421
423
|
##
|
422
424
|
# Validates the current instance using {Zen::Validation}.
|
423
425
|
#
|
424
|
-
# @since
|
426
|
+
# @since 2011-11-14
|
425
427
|
#
|
426
428
|
def validate
|
427
429
|
validates_presence([:name, :title])
|
@@ -17,7 +17,7 @@ module Zen
|
|
17
17
|
#
|
18
18
|
# For more general and expanded information see {Zen::Language}.
|
19
19
|
#
|
20
|
-
# @since
|
20
|
+
# @since 2011-11-16
|
21
21
|
#
|
22
22
|
class Translation
|
23
23
|
include Zen::Validation
|
@@ -37,7 +37,7 @@ module Zen
|
|
37
37
|
##
|
38
38
|
# Adds a new translation set.
|
39
39
|
#
|
40
|
-
# @since
|
40
|
+
# @since 2011-11-16
|
41
41
|
# @yield Zen::Language::Translation
|
42
42
|
#
|
43
43
|
def self.add
|
@@ -53,7 +53,7 @@ module Zen
|
|
53
53
|
##
|
54
54
|
# Sets the language for the collection of translations.
|
55
55
|
#
|
56
|
-
# @since
|
56
|
+
# @since 2011-11-16
|
57
57
|
# @param [#to_s] language The language code.
|
58
58
|
# @raise Zen::ValidationError Raised whenever a given language is invalid.
|
59
59
|
#
|
@@ -65,7 +65,7 @@ module Zen
|
|
65
65
|
# Stores the supplied block containing all translations in
|
66
66
|
# ``@translations``.
|
67
67
|
#
|
68
|
-
# @since
|
68
|
+
# @since 2011-11-17
|
69
69
|
# @param [Proc] block A block containing all calls to ``#[]=()``.
|
70
70
|
#
|
71
71
|
def translate(&block)
|
@@ -76,7 +76,7 @@ module Zen
|
|
76
76
|
# Loads the translations by invoking the block that was set using
|
77
77
|
# {#translate}.
|
78
78
|
#
|
79
|
-
# @since
|
79
|
+
# @since 2011-11-17
|
80
80
|
#
|
81
81
|
def load
|
82
82
|
@translations.call(self)
|
@@ -85,7 +85,7 @@ module Zen
|
|
85
85
|
##
|
86
86
|
# Sets the name of the collection of translations.
|
87
87
|
#
|
88
|
-
# @since
|
88
|
+
# @since 2011-11-16
|
89
89
|
# @param [#to_s] name The name of the collection.
|
90
90
|
#
|
91
91
|
def name=(name)
|
@@ -96,7 +96,7 @@ module Zen
|
|
96
96
|
# Adds a new translation by directly storing it in the cache
|
97
97
|
# ``Ramaze::Cache.translations``.
|
98
98
|
#
|
99
|
-
# @since
|
99
|
+
# @since 2011-11-16
|
100
100
|
# @param [#to_s] key The name of the language item, an example is
|
101
101
|
# "titles.index".
|
102
102
|
# @param [#to_s] value The value of the language item.
|
@@ -115,7 +115,7 @@ module Zen
|
|
115
115
|
##
|
116
116
|
# Validates the instance.
|
117
117
|
#
|
118
|
-
# @since
|
118
|
+
# @since 2011-11-17
|
119
119
|
#
|
120
120
|
def validate
|
121
121
|
validates_presence([:name, :name, :translations])
|
data/lib/zen/markup.rb
CHANGED
data/lib/zen/migrator.rb
CHANGED
@@ -3,13 +3,13 @@ module Zen
|
|
3
3
|
# Small wrapper around Sequel::Migrator to fix various issues and make it a
|
4
4
|
# bit easier to log data.
|
5
5
|
#
|
6
|
-
# @since
|
6
|
+
# @since 2012-01-07
|
7
7
|
#
|
8
8
|
module Migrator
|
9
9
|
##
|
10
10
|
# Runs a set of migrations and logs the actions.
|
11
11
|
#
|
12
|
-
# @since
|
12
|
+
# @since 2012-01-07
|
13
13
|
# @see Sequel::Migrator.run
|
14
14
|
# @param [String] name The name of the package/theme/etc to migrate.
|
15
15
|
# @param [String] dir The directory containing the migrations.
|
data/lib/zen/model/helper.rb
CHANGED
@@ -11,7 +11,7 @@ module Zen
|
|
11
11
|
#
|
12
12
|
# See the individual methods in this module for more information.
|
13
13
|
#
|
14
|
-
# @since
|
14
|
+
# @since 2011-10-16
|
15
15
|
#
|
16
16
|
module Helper
|
17
17
|
# Array containing the database adapters that don't support regular
|
@@ -22,7 +22,7 @@ module Zen
|
|
22
22
|
# Extends the including class with the methods in the {ClassMethods}
|
23
23
|
# module.
|
24
24
|
#
|
25
|
-
# @since
|
25
|
+
# @since 2011-10-16
|
26
26
|
#
|
27
27
|
def self.included(into)
|
28
28
|
into.extend(ClassMethods)
|
@@ -34,7 +34,7 @@ module Zen
|
|
34
34
|
# @example
|
35
35
|
# sanitize_fields([:name, :description])
|
36
36
|
#
|
37
|
-
# @since
|
37
|
+
# @since 2012-01-03
|
38
38
|
# @param [Array] fields An array containing all the fields to sanitize.
|
39
39
|
# @param [TrueClass|FalseClass] clean_html When set to true Loofah will be
|
40
40
|
# used to get rid of nasty HTML.
|
@@ -66,7 +66,7 @@ module Zen
|
|
66
66
|
# @example Using a DBMS that does not support the use of a regex
|
67
67
|
# search_column(:name, 'ruby \d+') # => #<Sequel::SQL::BooleanExpression ....>
|
68
68
|
#
|
69
|
-
# @since
|
69
|
+
# @since 2011-10-16
|
70
70
|
# @param [Symbol] column The column to use in the statement.
|
71
71
|
# @param [String] value The value for the statement.
|
72
72
|
# @return [Hash|Sequel::SQL::BooleanExpression]
|
@@ -5,12 +5,12 @@ module Sequel
|
|
5
5
|
# fired by {Zen::Event}. Based on the specified options it creates events
|
6
6
|
# for the following Sequel hooks:
|
7
7
|
#
|
8
|
-
# *
|
9
|
-
# *
|
10
|
-
# *
|
11
|
-
# *
|
12
|
-
# *
|
13
|
-
# *
|
8
|
+
# * before\_create
|
9
|
+
# * after\_create
|
10
|
+
# * before\_update
|
11
|
+
# * after\_update
|
12
|
+
# * before\_destroy
|
13
|
+
# * after\_destroy
|
14
14
|
#
|
15
15
|
# For example, to add the Zen event "before_new_post" and have it called by
|
16
16
|
# the Sequel hook "before_create" you'd do the following:
|
@@ -30,13 +30,13 @@ module Sequel
|
|
30
30
|
# Events don't have to return the modified object as objects are assigned by
|
31
31
|
# reference.
|
32
32
|
#
|
33
|
-
# @since
|
33
|
+
# @since 2012-02-05
|
34
34
|
#
|
35
35
|
module Events
|
36
36
|
##
|
37
37
|
# Configures the plugin for a single model.
|
38
38
|
#
|
39
|
-
# @since
|
39
|
+
# @since 2012-02-06
|
40
40
|
# @param [Class] model The model for which to enable the plugin.
|
41
41
|
# @param [Hash] options A hash containing the Sequel hook names and the
|
42
42
|
# Zen events to fire.
|
@@ -61,7 +61,7 @@ module Sequel
|
|
61
61
|
# Module containing the methods and attributes to make available on class
|
62
62
|
# level.
|
63
63
|
#
|
64
|
-
# @since
|
64
|
+
# @since 2012-02-06
|
65
65
|
#
|
66
66
|
module ClassMethods
|
67
67
|
# Hash containing all the Sequel hooks and the corresponding Zen events.
|
@@ -72,13 +72,13 @@ module Sequel
|
|
72
72
|
# Module containing the methods and attributes to make available on
|
73
73
|
# instance level.
|
74
74
|
#
|
75
|
-
# @since
|
75
|
+
# @since 2012-02-06
|
76
76
|
#
|
77
77
|
module InstanceMethods
|
78
78
|
##
|
79
79
|
# Hook executed before creating a new object.
|
80
80
|
#
|
81
|
-
# @since
|
81
|
+
# @since 2012-02-06
|
82
82
|
#
|
83
83
|
def before_create
|
84
84
|
if self.class.events and self.class.events.key?(:before_create)
|
@@ -91,7 +91,7 @@ module Sequel
|
|
91
91
|
##
|
92
92
|
# Hook executed after creating a new object.
|
93
93
|
#
|
94
|
-
# @since
|
94
|
+
# @since 2012-02-06
|
95
95
|
#
|
96
96
|
def after_create
|
97
97
|
super
|
@@ -104,7 +104,7 @@ module Sequel
|
|
104
104
|
##
|
105
105
|
# Hook executed before updating an existing object.
|
106
106
|
#
|
107
|
-
# @since
|
107
|
+
# @since 2012-02-06
|
108
108
|
#
|
109
109
|
def before_update
|
110
110
|
if self.class.events and self.class.events.key?(:before_update)
|
@@ -117,7 +117,7 @@ module Sequel
|
|
117
117
|
##
|
118
118
|
# Hook executed after updating an existing object.
|
119
119
|
#
|
120
|
-
# @since
|
120
|
+
# @since 2012-02-06
|
121
121
|
#
|
122
122
|
def after_update
|
123
123
|
super
|
@@ -130,7 +130,7 @@ module Sequel
|
|
130
130
|
##
|
131
131
|
# Hook executed before removing an existing object.
|
132
132
|
#
|
133
|
-
# @since
|
133
|
+
# @since 2012-02-06
|
134
134
|
#
|
135
135
|
def before_destroy
|
136
136
|
if self.class.events and self.class.events.key?(:before_destroy)
|
@@ -143,7 +143,7 @@ module Sequel
|
|
143
143
|
##
|
144
144
|
# Hook executed after removing an existing object.
|
145
145
|
#
|
146
|
-
# @since
|
146
|
+
# @since 2012-02-06
|
147
147
|
#
|
148
148
|
def after_destroy
|
149
149
|
super
|