zen 0.4.2 → 0.4.3
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 +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
|
@@ -13,12 +13,12 @@ module Menus
|
|
|
13
13
|
# end
|
|
14
14
|
#
|
|
15
15
|
# @since 0.2a
|
|
16
|
-
# @event
|
|
17
|
-
# @event
|
|
18
|
-
# @event
|
|
19
|
-
# @event
|
|
20
|
-
# @event
|
|
21
|
-
# @event
|
|
16
|
+
# @event before\_new\_menu\_item
|
|
17
|
+
# @event after\_new\_menu\_item
|
|
18
|
+
# @event before\_edit\_menu\_item
|
|
19
|
+
# @event after\_edit\_menu\_item
|
|
20
|
+
# @event before\_delete\_menu\_item
|
|
21
|
+
# @event after\_delete\_menu\_item
|
|
22
22
|
#
|
|
23
23
|
class MenuItem < Sequel::Model
|
|
24
24
|
include Zen::Model::Helper
|
|
@@ -26,7 +26,7 @@ module Menus
|
|
|
26
26
|
##
|
|
27
27
|
# Array containing the columns that can be set by the user.
|
|
28
28
|
#
|
|
29
|
-
# @since
|
|
29
|
+
# @since 2012-02-17
|
|
30
30
|
#
|
|
31
31
|
COLUMNS = [
|
|
32
32
|
:parent_id, :name, :url, :sort_order, :html_class, :html_id, :menu_id
|
|
@@ -48,7 +48,7 @@ module Menus
|
|
|
48
48
|
##
|
|
49
49
|
# Searches for a set of menu items.
|
|
50
50
|
#
|
|
51
|
-
# @since
|
|
51
|
+
# @since 2011-10-16
|
|
52
52
|
# @param [String] query The search query.
|
|
53
53
|
# @return [Mixed]
|
|
54
54
|
#
|
|
@@ -89,7 +89,7 @@ module Menus
|
|
|
89
89
|
##
|
|
90
90
|
# Hook that is called before creating a new object.
|
|
91
91
|
#
|
|
92
|
-
# @since
|
|
92
|
+
# @since 2012-02-28
|
|
93
93
|
#
|
|
94
94
|
def before_create
|
|
95
95
|
# Set the sort order based on the order of the last item.
|
|
@@ -112,7 +112,7 @@ module Menus
|
|
|
112
112
|
##
|
|
113
113
|
# Hook that is executed before creating or saving an object.
|
|
114
114
|
#
|
|
115
|
-
# @since
|
|
115
|
+
# @since 2012-01-03
|
|
116
116
|
#
|
|
117
117
|
def before_save
|
|
118
118
|
sanitize_fields([:name, :url, :html_class, :html_id])
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* * Added the methods serializeArray() and serializeItems().
|
|
14
14
|
* * Replaced various while() loops with calls to getParents() and the like.
|
|
15
15
|
*
|
|
16
|
-
* @since
|
|
16
|
+
* @since 2012-02-11
|
|
17
17
|
*/
|
|
18
18
|
var NestedSortables = new Class(
|
|
19
19
|
{
|
|
@@ -23,7 +23,7 @@ var NestedSortables = new Class(
|
|
|
23
23
|
* Object containing all the options that can be set in the secondary
|
|
24
24
|
* parameter of the constructor.
|
|
25
25
|
*
|
|
26
|
-
* @since
|
|
26
|
+
* @since 2012-02-11
|
|
27
27
|
*/
|
|
28
28
|
options:
|
|
29
29
|
{
|
|
@@ -76,7 +76,7 @@ var NestedSortables = new Class(
|
|
|
76
76
|
/**
|
|
77
77
|
* Creates a new instance of the class.
|
|
78
78
|
*
|
|
79
|
-
* @since
|
|
79
|
+
* @since 2012-02-11
|
|
80
80
|
* @param {string} list The ID of the list container.
|
|
81
81
|
* @param {object} options Object containing custom options to set. See
|
|
82
82
|
* NestedSortables.options for all the available options.
|
|
@@ -105,7 +105,7 @@ var NestedSortables = new Class(
|
|
|
105
105
|
/**
|
|
106
106
|
* Starts dragging an element.
|
|
107
107
|
*
|
|
108
|
-
* @since
|
|
108
|
+
* @since 2012-02-11
|
|
109
109
|
* @param {Event} event
|
|
110
110
|
*/
|
|
111
111
|
start: function(event)
|
|
@@ -175,7 +175,7 @@ var NestedSortables = new Class(
|
|
|
175
175
|
/**
|
|
176
176
|
* Event that is called whenever an element is collapsed.
|
|
177
177
|
*
|
|
178
|
-
* @since
|
|
178
|
+
* @since 2012-02-11
|
|
179
179
|
* @param {Event} event
|
|
180
180
|
*/
|
|
181
181
|
collapse: function(event)
|
|
@@ -217,7 +217,7 @@ var NestedSortables = new Class(
|
|
|
217
217
|
/**
|
|
218
218
|
* Stops an event.
|
|
219
219
|
*
|
|
220
|
-
* @since
|
|
220
|
+
* @since 2012-02-11
|
|
221
221
|
* @param {Event} event
|
|
222
222
|
*/
|
|
223
223
|
stop: function(event)
|
|
@@ -229,7 +229,7 @@ var NestedSortables = new Class(
|
|
|
229
229
|
/**
|
|
230
230
|
* Gets the depth of an element.
|
|
231
231
|
*
|
|
232
|
-
* @since
|
|
232
|
+
* @since 2012-02-11
|
|
233
233
|
* @param {Element} el
|
|
234
234
|
* @param {boolean} add
|
|
235
235
|
* @return {number}
|
|
@@ -244,7 +244,7 @@ var NestedSortables = new Class(
|
|
|
244
244
|
/**
|
|
245
245
|
* Removes the events of various elements.
|
|
246
246
|
*
|
|
247
|
-
* @since
|
|
247
|
+
* @since 2012-02-11
|
|
248
248
|
*/
|
|
249
249
|
detach: function()
|
|
250
250
|
{
|
|
@@ -259,7 +259,7 @@ var NestedSortables = new Class(
|
|
|
259
259
|
/**
|
|
260
260
|
* Stops the process of dragging an element.
|
|
261
261
|
*
|
|
262
|
-
* @since
|
|
262
|
+
* @since 2012-02-11
|
|
263
263
|
* @param {Event} event
|
|
264
264
|
* @param {Element} el
|
|
265
265
|
*/
|
|
@@ -289,7 +289,7 @@ var NestedSortables = new Class(
|
|
|
289
289
|
/**
|
|
290
290
|
* Method that is called whenever an element is being moved.
|
|
291
291
|
*
|
|
292
|
-
* @since
|
|
292
|
+
* @since 2012-02-11
|
|
293
293
|
* @param {Event} event
|
|
294
294
|
* @param {Element} el
|
|
295
295
|
*/
|
|
@@ -478,7 +478,7 @@ var NestedSortables = new Class(
|
|
|
478
478
|
* there are no sub elements or an object of sub elements (with the same
|
|
479
479
|
* structure).
|
|
480
480
|
*
|
|
481
|
-
* @since
|
|
481
|
+
* @since 2012-02-11
|
|
482
482
|
* @param {Function} fn
|
|
483
483
|
* @param {Element} base
|
|
484
484
|
* @return {object}
|
|
@@ -514,7 +514,7 @@ var NestedSortables = new Class(
|
|
|
514
514
|
* Builds an array containing all the menu items and their parent IDs. This
|
|
515
515
|
* array is sorted based on the sort order specified by the user.
|
|
516
516
|
*
|
|
517
|
-
* @since
|
|
517
|
+
* @since 2012-02-11
|
|
518
518
|
* @return {array}
|
|
519
519
|
*/
|
|
520
520
|
serializeArray: function()
|
|
@@ -523,7 +523,7 @@ var NestedSortables = new Class(
|
|
|
523
523
|
},
|
|
524
524
|
|
|
525
525
|
/**
|
|
526
|
-
* @since
|
|
526
|
+
* @since 2012-02-11
|
|
527
527
|
* @see NestedSortables.serializeArray()
|
|
528
528
|
*/
|
|
529
529
|
serializeItems: function(items, parent_id)
|
|
@@ -20,13 +20,18 @@ Zen::Package.add do |p|
|
|
|
20
20
|
p.permission :edit_section_entry , 'section_entries.permissions.edit'
|
|
21
21
|
p.permission :new_section_entry , 'section_entries.permissions.new'
|
|
22
22
|
p.permission :delete_section_entry, 'section_entries.permissions.delete'
|
|
23
|
+
|
|
24
|
+
p.permission :show_revision, 'revisions.permissions.show'
|
|
25
|
+
p.permission :restore_revision, 'revisions.permissions.restore'
|
|
23
26
|
end
|
|
24
27
|
|
|
25
28
|
require __DIR__('sections/model/section')
|
|
29
|
+
require __DIR__('sections/model/revision')
|
|
26
30
|
require __DIR__('sections/model/section_entry')
|
|
27
31
|
require __DIR__('sections/model/section_entry_status')
|
|
28
32
|
require __DIR__('sections/controller/sections')
|
|
29
33
|
require __DIR__('sections/controller/section_entries')
|
|
34
|
+
require __DIR__('sections/controller/revisions')
|
|
30
35
|
require __DIR__('sections/widget/recent_entries')
|
|
31
36
|
|
|
32
37
|
Zen::Controller::FrontendController.helper(:section_frontend)
|
|
@@ -35,3 +40,17 @@ Zen::Event.listen :post_start do
|
|
|
35
40
|
Zen::Language.load('sections')
|
|
36
41
|
Zen::Language.load('section_entries')
|
|
37
42
|
end
|
|
43
|
+
|
|
44
|
+
Settings::SettingsGroup.add do |group|
|
|
45
|
+
group.title = 'sections.tabs.content'
|
|
46
|
+
group.name = :content
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
Settings::Setting.add do |setting|
|
|
50
|
+
setting.title = 'revisions.labels.maximum'
|
|
51
|
+
setting.description = 'revisions.descriptions.maximum'
|
|
52
|
+
setting.name = :maximum_revisions
|
|
53
|
+
setting.group = :content
|
|
54
|
+
setting.type = 'textbox'
|
|
55
|
+
setting.default = 10
|
|
56
|
+
end
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
module Sections
|
|
2
|
+
module Controller
|
|
3
|
+
##
|
|
4
|
+
# In Zen a section entry's data is saved as a separate revision each time
|
|
5
|
+
# you save it manually or when it's saved automatically (every 10 minutes).
|
|
6
|
+
# Storing entries in separate revisions means you're able to revert to
|
|
7
|
+
# specific revisions by simply clicking the "Restore" link for a specific
|
|
8
|
+
# revision. No longer do you have to worry about accidently removing data
|
|
9
|
+
# without being able to easily revert that change.
|
|
10
|
+
#
|
|
11
|
+
# Revisions can be viewed as well as being restored by clicking on the
|
|
12
|
+
# "Revisions" link in the section entries overview. Once you've clicked this
|
|
13
|
+
# link you'll be presented with an overview similar to this one:
|
|
14
|
+
#
|
|
15
|
+
# 
|
|
16
|
+
#
|
|
17
|
+
# This overview lets you compare two revisions as well as restoring
|
|
18
|
+
# revisions.
|
|
19
|
+
#
|
|
20
|
+
# ## Comparing Revisions
|
|
21
|
+
#
|
|
22
|
+
# Comparing revisions makes it easy to see what has changed between two
|
|
23
|
+
# given revisions. In order to compare two revisions you must select the
|
|
24
|
+
# old and the new revision to compare. This can be done by checking the
|
|
25
|
+
# checkboxes in the "Old" and "New" column for the revisions you want to
|
|
26
|
+
# compare. Once you've selected the two revisions and have clicked on the
|
|
27
|
+
# "Compare" button you'll be presented with a set of differences between the
|
|
28
|
+
# two revisions.
|
|
29
|
+
#
|
|
30
|
+
# 
|
|
31
|
+
#
|
|
32
|
+
# Each field that had its value changed will be displayed with the changed
|
|
33
|
+
# data next to it. When showing such differences the following information
|
|
34
|
+
# is available for each field:
|
|
35
|
+
#
|
|
36
|
+
# * The line numbers of the old and new data. The numbers on the left are
|
|
37
|
+
# the old line numbers, the numbers on the right are the line numbers for
|
|
38
|
+
# the new revision.
|
|
39
|
+
# * Lines that were deleted. These are displayed in red and are prefixed
|
|
40
|
+
# with a minus (`-`) sign.
|
|
41
|
+
# * Lines that were added. These lines are displayed in green and are
|
|
42
|
+
# prefixed with a plus (`+`) sign.
|
|
43
|
+
#
|
|
44
|
+
# In case of the image above this means that line 1 was not changed and that
|
|
45
|
+
# lines 2 and 3 were added in the revision selected in the "New" column.
|
|
46
|
+
#
|
|
47
|
+
# A more expanded example of comparing differences between revisions:
|
|
48
|
+
#
|
|
49
|
+
# ![Revision Differences With Multiple Fields]
|
|
50
|
+
# (../../images/sections/revisions_diff_multiple.png)
|
|
51
|
+
#
|
|
52
|
+
# This example shows the result of comparing two revisions that contain
|
|
53
|
+
# changes for multiple custom fields.
|
|
54
|
+
#
|
|
55
|
+
# <div class="note todo">
|
|
56
|
+
# <p>
|
|
57
|
+
# <strong>Note:</strong>
|
|
58
|
+
# If there are no differences between a revision a notice will be
|
|
59
|
+
# displayed instead of the set of changes.
|
|
60
|
+
# </p>
|
|
61
|
+
# </div>
|
|
62
|
+
#
|
|
63
|
+
# ## Restoring Revisions
|
|
64
|
+
#
|
|
65
|
+
# Restoring revisions makes it easy to revert a set of changes without
|
|
66
|
+
# having to manually make these changes to a section entry, or worse: fiddle
|
|
67
|
+
# around with database backups.
|
|
68
|
+
#
|
|
69
|
+
# Restoring revisions is quite easy, once you've decided which revision you
|
|
70
|
+
# want to restore all you need to do is click the "Restore" link of the
|
|
71
|
+
# specific revision. Restoring a revision will result in the following two
|
|
72
|
+
# actions:
|
|
73
|
+
#
|
|
74
|
+
# * The revision ID of the entry is set to the ID of the revision you want
|
|
75
|
+
# to restore.
|
|
76
|
+
# * All newer revisions are deleted.
|
|
77
|
+
#
|
|
78
|
+
# ## Revision Limit
|
|
79
|
+
#
|
|
80
|
+
# Every time a section entry is saved a new revision will be created. To
|
|
81
|
+
# prevent the revisions table from filling up with thousands of revisions
|
|
82
|
+
# these revisions will be removed after a certain number has been exceeded.
|
|
83
|
+
#
|
|
84
|
+
# By default the oldest revision will be removed if there are more than 10
|
|
85
|
+
# revisions for a section entry. This limit can be changed by going to the
|
|
86
|
+
# settings manager. For more information about using the settings manager
|
|
87
|
+
# refer to {Settings::Controller::Settings Managing Settings}.
|
|
88
|
+
#
|
|
89
|
+
# @since 2012-04-30
|
|
90
|
+
# @map /admin/revisions
|
|
91
|
+
#
|
|
92
|
+
class Revisions < Zen::Controller::AdminController
|
|
93
|
+
map '/admin/revisions'
|
|
94
|
+
title 'revisions.titles.%s'
|
|
95
|
+
helper :section, :revision
|
|
96
|
+
|
|
97
|
+
##
|
|
98
|
+
# Shows an overview of the revisions for a given section entry ID.
|
|
99
|
+
#
|
|
100
|
+
# @since 2012-04-30
|
|
101
|
+
# @param [Fixnum|String] section_id The ID of the section the entry
|
|
102
|
+
# belongs to.
|
|
103
|
+
# @param [Fixnum|String] id The ID of the section entry for which to show
|
|
104
|
+
# the revisions.
|
|
105
|
+
# @permission show_revision
|
|
106
|
+
#
|
|
107
|
+
def index(section_id, id)
|
|
108
|
+
authorize_user!(:show_revision)
|
|
109
|
+
|
|
110
|
+
validate_section(section_id)
|
|
111
|
+
|
|
112
|
+
@entry = validate_section_entry(id, section_id)
|
|
113
|
+
@revisions = @entry.revisions
|
|
114
|
+
@entry_url = SectionEntries.a(
|
|
115
|
+
@entry.title,
|
|
116
|
+
:edit,
|
|
117
|
+
@entry.section_id,
|
|
118
|
+
@entry.id
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
# Compare two revisions if both IDs are specified.
|
|
122
|
+
if request.POST['old_revision_id'] and request.POST['new_revision_id']
|
|
123
|
+
@old_rev_id = request.POST['old_revision_id']
|
|
124
|
+
@new_rev_id = request.POST['new_revision_id']
|
|
125
|
+
@diff = revision_diff(@entry, @old_rev_id, @new_rev_id)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
set_breadcrumbs(
|
|
129
|
+
Sections.a(
|
|
130
|
+
lang('sections.titles.index'),
|
|
131
|
+
:index
|
|
132
|
+
),
|
|
133
|
+
SectionEntries.a(
|
|
134
|
+
lang('section_entries.titles.index'),
|
|
135
|
+
:index,
|
|
136
|
+
section_id
|
|
137
|
+
),
|
|
138
|
+
lang('revisions.titles.index')
|
|
139
|
+
)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
##
|
|
143
|
+
# Sets the revision ID of a section entry to a specific revision, deleting
|
|
144
|
+
# newer revisions.
|
|
145
|
+
#
|
|
146
|
+
# @since 2012-05-03
|
|
147
|
+
# @param [Fixnum|String] revision_id The ID of the revision to restore.
|
|
148
|
+
# @permission restore_revision
|
|
149
|
+
#
|
|
150
|
+
def restore(revision_id)
|
|
151
|
+
authorize_user!(:restore_revision)
|
|
152
|
+
|
|
153
|
+
revision = validate_revision(revision_id)
|
|
154
|
+
|
|
155
|
+
if revision
|
|
156
|
+
entry = revision.section_entry
|
|
157
|
+
|
|
158
|
+
begin
|
|
159
|
+
entry.update(:revision_id => revision.id)
|
|
160
|
+
rescue => e
|
|
161
|
+
Ramaze::Log.error(e)
|
|
162
|
+
|
|
163
|
+
message(:error, lang('revisions.errors.restore'))
|
|
164
|
+
redirect_referer
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
begin
|
|
168
|
+
Model::Revision \
|
|
169
|
+
.filter(:section_entry_id => entry.id) { id > revision.id } \
|
|
170
|
+
.delete
|
|
171
|
+
|
|
172
|
+
message(:success, lang('revisions.success.restore'))
|
|
173
|
+
rescue => e
|
|
174
|
+
Ramaze::Log.error(e)
|
|
175
|
+
|
|
176
|
+
message(:error, lang('revisions.errors.restore'))
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
redirect_referer
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
end # Revisions
|
|
183
|
+
end # Controller
|
|
184
|
+
end # Sections
|
|
@@ -90,10 +90,10 @@ module Sections
|
|
|
90
90
|
#
|
|
91
91
|
# This controller uses the following permissions:
|
|
92
92
|
#
|
|
93
|
-
# *
|
|
94
|
-
# *
|
|
95
|
-
# *
|
|
96
|
-
# *
|
|
93
|
+
# * show\_section\_entry
|
|
94
|
+
# * new\_section\_entry
|
|
95
|
+
# * edit\_section\_entry
|
|
96
|
+
# * delete\_section\_entry
|
|
97
97
|
#
|
|
98
98
|
# @since 0.1
|
|
99
99
|
# @map /admin/section-entries
|
|
@@ -267,7 +267,7 @@ module Sections
|
|
|
267
267
|
# Automatically saves a section entry. This is needed to take care of the
|
|
268
268
|
# custom fields, something the helper method itself can not do.
|
|
269
269
|
#
|
|
270
|
-
# @since
|
|
270
|
+
# @since 2012-02-17
|
|
271
271
|
#
|
|
272
272
|
def autosave
|
|
273
273
|
entry = Model::SectionEntry[request.params['id']]
|
|
@@ -5,17 +5,20 @@
|
|
|
5
5
|
#
|
|
6
6
|
# * {Sections::Controller::Sections}
|
|
7
7
|
# * {Sections::Controller::SectionEntries}
|
|
8
|
+
# * {Sections::Controller::Revisions}
|
|
8
9
|
#
|
|
9
10
|
# ## Helpers
|
|
10
11
|
#
|
|
11
12
|
# * {Ramaze::Helper::Section}
|
|
12
13
|
# * {Ramaze::Helper::SectionFrontend}
|
|
14
|
+
# * {Ramaze::Helper::Revision}
|
|
13
15
|
#
|
|
14
16
|
# ## Models
|
|
15
17
|
#
|
|
16
18
|
# * {Sections::Model::Section}
|
|
17
19
|
# * {Sections::Model::SectionEntry}
|
|
18
20
|
# * {Sections::Model::SectionEntryStatus}
|
|
21
|
+
# * {Sections::Model::Revision}
|
|
19
22
|
#
|
|
20
23
|
module Sections
|
|
21
24
|
#:nodoc:
|
|
@@ -127,10 +130,10 @@ module Sections
|
|
|
127
130
|
#
|
|
128
131
|
# ## Used Permissions
|
|
129
132
|
#
|
|
130
|
-
# *
|
|
131
|
-
# *
|
|
132
|
-
# *
|
|
133
|
-
# *
|
|
133
|
+
# * show\_section
|
|
134
|
+
# * new\_section
|
|
135
|
+
# * edit\_section
|
|
136
|
+
# * delete\_section
|
|
134
137
|
#
|
|
135
138
|
# @since 0.1
|
|
136
139
|
# @map /admin/sections
|
|
@@ -152,10 +155,10 @@ module Sections
|
|
|
152
155
|
}
|
|
153
156
|
|
|
154
157
|
@custom_field_group_pk_hash = ::CustomFields::Model::CustomFieldGroup \
|
|
155
|
-
.
|
|
158
|
+
.to_hash(:id, :name).invert
|
|
156
159
|
|
|
157
160
|
@category_group_pk_hash = ::Categories::Model::CategoryGroup \
|
|
158
|
-
.
|
|
161
|
+
.to_hash(:id, :name).invert
|
|
159
162
|
end
|
|
160
163
|
|
|
161
164
|
##
|