kiosk 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/kiosk/cacheable/connection.rb +4 -5
- data/lib/kiosk/cacheable/resource.rb +4 -6
- data/lib/kiosk/controller.rb +46 -48
- data/lib/kiosk/version.rb +1 -1
- metadata +17 -6
@@ -31,8 +31,7 @@ module Kiosk
|
|
31
31
|
# +cache_expire_by_pattern+.
|
32
32
|
#
|
33
33
|
def cache_key_matcher
|
34
|
-
|
35
|
-
when ActiveSupport::Cache::RedisStore
|
34
|
+
if defined?(ActiveSupport::Cache::RedisStore) && Rails.cache.is_a?(ActiveSupport::Cache::RedisStore)
|
36
35
|
:glob
|
37
36
|
else
|
38
37
|
:regexp
|
@@ -73,11 +72,11 @@ module Kiosk
|
|
73
72
|
# fresh result is returned.
|
74
73
|
#
|
75
74
|
def cache_read_write(key)
|
76
|
-
if
|
77
|
-
result =
|
75
|
+
if cached_object = cache(:read, cache_key(key))
|
76
|
+
result = cached_object
|
78
77
|
elsif result = yield
|
79
78
|
options = (expiry = cache_expiry_of(result)) ? {:expires_in => expiry} : {}
|
80
|
-
cache(:write, cache_key(key), result
|
79
|
+
cache(:write, cache_key(key), result, options) if result
|
81
80
|
end
|
82
81
|
result
|
83
82
|
end
|
@@ -100,12 +100,10 @@ module Kiosk
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
self.class.expire_resource(self)
|
108
|
-
end
|
103
|
+
# Expire the resource from the cache.
|
104
|
+
#
|
105
|
+
def expire
|
106
|
+
self.class.expire_resource(self)
|
109
107
|
end
|
110
108
|
end
|
111
109
|
end
|
data/lib/kiosk/controller.rb
CHANGED
@@ -6,56 +6,54 @@ module Kiosk
|
|
6
6
|
module Controller
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
9
|
+
# Declares a rewrite of content nodes that sets the host portion of
|
10
|
+
# each node's URI attribute (href or src) to target the configured CDN
|
11
|
+
# host.
|
12
|
+
#
|
13
|
+
def rewrite_cdn_paths_for(resource_model)
|
14
|
+
Kiosk.rewriter.add_rewrite(Rewrite.new(:cdn, resource_model))
|
15
|
+
end
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
17
|
+
# Declares a rewrite of content nodes.
|
18
|
+
#
|
19
|
+
# Example:
|
20
|
+
#
|
21
|
+
# class PostsController
|
22
|
+
# include Kiosk::Controller
|
23
|
+
#
|
24
|
+
# before_filter do
|
25
|
+
# rewrite_content_for(Attachment) do |attachment,node|
|
26
|
+
# case node.name
|
27
|
+
# when 'a'
|
28
|
+
# node['title'] = 'Some photo'
|
29
|
+
# when 'img'
|
30
|
+
# node['src'] = attachment_path(attachment.filename)
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
def rewrite_content_for(resource_model, &blk)
|
37
|
+
Kiosk.rewriter.add_rewrite(Rewrite.new(:node, resource_model, &blk))
|
38
|
+
end
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
40
|
+
# Declares a rewrite of content nodes that sets a new URL any href or src
|
41
|
+
# attributes (the first one found, it that order). The given block is
|
42
|
+
# passed the instantiated resource and node as its arguments and should
|
43
|
+
# return the new value for the node attribute.
|
44
|
+
#
|
45
|
+
# Example:
|
46
|
+
#
|
47
|
+
# class PostsController
|
48
|
+
# include Kiosk::Controller
|
49
|
+
#
|
50
|
+
# before_filter do
|
51
|
+
# rewrite_paths_for(Post) { |post| post_path(post.slug) }
|
52
|
+
# end
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
def rewrite_paths_for(resource_model, &blk)
|
56
|
+
Kiosk.rewriter.add_rewrite(Rewrite.new(:path, resource_model, &blk))
|
59
57
|
end
|
60
58
|
end
|
61
59
|
end
|
data/lib/kiosk/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: kiosk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.3.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Daniel Duvall
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-05-
|
13
|
+
date: 2012-05-15 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 3.
|
34
|
+
version: 3.2.3
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id002
|
37
37
|
- !ruby/object:Gem::Dependency
|
@@ -46,16 +46,27 @@ dependencies:
|
|
46
46
|
type: :development
|
47
47
|
version_requirements: *id003
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
|
-
name: shoulda
|
49
|
+
name: shoulda-matchers
|
50
50
|
prerelease: false
|
51
51
|
requirement: &id004 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|
54
|
-
- -
|
54
|
+
- - ~>
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: "
|
56
|
+
version: "1.1"
|
57
57
|
type: :development
|
58
58
|
version_requirements: *id004
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: thinking-sphinx
|
61
|
+
prerelease: false
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 2.0.3
|
68
|
+
type: :development
|
69
|
+
version_requirements: *id005
|
59
70
|
description: "Kiosk provides APIs for integrating WordPress content into a Ruby application: a base REST model for retrieving content, a caching layer, and a rewriting engine for canonicalizing and contextualizing content elements."
|
60
71
|
email:
|
61
72
|
- dan@mutual.io
|