caboose-cms 0.5.37 → 0.5.38
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/controllers/caboose/application_controller.rb +4 -3
- data/app/controllers/caboose/pages_controller.rb +2 -2
- data/app/models/caboose/block.rb +12 -22
- data/app/models/caboose/block_cache.rb +89 -0
- data/app/models/caboose/block_cache_file.rb +22 -0
- data/app/models/caboose/block_cache_image.rb +53 -0
- data/app/models/caboose/page.rb +1 -0
- data/app/models/caboose/page_cache.rb +12 -0
- data/app/models/caboose/page_cacher.rb +115 -0
- data/app/models/caboose/schema.rb +7 -0
- data/app/views/caboose/blocks/_select.html.erb +12 -0
- data/app/views/layouts/caboose/application.html.erb +30 -16
- data/lib/caboose/version.rb +1 -1
- data/lib/tasks/caboose.rake +5 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjlkZmI4M2ZiZDk5ZjBiZDA1OTcyNDE5NWMzZjlkZWJkMWIyOTgyZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWRjYTVhMjMzZjA3Zjc0MjI1NWM0MzNkYjFiNGI5Mjg2MWU1YjFhZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmViNzcwZWQ2OWYwYmNhZjk1YTdiYTY0Njc5YjY4NzYxZWVlOWI1MTRmM2E0
|
10
|
+
NzUwOTg1YjkwN2E5YWNmNTQ2MDNhNmQxMGFlMjY4ZTk2NGQ2MjIwZWI1OGYx
|
11
|
+
NzBiYzI5YzE3NDY2MDBhOTI5ZWRiNGJjNTFkYThkZTc5YzQ2M2U=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGIwMTgzMWY1YjQwMTQzYzhiMDQ4ZWNlNjIxN2YzZDZmNTBiMDMxZTQ2YjEx
|
14
|
+
ZTVlYzA5ZjM3NDc4MTMwZTQ4NmE2YjA5Yzk1YzQ4YWUxYjhmOTlkOGFlYWNl
|
15
|
+
ZTY4YmU1ZmZkNGU3NjFlNGQyZmZkOTYzNzlkODIyZDEyN2U0MjI=
|
@@ -6,13 +6,14 @@ module Caboose
|
|
6
6
|
helper_method :logged_in?
|
7
7
|
helper :all
|
8
8
|
|
9
|
-
@find_page = true
|
9
|
+
@find_page = true
|
10
10
|
|
11
|
-
def before_before_action
|
12
|
-
|
11
|
+
def before_before_action
|
13
12
|
# Modify the built-in params array with URL params if necessary
|
14
13
|
parse_url_params if Caboose.use_url_params
|
15
14
|
|
15
|
+
@use_page_cache = !request.fullpath.starts_with?('/admin')
|
16
|
+
|
16
17
|
# Get the site we're working with
|
17
18
|
domain = Domain.where(:domain => request.host_with_port).first
|
18
19
|
@site = domain ? domain.site : nil
|
@@ -5,14 +5,14 @@ module Caboose
|
|
5
5
|
helper :application
|
6
6
|
|
7
7
|
def before_action
|
8
|
-
@page = Page.page_with_uri(request.host_with_port, '/admin')
|
8
|
+
@page = Page.page_with_uri(request.host_with_port, '/admin')
|
9
9
|
end
|
10
10
|
|
11
11
|
# GET /pages/:id
|
12
12
|
def show
|
13
13
|
|
14
14
|
# Find the page with an exact URI match
|
15
|
-
page = Page.page_with_uri(request.host_with_port, request.fullpath, false)
|
15
|
+
page = Page.page_with_uri(request.host_with_port, request.fullpath, false)
|
16
16
|
|
17
17
|
# Make sure we're not under construction
|
18
18
|
d = Caboose::Domain.where(:domain => request.host_with_port).first
|
data/app/models/caboose/block.rb
CHANGED
@@ -33,21 +33,20 @@ class Caboose::Block < ActiveRecord::Base
|
|
33
33
|
before_save :caste_value
|
34
34
|
|
35
35
|
def caste_value
|
36
|
-
if self.
|
36
|
+
if self.block_type_id.nil?
|
37
37
|
bt = Caboose::BlockType.where(:field_type => 'text').first
|
38
38
|
if bt.nil?
|
39
39
|
bt = Caboose::BlockType.create(:name => 'text', :description => 'Text', :field_type => 'text', :default => '', :width => 800, :height => 400, :fixed_placeholder => false)
|
40
40
|
end
|
41
41
|
self.block_type_id = bt.id
|
42
42
|
end
|
43
|
-
if self.
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
43
|
+
#if self.block_type_id.field_type.nil?
|
44
|
+
# self.block_type.field_type = 'text'
|
45
|
+
#end
|
46
|
+
#if self.block_type.field_type == 'checkbox'
|
47
|
+
# v = self.value
|
48
|
+
# self.value = v ? (v == 1 || v == '1' || v == true ? 1 : 0) : 0
|
49
|
+
#end
|
51
50
|
end
|
52
51
|
|
53
52
|
def full_name
|
@@ -137,19 +136,10 @@ class Caboose::Block < ActiveRecord::Base
|
|
137
136
|
end
|
138
137
|
options2[:block] = block
|
139
138
|
|
140
|
-
view = options2[:view]
|
141
|
-
view = ActionView::Base.new(ActionController::Base.view_paths) if view.nil?
|
142
|
-
if block.block_type.use_render_function && block.block_type.render_function
|
143
|
-
#str = block.render_from_function(options2)
|
144
|
-
|
145
|
-
#locals = OpenStruct.new(options)
|
146
|
-
#locals = OpenStruct.new(options2)
|
147
|
-
#str = ERB.new(block_type.render_function).result(locals.instance_eval { binding })
|
148
|
-
#return erb.result(locals.instance_eval { binding })
|
149
|
-
|
150
|
-
#eval("def render_my_function\n#{block.block_type.render_function}\nend\n\n, :locals => options2)
|
151
|
-
#Caboose.log(block.id)
|
139
|
+
view = options2[:view]
|
140
|
+
view = ActionView::Base.new(ActionController::Base.view_paths) if view.nil?
|
152
141
|
|
142
|
+
if block.block_type.use_render_function && block.block_type.render_function
|
153
143
|
begin
|
154
144
|
str = view.render(:partial => "caboose/blocks/render_function", :locals => options2)
|
155
145
|
rescue Exception => ex
|
@@ -209,7 +199,7 @@ class Caboose::Block < ActiveRecord::Base
|
|
209
199
|
rescue Exception => ex
|
210
200
|
str = "<p class='note error'>#{self.block_message(block, ex)}</p>"
|
211
201
|
end
|
212
|
-
end
|
202
|
+
end
|
213
203
|
return str
|
214
204
|
end
|
215
205
|
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Caboose
|
2
|
+
class BlockCache
|
3
|
+
|
4
|
+
attr_accessor :id,
|
5
|
+
:page_id,
|
6
|
+
:parent_id,
|
7
|
+
:block_type_id,
|
8
|
+
:block_type_field_type,
|
9
|
+
:sort_order,
|
10
|
+
:name,
|
11
|
+
:value,
|
12
|
+
:file,
|
13
|
+
:image,
|
14
|
+
:children
|
15
|
+
|
16
|
+
def child_value(name)
|
17
|
+
b = self.child(name)
|
18
|
+
return nil if b.nil?
|
19
|
+
return b.image if b.block_type_field_type == 'image'
|
20
|
+
return b.file if b.block_type_field_type == 'file'
|
21
|
+
return b.value
|
22
|
+
end
|
23
|
+
|
24
|
+
def child(name)
|
25
|
+
self.children.each do |kid|
|
26
|
+
return kid if kid.name == name
|
27
|
+
end
|
28
|
+
return nil
|
29
|
+
end
|
30
|
+
|
31
|
+
#def render(block, options = nil)
|
32
|
+
# block = self.child(block) if block && block.is_a?(String)
|
33
|
+
# eval("CabooseBlockRendering::render_block_type_#{block.block_type_id}(block)")
|
34
|
+
#end
|
35
|
+
|
36
|
+
def initialize(b)
|
37
|
+
self.id = b.id
|
38
|
+
self.page_id = b.page_id
|
39
|
+
self.parent_id = b.parent_id
|
40
|
+
self.block_type_id = b.block_type_id
|
41
|
+
self.block_type_field_type = b.block_type ? b.block_type.field_type : nil
|
42
|
+
self.sort_order = b.sort_order
|
43
|
+
self.name = b.name
|
44
|
+
self.value = b.value
|
45
|
+
self.file = BlockCacheFile.new(b.file)
|
46
|
+
self.image = BlockCacheImage.new(b.image)
|
47
|
+
self.children = b.children.collect{ |b2| BlockCache.new(b2) }
|
48
|
+
end
|
49
|
+
|
50
|
+
def page
|
51
|
+
return $page
|
52
|
+
end
|
53
|
+
|
54
|
+
def marshal_dump
|
55
|
+
[
|
56
|
+
self.id,
|
57
|
+
self.page_id,
|
58
|
+
self.parent_id,
|
59
|
+
self.block_type_id,
|
60
|
+
self.block_type_field_type,
|
61
|
+
self.sort_order,
|
62
|
+
self.name,
|
63
|
+
self.value,
|
64
|
+
Marshal.dump(self.file),
|
65
|
+
Marshal.dump(self.image),
|
66
|
+
self.children.collect{ |b| Marshal.dump(b) }
|
67
|
+
]
|
68
|
+
end
|
69
|
+
|
70
|
+
def marshal_load array
|
71
|
+
self.id,
|
72
|
+
self.page_id,
|
73
|
+
self.parent_id,
|
74
|
+
self.block_type_id,
|
75
|
+
self.block_type_field_type,
|
76
|
+
self.sort_order,
|
77
|
+
self.name,
|
78
|
+
self.value,
|
79
|
+
self.file,
|
80
|
+
self.image,
|
81
|
+
self.children = array
|
82
|
+
|
83
|
+
self.file = Marshal.load(self.file)
|
84
|
+
self.image = Marshal.load(self.image)
|
85
|
+
self.children = self.children.collect{ |kid| Marshal.load(kid) }
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
module Caboose
|
3
|
+
class BlockCacheFile
|
4
|
+
|
5
|
+
def initialize(file)
|
6
|
+
@_url = file.url
|
7
|
+
end
|
8
|
+
|
9
|
+
def url(style = nil)
|
10
|
+
return @_url
|
11
|
+
end
|
12
|
+
|
13
|
+
def marshal_dump
|
14
|
+
[@_url]
|
15
|
+
end
|
16
|
+
|
17
|
+
def marshal_load array
|
18
|
+
@url = array.first
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
|
2
|
+
module Caboose
|
3
|
+
class BlockCacheImage
|
4
|
+
|
5
|
+
def initialize(image)
|
6
|
+
@urls = {}
|
7
|
+
image.styles.each do |style|
|
8
|
+
@urls[style[0].to_s] = image.url(style[0])
|
9
|
+
end
|
10
|
+
#puts "--------------------------------------------"
|
11
|
+
#puts "Caboose::BlockCacheImage.initialize"
|
12
|
+
#puts "urls = #{@urls.inspect}"
|
13
|
+
#puts "--------------------------------------------"
|
14
|
+
end
|
15
|
+
|
16
|
+
def url(style = nil)
|
17
|
+
#puts "--------------------------------------------"
|
18
|
+
#puts "Caboose::BlockCacheImage.url"
|
19
|
+
#puts "urls = #{@urls.inspect}"
|
20
|
+
#puts "--------------------------------------------"
|
21
|
+
|
22
|
+
return @urls['thumb'] if style.nil?
|
23
|
+
return @urls[style.to_s]
|
24
|
+
end
|
25
|
+
|
26
|
+
def marshal_dump
|
27
|
+
arr = []
|
28
|
+
if @urls && @urls.count > 0
|
29
|
+
@urls.each do |k,v|
|
30
|
+
arr << k
|
31
|
+
arr << v
|
32
|
+
end
|
33
|
+
end
|
34
|
+
return arr
|
35
|
+
end
|
36
|
+
|
37
|
+
def marshal_load arr
|
38
|
+
@urls = {}
|
39
|
+
i = 0
|
40
|
+
count = arr.count
|
41
|
+
while i<count
|
42
|
+
k = arr[i]
|
43
|
+
@urls[k] = arr[i+1]
|
44
|
+
i = i + 2
|
45
|
+
end
|
46
|
+
#puts "--------------------------------------------"
|
47
|
+
#puts "Caboose::BlockCacheImage.marshal_load"
|
48
|
+
#puts "urls = #{@urls.inspect}"
|
49
|
+
#puts "--------------------------------------------"
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
data/app/models/caboose/page.rb
CHANGED
@@ -8,6 +8,7 @@ class Caboose::Page < ActiveRecord::Base
|
|
8
8
|
has_many :page_permissions
|
9
9
|
has_many :blocks, :order => 'sort_order'
|
10
10
|
has_many :page_tags, :class_name => 'Caboose::PageTag', :dependent => :delete_all, :order => 'tag'
|
11
|
+
has_one :page_cache
|
11
12
|
attr_accessible :id ,
|
12
13
|
:site_id ,
|
13
14
|
:parent_id ,
|
@@ -0,0 +1,115 @@
|
|
1
|
+
|
2
|
+
module Caboose
|
3
|
+
class PageCacher
|
4
|
+
|
5
|
+
def self.cache_all
|
6
|
+
Page.reorder(:id).all.each do |p|
|
7
|
+
puts "Caching #{p.title}..."
|
8
|
+
self.cache(p)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.cache(page_id)
|
13
|
+
p = (page_id.is_a?(Integer) ? Page.where(:id => page_id).first : page_id)
|
14
|
+
return if p.nil?
|
15
|
+
return if p.site_id.nil?
|
16
|
+
return if p.block.nil?
|
17
|
+
|
18
|
+
@render_functions = {} if @render_functions.nil?
|
19
|
+
@page_render_functions = {} if @page_render_functions.nil?
|
20
|
+
@page_render_functions[p.id] = []
|
21
|
+
@dups = {}
|
22
|
+
|
23
|
+
self.cache_helper(p.site, p, p.block)
|
24
|
+
|
25
|
+
arr = @page_render_functions[p.id].collect do |bt_id|
|
26
|
+
"<% def render_block_type_#{bt_id}(block, page, view, controller_view_content, modal, empty_text, editing, css, js, csrf_meta_tags, csrf_meta_tags2, logged_in_user, site) %>#{@render_functions[bt_id]}<% end %>"
|
27
|
+
end
|
28
|
+
|
29
|
+
dups = []
|
30
|
+
@dups.each{ |bt_id, arr| dups << "#{bt_id} => [#{arr.join(',')}]" }
|
31
|
+
dups = dups.join(', ')
|
32
|
+
|
33
|
+
str = arr.join("\n\n")
|
34
|
+
str << "<%\n"
|
35
|
+
str << "def dup_id(bt_id)\n"
|
36
|
+
str << " dups = {#{dups}}\n"
|
37
|
+
str << " dups.each do |bt_id2, arr|\n"
|
38
|
+
str << " return bt_id2 if arr.include?(bt_id)\n"
|
39
|
+
str << " end\n"
|
40
|
+
str << " return bt_id\n"
|
41
|
+
str << "end\n"
|
42
|
+
str << "def render_block_type(block, child_block, page, view, controller_view_content, modal, empty_text, editing, css, js, csrf_meta_tags, csrf_meta_tags2, logged_in_user, site)\n"
|
43
|
+
str << " b = child_block && child_block.is_a?(String) ? block.child(child_block) : child_block\n"
|
44
|
+
str << " send(\"render_block_type_\#\{dup_id(b.block_type_id)\}\", b, page, view, controller_view_content, modal, empty_text, editing, css, js, csrf_meta_tags, csrf_meta_tags2, logged_in_user, site)\n"
|
45
|
+
str << "end\n\n"
|
46
|
+
str << "render_block_type_#{p.block.block_type_id}(@block, @page, @view, @controller_view_content, @modal, @empty_text, @editing, @css, @js, @csrf_meta_tags, @csrf_meta_tags2, @logged_in_user, @site)\n"
|
47
|
+
str << "%>\n"
|
48
|
+
|
49
|
+
pc = PageCache.where(:page_id => p.id).first
|
50
|
+
pc = PageCache.new(:page_id => p.id) if pc.nil?
|
51
|
+
pc.render_function = str
|
52
|
+
pc.block = Marshal.dump(BlockCache.new(p.block))
|
53
|
+
pc.save
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.cache_helper(site, p, block)
|
57
|
+
return if block.nil?
|
58
|
+
self.cache_helper2(site, p, block.block_type)
|
59
|
+
block.children.each{ |b2| self.cache_helper(site, p, b2) }
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.cache_helper2(site, p, bt)
|
63
|
+
self.add_block_type(site, p, bt)
|
64
|
+
bt.children.each{ |bt2| self.cache_helper2(site, p, bt2) }
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.add_block_type(site, p, bt)
|
68
|
+
if !@render_functions.has_key?(bt.id)
|
69
|
+
f = ''
|
70
|
+
if bt.use_render_function && bt.render_function
|
71
|
+
f = bt.render_function
|
72
|
+
else
|
73
|
+
full_name = bt.full_name
|
74
|
+
full_name = "lksdjflskfjslkfjlskdfjlkjsdf" if full_name.nil? || full_name.length == 0
|
75
|
+
if File.file?(Rails.root.join("sites/#{site.name}/blocks/_#{full_name}.html.erb" )) then f = Rails.root.join("sites/#{site.name}/blocks/_#{full_name}.html.erb")
|
76
|
+
elsif File.file?(Rails.root.join("sites/#{site.name}/blocks/_#{bt.name}.html.erb" )) then f = Rails.root.join("sites/#{site.name}/blocks/_#{bt.name}.html.erb")
|
77
|
+
elsif File.file?(Rails.root.join("sites/#{site.name}/blocks/_#{bt.field_type}.html.erb" )) then f = Rails.root.join("sites/#{site.name}/blocks/_#{bt.field_type}.html.erb")
|
78
|
+
elsif File.file?(Rails.root.join("app/views/caboose/blocks/_#{full_name}.html.erb" )) then f = Rails.root.join("app/views/caboose/blocks/_#{full_name}.html.erb")
|
79
|
+
elsif File.file?(Rails.root.join("app/views/caboose/blocks/_#{bt.name}.html.erb" )) then f = Rails.root.join("app/views/caboose/blocks/_#{bt.name}.html.erb")
|
80
|
+
elsif File.file?(Rails.root.join("app/views/caboose/blocks/_#{bt.field_type}.html.erb" )) then f = Rails.root.join("app/views/caboose/blocks/_#{bt.field_type}.html.erb")
|
81
|
+
elsif File.file?("#{Caboose.root}/app/views/caboose/blocks/_#{full_name}.html.erb" ) then f = "#{Caboose.root}/app/views/caboose/blocks/_#{full_name}.html.erb"
|
82
|
+
elsif File.file?("#{Caboose.root}/app/views/caboose/blocks/_#{bt.name}.html.erb" ) then f = "#{Caboose.root}/app/views/caboose/blocks/_#{bt.name}.html.erb"
|
83
|
+
elsif File.file?("#{Caboose.root}/app/views/caboose/blocks/_#{bt.field_type}.html.erb" ) then f = "#{Caboose.root}/app/views/caboose/blocks/_#{bt.field_type}.html.erb"
|
84
|
+
end
|
85
|
+
f = File.read(f)
|
86
|
+
end
|
87
|
+
f.gsub!(/block\.partial\((.*?),(.*?)\)/ , 'render :partial => \1')
|
88
|
+
f.gsub!(/block\.render\((.*?),(.*?)\)/ , 'render_block_type(block, \1, page, view, controller_view_content, modal, empty_text, editing, css, js, csrf_meta_tags, csrf_meta_tags2, logged_in_user, site)')
|
89
|
+
f.gsub!(/\=\s*render_block_type\(/ , 'render_block_type(')
|
90
|
+
f.gsub!(/\=\s*raw render_block_type\(/ , 'render_block_type(')
|
91
|
+
|
92
|
+
#@render_functions[bt.id] = "<% def render_block_type_#{bt.id}(block, page, view, controller_view_content, modal, empty_text, editing, css, js, csrf_meta_tags, csrf_meta_tags2, logged_in_user, site) %>#{f}<% end %>"
|
93
|
+
|
94
|
+
@render_functions[bt.id] = f
|
95
|
+
end
|
96
|
+
|
97
|
+
is_dup = false
|
98
|
+
f = @render_functions[bt.id]
|
99
|
+
@render_functions.each do |bt_id, f2|
|
100
|
+
if f == f2 && @page_render_functions[p.id].include?(bt_id)
|
101
|
+
@dups[bt_id] = [] if !@dups.has_key?(bt_id)
|
102
|
+
@dups[bt_id] << bt.id if !@dups[bt_id].include?(bt.id)
|
103
|
+
is_dup = true
|
104
|
+
break
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
if !is_dup
|
109
|
+
@page_render_functions[p.id] = [] if !@page_render_functions.has_key?(p.id)
|
110
|
+
@page_render_functions[p.id] << bt.id if !@page_render_functions[p.id].include?(bt.id)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
@@ -54,6 +54,7 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
54
54
|
:repeat_start ,
|
55
55
|
:repeat_end
|
56
56
|
],
|
57
|
+
#Caboose::PageCache => [:block],
|
57
58
|
Caboose::Variant => [:quantity]
|
58
59
|
}
|
59
60
|
end
|
@@ -342,6 +343,12 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
342
343
|
[ :fb_description , :string , { :limit => 156 }],
|
343
344
|
[ :gp_description , :string , { :limit => 156 }]
|
344
345
|
],
|
346
|
+
Caboose::PageCache => [
|
347
|
+
[ :page_id , :integer ],
|
348
|
+
[ :render_function , :text ],
|
349
|
+
[ :block , :binary ],
|
350
|
+
[ :refresh , :boolean , { :default => false }]
|
351
|
+
],
|
345
352
|
Caboose::PagePermission => [
|
346
353
|
[ :role_id , :integer ],
|
347
354
|
[ :page_id , :integer ],
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
<% if @page && @page.title != 'Access Denied' %>
|
3
2
|
<% content_for :js do %>
|
4
3
|
<%= javascript_include_tag "caboose/application" %>
|
@@ -26,7 +25,7 @@
|
|
26
25
|
b.create_children
|
27
26
|
end
|
28
27
|
#b.log_helper
|
29
|
-
|
28
|
+
options = {
|
30
29
|
:page => @page,
|
31
30
|
:view => self,
|
32
31
|
:controller_view_content => yield,
|
@@ -36,11 +35,38 @@
|
|
36
35
|
:css => '|CABOOSE_CSS|',
|
37
36
|
:js => '|CABOOSE_JAVASCRIPT|',
|
38
37
|
:csrf_meta_tags => '|CABOOSE_CSRF|',
|
39
|
-
:csrf_meta_tags2 => '|CABOOSE_CSRF|',
|
38
|
+
:csrf_meta_tags2 => '|CABOOSE_CSRF|',
|
40
39
|
:logged_in_user => @logged_in_user,
|
41
40
|
:site => @site
|
42
|
-
}
|
41
|
+
}
|
42
|
+
|
43
|
+
str = nil
|
44
|
+
if @use_page_cache
|
45
|
+
pc = Caboose::PageCache.where(:page_id => @page.id).first
|
46
|
+
if pc # If the page is cached, send it to the user
|
47
|
+
|
48
|
+
require_dependency "#{Caboose.root}/app/models/caboose/block_cache.rb"
|
49
|
+
require_dependency "#{Caboose.root}/app/models/caboose/block_cache_file.rb"
|
50
|
+
require_dependency "#{Caboose.root}/app/models/caboose/block_cache_image.rb"
|
51
|
+
|
52
|
+
@block = Marshal.load(pc.block)
|
53
|
+
@view = options[:view ]
|
54
|
+
@controller_view_content = options[:controller_view_content ]
|
55
|
+
@modal = options[:modal ]
|
56
|
+
@empty_text = options[:empty_text ]
|
57
|
+
@editing = options[:editing ]
|
58
|
+
@css = options[:css ]
|
59
|
+
@js = options[:js ]
|
60
|
+
@csrf_meta_tags = options[:csrf_meta_tags ]
|
61
|
+
@csrf_meta_tags2 = options[:csrf_meta_tags2 ]
|
62
|
+
|
63
|
+
str = render(:inline => pc.render_function)
|
64
|
+
end
|
65
|
+
end
|
43
66
|
|
67
|
+
# Render the blocks if we don't have it cached
|
68
|
+
str = b.render(b, options) if str.nil?
|
69
|
+
|
44
70
|
protocol = request.protocol
|
45
71
|
css = yield(:css)
|
46
72
|
css.gsub!("<link href=\"//", "<link href=\"#{protocol}")
|
@@ -52,18 +78,6 @@
|
|
52
78
|
str.gsub!('|CABOOSE_CSRF|' , csrf_meta_tags)
|
53
79
|
|
54
80
|
%><%= raw str %><%
|
55
|
-
|
56
|
-
#b = @page.block
|
57
|
-
#
|
58
|
-
#raw b.render(b, {
|
59
|
-
# :controller_view_content => yield,
|
60
|
-
# :modal => false,
|
61
|
-
# :empty_text => '',
|
62
|
-
# :editing => defined?(@editing) ? @editing : false,
|
63
|
-
# :css => yield(:css),
|
64
|
-
# :js => yield(:js),
|
65
|
-
# :csrf_meta_tags => csrf_meta_tags
|
66
|
-
# })
|
67
81
|
|
68
82
|
end
|
69
83
|
%>
|
data/lib/caboose/version.rb
CHANGED
data/lib/tasks/caboose.rake
CHANGED
@@ -2,6 +2,11 @@ require "caboose/version"
|
|
2
2
|
|
3
3
|
namespace :caboose do
|
4
4
|
|
5
|
+
desc "Cache pages"
|
6
|
+
task :cache_pages => :environment do
|
7
|
+
Caboose::PageCacher.cache_all
|
8
|
+
end
|
9
|
+
|
5
10
|
desc "Run rspec tests on Caboose"
|
6
11
|
task :test => :environment do
|
7
12
|
system("rspec #{Caboose::root}/spec")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caboose-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.38
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -518,6 +518,9 @@ files:
|
|
518
518
|
- app/models/caboose/asset.rb
|
519
519
|
- app/models/caboose/authenticator.rb
|
520
520
|
- app/models/caboose/block.rb
|
521
|
+
- app/models/caboose/block_cache.rb
|
522
|
+
- app/models/caboose/block_cache_file.rb
|
523
|
+
- app/models/caboose/block_cache_image.rb
|
521
524
|
- app/models/caboose/block_type.rb
|
522
525
|
- app/models/caboose/block_type_category.rb
|
523
526
|
- app/models/caboose/block_type_icons.rb
|
@@ -548,6 +551,8 @@ files:
|
|
548
551
|
- app/models/caboose/order_pdf.rb
|
549
552
|
- app/models/caboose/page.rb
|
550
553
|
- app/models/caboose/page_bar_generator.rb
|
554
|
+
- app/models/caboose/page_cache.rb
|
555
|
+
- app/models/caboose/page_cacher.rb
|
551
556
|
- app/models/caboose/page_permission.rb
|
552
557
|
- app/models/caboose/page_tag.rb
|
553
558
|
- app/models/caboose/pager.rb
|
@@ -623,6 +628,7 @@ files:
|
|
623
628
|
- app/views/caboose/blocks/_render_function.html.erb
|
624
629
|
- app/views/caboose/blocks/_richtext.html.erb
|
625
630
|
- app/views/caboose/blocks/_ruby_block.rb
|
631
|
+
- app/views/caboose/blocks/_select.html.erb
|
626
632
|
- app/views/caboose/blocks/_selector_switch_one.html.erb
|
627
633
|
- app/views/caboose/blocks/_selector_switch_three.html.erb
|
628
634
|
- app/views/caboose/blocks/_selector_switch_two.html.erb
|