refinerycms-core 2.0.4 → 2.0.5
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/app/assets/javascripts/refinery/admin.js.erb +3 -3
- data/app/assets/javascripts/refinery/nestedsortables.js +312 -312
- data/app/assets/javascripts/wymeditor/lang/ru.js +1 -0
- data/app/assets/stylesheets/refinery/layout.css.scss +4 -1
- data/app/views/layouts/refinery/flash.html.erb +1 -1
- data/app/views/refinery/_content_page.html.erb +1 -1
- data/app/views/refinery/_head.html.erb +3 -3
- data/lib/generators/refinery/engine/engine_generator.rb +2 -0
- data/lib/generators/refinery/engine/templates/app/models/refinery/namespace/singular_name.rb +2 -2
- data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/plural_name/index.html.erb +1 -1
- data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/plural_name/show.html.erb +2 -2
- data/lib/generators/refinery/engine/templates/db/seeds.rb +22 -18
- data/lib/generators/refinery/engine/templates/spec/spec_helper.rb +2 -2
- data/lib/generators/refinery/form/form_generator.rb +2 -0
- data/lib/generators/refinery/form/templates/app/models/refinery/namespace/singular_name.rb +5 -3
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/plural_name/new.html.erb +1 -1
- data/lib/generators/refinery/form/templates/db/seeds.rb +26 -22
- data/lib/refinery/activity.rb +17 -6
- data/lib/refinery/cli.rb +1 -1
- data/lib/refinery/extension_generation.rb +22 -0
- data/lib/refinery/version.rb +1 -1
- data/spec/lib/generators/refinery/engine/engine_generator_spec.rb +15 -0
- metadata +4 -4
@@ -70,9 +70,9 @@ init_modal_dialogs = function(){
|
|
70
70
|
height = parseInt($(href.match("height=([0-9]*)")).last().get(0), 10)||473,
|
71
71
|
title = $anchor.attr('title') || $anchor.attr('name') || $anchor.html() || null;
|
72
72
|
|
73
|
-
href = href.replace(/(\&(amp\;)?)
|
74
|
-
.replace(/(\&(amp\;)?)
|
75
|
-
.replace(/(\&(amp\;)?)
|
73
|
+
href = href.replace(/((\&(amp\;)?)|\?)dialog\=true/, '')
|
74
|
+
.replace(/((\&(amp\;)?)|\?)width\=\d+/, '')
|
75
|
+
.replace(/((\&(amp\;)?)|\?)height\=\d+/, '')
|
76
76
|
.replace(/(\?&(amp\;)?)/, '?')
|
77
77
|
.replace(/\?$/, '');
|
78
78
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
* http://mjsarfatti.com/sandbox/nestedSortable
|
5
5
|
*
|
6
6
|
* Depends:
|
7
|
-
*
|
7
|
+
* jquery.ui.sortable.js 1.8+
|
8
8
|
*
|
9
9
|
* License CC BY-SA 3.0
|
10
10
|
* Copyright 2010-2011, Manuele J Sarfatti
|
@@ -12,345 +12,345 @@
|
|
12
12
|
|
13
13
|
(function($) {
|
14
14
|
|
15
|
-
|
15
|
+
$.widget("ui.nestedSortable", $.extend({}, $.ui.sortable.prototype, {
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
17
|
+
options: {
|
18
|
+
tabSize: 20,
|
19
|
+
disableNesting: 'ui-nestedSortable-no-nesting',
|
20
|
+
errorClass: 'ui-nestedSortable-error',
|
21
|
+
listType: 'ol',
|
22
|
+
maxLevels: 0,
|
23
|
+
noJumpFix: 0
|
24
|
+
},
|
25
|
+
|
26
|
+
_create: function(){
|
27
|
+
if (this.noJumpFix == false)
|
28
|
+
this.element.height(this.element.height());
|
29
|
+
this.element.data('sortable', this.element.data('nestedSortable'));
|
30
|
+
return $.ui.sortable.prototype._create.apply(this, arguments);
|
31
|
+
},
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
_mouseDrag: function(event) {
|
36
|
+
|
37
|
+
//Compute the helpers position
|
38
|
+
this.position = this._generatePosition(event);
|
39
|
+
this.positionAbs = this._convertPositionTo("absolute");
|
40
|
+
|
41
|
+
if (!this.lastPositionAbs) {
|
42
|
+
this.lastPositionAbs = this.positionAbs;
|
43
|
+
}
|
44
|
+
|
45
|
+
//Do scrolling
|
46
|
+
if(this.options.scroll) {
|
47
|
+
var o = this.options, scrolled = false;
|
48
|
+
if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
|
49
|
+
|
50
|
+
if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
|
51
|
+
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
|
52
|
+
else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
|
53
|
+
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
|
54
|
+
|
55
|
+
if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
|
56
|
+
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
|
57
|
+
else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
|
58
|
+
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
|
59
|
+
|
60
|
+
} else {
|
61
|
+
|
62
|
+
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
|
63
|
+
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
|
64
|
+
else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
|
65
|
+
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
|
66
|
+
|
67
|
+
if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
|
68
|
+
scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
|
69
|
+
else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
|
70
|
+
scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
|
71
|
+
|
72
|
+
}
|
73
|
+
|
74
|
+
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
|
75
|
+
$.ui.ddmanager.prepareOffsets(this, event);
|
76
|
+
}
|
77
|
+
|
78
|
+
//Regenerate the absolute position used for position checks
|
79
|
+
this.positionAbs = this._convertPositionTo("absolute");
|
80
|
+
|
81
|
+
//Set the helper position
|
82
|
+
if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
|
83
|
+
if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
|
84
|
+
|
85
|
+
//Rearrange
|
86
|
+
for (var i = this.items.length - 1; i >= 0; i--) {
|
87
|
+
|
88
|
+
//Cache variables and intersection, continue if no intersection
|
89
|
+
var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
|
90
|
+
if (!intersection) continue;
|
91
|
+
|
92
|
+
if(itemElement != this.currentItem[0] //cannot intersect with itself
|
93
|
+
&& this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
|
94
|
+
&& !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
|
95
|
+
&& (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true)
|
96
|
+
//&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
|
97
|
+
) {
|
98
|
+
|
99
|
+
this.direction = intersection == 1 ? "down" : "up";
|
100
|
+
|
101
|
+
if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
|
102
|
+
this._rearrange(event, item);
|
103
|
+
} else {
|
104
|
+
break;
|
105
|
+
}
|
106
|
+
|
107
|
+
// Clear emtpy ul's/ol's
|
108
|
+
this._clearEmpty(itemElement);
|
109
|
+
|
110
|
+
this._trigger("change", event, this._uiHash());
|
111
|
+
break;
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
var parentItem = (this.placeholder[0].parentNode.parentNode && $(this.placeholder[0].parentNode.parentNode).closest('.ui-sortable').length) ? $(this.placeholder[0].parentNode.parentNode) : null;
|
116
|
+
var level = this._getLevel(this.placeholder);
|
117
|
+
var childLevels = this._getChildLevels(this.helper);
|
118
|
+
var previousItem = this.placeholder[0].previousSibling ? $(this.placeholder[0].previousSibling) : null;
|
119
|
+
if (previousItem != null) {
|
120
|
+
while (previousItem[0].nodeName.toLowerCase() != 'li' || previousItem[0] == this.currentItem[0]) {
|
121
|
+
if (previousItem[0].previousSibling) {
|
122
|
+
previousItem = $(previousItem[0].previousSibling);
|
123
|
+
} else {
|
124
|
+
previousItem = null;
|
125
|
+
break;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
newList = document.createElement(o.listType);
|
131
|
+
|
132
|
+
this.beyondMaxLevels = 0;
|
133
|
+
|
134
|
+
// If the item is moved to the left, send it to its parent level
|
135
|
+
if (parentItem != null && this.positionAbs.left < parentItem.offset().left) {
|
136
|
+
parentItem.after(this.placeholder[0]);
|
137
|
+
this._clearEmpty(parentItem[0]);
|
138
|
+
this._trigger("change", event, this._uiHash());
|
139
|
+
}
|
140
|
+
// If the item is below another one and is moved to the right, make it a children of it
|
141
|
+
else if (previousItem != null && this.positionAbs.left > previousItem.offset().left + o.tabSize) {
|
142
|
+
this._isAllowed(previousItem, level+childLevels+1);
|
143
|
+
if (!previousItem.children(o.listType).length) {
|
144
|
+
previousItem[0].appendChild(newList);
|
145
|
+
}
|
146
|
+
previousItem.children(o.listType)[0].appendChild(this.placeholder[0]);
|
147
|
+
this._trigger("change", event, this._uiHash());
|
148
|
+
}
|
149
|
+
else {
|
150
|
+
this._isAllowed(parentItem, level+childLevels);
|
151
|
+
}
|
152
|
+
|
153
|
+
//Post events to containers
|
154
|
+
this._contactContainers(event);
|
155
|
+
|
156
|
+
//Interconnect with droppables
|
157
|
+
if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
|
158
|
+
|
159
|
+
//Call callbacks
|
160
|
+
this._trigger('sort', event, this._uiHash());
|
161
|
+
|
162
|
+
this.lastPositionAbs = this.positionAbs;
|
163
|
+
return false;
|
164
|
+
|
165
|
+
},
|
166
|
+
|
167
|
+
_mouseStop: function(event, noPropagation) {
|
168
|
+
|
169
|
+
// If the item is in a position not allowed, send it back
|
170
|
+
if (this.beyondMaxLevels) {
|
171
|
+
var parent = this.placeholder.parent().closest(this.options.items);
|
172
|
+
|
173
|
+
for (var i = this.beyondMaxLevels - 1; i > 0; i--) {
|
174
|
+
parent = parent.parent().closest(this.options.items);
|
175
|
+
}
|
176
|
+
|
177
|
+
this.placeholder.removeClass(this.options.errorClass);
|
178
|
+
parent.after(this.placeholder);
|
179
|
+
this._trigger("change", event, this._uiHash());
|
180
|
+
}
|
181
|
+
|
182
|
+
$.ui.sortable.prototype._mouseStop.apply(this, arguments);
|
183
|
+
|
184
|
+
},
|
185
|
+
|
186
|
+
serialize: function(o) {
|
187
|
+
|
188
|
+
var items = this._getItemsAsjQuery(o && o.connected);
|
189
|
+
var str = []; o = o || {};
|
190
|
+
|
191
|
+
$(items).each(function() {
|
192
|
+
var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
|
193
|
+
var pid = ($(o.item || this).parent(o.listType).parent('li').attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
|
194
|
+
if(res) str.push((o.key || res[1]+'['+(o.key && o.expression ? res[1] : res[2])+']')+'='+(pid ? (o.key && o.expression ? pid[1] : pid[2]) : 'root'));
|
195
|
+
});
|
196
|
+
|
197
|
+
if(!str.length && o.key) {
|
198
|
+
str.push(o.key + '=');
|
199
|
+
}
|
200
|
+
|
201
|
+
return str.join('&');
|
202
|
+
|
203
|
+
},
|
204
|
+
|
205
|
+
toHierarchy: function(o) {
|
206
|
+
|
207
|
+
o = o || {};
|
208
|
+
var sDepth = o.startDepthCount || 0;
|
209
|
+
var ret = [];
|
210
|
+
|
211
|
+
$(this.element).children('li').each(function() {
|
212
|
+
var level = _recursiveItems($(this));
|
213
|
+
ret.push(level);
|
214
|
+
});
|
215
|
+
|
216
|
+
return ret;
|
217
|
+
|
218
|
+
function _recursiveItems(li) {
|
219
|
+
var id = ($(li).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
|
220
|
+
if (id != null) {
|
221
|
+
var item = {"id" : id[2]};
|
222
|
+
if ($(li).children(o.listType).children('li').length > 0) {
|
223
|
+
item.children = [];
|
224
|
+
$(li).children(o.listType).children('li').each(function () {
|
225
|
+
var level = _recursiveItems($(this));
|
226
|
+
item.children.push(level);
|
227
|
+
});
|
228
|
+
}
|
229
|
+
return item;
|
230
|
+
}
|
231
|
+
}
|
232
232
|
},
|
233
233
|
|
234
|
-
|
234
|
+
toArray: function(o) {
|
235
235
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
236
|
+
o = o || {};
|
237
|
+
var sDepth = o.startDepthCount || 0;
|
238
|
+
var ret = [];
|
239
|
+
var left = 2;
|
240
240
|
|
241
|
-
|
241
|
+
ret.push({"item_id": 'root', "parent_id": 'none', "depth": sDepth, "left": '1', "right": ($('li', this.element).length + 1) * 2});
|
242
242
|
|
243
|
-
|
244
|
-
|
245
|
-
|
243
|
+
$(this.element).children('li').each(function () {
|
244
|
+
left = _recursiveArray(this, sDepth + 1, left);
|
245
|
+
});
|
246
246
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
247
|
+
function _sortByLeft(a,b) {
|
248
|
+
return a['left'] - b['left'];
|
249
|
+
}
|
250
|
+
ret = ret.sort(_sortByLeft);
|
251
251
|
|
252
|
-
|
252
|
+
return ret;
|
253
253
|
|
254
|
-
|
254
|
+
function _recursiveArray(item, depth, left) {
|
255
255
|
|
256
|
-
|
256
|
+
right = left + 1;
|
257
257
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
258
|
+
if ($(item).children(o.listType).children('li').length > 0) {
|
259
|
+
depth ++;
|
260
|
+
$(item).children(o.listType).children('li').each(function () {
|
261
|
+
right = _recursiveArray($(this), depth, right);
|
262
|
+
});
|
263
|
+
depth --;
|
264
|
+
}
|
265
265
|
|
266
|
-
|
266
|
+
id = ($(item).attr(o.attribute || 'id')).match(o.expression || (/(.+)[-=_](.+)/));
|
267
267
|
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
268
|
+
if (depth === sDepth + 1) pid = 'root';
|
269
|
+
else {
|
270
|
+
parentItem = ($(item).parent(o.listType).parent('li').attr('id')).match(o.expression || (/(.+)[-=_](.+)/));
|
271
|
+
pid = parentItem[2];
|
272
|
+
}
|
273
273
|
|
274
|
-
|
275
|
-
|
276
|
-
|
274
|
+
if (id != null) {
|
275
|
+
ret.push({"item_id": id[2], "parent_id": pid, "depth": depth, "left": left, "right": right});
|
276
|
+
}
|
277
277
|
|
278
|
-
|
279
|
-
|
278
|
+
return left = right + 1;
|
279
|
+
}
|
280
280
|
|
281
|
-
|
281
|
+
},
|
282
282
|
|
283
|
-
|
283
|
+
_clear: function(event, noPropagation) {
|
284
284
|
|
285
|
-
|
285
|
+
$.ui.sortable.prototype._clear.apply(this, arguments);
|
286
286
|
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
287
|
+
// Clean last empty ul/ol
|
288
|
+
for (var i = this.items.length - 1; i >= 0; i--) {
|
289
|
+
var item = this.items[i].item[0];
|
290
|
+
this._clearEmpty(item);
|
291
|
+
}
|
292
|
+
return true;
|
293
293
|
|
294
|
-
|
294
|
+
},
|
295
295
|
|
296
|
-
|
296
|
+
_clearEmpty: function(item) {
|
297
297
|
|
298
|
-
|
299
|
-
|
300
|
-
|
298
|
+
if (item.children[1] && item.children[1].children.length == 0) {
|
299
|
+
item.removeChild(item.children[1]);
|
300
|
+
}
|
301
301
|
|
302
|
-
|
302
|
+
},
|
303
303
|
|
304
|
-
|
304
|
+
_getLevel: function(item) {
|
305
305
|
|
306
|
-
|
306
|
+
var level = 1;
|
307
307
|
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
308
|
+
if (this.options.listType) {
|
309
|
+
var list = item.closest(this.options.listType);
|
310
|
+
while (!list.is('.ui-sortable')/* && level < this.options.maxLevels*/) {
|
311
|
+
level++;
|
312
|
+
list = list.parent().closest(this.options.listType);
|
313
|
+
}
|
314
|
+
}
|
315
315
|
|
316
|
-
|
317
|
-
|
316
|
+
return level;
|
317
|
+
},
|
318
318
|
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
319
|
+
_getChildLevels: function(parent, depth) {
|
320
|
+
var self = this,
|
321
|
+
o = this.options,
|
322
|
+
result = 0;
|
323
|
+
depth = depth || 0;
|
324
324
|
|
325
|
-
|
326
|
-
|
327
|
-
|
325
|
+
$(parent).children(o.listType).children(o.items).each(function (index, child) {
|
326
|
+
result = Math.max(self._getChildLevels(child, depth + 1), result);
|
327
|
+
});
|
328
328
|
|
329
|
-
|
330
|
-
|
329
|
+
return depth ? result + 1 : result;
|
330
|
+
},
|
331
331
|
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
})(jQuery);
|
332
|
+
_isAllowed: function(parentItem, levels) {
|
333
|
+
var o = this.options
|
334
|
+
// Are we trying to nest under a no-nest or are we nesting too deep?
|
335
|
+
if (parentItem == null || !(parentItem.hasClass(o.disableNesting))) {
|
336
|
+
if (o.maxLevels < levels && o.maxLevels != 0) {
|
337
|
+
this.placeholder.addClass(o.errorClass);
|
338
|
+
this.beyondMaxLevels = levels - o.maxLevels;
|
339
|
+
} else {
|
340
|
+
this.placeholder.removeClass(o.errorClass);
|
341
|
+
this.beyondMaxLevels = 0;
|
342
|
+
}
|
343
|
+
} else {
|
344
|
+
this.placeholder.addClass(o.errorClass);
|
345
|
+
if (o.maxLevels < levels && o.maxLevels != 0) {
|
346
|
+
this.beyondMaxLevels = levels - o.maxLevels;
|
347
|
+
} else {
|
348
|
+
this.beyondMaxLevels = 1;
|
349
|
+
}
|
350
|
+
}
|
351
|
+
}
|
352
|
+
|
353
|
+
}));
|
354
|
+
|
355
|
+
$.ui.nestedSortable.prototype.options = $.extend({}, $.ui.sortable.prototype.options, $.ui.nestedSortable.prototype.options);
|
356
|
+
})(jQuery);
|
@@ -230,6 +230,9 @@ a:hover {
|
|
230
230
|
padding: 0px;
|
231
231
|
a {
|
232
232
|
border-bottom: 1px dotted #727272;
|
233
|
+
&.locale {
|
234
|
+
border-bottom: 0;
|
235
|
+
}
|
233
236
|
}
|
234
237
|
h1 {
|
235
238
|
font-size: 18px;
|
@@ -1565,4 +1568,4 @@ a.information:hover {
|
|
1565
1568
|
}
|
1566
1569
|
.ie8 .pagination a, .ie8 #content .pagination a, .ie8 .pagination .current, .ie8 .disabled, .ie8 .pagination em {
|
1567
1570
|
padding-bottom: 6px;
|
1568
|
-
}
|
1571
|
+
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
<%= render
|
1
|
+
<%= render '/refinery/message' if request.xhr? %>
|
2
2
|
<%= yield %>
|
@@ -2,4 +2,4 @@
|
|
2
2
|
:hide_sections => local_assigns[:hide_sections],
|
3
3
|
:can_use_fallback => !local_assigns[:show_empty_sections] && !local_assigns[:remove_automatic_sections]
|
4
4
|
}) %>
|
5
|
-
<%= render
|
5
|
+
<%= render '/refinery/draft_page_message' unless @page.nil? or @page.live? -%>
|
@@ -2,9 +2,9 @@
|
|
2
2
|
<meta charset='<%= Rails.application.config.encoding %>' />
|
3
3
|
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><![endif]-->
|
4
4
|
<title><%= browser_title(yield(:title)) %></title>
|
5
|
-
<%= raw
|
6
|
-
<%= raw
|
7
|
-
<%= raw
|
5
|
+
<%= raw %(<meta name="description" content="#{@meta.meta_description}" />) if @meta.meta_description.present? -%>
|
6
|
+
<%= raw %(<meta name="keywords" content="#{@meta.meta_keywords}">) if @meta.meta_keywords.present? -%>
|
7
|
+
<%= raw %(<link rel="canonical" content="#{@canonical}" />) if @canonical.present? -%>
|
8
8
|
<%= csrf_meta_tags if Refinery::Core.authenticity_token_on_frontend -%>
|
9
9
|
<%= yield :meta %>
|
10
10
|
|
data/lib/generators/refinery/engine/templates/app/models/refinery/namespace/singular_name.rb
CHANGED
@@ -14,13 +14,12 @@ module Refinery
|
|
14
14
|
<% end -%>
|
15
15
|
<% if (string_attributes = attributes.select{ |a| a.type.to_s =~ /string|text/ }.uniq).any? -%>
|
16
16
|
|
17
|
-
attr_accessible <%=
|
17
|
+
attr_accessible <%= attributes.map { |attr| ":#{attr.name}" }.join(', ') %>, :position
|
18
18
|
|
19
19
|
acts_as_indexed :fields => <%= string_attributes.map{|s| s.name.to_sym}.inspect %>
|
20
20
|
|
21
21
|
validates <%= string_attributes.first.name.to_sym.inspect %>, :presence => true, :uniqueness => true
|
22
22
|
<% else -%>
|
23
|
-
|
24
23
|
# def title was created automatically because you didn't specify a string field
|
25
24
|
# when you ran the refinery:engine generator. <3 <3 Refinery CMS.
|
26
25
|
def title
|
@@ -34,6 +33,7 @@ module Refinery
|
|
34
33
|
<% attributes.select{|a| a.type.to_s == 'resource'}.uniq.each do |a| -%>
|
35
34
|
|
36
35
|
belongs_to :<%= a.name.gsub("_id", "") %>, :class_name => '::Refinery::Resource'
|
36
|
+
|
37
37
|
<% end -%>
|
38
38
|
end
|
39
39
|
end
|
data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/plural_name/show.html.erb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
<%%= @<%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>.<%= title.name %><% else %>.title<% end %> %>
|
3
3
|
<%% end %>
|
4
4
|
|
5
|
-
<%% content_for :
|
5
|
+
<%% content_for :body do %>
|
6
6
|
<% attributes.each do |attribute| -%>
|
7
7
|
<section>
|
8
8
|
<h1><%= attribute.name.titleize %></h1>
|
@@ -23,7 +23,7 @@
|
|
23
23
|
<% end -%>
|
24
24
|
<%% end %>
|
25
25
|
|
26
|
-
<%% content_for :
|
26
|
+
<%% content_for :side_body do %>
|
27
27
|
<aside>
|
28
28
|
<h2><%%= t('.other') %></h2>
|
29
29
|
<ul id="<%= plural_name %>">
|
@@ -1,23 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
(Refinery.i18n_enabled? ? Refinery::I18n.frontend_locales : [:en]).each do |lang|
|
2
|
+
I18n.locale = lang
|
3
|
+
|
4
|
+
if defined?(Refinery::User)
|
5
|
+
Refinery::User.all.each do |user|
|
6
|
+
if user.plugins.where(:name => 'refinerycms-<%= namespacing.underscore %>').blank?
|
7
|
+
user.plugins.create(:name => 'refinerycms-<%= namespacing.underscore %>',
|
8
|
+
:position => (user.plugins.maximum(:position) || -1) +1)
|
9
|
+
end
|
6
10
|
end
|
7
11
|
end
|
8
|
-
end
|
9
12
|
|
10
|
-
<% unless skip_frontend?
|
11
|
-
url = "/<%= [(namespacing.underscore if namespacing.underscore != plural_name), plural_name].compact.join('/') %>"
|
12
|
-
if defined?(
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
<% unless skip_frontend? -%>
|
14
|
+
url = "/<%= [(namespacing.underscore if namespacing.underscore != plural_name), plural_name].compact.join('/') %>"
|
15
|
+
if defined?(Refinery::Page) && Refinery::Page.where(:link_url => url).empty?
|
16
|
+
page = Refinery::Page.create(
|
17
|
+
:title => '<%= class_name.pluralize.underscore.titleize %>',
|
18
|
+
:link_url => url,
|
19
|
+
:deletable => false,
|
20
|
+
:menu_match => "^#{url}(\/|\/.+?|)$"
|
21
|
+
)
|
22
|
+
Refinery::Pages.default_parts.each_with_index do |default_page_part, index|
|
23
|
+
page.parts.create(:title => default_page_part, :body => nil, :position => index)
|
24
|
+
end
|
21
25
|
end
|
26
|
+
<% end -%>
|
22
27
|
end
|
23
|
-
<% end %>
|
@@ -2,13 +2,13 @@ def setup_environment
|
|
2
2
|
# Configure Rails Environment
|
3
3
|
ENV["RAILS_ENV"] ||= 'test'
|
4
4
|
|
5
|
-
if File.exist?(dummy_path = File.expand_path('../
|
5
|
+
if File.exist?(dummy_path = File.expand_path('../dummy/config/environment.rb', __FILE__))
|
6
6
|
require dummy_path
|
7
7
|
elsif File.dirname(__FILE__) =~ %r{vendor/extensions}
|
8
8
|
# Require the path to the refinerycms application this is vendored inside.
|
9
9
|
require File.expand_path('../../../../../config/environment', __FILE__)
|
10
10
|
else
|
11
|
-
raise "Could not find a config/environment.rb file to require. Please specify this in
|
11
|
+
raise "Could not find a config/environment.rb file to require. Please specify this in #{File.expand_path(__FILE__)}"
|
12
12
|
end
|
13
13
|
|
14
14
|
require 'rspec/rails'
|
@@ -3,11 +3,13 @@ module Refinery
|
|
3
3
|
class <%= class_name %> < Refinery::Core::BaseModel
|
4
4
|
<% if table_name == namespacing.underscore.pluralize -%>
|
5
5
|
self.table_name = 'refinery_<%= plural_name %>'
|
6
|
-
<% end
|
7
|
-
|
6
|
+
<% end %>
|
7
|
+
attr_accessible <%= attributes.map { |attr| ":#{attr.name}" }.join(', ') %>, :position
|
8
|
+
|
9
|
+
<% if (text_or_string_fields = attributes.map{ |a| a.name if a.type.to_s =~ /string|text/ }.compact.uniq).any? -%>
|
8
10
|
acts_as_indexed :fields => [:<%= text_or_string_fields.join(", :") %>]
|
9
11
|
<% end -%>
|
10
|
-
<% if (text_fields = attributes.map {|a| a.name if a.type.to_s == 'text'}.compact.uniq).any? && text_fields.detect{|a| a.to_s == 'message'}.nil?
|
12
|
+
<% if (text_fields = attributes.map {|a| a.name if a.type.to_s == 'text'}.compact.uniq).any? && text_fields.detect{|a| a.to_s == 'message'}.nil? -%>
|
11
13
|
alias_attribute :message, :<%= text_fields.first %>
|
12
14
|
<% elsif text_fields.empty? %>
|
13
15
|
# def message was created automatically because you didn't specify a text field
|
@@ -1,27 +1,31 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
(Refinery.i18n_enabled? ? Refinery::I18n.frontend_locales : [:en]).each do |lang|
|
2
|
+
I18n.locale = lang
|
3
|
+
|
4
|
+
if defined?(Refinery::User)
|
5
|
+
Refinery::User.all.each do |user|
|
6
|
+
if user.plugins.find_by_name('<%= plural_name %>').nil?
|
7
|
+
user.plugins.create(:name => "<%= plural_name %>",
|
8
|
+
:position => (user.plugins.maximum(:position) || -1) +1)
|
9
|
+
end
|
6
10
|
end
|
7
11
|
end
|
8
|
-
end
|
9
12
|
|
10
|
-
if defined?(
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
13
|
+
if defined?(Refinery::Page)
|
14
|
+
page = Refinery::Page.create(
|
15
|
+
:title => "<%= class_name.pluralize.underscore.titleize %>",
|
16
|
+
:link_url => "/<%= plural_name %>/new",
|
17
|
+
:deletable => false,
|
18
|
+
:menu_match => "^/<%= plural_name %>(\/|\/.+?|)$"
|
19
|
+
)
|
20
|
+
thank_you_page = page.children.create(
|
21
|
+
:title => "Thank You",
|
22
|
+
:link_url => "/<%= plural_name %>/thank_you",
|
23
|
+
:deletable => false,
|
24
|
+
:show_in_menu => false
|
25
|
+
)
|
26
|
+
Refinery::Pages.default_parts.each do |default_page_part|
|
27
|
+
page.parts.create(:title => default_page_part, :body => nil)
|
28
|
+
thank_you_page.parts.create(:title => default_page_part, :body => nil)
|
29
|
+
end
|
26
30
|
end
|
27
31
|
end
|
data/lib/refinery/activity.rb
CHANGED
@@ -9,6 +9,7 @@ module Refinery
|
|
9
9
|
# Total number of activies to show for a given class of activity
|
10
10
|
attr_accessor :limit
|
11
11
|
|
12
|
+
# Other objects, like parents, to include in the nesting structure
|
12
13
|
attr_accessor :nested_with
|
13
14
|
|
14
15
|
# SQL order by string to specify how to order the activities in the activity feed for
|
@@ -21,6 +22,10 @@ module Refinery
|
|
21
22
|
# Image asset to use to represent updated instance of the class thisa activity represents
|
22
23
|
attr_accessor :updated_image
|
23
24
|
|
25
|
+
# Boolean; whether or not to use the record itself when constructing the nesting
|
26
|
+
# Default true
|
27
|
+
attr_accessor :use_record_in_nesting
|
28
|
+
|
24
29
|
# Creates a new instance of Activity for a registered Refinery Plugin. An optional
|
25
30
|
# hash of options can be specified to customize the values of each attribute
|
26
31
|
# accessor defined on this class. Each key specified in the options hash should be a
|
@@ -31,7 +36,8 @@ module Refinery
|
|
31
36
|
# Activity.new(:limit => 10, :title => "Newest Activity!")
|
32
37
|
#
|
33
38
|
# Warning:
|
34
|
-
# for the nested_with option, pass in the reverse order of ancestry
|
39
|
+
# for the nested_with option, pass in the reverse order of ancestry
|
40
|
+
# e.g. [parent.parent_of_parent, parent]
|
35
41
|
def initialize(options = {})
|
36
42
|
{
|
37
43
|
:class_name => nil,
|
@@ -43,7 +49,8 @@ module Refinery
|
|
43
49
|
:title => "title",
|
44
50
|
:updated_image => "edit.png",
|
45
51
|
:url => nil,
|
46
|
-
:url_prefix => "edit"
|
52
|
+
:url_prefix => "edit",
|
53
|
+
:use_record_in_nesting => true
|
47
54
|
}.merge(options).each { |key, value| self.send(:"#{key}=", value) }
|
48
55
|
end
|
49
56
|
|
@@ -80,11 +87,15 @@ module Refinery
|
|
80
87
|
end
|
81
88
|
|
82
89
|
# to use in a URL like edit_refinery_admin_group_individuals_path(record.group, record)
|
83
|
-
# which will help you if you're using nested
|
90
|
+
# which will help you if you're using nested routes.
|
84
91
|
def nesting(record_string = "record")
|
85
|
-
|
86
|
-
|
87
|
-
|
92
|
+
@nesting ||= begin
|
93
|
+
chain = self.nested_with.inject([]) { |nest_chain, nesting|
|
94
|
+
nest_chain << "#{record_string}.#{nesting}"
|
95
|
+
}
|
96
|
+
chain << record_string if self.use_record_in_nesting
|
97
|
+
chain.join(',')
|
98
|
+
end
|
88
99
|
end
|
89
100
|
|
90
101
|
attr_writer :url_prefix
|
data/lib/refinery/cli.rb
CHANGED
@@ -67,7 +67,7 @@ module Refinery
|
|
67
67
|
puts "Couldn't match any model files in any extensions like #{model}"
|
68
68
|
end
|
69
69
|
elsif (javascripts = env["javascript"]).present?
|
70
|
-
pattern = "#{javascripts.split("/").join(File::SEPARATOR)}*.js"
|
70
|
+
pattern = "#{javascripts.split("/").join(File::SEPARATOR)}*.js{,.*}"
|
71
71
|
looking_for = ::Refinery::Plugins.registered.pathnames.map{|p| p.join("app", "assets", "javascripts", pattern).to_s}
|
72
72
|
|
73
73
|
# copy in the matches
|
@@ -139,6 +139,7 @@ module Refinery
|
|
139
139
|
reject_template?(f)
|
140
140
|
}.sort.each do |path|
|
141
141
|
if (template_path = extension_path_for(path, extension_name)).present?
|
142
|
+
next if path.to_s =~ /seeds.rb/
|
142
143
|
template path, template_path
|
143
144
|
end
|
144
145
|
end
|
@@ -209,6 +210,27 @@ module Refinery
|
|
209
210
|
end
|
210
211
|
end
|
211
212
|
|
213
|
+
def copy_or_merge_seeds!
|
214
|
+
source_seed_file = source_pathname.join("db/seeds.rb")
|
215
|
+
destination_seed_file = destination_pathname.join(extension_path_for(source_seed_file, extension_name))
|
216
|
+
|
217
|
+
if existing_extension?
|
218
|
+
# create temp seeds file
|
219
|
+
temp_seed_file = destination_pathname.join(extension_path_for("tmp/seeds.rb", extension_name))
|
220
|
+
|
221
|
+
# copy/evaluate seeds template to temp file
|
222
|
+
template source_seed_file, temp_seed_file, :verbose => false
|
223
|
+
|
224
|
+
# append temp seeds file content to extension seeds file
|
225
|
+
destination_seed_file.open('a+') { |file| file.puts temp_seed_file.read.to_s }
|
226
|
+
|
227
|
+
# remove temp file
|
228
|
+
FileUtils.rm_rf temp_seed_file
|
229
|
+
else
|
230
|
+
template source_seed_file, destination_seed_file
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
212
234
|
def puts_instructions!
|
213
235
|
unless Rails.env.test?
|
214
236
|
puts "------------------------"
|
data/lib/refinery/version.rb
CHANGED
@@ -80,5 +80,20 @@ module Refinery
|
|
80
80
|
end
|
81
81
|
}
|
82
82
|
end
|
83
|
+
|
84
|
+
context "when generating extension inside existing extensions dir" do
|
85
|
+
before do
|
86
|
+
Refinery::EngineGenerator.any_instance.stub(:merge_locales!).and_return(true)
|
87
|
+
Refinery::EngineGenerator.any_instance.stub(:existing_extension?).and_return(true)
|
88
|
+
|
89
|
+
run_generator %w{ rspec_item_test title:string --extension rspec_product_tests --skip }
|
90
|
+
end
|
91
|
+
|
92
|
+
it "appends existing seeds file" do
|
93
|
+
File.open("#{destination_root}/vendor/extensions/rspec_product_tests/db/seeds.rb") do |file|
|
94
|
+
file.grep(%r{/rspec_product_tests|/rspec_item_tests}).count.should eq(2)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
83
98
|
end
|
84
99
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2012-
|
16
|
+
date: 2012-06-11 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: acts_as_indexed
|
@@ -698,7 +698,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
698
698
|
version: '0'
|
699
699
|
segments:
|
700
700
|
- 0
|
701
|
-
hash:
|
701
|
+
hash: 753990109908748551
|
702
702
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
703
703
|
none: false
|
704
704
|
requirements:
|
@@ -707,7 +707,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
707
707
|
version: '0'
|
708
708
|
segments:
|
709
709
|
- 0
|
710
|
-
hash:
|
710
|
+
hash: 753990109908748551
|
711
711
|
requirements: []
|
712
712
|
rubyforge_project: refinerycms
|
713
713
|
rubygems_version: 1.8.22
|