spud_cms 0.8.17 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +30 -13
- data/app/assets/images/spud/admin/snippets_thumb.png +0 -0
- data/app/assets/images/spud/admin/snippets_thumb@2x.png +0 -0
- data/app/assets/javascripts/spud/admin/cms/application.js +3 -3
- data/app/controllers/pages_controller.rb +6 -23
- data/app/controllers/spud/admin/menu_items_controller.rb +6 -10
- data/app/controllers/spud/admin/menus_controller.rb +1 -1
- data/app/controllers/spud/admin/pages_controller.rb +40 -86
- data/app/controllers/spud/cms/sitemaps_controller.rb +1 -1
- data/app/helpers/spud/cms/application_helper.rb +50 -26
- data/app/models/spud_menu_item.rb +10 -13
- data/app/models/spud_page.rb +12 -4
- data/app/models/spud_page_liquid_tag.rb +4 -0
- data/app/models/spud_page_partial.rb +40 -1
- data/app/observers/page_sweeper.rb +48 -0
- data/app/views/pages/show.html.erb +9 -11
- data/app/views/spud/admin/pages/_form.html.erb +15 -16
- data/app/views/spud/admin/pages/_page_partials_form.html.erb +3 -3
- data/app/views/spud/admin/pages/index.html.erb +1 -1
- data/app/views/spud/admin/pages/show.html.erb +4 -6
- data/config/routes.rb +3 -3
- data/db/migrate/20120911190030_add_symbol_name_to_spud_page_partials.rb +5 -0
- data/db/migrate/20120912121313_modify_site_id_for_spud_pages.rb +15 -0
- data/db/migrate/20121016233715_add_content_processed_to_spud_page_partials.rb +5 -0
- data/db/migrate/20121112151110_add_layout_to_spud_pages.rb +8 -0
- data/db/migrate/20121112212113_create_spud_page_liquid_tags.rb +11 -0
- data/lib/spud_cms.rb +1 -0
- data/lib/spud_cms/configuration.rb +4 -7
- data/lib/spud_cms/engine.rb +37 -16
- data/lib/spud_cms/template_parser.rb +121 -0
- data/lib/spud_cms/version.rb +1 -1
- data/spec/controllers/pages_controller_spec.rb +108 -0
- data/spec/controllers/spud/admin/menu_items_controller_spec.rb +148 -0
- data/spec/controllers/spud/admin/menus_controller_spec.rb +121 -0
- data/spec/controllers/spud/admin/pages_controller_spec.rb +5 -13
- data/spec/controllers/spud/cms/sitemaps_controller_spec.rb +35 -4
- data/spec/dummy/app/controllers/application_controller.rb +1 -1
- data/spec/dummy/db/schema.rb +146 -0
- data/spec/dummy/log/development.log +341 -0
- data/spec/dummy/log/test.log +182863 -0
- data/spec/helpers/spud/cms/application_helper_spec.rb +160 -0
- data/spec/models/spud_menu_item_spec.rb +31 -0
- data/spec/models/spud_page_liquid_tag_spec.rb +5 -0
- data/spec/models/spud_page_partial_spec.rb +44 -0
- data/spec/models/spud_page_spec.rb +1 -2
- metadata +50 -19
- data/app/assets/images/spud/admin/templates_thumb.png +0 -0
- data/app/controllers/spud/admin/templates_controller.rb +0 -73
- data/app/models/page_sweeper.rb +0 -63
- data/app/models/spud_template.rb +0 -10
- data/app/views/layouts/spud/admin/cms/detail.html.erb +0 -5
- data/spec/models/spud_template_spec.rb +0 -34
Binary file
|
@@ -1,73 +0,0 @@
|
|
1
|
-
class Spud::Admin::TemplatesController < Spud::Admin::CmsController
|
2
|
-
layout 'spud/admin/cms/detail'
|
3
|
-
add_breadcrumb "Templates", :spud_admin_templates_path
|
4
|
-
belongs_to_spud_app :templates
|
5
|
-
before_filter :load_template,:only => [:edit,:update,:show,:destroy]
|
6
|
-
cache_sweeper :page_sweeper,:only => [:update,:destroy]
|
7
|
-
|
8
|
-
def index
|
9
|
-
flash.now[:warning] = "Templates are an advanced way to create modified pages and require some experience in HTML and Ruby."
|
10
|
-
@templates = SpudTemplate.site(session[:admin_site]).order(:name).paginate :page => params[:page]
|
11
|
-
respond_with @templates
|
12
|
-
end
|
13
|
-
|
14
|
-
def new
|
15
|
-
add_breadcrumb "New", :new_spud_admin_template_path
|
16
|
-
parts = Spud::Cms.default_page_parts
|
17
|
-
if Spud::Core.multisite_mode_enabled && !session[:admin_site].blank?
|
18
|
-
site_config = Spud::Core.multisite_config.select{|c| c[:site_id] == session[:admin_site]}
|
19
|
-
if !site_config.blank?
|
20
|
-
cms_config = Spud::Cms.site_config_for_short_name(site_config[0][:short_name])
|
21
|
-
parts = cms_config[:default_page_parts] if !cms_config.blank? && !cms_config[:default_page_parts].blank?
|
22
|
-
end
|
23
|
-
end
|
24
|
-
@template = SpudTemplate.new(:base_layout => Spud::Cms.default_page_layout,:page_parts => parts.join(","))
|
25
|
-
respond_with @template
|
26
|
-
end
|
27
|
-
|
28
|
-
def create
|
29
|
-
add_breadcrumb "New", :new_spud_admin_template_path
|
30
|
-
|
31
|
-
@template = SpudTemplate.new(params[:spud_template])
|
32
|
-
@template.site_id = session[:admin_site]
|
33
|
-
flash[:notice] = "Template created successfully!" if @template.save
|
34
|
-
|
35
|
-
respond_with @template, :location => spud_admin_templates_url
|
36
|
-
end
|
37
|
-
|
38
|
-
def edit
|
39
|
-
add_breadcrumb "Edit #{@template.name}", :edit_spud_admin_template_path
|
40
|
-
respond_with @template
|
41
|
-
end
|
42
|
-
|
43
|
-
def update
|
44
|
-
|
45
|
-
add_breadcrumb "Edit #{@template.name}", :edit_spud_admin_template_path
|
46
|
-
flash[:notice] = "Template updated successfully" if @template.update_attributes(params[:spud_template])
|
47
|
-
|
48
|
-
respond_with @template, :location => spud_admin_templates_url
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
def destroy
|
53
|
-
|
54
|
-
flash[:notice] = "Template removed" if @template.destroy
|
55
|
-
|
56
|
-
respond_with @template, :location => spud_admin_templates_url
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
def load_template
|
61
|
-
@template = SpudTemplate.where(:id => params[:id]).first
|
62
|
-
if @template.blank?
|
63
|
-
flash[:error] = "Template not found!"
|
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
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
data/app/models/page_sweeper.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
class PageSweeper < ActionController::Caching::Sweeper
|
2
|
-
observe SpudPage,SpudTemplate,SpudMenuItem
|
3
|
-
|
4
|
-
def before_save(record)
|
5
|
-
if record.is_a?(SpudPage) && record.changed_attributes.has_key?("url_name")
|
6
|
-
if Spud::Cms.enable_full_page_caching
|
7
|
-
if record.changed_attributes["url_name"] == Spud::Cms.root_page_name
|
8
|
-
expire_page root_path
|
9
|
-
else
|
10
|
-
expire_page page_path(:id => record.changed_attributes["url_name"])
|
11
|
-
end
|
12
|
-
elsif Spud::Cms.enable_action_caching
|
13
|
-
if record.changed_attributes["url_name"] == Spud::Cms.root_page_name
|
14
|
-
expire_action root_path
|
15
|
-
else
|
16
|
-
expire_action page_path(:id => record.changed_attributes["url_name"])
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
def after_save(record)
|
22
|
-
expire_cache_for(record)
|
23
|
-
expire_page spud_cms_sitemap_path(:format => :xml)
|
24
|
-
expire_page spud_sitemap_path(:format => :xml)
|
25
|
-
end
|
26
|
-
def after_destroy(record)
|
27
|
-
expire_cache_for(record)
|
28
|
-
expire_page spud_cms_sitemap_path
|
29
|
-
expire_page spud_sitemap_path
|
30
|
-
end
|
31
|
-
private
|
32
|
-
def expire_cache_for(record)
|
33
|
-
if(record.is_a?(SpudTemplate))
|
34
|
-
record.spud_pages.each do |page|
|
35
|
-
expire_cache_for(page)
|
36
|
-
end
|
37
|
-
elsif record.is_a?(SpudPage)
|
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
|
-
|
46
|
-
if record.url_name == Spud::Cms.root_page_name
|
47
|
-
expire_page root_path
|
48
|
-
else
|
49
|
-
expire_page page_path(:id => record.url_name)
|
50
|
-
end
|
51
|
-
elsif Spud::Cms.enable_action_caching
|
52
|
-
if record.url_name == Spud::Cms.root_page_name
|
53
|
-
expire_action root_path
|
54
|
-
else
|
55
|
-
expire_action page_path(:id => record.url_name)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
else
|
59
|
-
Rails.cache.clear
|
60
|
-
SpudPage.site(record.spud_menu.site_id).published_pages.all.each {|page| expire_cache_for(page)}
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
data/app/models/spud_template.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
class SpudTemplate < ActiveRecord::Base
|
2
|
-
has_many :spud_pages,:dependent => :nullify,:foreign_key => :template_id
|
3
|
-
|
4
|
-
validates :base_layout, :presence => true
|
5
|
-
validates :page_parts, :presence => true
|
6
|
-
validates :name, :presence => true,:uniqueness => true
|
7
|
-
|
8
|
-
attr_protected :site_id
|
9
|
-
scope :site, lambda {|sid| where(:site_id => sid)}
|
10
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe SpudTemplate do
|
4
|
-
it {should have_many(:spud_pages)}
|
5
|
-
describe "validations" do
|
6
|
-
it "should require a base layout" do
|
7
|
-
t = Factory.build(:spud_template, :base_layout => nil)
|
8
|
-
t.valid?.should == false
|
9
|
-
end
|
10
|
-
it "should require a page_part" do
|
11
|
-
t = Factory.build(:spud_template, :page_parts => nil)
|
12
|
-
t.valid?.should == false
|
13
|
-
end
|
14
|
-
it "should require a name" do
|
15
|
-
t = Factory.build(:spud_template, :name => nil)
|
16
|
-
t.valid?.should == false
|
17
|
-
end
|
18
|
-
it "should require a unique name" do
|
19
|
-
t = Factory.build(:spud_template, :name => "test")
|
20
|
-
t.save.should == true
|
21
|
-
t = Factory.build(:spud_template, :name => "test")
|
22
|
-
t.valid?.should == false
|
23
|
-
end
|
24
|
-
it "should not destroy pages on destroy" do
|
25
|
-
t = Factory.build(:spud_template)
|
26
|
-
t.save
|
27
|
-
p = Factory.build(:spud_page,:id => 1,:spud_template => t)
|
28
|
-
p.save
|
29
|
-
t.destroy
|
30
|
-
page = SpudPage.find(1)
|
31
|
-
page.should == page
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|