spud_cms 0.4.5 → 0.4.6
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/controllers/pages_controller.rb +2 -1
- data/app/controllers/spud/admin/menu_items_controller.rb +4 -16
- data/app/controllers/spud/admin/pages_controller.rb +4 -10
- data/app/controllers/spud/admin/templates_controller.rb +4 -14
- data/app/models/page_sweeper.rb +36 -0
- data/lib/spud_cms/configuration.rb +2 -1
- data/lib/spud_cms/engine.rb +2 -0
- metadata +7 -6
@@ -1,5 +1,6 @@
|
|
1
1
|
class PagesController < ApplicationController
|
2
|
-
caches_action :show, :if => Proc.new { |c| Spud::Cms.
|
2
|
+
caches_action :show, :if => Proc.new { |c| Spud::Cms.enable_action_caching }
|
3
|
+
caches_page :show, :if => Proc.new { |c| Spud::Cms.enable_full_page_caching }
|
3
4
|
def show
|
4
5
|
url_name = !params[:id].blank? ? params[:id] : Spud::Cms.root_page_name
|
5
6
|
@page = SpudPage.published_pages.where(:url_name => url_name).includes([:spud_template,:spud_page_partials]).first
|
@@ -4,7 +4,7 @@ class Spud::Admin::MenuItemsController < Spud::Admin::ApplicationController
|
|
4
4
|
layout 'spud/admin/cms/detail'
|
5
5
|
before_filter :load_menu
|
6
6
|
before_filter :load_menu_item, :only => [:edit,:update,:show,:destroy]
|
7
|
-
|
7
|
+
cache_sweeper :page_sweeper,:only => [:create,:update,:destroy]
|
8
8
|
def index
|
9
9
|
@page_name = "Menu Items"
|
10
10
|
@menu_items = @menu.spud_menu_items.order(:menu_order).includes(:spud_menu_items).paginate :page => params[:page]
|
@@ -20,7 +20,7 @@ class Spud::Admin::MenuItemsController < Spud::Admin::ApplicationController
|
|
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::ApplicationController
|
|
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,7 +74,7 @@ class Spud::Admin::MenuItemsController < Spud::Admin::ApplicationController
|
|
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
|
@@ -98,19 +98,7 @@ private
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
-
def clear_action_cache
|
102
101
|
|
103
|
-
if(Spud::Cms.enable_full_page_caching == false)
|
104
|
-
return
|
105
|
-
end
|
106
|
-
Rails.cache.clear
|
107
|
-
# @pages = SpudPage.published_pages.all
|
108
|
-
# if !@pages.blank?
|
109
|
-
# @pages.each do |page|
|
110
|
-
# expire_action page_url(:id => page.url_name)
|
111
|
-
# end
|
112
|
-
# end
|
113
|
-
end
|
114
102
|
|
115
103
|
|
116
104
|
|
@@ -3,7 +3,7 @@ class Spud::Admin::PagesController < Spud::Admin::ApplicationController
|
|
3
3
|
add_breadcrumb "Pages", :spud_admin_pages_path
|
4
4
|
belongs_to_spud_app :pages
|
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.where(:spud_page_id => nil).order(:page_order).includes(:spud_pages).paginate :page => params[:page]
|
@@ -72,7 +72,7 @@ class Spud::Admin::PagesController < Spud::Admin::ApplicationController
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def update
|
75
|
-
|
75
|
+
|
76
76
|
if @page.update_attributes(params[:spud_page])
|
77
77
|
flash[:notice] = "Page updated successfully!"
|
78
78
|
redirect_to spud_admin_pages_url() and return
|
@@ -85,7 +85,7 @@ class Spud::Admin::PagesController < Spud::Admin::ApplicationController
|
|
85
85
|
|
86
86
|
def destroy
|
87
87
|
status = 500
|
88
|
-
|
88
|
+
|
89
89
|
if @page.destroy
|
90
90
|
flash[:notice] = "Page removed successfully!"
|
91
91
|
status = 200
|
@@ -140,12 +140,6 @@ private
|
|
140
140
|
return true
|
141
141
|
end
|
142
142
|
|
143
|
-
|
144
|
-
if @page.url_name == Spud::Cms.root_page_name
|
145
|
-
expire_action root_url
|
146
|
-
else
|
147
|
-
expire_action page_url(:id => @page.url_name)
|
148
|
-
end
|
149
|
-
end
|
143
|
+
|
150
144
|
|
151
145
|
end
|
@@ -3,7 +3,7 @@ class Spud::Admin::TemplatesController < Spud::Admin::ApplicationController
|
|
3
3
|
add_breadcrumb "Templates", :spud_admin_templates_path
|
4
4
|
belongs_to_spud_app :templates
|
5
5
|
before_filter :load_template,:only => [:edit,:update,:show,:destroy]
|
6
|
-
|
6
|
+
cache_sweeper :page_sweeper,:only => [:update,:destroy]
|
7
7
|
|
8
8
|
def index
|
9
9
|
flash.now[:warning] = "Templates are an advanced way to create modified pages and require some experience in HTML and Ruby."
|
@@ -33,7 +33,7 @@ class Spud::Admin::TemplatesController < Spud::Admin::ApplicationController
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def update
|
36
|
-
|
36
|
+
|
37
37
|
add_breadcrumb "Edit #{@template.name}", :edit_spud_admin_template_path
|
38
38
|
flash[:notice] = "Template updated successfully" if @template.update_attributes(params[:spud_template])
|
39
39
|
|
@@ -42,7 +42,7 @@ class Spud::Admin::TemplatesController < Spud::Admin::ApplicationController
|
|
42
42
|
|
43
43
|
|
44
44
|
def destroy
|
45
|
-
|
45
|
+
|
46
46
|
flash[:notice] = "Template removed" if @template.destroy
|
47
47
|
|
48
48
|
respond_with @template, :location => spud_admin_templates_url
|
@@ -57,16 +57,6 @@ private
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
|
61
|
-
if(Spud::Cms.enable_full_page_caching == false)
|
62
|
-
return
|
63
|
-
end
|
64
|
-
Rails.cache.clear
|
65
|
-
# if !@template.spud_pages.blank?
|
66
|
-
# @template.spud_pages.each do |page|
|
67
|
-
# expire_action page_path(:id => page.url_name)
|
68
|
-
# end
|
69
|
-
# end
|
70
|
-
end
|
60
|
+
|
71
61
|
|
72
62
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class PageSweeper < ActionController::Caching::Sweeper
|
2
|
+
observe SpudPage,SpudTemplate,SpudMenuItem
|
3
|
+
|
4
|
+
def after_save(record)
|
5
|
+
logger.debug("SWEEPING!")
|
6
|
+
expire_cache_for(record)
|
7
|
+
end
|
8
|
+
def after_destroy(record)
|
9
|
+
expire_cache_for(record)
|
10
|
+
end
|
11
|
+
private
|
12
|
+
def expire_cache_for(record)
|
13
|
+
if(record.is_a?(SpudTemplate))
|
14
|
+
record.spud_pages.each do |page|
|
15
|
+
expire_cache_for(page)
|
16
|
+
end
|
17
|
+
elsif record.is_a?(SpudPage)
|
18
|
+
if Spud::Cms.enable_full_page_caching
|
19
|
+
if record.url_name == Spud::Cms.root_page_name
|
20
|
+
expire_page root_path
|
21
|
+
else
|
22
|
+
expire_page page_path(:id => record.url_name)
|
23
|
+
end
|
24
|
+
elsif Spud::Cms.enable_action_caching
|
25
|
+
if record.url_name == Spud::Cms.root_page_name
|
26
|
+
expire_action root_path
|
27
|
+
else
|
28
|
+
expire_action page_path(:id => record.url_name)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
else
|
32
|
+
Rails.cache.clear
|
33
|
+
SpudPage.published_pages.all.each {|page| expire_cache_for(page)}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -2,7 +2,7 @@ module Spud
|
|
2
2
|
module Cms
|
3
3
|
include ActiveSupport::Configurable
|
4
4
|
|
5
|
-
config_accessor :menus_enabled,:templates_enabled,:root_page_name,:default_page_parts,:yield_body_as_content_block,:default_page_layout,:enable_sitemap,:enable_full_page_caching
|
5
|
+
config_accessor :menus_enabled,:templates_enabled,:root_page_name,:default_page_parts,:yield_body_as_content_block,:default_page_layout,:enable_sitemap,:enable_full_page_caching,:enable_action_caching
|
6
6
|
|
7
7
|
self.root_page_name = "home"
|
8
8
|
self.menus_enabled = true
|
@@ -11,6 +11,7 @@ module Spud
|
|
11
11
|
self.default_page_parts = ["Body"]
|
12
12
|
self.yield_body_as_content_block = false
|
13
13
|
self.enable_full_page_caching = false
|
14
|
+
self.enable_action_caching = false
|
14
15
|
self.enable_sitemap = true
|
15
16
|
end
|
16
17
|
end
|
data/lib/spud_cms/engine.rb
CHANGED
@@ -4,7 +4,9 @@ module Spud
|
|
4
4
|
module Cms
|
5
5
|
class Engine < Rails::Engine
|
6
6
|
engine_name :spud_cms
|
7
|
+
# config.autoload_paths << File.expand_path("../app/sweepers", __FILE__)
|
7
8
|
|
9
|
+
|
8
10
|
initializer :admin do
|
9
11
|
Spud::Core.configure do |config|
|
10
12
|
config.admin_applications += [{:name => "Pages",:thumbnail => "spud/admin/pages_thumb.png",:url => "/spud/admin/pages",:order => 0}]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spud_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spud_core
|
16
|
-
requirement: &
|
16
|
+
requirement: &70314688986880 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.6.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70314688986880
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: codemirror-rails
|
27
|
-
requirement: &
|
27
|
+
requirement: &70314688986400 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70314688986400
|
36
36
|
description:
|
37
37
|
email: destes@redwindsw.com
|
38
38
|
executables: []
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- app/controllers/spud/admin/templates_controller.rb
|
59
59
|
- app/controllers/spud/cms/sitemaps_controller.rb
|
60
60
|
- app/helpers/spud/cms/application_helper.rb
|
61
|
+
- app/models/page_sweeper.rb
|
61
62
|
- app/models/spud_menu.rb
|
62
63
|
- app/models/spud_menu_item.rb
|
63
64
|
- app/models/spud_page.rb
|