tb_cms 1.2.3 → 1.3.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/app/assets/javascripts/admin/cms/menu_items.js +39 -17
- data/app/assets/stylesheets/admin/cms/application.css +11 -0
- data/app/controllers/admin/menu_items_controller.rb +103 -113
- data/app/controllers/admin/menus_controller.rb +52 -53
- data/app/controllers/admin/pages_controller.rb +107 -111
- data/app/controllers/admin/snippets_controller.rb +16 -16
- data/app/controllers/cms/sitemaps_controller.rb +5 -5
- data/app/controllers/pages_controller.rb +30 -34
- data/app/helpers/cms/application_helper.rb +184 -212
- data/app/models/concerns/cms_deprecated_multisite.rb +3 -3
- data/app/models/spud_menu.rb +4 -4
- data/app/models/spud_menu_item.rb +58 -61
- data/app/models/spud_page.rb +63 -67
- data/app/models/spud_page_partial.rb +42 -44
- data/app/models/spud_page_partial_revision.rb +3 -3
- data/app/models/spud_snippet.rb +7 -7
- data/app/views/admin/menu_items/index.html.erb +1 -1
- data/lib/generators/spud/cms/layout_generator.rb +8 -8
- data/lib/spud_cms/configuration.rb +10 -10
- data/lib/spud_cms/engine.rb +28 -28
- data/lib/spud_cms/liquid_snippet.rb +5 -7
- data/lib/spud_cms/page_route.rb +1 -1
- data/lib/spud_cms/template_parser.rb +35 -40
- data/lib/spud_cms/test_files.rb +6 -6
- data/lib/spud_cms/version.rb +3 -3
- data/spec/controllers/admin/menu_items_controller_spec.rb +54 -56
- data/spec/controllers/admin/menus_controller_spec.rb +31 -37
- data/spec/controllers/admin/pages_controller_spec.rb +31 -36
- data/spec/controllers/admin/snippets_controller_spec.rb +1 -1
- data/spec/controllers/pages_controller_spec.rb +21 -21
- data/spec/dummy/config/application.rb +3 -4
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/environments/production.rb +1 -1
- data/spec/dummy/config/environments/test.rb +3 -3
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/db/migrate/20141231214447_create_spud_users.tb_core.rb +12 -12
- data/spec/dummy/db/migrate/20141231214448_add_time_zone_to_spud_user.tb_core.rb +0 -1
- data/spec/dummy/db/migrate/20141231214449_add_scope_to_spud_admin_permissions.tb_core.rb +0 -1
- data/spec/dummy/db/migrate/20141231214452_create_spud_permissions.tb_core.rb +3 -3
- data/spec/dummy/db/migrate/20141231214453_create_spud_role_permissions.tb_core.rb +2 -2
- data/spec/dummy/db/migrate/20141231214455_create_spud_permalinks.tb_permalinks.rb +1 -1
- data/spec/dummy/db/migrate/20141231214456_add_site_id_to_spud_permalinks.tb_permalinks.rb +1 -1
- data/spec/dummy/db/migrate/20141231214457_modify_site_id_for_spud_permalinks.tb_permalinks.rb +4 -4
- data/spec/dummy/db/migrate/20141231214459_create_spud_pages.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214461_create_spud_menu_items.tb_cms.rb +3 -3
- data/spec/dummy/db/migrate/20141231214463_create_spud_page_partials.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214464_add_visibility_to_spud_pages.tb_cms.rb +2 -2
- data/spec/dummy/db/migrate/20141231214466_add_use_custom_url_name_to_spud_pages.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214468_add_menu_id_to_spud_menu_items.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214469_add_classes_to_spud_menu_items.tb_cms.rb +0 -1
- data/spec/dummy/db/migrate/20141231214470_add_site_id_to_spud_pages.tb_cms.rb +2 -2
- data/spec/dummy/db/migrate/20141231214471_add_site_id_to_spud_templates.tb_cms.rb +2 -2
- data/spec/dummy/db/migrate/20141231214472_add_site_id_to_spud_menus.tb_cms.rb +2 -2
- data/spec/dummy/db/migrate/20141231214473_create_spud_page_partial_revisions.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214475_modify_site_id_for_spud_pages.tb_cms.rb +8 -8
- data/spec/dummy/db/migrate/20141231214478_create_spud_page_liquid_tags.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214479_create_spud_snippets.tb_cms.rb +1 -2
- data/spec/dummy/db/migrate/20141231214480_change_liquid_tags_to_polymorphic.tb_cms.rb +2 -2
- data/spec/dummy/db/migrate/20141231214481_drop_spud_page_liquid_tags.tb_cms.rb +6 -8
- data/spec/dummy/db/migrate/20150108164814_remove_site_id_from_cms_tables.tb_cms.rb +1 -0
- data/spec/dummy/db/migrate/20150911185843_add_requires_password_change_to_spud_users.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20160215180157_create_tb_redirects.tb_redirects.rb +3 -3
- data/spec/dummy/db/schema.rb +142 -153
- data/spec/dummy/script/rails +2 -2
- data/spec/helpers/cms/application_helper_spec.rb +39 -41
- data/spec/models/spud_menu_item_spec.rb +13 -13
- data/spec/models/spud_page_partial_revision_spec.rb +1 -1
- data/spec/models/spud_page_partial_spec.rb +19 -20
- data/spec/models/spud_page_spec.rb +90 -91
- data/spec/models/spud_snippet_spec.rb +1 -1
- data/spec/rails_helper.rb +12 -6
- data/spec/spec_helper.rb +42 -44
- metadata +64 -38
- data/spec/authlogic_helper.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de4396854d57732f8a52e8efbace10d73fdcaded
|
4
|
+
data.tar.gz: 93a220547d65d8c0a94fb9123ae346409a782391
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8857e4dabfd684a60633fa40e179a1c596cc2efa9d3c5ad9485020e37959bcfdff74971aa1faf41d18ed01900b04ccfca81d8ad7cdbe78e6a6dda82c063cb737
|
7
|
+
data.tar.gz: 673da85578b647fe67ce656dea4908d42658d274f6157759834d97acf703978df27166926cc1d28a157800758aecc22657f4854289608a1ffa41a194efb35e2c
|
data/Rakefile
CHANGED
@@ -20,7 +20,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
20
20
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
21
|
end
|
22
22
|
|
23
|
-
APP_RAKEFILE = File.expand_path(
|
23
|
+
APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
|
24
24
|
load 'rails/tasks/engine.rake'
|
25
25
|
|
26
26
|
Bundler::GemHelper.install_tasks
|
@@ -2,44 +2,66 @@ spud.admin.cms.menu_items = {};
|
|
2
2
|
|
3
3
|
(function() {
|
4
4
|
var menu_items = spud.admin.cms.menu_items;
|
5
|
+
var val;
|
6
|
+
|
7
|
+
var setUrl = function(){
|
8
|
+
return '/admin/menus/'+ val +'/menu_items/update_sort';
|
9
|
+
};
|
5
10
|
|
6
|
-
|
7
|
-
|
8
|
-
|
11
|
+
var fixHelper = function(e, ui) {
|
12
|
+
ui.children().each(function() {
|
13
|
+
$(this).width($(this).width());
|
14
|
+
});
|
15
|
+
return ui;
|
16
|
+
};
|
17
|
+
|
18
|
+
menu_items.updateStatus = function(delay, shadow) {
|
19
|
+
if(!delay) { //Default 300ms delay if not provided
|
20
|
+
delay = 300;
|
21
|
+
}
|
22
|
+
setTimeout(function() {
|
23
|
+
$('.detail-wrapper').css({
|
24
|
+
boxShadow: shadow
|
25
|
+
});
|
26
|
+
}, delay);
|
9
27
|
};
|
10
28
|
|
11
|
-
var sortableIcons = function(){
|
29
|
+
var sortableIcons = function() {
|
12
30
|
$("#sort tbody").sortable({
|
13
31
|
update : function(e, ui) {
|
14
32
|
var sortArr = [];
|
15
33
|
$("#sort tbody > tr > input").each(function() {
|
16
34
|
sortArr.push($(this).attr('value'));
|
17
35
|
});
|
18
|
-
|
36
|
+
val = $("#menu-id").val();
|
37
|
+
//Update order of menuItems
|
19
38
|
$.ajax(setUrl(), {
|
20
39
|
method: 'PUT',
|
21
|
-
data: {
|
40
|
+
data: {
|
41
|
+
order: sortArr
|
42
|
+
},
|
22
43
|
dataType: "json",
|
23
44
|
success: function(data, status, jqXHR) {
|
24
|
-
|
45
|
+
menu_items.updateStatus(200, '0px 0px 26px 2px rgba(4, 252, -49, 0.59)');
|
25
46
|
},
|
26
|
-
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
27
|
-
|
47
|
+
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
48
|
+
menu_items.updateStatus(100, '0px 0px 26px 2px rgba(255, 0, 40, 0.59)');
|
49
|
+
alert("Status: " + textStatus); alert("Error: " + errorThrown);
|
28
50
|
}
|
29
51
|
});
|
30
52
|
}
|
31
53
|
});
|
32
54
|
};
|
33
55
|
|
34
|
-
|
35
|
-
|
36
|
-
|
56
|
+
menu_items.init = function() {
|
57
|
+
$("#sort tbody").sortable({
|
58
|
+
helper: fixHelper,
|
59
|
+
cursor: "move",
|
60
|
+
activate: function( event, ui ) {
|
61
|
+
menu_items.updateStatus(100, '0px 0px 26px 2px rgba(4, 252, 255, 0.59)');
|
62
|
+
}
|
37
63
|
});
|
38
|
-
|
39
|
-
};
|
40
|
-
|
41
|
-
var setUrl = function(){
|
42
|
-
return '/admin/menus/'+$("#menu-id").val()+'/menu_items/update_sort';
|
64
|
+
sortableIcons();
|
43
65
|
};
|
44
66
|
|
45
67
|
})();
|
@@ -1,116 +1,106 @@
|
|
1
1
|
class Admin::MenuItemsController < Admin::ApplicationController
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
@menu_item = SpudMenuItem.where(:id =>params[:id]).first
|
106
|
-
if @menu_item.blank?
|
107
|
-
flash[:error] = "Menu Item not found!"
|
108
|
-
redirect_to admin_menu_menu_items_url() and return false
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
def menu_item_params
|
113
|
-
params.require(:spud_menu_item).permit(:name, :parent_type, :parent_id, :item_type, :spud_page_id, :menu_order, :url, :classes)
|
114
|
-
end
|
2
|
+
add_breadcrumb 'Menus', :admin_menus_path
|
3
|
+
belongs_to_app :menus, page_title: 'Menu Items'
|
4
|
+
before_action :load_menu
|
5
|
+
before_action :load_menu_item, only: [:edit, :update, :show, :destroy, :reorder]
|
6
|
+
|
7
|
+
def index
|
8
|
+
@menu_items = @menu.spud_menu_items.order(:menu_order).includes(:spud_menu_items)
|
9
|
+
respond_with @menu_items
|
10
|
+
end
|
11
|
+
|
12
|
+
def new
|
13
|
+
add_breadcrumb 'New', :new_admin_page_path
|
14
|
+
|
15
|
+
@menu_item = @menu.spud_menu_items.new
|
16
|
+
respond_with @menu_item
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
add_breadcrumb 'New', :new_admin_page_path
|
21
|
+
@menu_item = SpudMenuItem.new(menu_item_params)
|
22
|
+
@menu_item.spud_menu_id = @menu.id
|
23
|
+
if params[:spud_menu_item][:parent_id].blank?
|
24
|
+
@menu_item.parent_id = @menu.id
|
25
|
+
@menu_item.parent_type = 'SpudMenu'
|
26
|
+
else
|
27
|
+
@menu_item.parent_type = 'SpudMenuItem'
|
28
|
+
end
|
29
|
+
if @menu_item.name.blank? && !@menu_item.spud_page.blank?
|
30
|
+
@menu_item.name = @menu_item.spud_page.name
|
31
|
+
end
|
32
|
+
if @menu_item.menu_order.blank?
|
33
|
+
highest_sibling = @menu_item.parent.spud_menu_items.order('menu_order desc').first
|
34
|
+
unless highest_sibling.blank?
|
35
|
+
@menu_item.menu_order = highest_sibling.menu_order + 1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
flash[:notice] = 'Menu Created successfully!' if @menu_item.save
|
39
|
+
|
40
|
+
respond_with @menu_item, location: admin_menu_menu_items_url
|
41
|
+
end
|
42
|
+
|
43
|
+
def edit
|
44
|
+
add_breadcrumb "Edit #{@menu_item.name}", :edit_admin_menu_menu_item_path
|
45
|
+
@menu_item.parent_id = nil if @menu_item.parent_type == 'SpudMenu'
|
46
|
+
respond_with @menu_item
|
47
|
+
end
|
48
|
+
|
49
|
+
def update
|
50
|
+
add_breadcrumb "Edit #{@menu_item.name}", :edit_admin_menu_menu_item_path
|
51
|
+
if params[:spud_menu_item][:parent_id].blank?
|
52
|
+
params[:spud_menu_item][:parent_type] = 'SpudMenu'
|
53
|
+
params[:spud_menu_item][:parent_id] = @menu.id
|
54
|
+
else
|
55
|
+
params[:spud_menu_item][:parent_type] = 'SpudMenuItem'
|
56
|
+
end
|
57
|
+
@menu_item.attributes = menu_item_params()
|
58
|
+
@menu_item.spud_menu_id = @menu.id
|
59
|
+
flash[:notice] = 'Menu saved successfully!' if @menu_item.save
|
60
|
+
|
61
|
+
respond_with @menu_item, location: admin_menu_menu_items_url
|
62
|
+
end
|
63
|
+
|
64
|
+
def destroy
|
65
|
+
flash[:notice] = 'Menu Item removed!' if @menu_item.destroy
|
66
|
+
|
67
|
+
respond_with @menu_item, location: admin_menu_menu_items_url
|
68
|
+
end
|
69
|
+
|
70
|
+
def update_sort
|
71
|
+
params[:order]&.each_with_index do |item, index|
|
72
|
+
val = item.to_i
|
73
|
+
menu_item = @menu.spud_menu_items.find_by(id: val)
|
74
|
+
menu_item.menu_order = index
|
75
|
+
menu_item.save
|
76
|
+
end
|
77
|
+
respond_to do |format|
|
78
|
+
format.json { head :no_content }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
def load_menu
|
85
|
+
@menu = SpudMenu.where(id: params[:menu_id]).first
|
86
|
+
|
87
|
+
if @menu.blank?
|
88
|
+
flash[:error] = 'Menu not found!'
|
89
|
+
redirect_to(admin_menus_url()) && (return false)
|
90
|
+
end
|
91
|
+
add_breadcrumb @menu.name.to_s, :admin_menu_menu_items_path
|
92
|
+
end
|
93
|
+
|
94
|
+
def load_menu_item
|
95
|
+
@menu_item = SpudMenuItem.where(id: params[:id]).first
|
96
|
+
if @menu_item.blank?
|
97
|
+
flash[:error] = 'Menu Item not found!'
|
98
|
+
redirect_to(admin_menu_menu_items_url()) && (return false)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def menu_item_params
|
103
|
+
params.require(:spud_menu_item).permit(:name, :parent_type, :parent_id, :item_type, :spud_page_id, :menu_order, :url, :classes)
|
104
|
+
end
|
115
105
|
|
116
106
|
end
|
@@ -1,56 +1,55 @@
|
|
1
1
|
class Admin::MenusController < Admin::ApplicationController
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
end
|
2
|
+
belongs_to_app :menus
|
3
|
+
add_breadcrumb 'Menus', :admin_menus_path
|
4
|
+
before_action :load_menu, only: [:edit, :update, :show, :destroy]
|
5
|
+
|
6
|
+
def index
|
7
|
+
@menus = SpudMenu.all.paginate(page: params[:page])
|
8
|
+
respond_with @menus
|
9
|
+
end
|
10
|
+
|
11
|
+
def new
|
12
|
+
add_breadcrumb 'New', :new_admin_menu_path
|
13
|
+
@menu = SpudMenu.new
|
14
|
+
respond_with @menu
|
15
|
+
end
|
16
|
+
|
17
|
+
def create
|
18
|
+
add_breadcrumb 'New', :new_admin_menu_path
|
19
|
+
@menu = SpudMenu.new(menu_params)
|
20
|
+
flash[:notice] = 'New menu created' if @menu.save
|
21
|
+
respond_with @menu, location: !@menu.id.nil? ? admin_menu_menu_items_url(menu_id: @menu.id) : admin_menus_url
|
22
|
+
end
|
23
|
+
|
24
|
+
def edit
|
25
|
+
add_breadcrumb "Edit #{@menu.name}", :edit_admin_menu_path
|
26
|
+
respond_with @menu
|
27
|
+
end
|
28
|
+
|
29
|
+
def update
|
30
|
+
add_breadcrumb "Edit #{@menu.name}", :edit_admin_menu_path
|
31
|
+
|
32
|
+
flash[:notice] = 'Menu saved successfully' if @menu.update_attributes(menu_params)
|
33
|
+
respond_with @menu, location: admin_menu_menu_items_url(menu_id: @menu.id)
|
34
|
+
end
|
35
|
+
|
36
|
+
def destroy
|
37
|
+
flash[:notice] = 'Menu removed!' if @menu.destroy
|
38
|
+
respond_with @menu, location: admin_menus_url
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def load_menu
|
44
|
+
@menu = SpudMenu.where(id: params[:id]).first
|
45
|
+
if @menu.blank?
|
46
|
+
flash[:error] = 'Menu not found!'
|
47
|
+
redirect_to(admin_menus_url()) && (return false)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def menu_params
|
52
|
+
params.require(:spud_menu).permit(:name)
|
53
|
+
end
|
55
54
|
|
56
55
|
end
|