imagine_cms 4.1.2 → 4.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/app/sweepers/cms_content_sweeper.rb +56 -4
- data/imagine_cms.gemspec +1 -1
- data/lib/extensions/action_controller_extensions.rb +21 -0
- data/lib/imagine_cms/engine.rb +4 -1
- data/lib/imagine_cms/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7901f9485760be5cf335debb90d505feb76e66e4
|
4
|
+
data.tar.gz: ca8bbfb24c3caebc655447d98d3832e93aefb6bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12177249b22e35b6882180a83ddbef2eda148d2fde9d04661d6bbb29b42ba49310bf9f21857fb17efd74000c49530024c90039e117fb7ee9467da5fdf2362d9c
|
7
|
+
data.tar.gz: 09b2f980f7274949f579ad5156df3d2fd6886f00f117586bffd391a874cc3346d9e6dbe2312bac2cc272a96e794706e35da99d07d64b0c8ae0b2fddfb1c367e3
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.2
|
@@ -10,15 +10,55 @@ class CmsContentSweeper < ActionController::Caching::Sweeper
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def delete_all_cached_pages
|
13
|
+
cache_dir = File.expand_path(Management::CmsController.page_cache_directory)
|
14
|
+
public_dir = File.expand_path("#{Rails.root}/public")
|
15
|
+
|
16
|
+
# this could throw Errno::ENOENT
|
13
17
|
begin
|
14
|
-
|
18
|
+
cache_dir = File.realpath cache_dir
|
19
|
+
public_dir = File.realpath public_dir
|
20
|
+
end
|
21
|
+
|
22
|
+
begin
|
23
|
+
if cache_dir == public_dir
|
15
24
|
# expire home page
|
16
|
-
expire_page :
|
25
|
+
expire_page controller: 'cms/content', action: 'show', content_path: nil
|
17
26
|
|
18
27
|
# expire all other pages
|
19
|
-
|
20
|
-
|
28
|
+
|
29
|
+
# original method is too slow for large sites:
|
30
|
+
# CmsPage.select([ :id, :path ]).find_each do |page|
|
31
|
+
# expire_page controller: 'cms/content', action: 'show', content_path: page.path.split('/')
|
32
|
+
# end
|
33
|
+
|
34
|
+
# quicker method: remove entire directory trees when possible
|
35
|
+
dangerous_names = [ 'assets', 'images', 'javascripts', 'media', 'stylesheets' ]
|
36
|
+
home_page = CmsPage.find_by_path('')
|
37
|
+
CmsPage.where(parent_id: home_page.id).each do |page|
|
38
|
+
if dangerous_names.include?(page.path)
|
39
|
+
# expire pages the old way
|
40
|
+
Rails.logger.info "Expire tree #{path} using safe method"
|
41
|
+
sub_page_paths(page).each do |path|
|
42
|
+
expire_page controller: 'cms/content', action: 'show', content_path: path.split('/')
|
43
|
+
end
|
44
|
+
else
|
45
|
+
# first clear this page
|
46
|
+
expire_page controller: 'cms/content', action: 'show', content_path: page.path.split('/')
|
47
|
+
|
48
|
+
# then attempt to remove entire directory tree, after sanity check
|
49
|
+
path = File.expand_path(File.join(Management::CmsController.page_cache_directory, page.path))
|
50
|
+
Dir.chdir Rails.root
|
51
|
+
Dir.glob(Pathname.new(path).relative_path_from(Pathname.new(Rails.root)).to_s, File::FNM_CASEFOLD).each do |path|
|
52
|
+
path = File.realpath(File.expand_path(path, Rails.root))
|
53
|
+
if path && File.directory?(path) # could be nil if realpath threw an Errno::ENOENT
|
54
|
+
raise "Cache directory name #{path} failed sanity check" unless path =~ /^#{public_dir}/
|
55
|
+
Rails.logger.info "Expire tree #{path} using rm -rf"
|
56
|
+
FileUtils.rm_rf(path, secure: true)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
21
60
|
end
|
61
|
+
|
22
62
|
else
|
23
63
|
FileUtils.rm_r(Dir.glob("#{cache_dir}/*")) rescue Errno::ENOENT
|
24
64
|
end
|
@@ -27,4 +67,16 @@ class CmsContentSweeper < ActionController::Caching::Sweeper
|
|
27
67
|
end
|
28
68
|
end
|
29
69
|
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def sub_page_paths(page)
|
74
|
+
paths = [ page.path ]
|
75
|
+
CmsPage.where(parent_id: page.id).each do |pg|
|
76
|
+
paths << pg.path
|
77
|
+
paths.concat sub_page_paths(pg)
|
78
|
+
end
|
79
|
+
paths
|
80
|
+
end
|
81
|
+
|
30
82
|
end
|
data/imagine_cms.gemspec
CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.add_dependency "actionpack-page_caching", "~> 1.0"
|
34
34
|
s.add_dependency "non-stupid-digest-assets", "~> 1.0"
|
35
35
|
s.add_dependency "prototype-rails", "~> 4.0.0"
|
36
|
-
s.add_dependency "aws-sdk", "~> 2.0.0
|
36
|
+
s.add_dependency "aws-sdk", "~> 2.0.0"
|
37
37
|
s.add_dependency "rmagick", [ ">= 1.15.0", "< 3.0" ]
|
38
38
|
s.add_dependency "mini_magick", "~> 3.3"
|
39
39
|
s.add_dependency "rubyzip", "~> 1.0"
|
@@ -244,4 +244,25 @@ module ActionControllerExtensions
|
|
244
244
|
end
|
245
245
|
|
246
246
|
end
|
247
|
+
|
248
|
+
end
|
249
|
+
|
250
|
+
module ActionControllerCachingExtensions
|
251
|
+
|
252
|
+
module ClassMethods
|
253
|
+
|
254
|
+
def expire_page(path)
|
255
|
+
return unless perform_caching
|
256
|
+
|
257
|
+
path = Pathname.new(page_cache_path(path)).relative_path_from(Pathname.new(Rails.root))
|
258
|
+
Dir.chdir Rails.root
|
259
|
+
|
260
|
+
instrument_page_cache :expire_page, path do
|
261
|
+
Dir.glob(path, File::FNM_CASEFOLD).each { |f| File.delete(f) }
|
262
|
+
Dir.glob(path + '.gz', File::FNM_CASEFOLD).each { |f| File.delete(f) }
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
end
|
267
|
+
|
247
268
|
end
|
data/lib/imagine_cms/engine.rb
CHANGED
@@ -13,7 +13,10 @@ module ImagineCms
|
|
13
13
|
|
14
14
|
initializer 'imagine_cms.load_helpers' do |app|
|
15
15
|
ActionController::Base.send :include, CmsApplicationHelper
|
16
|
-
|
16
|
+
end
|
17
|
+
|
18
|
+
initializer 'imagine_cms.caching_extensions' do |app|
|
19
|
+
ActionController::Base.send :extend, ActionControllerCachingExtensions::ClassMethods
|
17
20
|
end
|
18
21
|
|
19
22
|
def self.activate
|
data/lib/imagine_cms/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imagine_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Namba
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -106,14 +106,14 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 2.0.0
|
109
|
+
version: 2.0.0
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: 2.0.0
|
116
|
+
version: 2.0.0
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
name: rmagick
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -612,7 +612,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
612
612
|
version: 1.8.11
|
613
613
|
requirements: []
|
614
614
|
rubyforge_project: imagine_cms
|
615
|
-
rubygems_version: 2.4.
|
615
|
+
rubygems_version: 2.4.6
|
616
616
|
signing_key:
|
617
617
|
specification_version: 4
|
618
618
|
summary: Imagine Content Management System for Rails
|