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