spud_cms 0.8.15 → 0.8.17

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.
@@ -4,6 +4,7 @@
4
4
  //= require codemirror/modes/css
5
5
  //= require codemirror/modes/htmlmixed
6
6
  //= require codemirror/modes/htmlembedded
7
+ //= require spud/admin/cms/menu_items
7
8
  // Place all the behaviors and hooks related to the matching controller here.
8
9
  // All this logic will automatically be available in application.js.
9
10
 
@@ -14,8 +15,8 @@ $(document).ready(function() {
14
15
  var $this = $(this);
15
16
  $.get($this.attr("data-source"), { template: $this.val() }, function(data) {
16
17
  $('.formtabs').tabs('destroy');
17
- console.log($("#page_partials_form"))
18
-
18
+
19
+
19
20
  $('textarea.tinymce').each(function() {$(this).tinymce().execCommand('mceRemoveControl',false,this.id)});
20
21
  $("#page_partials_form").replaceWith(data)
21
22
  initFormTabs();
@@ -25,4 +26,4 @@ $(document).ready(function() {
25
26
  $('<p> Error: ' + jqXHR.responseText + '</p>').dialog();
26
27
  });
27
28
  });
28
- });
29
+ });
@@ -0,0 +1,44 @@
1
+ Spud = (typeof(Spud) == 'undefined') ? {} : Spud;
2
+ Spud.Admin = (typeof(Spud.Admin) == 'undefined') ? {} : Spud.Admin;
3
+ Spud.Admin.Cms = (typeof(Spud.Admin.Cms) == 'undefined') ? {} : Spud.Admin.Cms;
4
+
5
+ Spud.Admin.Cms.MenuItems = new function() {
6
+ var self=this;
7
+
8
+ self.editMode = false;
9
+ self.mouseIsDown = false;
10
+ self.init = function() {
11
+ // $('.admin_application').effect('shake',{},100,self.shakeLoop)
12
+
13
+ $('.sortable').sortable({
14
+ connectWith:".connectedSortable",
15
+ start: function(event,ui) {
16
+ $('#root_menu_list').addClass('menu_edit');
17
+ },
18
+ axis:"y",
19
+ tolerance:'pointer',
20
+ cursor: "move",
21
+ items:'li',
22
+ stop: function(event,ui) {
23
+ $('#root_menu_list').removeClass('menu_edit');
24
+ },
25
+ over: function(event,ui) {
26
+ // console.log(event);
27
+ var source = ui.item[0];
28
+ // ui.placeholder.style.backgroundColor('#FAE7D9');
29
+ var destination = $(event.target);
30
+ // console.log(destination);
31
+ $('ul.left_guide').removeClass('left_guide');
32
+
33
+ if(destination.hasClass('subitem'))
34
+ {
35
+ destination.addClass('left_guide');
36
+ }
37
+ // console.log(ui.item[0].innerHTML)
38
+ }
39
+ }).disableSelection();
40
+ // $('.admin_application').addClass('jiggly')
41
+ // $('.admin_application').draggable();
42
+ };
43
+
44
+ }();
@@ -1,4 +1,28 @@
1
1
  /*
2
2
  //= require codemirror
3
3
  //= require codemirror/themes/night
4
- */
4
+ */
5
+ .menu_list {
6
+ list-style-type:none;
7
+ }
8
+ .page_row {
9
+ background:white;
10
+ }
11
+ .menu_edit .subitem {
12
+
13
+ min-height:10px;
14
+ /*padding-bottom:12px;*/
15
+ }
16
+
17
+ .subitem .page_row {
18
+
19
+ border-left:2px solid #999;
20
+ }
21
+ .left_guide.subitem .page_row {
22
+ border:none;
23
+ }
24
+
25
+ .ui-sortable-placeholder {
26
+ background:#FAE7D9 !important;
27
+ visibility:visible !important;
28
+ }
@@ -3,24 +3,24 @@ class Spud::Admin::MenuItemsController < Spud::Admin::CmsController
3
3
  belongs_to_spud_app :menus
4
4
  layout 'spud/admin/cms/detail'
5
5
  before_filter :load_menu
6
- before_filter :load_menu_item, :only => [:edit,:update,:show,:destroy]
6
+ before_filter :load_menu_item, :only => [:edit,:update,:show,:destroy,:reorder]
7
7
  cache_sweeper :page_sweeper,:only => [:create,:update,:destroy]
8
8
  def index
9
9
  @page_name = "Menu Items"
10
- @menu_items = @menu.spud_menu_items.order(:menu_order).includes(:spud_menu_items).paginate :page => params[:page]
10
+ @menu_items = @menu.spud_menu_items.order(:menu_order).includes(:spud_menu_items)
11
11
  respond_with @menu_items
12
12
  end
13
13
 
14
14
  def new
15
15
  add_breadcrumb "New", :new_spud_admin_page_path
16
16
  @page_name = "New Menu Item"
17
-
17
+
18
18
  @menu_item = @menu.spud_menu_items.new
19
19
  respond_with @menu_item
20
20
  end
21
21
 
22
22
  def create
23
-
23
+
24
24
  add_breadcrumb "New", :new_spud_admin_page_path
25
25
  @page_name = "New Menu Item"
26
26
  @menu_item = SpudMenuItem.new(params[:spud_menu_item])
@@ -57,7 +57,7 @@ class Spud::Admin::MenuItemsController < Spud::Admin::CmsController
57
57
  end
58
58
 
59
59
  def update
60
-
60
+
61
61
  add_breadcrumb "Edit #{@menu_item.name}", :edit_spud_admin_menu_menu_item_path
62
62
  @page_name = "Edit #{@menu_item.name}"
63
63
  if params[:spud_menu_item][:parent_id].blank?
@@ -74,18 +74,32 @@ class Spud::Admin::MenuItemsController < Spud::Admin::CmsController
74
74
  end
75
75
 
76
76
  def destroy
77
-
77
+
78
78
  flash[:notice] = "Menu Item removed!" if @menu_item.destroy
79
79
 
80
80
  respond_with @menu_item,:location => spud_admin_menu_menu_items_url
81
81
  end
82
+
83
+ def reorder
84
+ #id param
85
+ #source position
86
+ #destination position
87
+ #parent
88
+ # @menu_items = @menu.spud_menu_items.order(:menu_order).includes(:spud_menu_items).paginate :page => params[:page]
89
+
90
+
91
+ end
82
92
  private
83
93
  def load_menu
84
94
 
85
95
  @menu = SpudMenu.find(params[:menu_id])
96
+
86
97
  if @menu.blank?
87
98
  flash[:error] = "Menu not found!"
88
99
  redirect_to spud_admin_menus_url() and return false
100
+ elsif Spud::Core.multisite_mode_enabled && @menu.site_id != session[:admin_site]
101
+ flash[:warning] = "Site Context Changed. The menu you were viewing is not associated with the current site. Redirected back to menu selections."
102
+ redirect_to spud_admin_menus_url() and return false
89
103
  end
90
104
  add_breadcrumb "#{@menu.name}", :spud_admin_menu_menu_items_path
91
105
  end
@@ -99,7 +113,7 @@ private
99
113
  end
100
114
 
101
115
 
102
-
116
+
103
117
 
104
118
 
105
119
  end
@@ -3,12 +3,12 @@ class Spud::Admin::MenusController < Spud::Admin::CmsController
3
3
  belongs_to_spud_app :menus
4
4
  add_breadcrumb "Menus", :spud_admin_menus_path
5
5
  before_filter :load_menu,:only => [:edit,:update,:show,:destroy]
6
-
6
+
7
7
  def index
8
8
  @menus = SpudMenu.site(session[:admin_site]).order(:name).paginate :page => params[:page]
9
9
  respond_with @menus
10
10
  end
11
-
11
+
12
12
 
13
13
  def new
14
14
  add_breadcrumb "New", :new_spud_admin_menu_path
@@ -31,7 +31,7 @@ class Spud::Admin::MenusController < Spud::Admin::CmsController
31
31
 
32
32
  def update
33
33
  add_breadcrumb "Edit #{@menu.name}", :edit_spud_admin_menu_path
34
-
34
+
35
35
  flash[:notice] = "Menu saved successfully" if @menu.update_attributes(params[:spud_menu])
36
36
  respond_with @menu,:location => spud_admin_menu_menu_items_url(:menu_id => @menu.id)
37
37
  end
@@ -47,6 +47,9 @@ private
47
47
  if @menu.blank?
48
48
  flash[:error] = "Menu not found!"
49
49
  redirect_to spud_admin_menus_url() and return false
50
+ elsif Spud::Core.multisite_mode_enabled && @menu.site_id != session[:admin_site]
51
+ flash[:warning] = "Site Context Changed. The menu you were viewing is not associated with the current site. Redirected back to menu selections."
52
+ redirect_to spud_admin_menus_url() and return false
50
53
  end
51
54
  end
52
55
  end
@@ -5,24 +5,13 @@ class Spud::Admin::PagesController < Spud::Admin::CmsController
5
5
  before_filter :load_page,:only => [:edit,:update,:show,:destroy]
6
6
  cache_sweeper :page_sweeper,:only => [:update,:destroy]
7
7
  def index
8
-
8
+
9
9
  @pages = SpudPage.site(session[:admin_site]).where(:spud_page_id => nil).order(:page_order).includes(:spud_pages).paginate :page => params[:page]
10
10
  respond_with @pages
11
11
  end
12
12
 
13
13
  def show
14
-
15
-
16
- if @page.blank?
17
- flash[:error] = "Page not found"
18
- if !params[:id].blank?
19
- redirect_to spud_admin_pages_url() and return
20
- else
21
- return
22
- end
23
- end
24
- layout = 'application'
25
-
14
+ layout = Spud::Cms.default_page_layout
26
15
 
27
16
  if !@page.spud_template.blank?
28
17
  if !@page.spud_template.base_layout.blank?
@@ -36,7 +25,7 @@ class Spud::Admin::PagesController < Spud::Admin::CmsController
36
25
  def new
37
26
  add_breadcrumb "New", :new_spud_admin_page_path
38
27
 
39
-
28
+
40
29
  @templates = SpudTemplate.all
41
30
  @page = SpudPage.new
42
31
  parts = Spud::Cms.default_page_parts
@@ -50,11 +39,11 @@ class Spud::Admin::PagesController < Spud::Admin::CmsController
50
39
  parts.each do |part|
51
40
  @page.spud_page_partials.new(:name => part.strip)
52
41
  end
53
- respond_with @page
42
+ respond_with @page
54
43
  end
55
44
 
56
45
  def create
57
-
46
+
58
47
  @page = SpudPage.new(params[:spud_page])
59
48
  @page.site_id = session[:admin_site]
60
49
  if params[:preview] && params[:preview].to_i == 1
@@ -68,7 +57,7 @@ class Spud::Admin::PagesController < Spud::Admin::CmsController
68
57
  def edit
69
58
  add_breadcrumb "#{@page.name}", :spud_admin_page_path
70
59
  add_breadcrumb "Edit", :edit_spud_admin_page_path
71
-
60
+
72
61
  @templates = SpudTemplate.all
73
62
  if @page.spud_page_partials.blank?
74
63
  parts = Spud::Cms.default_page_parts
@@ -94,7 +83,7 @@ class Spud::Admin::PagesController < Spud::Admin::CmsController
94
83
  end
95
84
 
96
85
  def update
97
-
86
+
98
87
  @page.attributes = params[:spud_page]
99
88
  if params[:preview] && params[:preview].to_i == 1
100
89
  preview
@@ -128,7 +117,7 @@ class Spud::Admin::PagesController < Spud::Admin::CmsController
128
117
 
129
118
  def destroy
130
119
  status = 500
131
-
120
+
132
121
  if @page.destroy
133
122
  flash[:notice] = "Page removed successfully!"
134
123
  status = 200
@@ -140,7 +129,7 @@ class Spud::Admin::PagesController < Spud::Admin::CmsController
140
129
  format.html { redirect_to spud_admin_pages_url()}
141
130
  end
142
131
  end
143
-
132
+
144
133
  def page_parts
145
134
  template = params[:template] && !params[:template].blank? ? SpudTemplate.where(:id => params[:template]).first : nil
146
135
  page = SpudPage.where(:id => params[:page]).includes(:spud_page_partials).first
@@ -163,7 +152,7 @@ class Spud::Admin::PagesController < Spud::Admin::CmsController
163
152
  parts.each do |part|
164
153
  new_page_partials << page.spud_page_partials.build(:name => part)
165
154
  end
166
-
155
+
167
156
  end
168
157
  new_page_partials.each do |partial|
169
158
  old_partial = old_page_partials.select {|pp| partial.name.strip.downcase == pp.name.strip.downcase }
@@ -195,7 +184,7 @@ class Spud::Admin::PagesController < Spud::Admin::CmsController
195
184
  expire_action root_path
196
185
  else
197
186
  expire_action page_path(:id => record.url_name)
198
- end
187
+ end
199
188
  end
200
189
  end
201
190
  redirect_to spud_admin_pages_url
@@ -203,14 +192,17 @@ class Spud::Admin::PagesController < Spud::Admin::CmsController
203
192
 
204
193
  private
205
194
  def load_page
206
- @page = SpudPage.site(session[:admin_site]).where(:id => params[:id]).includes(:spud_page_partials).first
195
+ @page = SpudPage.where(:id => params[:id]).includes(:spud_page_partials).first
207
196
  if @page.blank?
208
197
  flash[:error] = "Page not found!"
209
198
  redirect_to spud_admin_pages_url() and return false
199
+ elsif Spud::Core.multisite_mode_enabled && @page.site_id != session[:admin_site]
200
+ flash[:warning] = "Site Context Changed. The page you were viewing is not associated with the current site. Redirected back to page selections."
201
+ redirect_to spud_admin_pages_url() and return false
210
202
  end
211
203
  return true
212
204
  end
213
205
 
214
-
206
+
215
207
 
216
208
  end
@@ -31,7 +31,7 @@ class Spud::Admin::TemplatesController < Spud::Admin::CmsController
31
31
  @template = SpudTemplate.new(params[:spud_template])
32
32
  @template.site_id = session[:admin_site]
33
33
  flash[:notice] = "Template created successfully!" if @template.save
34
-
34
+
35
35
  respond_with @template, :location => spud_admin_templates_url
36
36
  end
37
37
 
@@ -41,30 +41,33 @@ class Spud::Admin::TemplatesController < Spud::Admin::CmsController
41
41
  end
42
42
 
43
43
  def update
44
-
44
+
45
45
  add_breadcrumb "Edit #{@template.name}", :edit_spud_admin_template_path
46
46
  flash[:notice] = "Template updated successfully" if @template.update_attributes(params[:spud_template])
47
-
47
+
48
48
  respond_with @template, :location => spud_admin_templates_url
49
49
  end
50
50
 
51
51
 
52
52
  def destroy
53
-
53
+
54
54
  flash[:notice] = "Template removed" if @template.destroy
55
-
55
+
56
56
  respond_with @template, :location => spud_admin_templates_url
57
57
  end
58
58
 
59
59
  private
60
60
  def load_template
61
- @template = SpudTemplate.site(session[:admin_site]).where(:id => params[:id]).first
61
+ @template = SpudTemplate.where(:id => params[:id]).first
62
62
  if @template.blank?
63
63
  flash[:error] = "Template not found!"
64
64
  redirect_to spud_admin_templates_url and return false
65
+ elsif Spud::Core.multisite_mode_enabled && @template.site_id != session[:admin_site]
66
+ flash[:warning] = "Site Context Changed. The template you were viewing is not associated with the current site. Redirected back to template selections."
67
+ redirect_to spud_admin_templates_url() and return false
65
68
  end
66
69
  end
67
70
 
68
-
71
+
69
72
 
70
73
  end
@@ -20,8 +20,8 @@ class PageSweeper < ActionController::Caching::Sweeper
20
20
  end
21
21
  def after_save(record)
22
22
  expire_cache_for(record)
23
- expire_page spud_cms_sitemap_path
24
- expire_page spud_sitemap_path
23
+ expire_page spud_cms_sitemap_path(:format => :xml)
24
+ expire_page spud_sitemap_path(:format => :xml)
25
25
  end
26
26
  def after_destroy(record)
27
27
  expire_cache_for(record)
@@ -36,6 +36,13 @@ private
36
36
  end
37
37
  elsif record.is_a?(SpudPage)
38
38
  if Spud::Cms.enable_full_page_caching
39
+ multisite_prefix = ""
40
+
41
+ if Spud::Core.multisite_mode_enabled
42
+ site_config = Spud::Core.site_config_for_id(record.site_id)
43
+ multisite_prefix = "/" + site_config[:short_name].to_s.downcase
44
+ end
45
+
39
46
  if record.url_name == Spud::Cms.root_page_name
40
47
  expire_page root_path
41
48
  else
@@ -50,7 +57,7 @@ private
50
57
  end
51
58
  else
52
59
  Rails.cache.clear
53
- SpudPage.site(session[:admin_site]).published_pages.all.each {|page| expire_cache_for(page)}
60
+ SpudPage.site(record.spud_menu.site_id).published_pages.all.each {|page| expire_cache_for(page)}
54
61
  end
55
62
  end
56
- end
63
+ end
@@ -11,13 +11,13 @@ class SpudPage < ActiveRecord::Base
11
11
 
12
12
 
13
13
  attr_accessible :name,:url_name,:created_by,:updated_by,:template_id,:visibility,:spud_page_id,:publish_at,:format,:meta_description,:meta_keywords,:page_order,:spud_page_partials_attributes,:use_custom_url_name,:published,:notes
14
-
14
+
15
15
  before_validation :generate_url_name
16
16
  validates :name,:presence => true
17
17
  validates_uniqueness_of :name, :scope => [:site_id,:spud_page_id]
18
18
  validates :url_name,:presence => true
19
19
  validates_uniqueness_of :url_name, :scope => :site_id
20
-
20
+
21
21
  accepts_nested_attributes_for :spud_page_partials, :allow_destroy => true
22
22
  scope :parent_pages, where(:spud_page_id => nil)
23
23
  scope :site, lambda {|sid| where(:site_id => sid)}
@@ -61,7 +61,7 @@ class SpudPage < ActiveRecord::Base
61
61
  url_name += self.name.parameterize.downcase
62
62
  if !self.use_custom_url_name
63
63
  pages = SpudPage
64
-
64
+
65
65
  if !self.id.blank?
66
66
  pages = pages.where("id != #{self.id}")
67
67
  end
@@ -79,7 +79,7 @@ class SpudPage < ActiveRecord::Base
79
79
  permalink = SpudPermalink.site(self.site_id).where(:url_name => url_name_new).first
80
80
  counter = 1
81
81
  while permalink.blank? == false
82
-
82
+
83
83
  if permalink.attachment == self
84
84
  permalink.destroy
85
85
  permalink = nil
@@ -97,21 +97,21 @@ class SpudPage < ActiveRecord::Base
97
97
  self.url_name = url_name
98
98
  self.use_custom_url_name = false
99
99
  elsif self.id.to_i > 0
100
- page = SpudPage.where(:id => self.id).first
101
- if page.url_name.blank? == false && page.url_name != self.url_name
102
- permalink = SpudPermalink.site(self.site_id).where(:url_name => self.url_name).first
103
- if permalink.blank? == false
104
- if permalink.attachment == self
105
- permalink.destroy
106
- else
107
- self.errors.add :url_name, "This permalink has already been used by another page."
108
- return false
100
+ page = SpudPage.where(:id => self.id).first
101
+ if page.url_name.blank? == false && page.url_name != self.url_name
102
+ permalink = SpudPermalink.site(self.site_id).where(:url_name => self.url_name).first
103
+ if permalink.blank? == false
104
+ if permalink.attachment == self
105
+ permalink.destroy
106
+ else
107
+ self.errors.add :url_name, "This permalink has already been used by another page."
108
+ return false
109
+ end
109
110
  end
111
+ self.spud_permalinks.create(:url_name => page.url_name,:site_id => self.site_id)
110
112
  end
111
- self.spud_permalinks.create(:url_name => page.url_name,:site_id => self.site_id)
112
- end
113
- end
114
- return true
113
+ end
114
+ return true
115
115
  end
116
116
 
117
117
  def is_private?