Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 4876 Bytes
1 | module ActionController |
2 | class AbstractResponse |
3 | |
4 | # This isn't just +attr_accessor :lifetime+ because we need to trick components into doing |
5 | # the right thing--it should be possible to do +lifetime = 1.hour+ in a component and have |
6 | # the lifetime carried back to the original response. Unfortunately, components are called |
7 | # with their own copy of the parent's response object. Fortunately, the copy uses |
8 | # +dup+, so if we shove the actual lifetime into a hash (or anything even slighty complex), |
9 | # the +dup+ will leave the parent response and the child response sharing the same |
10 | # hash, so the lifetime will become a shared resource and The Right Thing will happen. |
11 | def lifetime |
12 | @lifetime[:time] |
13 | end |
14 | |
15 | def lifetime=(seconds) |
16 | # Only allow the lifetime to be lowered--if one component wants |
17 | # lifetime=3.hours and another wants lifetime=15.minutes, then |
18 | # the right thing to do is to always use lifetime=15.minutes, no |
19 | # matter which order they're called in. |
20 | return if @lifetime[:time] and @lifetime[:time] < seconds |
21 | @lifetime[:time] = seconds |
22 | end |
23 | |
24 | def initialize |
25 | @body, @headers, @session, @assigns = "", DEFAULT_HEADERS.merge("cookie" => []), [], [] |
26 | @lifetime = Hash.new |
27 | end |
28 | end |
29 | |
30 | module Caching |
31 | module ActionParams |
32 | def self.append_features(base) #:nodoc: |
33 | super |
34 | base.extend(ClassMethods) |
35 | base.send(:attr_accessor, :rendered_action_cache) |
36 | end |
37 | |
38 | module ClassMethods #:nodoc: |
39 | def caches_action_with_params(*actions) |
40 | return unless perform_caching |
41 | prepend_around_filter(ActionParamCacheFilter.new(*actions)) |
42 | end |
43 | end |
44 | |
45 | def expire_action_with_params(options = {}) |
46 | return unless perform_caching |
47 | |
48 | if options == {} |
49 | expire_meta_fragment(%r{ACTION_PARAM/.*}) |
50 | else |
51 | controller = options[:controller] || '[^/]+' |
52 | action = options[:action] || '[^/]+' |
53 | keys = (options.reject {|k,v| v.blank?}.keys-[:controller,:action]).sort_by {|k| k.to_s} |
54 | param_string = keys.collect { |key| "#{key.to_s}=#{controller.params[key]}"}.join('.*') |
55 | expire_meta_fragment(%r{ACTION_PARAM/[^/]+/#{controller}/#{action}/#{param_string}}) |
56 | end |
57 | end |
58 | |
59 | class ActionParamCacheFilter #:nodoc: |
60 | def initialize(*actions) |
61 | @actions = actions |
62 | end |
63 | |
64 | def cache_key(controller) |
65 | hostname = controller.request.host_with_port |
66 | keys = (controller.params.reject {|k,v| v.blank?}.keys-['controller','action']).sort |
67 | param_string = keys.collect { |key| "#{key.to_s}=#{controller.params[key]}"}.join('&') |
68 | "ACTION_PARAM/#{hostname}/#{controller.controller_name}/#{controller.action_name}/#{param_string}" |
69 | end |
70 | |
71 | def before(controller) |
72 | return unless @actions.include?(controller.action_name.intern) |
73 | meta, cache = controller.read_meta_fragment_expire(cache_key(controller)) |
74 | |
75 | if cache |
76 | # 304 handling from Tom Fakes, |
77 | # http://craz8.com/svn/trunk/plugins/action_cache/lib/action_cache.rb |
78 | request_time = Time.rfc2822(controller.request.env["HTTP_IF_MODIFIED_SINCE"]).utc rescue nil |
79 | cached_time = meta[:cached_at] rescue nil |
80 | controller.response.headers['Cache-Control'] = 'max-age=1' |
81 | controller.response.headers['Last-Modified'] = meta[:cached_at].httpdate rescue nil |
82 | controller.response.headers['Content-Type'] = meta[:content_type] |
83 | |
84 | if request_time and cached_time <= (request_time + 1) |
85 | controller.render(:text => "", :status => 304) |
86 | else |
87 | controller.render(:text => cache) |
88 | end |
89 | |
90 | controller.rendered_action_cache = true |
91 | return false |
92 | else |
93 | return true |
94 | end |
95 | end |
96 | |
97 | def after(controller) |
98 | return true if !@actions.include?(controller.action_name.intern) || controller.rendered_action_cache |
99 | return true if controller.response.headers['Status'] != "200 OK" # without this, we cache errors. grr |
100 | |
101 | meta = Hash.new |
102 | if controller.response.lifetime |
103 | meta[:expires] = Time.now + controller.response.lifetime |
104 | end |
105 | meta[:cached_at] = Time.now.utc |
106 | meta[:content_type] = controller.response.headers['Content-Type'] |
107 | controller.response.headers['Cache-Control'] = 'max-age=1' |
108 | controller.response.headers['Last-Modified'] = meta[:cached_at].httpdate |
109 | controller.write_meta_fragment(cache_key(controller), meta, controller.response.body) |
110 | end |
111 | end |
112 | end |
113 | end |
114 | end |
115 | |
116 | ActionController::Caching::ActionParams.append_features(ActionController::Base) |