nitro 0.31.0 → 0.40.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. data/bin/nitro +135 -37
  2. data/doc/CHANGELOG.1 +108 -108
  3. data/doc/CHANGELOG.2 +89 -89
  4. data/doc/CHANGELOG.3 +105 -105
  5. data/{CHANGELOG → doc/CHANGELOG.4} +509 -509
  6. data/doc/{AUTHORS → CONTRIBUTORS} +49 -37
  7. data/doc/LIBRARIES +13 -0
  8. data/doc/LICENSE +2 -3
  9. data/doc/MIGRATION +45 -0
  10. data/doc/RELEASES +131 -11
  11. data/doc/TODO +67 -0
  12. data/lib/glue/magick.rb +0 -3
  13. data/lib/glue/sweeper.rb +30 -15
  14. data/lib/glue/thumbnails.rb +0 -2
  15. data/lib/glue/webfile.rb +23 -11
  16. data/lib/nitro.rb +37 -44
  17. data/lib/nitro/adapter/cgi.rb +0 -3
  18. data/lib/nitro/adapter/console.rb +0 -2
  19. data/lib/nitro/adapter/fastcgi.rb +6 -3
  20. data/lib/nitro/adapter/mongrel.rb +97 -58
  21. data/lib/nitro/adapter/script.rb +4 -6
  22. data/lib/nitro/adapter/webrick.rb +33 -87
  23. data/lib/nitro/adapter/webrick/vcr.rb +85 -0
  24. data/lib/nitro/caching.rb +0 -2
  25. data/lib/nitro/caching/actions.rb +0 -2
  26. data/lib/nitro/caching/fragments.rb +0 -2
  27. data/lib/nitro/caching/output.rb +45 -16
  28. data/lib/nitro/caching/proxy.rb +49 -0
  29. data/lib/nitro/cgi.rb +3 -6
  30. data/lib/nitro/cgi/cookie.rb +0 -3
  31. data/lib/nitro/cgi/request.rb +67 -24
  32. data/lib/nitro/cgi/response.rb +0 -2
  33. data/lib/nitro/cgi/{sendfile.rb → send_file.rb} +7 -6
  34. data/lib/nitro/compiler.rb +62 -55
  35. data/lib/nitro/compiler/cleanup.rb +0 -3
  36. data/lib/nitro/compiler/elements.rb +31 -28
  37. data/lib/nitro/compiler/errors.rb +2 -5
  38. data/lib/nitro/compiler/include.rb +10 -8
  39. data/lib/nitro/compiler/layout.rb +0 -2
  40. data/lib/nitro/compiler/localization.rb +0 -2
  41. data/lib/nitro/compiler/markup.rb +14 -6
  42. data/lib/nitro/compiler/morphing.rb +1 -5
  43. data/lib/nitro/compiler/script.rb +2 -4
  44. data/lib/nitro/compiler/squeeze.rb +0 -2
  45. data/lib/nitro/compiler/xslt.rb +0 -2
  46. data/lib/nitro/context.rb +10 -5
  47. data/lib/nitro/control.rb +18 -0
  48. data/lib/nitro/control/attribute.rb +88 -0
  49. data/lib/nitro/control/attribute/checkbox.rb +19 -0
  50. data/lib/nitro/control/attribute/datetime.rb +21 -0
  51. data/lib/nitro/control/attribute/file.rb +20 -0
  52. data/lib/nitro/control/attribute/fixnum.rb +26 -0
  53. data/lib/nitro/control/attribute/float.rb +26 -0
  54. data/lib/nitro/control/attribute/options.rb +38 -0
  55. data/lib/nitro/control/attribute/password.rb +16 -0
  56. data/lib/nitro/control/attribute/text.rb +16 -0
  57. data/lib/nitro/control/attribute/textarea.rb +16 -0
  58. data/lib/nitro/control/none.rb +16 -0
  59. data/lib/nitro/control/relation.rb +53 -0
  60. data/lib/nitro/control/relation/belongs_to.rb +0 -0
  61. data/lib/nitro/control/relation/has_many.rb +97 -0
  62. data/lib/nitro/control/relation/joins_many.rb +0 -0
  63. data/lib/nitro/control/relation/many_to_many.rb +0 -0
  64. data/lib/nitro/control/relation/refers_to.rb +29 -0
  65. data/lib/nitro/controller.rb +7 -296
  66. data/lib/nitro/dispatcher.rb +72 -34
  67. data/lib/nitro/element.rb +36 -10
  68. data/lib/nitro/element/javascript.rb +0 -2
  69. data/lib/nitro/flash.rb +23 -10
  70. data/lib/nitro/global.rb +36 -11
  71. data/lib/nitro/helper.rb +22 -8
  72. data/lib/nitro/helper/benchmark.rb +0 -2
  73. data/lib/nitro/helper/buffer.rb +0 -3
  74. data/lib/nitro/helper/css.rb +12 -0
  75. data/lib/nitro/helper/debug.rb +1 -3
  76. data/lib/nitro/helper/default.rb +1 -0
  77. data/lib/nitro/helper/feed.rb +400 -386
  78. data/lib/nitro/helper/form.rb +246 -116
  79. data/lib/nitro/helper/javascript.rb +28 -2
  80. data/lib/nitro/helper/javascript/morphing.rb +0 -2
  81. data/lib/nitro/helper/javascript/prototype.rb +0 -2
  82. data/lib/nitro/helper/javascript/scriptaculous.rb +0 -1
  83. data/lib/nitro/helper/layout.rb +0 -2
  84. data/lib/nitro/helper/navigation.rb +87 -0
  85. data/lib/nitro/helper/pager.rb +11 -22
  86. data/lib/nitro/helper/table.rb +9 -32
  87. data/lib/nitro/helper/url.rb +104 -0
  88. data/lib/nitro/helper/xhtml.rb +20 -4
  89. data/lib/nitro/helper/xml.rb +0 -2
  90. data/lib/nitro/markup.rb +131 -0
  91. data/lib/nitro/part.rb +52 -7
  92. data/lib/nitro/publishable.rb +328 -0
  93. data/lib/nitro/render.rb +30 -61
  94. data/lib/nitro/router.rb +12 -4
  95. data/lib/nitro/sanitize.rb +48 -0
  96. data/lib/nitro/scaffold.rb +9 -11
  97. data/lib/nitro/scaffold/controller.rb +25 -0
  98. data/lib/nitro/scaffold/model.rb +150 -0
  99. data/lib/nitro/scaffolding.rb +1 -3
  100. data/lib/nitro/server.rb +57 -32
  101. data/lib/nitro/server/drb.rb +16 -2
  102. data/lib/nitro/server/runner.rb +80 -102
  103. data/lib/nitro/service.rb +0 -1
  104. data/lib/nitro/service/xmlrpc.rb +0 -2
  105. data/lib/nitro/session.rb +26 -18
  106. data/lib/nitro/session/drb.rb +2 -16
  107. data/lib/nitro/session/memory.rb +0 -2
  108. data/lib/nitro/template.rb +219 -0
  109. data/lib/nitro/test/assertions.rb +1 -3
  110. data/lib/nitro/test/context.rb +0 -1
  111. data/lib/nitro/test/testcase.rb +0 -1
  112. data/lib/nitro/version.rb +6 -0
  113. data/lib/part/admin.rb +16 -0
  114. data/lib/part/admin/controller.rb +19 -0
  115. data/lib/part/admin/helper.rb +30 -0
  116. data/lib/part/admin/og/controller.rb +114 -0
  117. data/lib/part/admin/og/customize.rb +4 -0
  118. data/lib/part/admin/og/template/index.xhtml +27 -0
  119. data/lib/part/admin/og/template/list.xhtml +38 -0
  120. data/lib/part/admin/og/template/search.xhtml +20 -0
  121. data/lib/part/admin/og/template/update.xhtml +25 -0
  122. data/lib/part/admin/skin.rb +207 -0
  123. data/lib/part/admin/template/denied.xhtml +13 -0
  124. data/lib/part/admin/template/index.xhtml +12 -0
  125. data/lib/part/admin/todo.txt +2 -0
  126. data/proto/public/error.xhtml +4 -2
  127. data/proto/run.rb +0 -2
  128. data/test/glue/tc_webfile.rb +1 -0
  129. data/test/nitro/cgi/tc_request.rb +23 -0
  130. data/test/nitro/helper/tc_feed.rb +0 -3
  131. data/test/nitro/helper/tc_navbar.rb +74 -0
  132. data/test/nitro/helper/tc_table.rb +2 -0
  133. data/test/nitro/tc_cgi.rb +72 -19
  134. data/test/nitro/tc_controller.rb +35 -26
  135. data/test/nitro/tc_controller_aspect.rb +1 -0
  136. data/test/nitro/tc_controller_params.rb +864 -0
  137. data/test/nitro/tc_dispatcher.rb +2 -2
  138. data/test/nitro/tc_element.rb +16 -16
  139. data/test/nitro/tc_flash.rb +3 -3
  140. data/test/nitro/tc_markup.rb +31 -0
  141. data/test/nitro/tc_render.rb +12 -14
  142. data/test/nitro/tc_session.rb +9 -7
  143. data/test/nitro/tc_template.rb +34 -0
  144. metadata +217 -198
  145. data/INSTALL +0 -121
  146. data/ProjectInfo +0 -74
  147. data/README +0 -555
  148. data/doc/apache.txt +0 -9
  149. data/doc/config.txt +0 -28
  150. data/doc/faq.txt +0 -7
  151. data/doc/lhttpd.txt +0 -7
  152. data/lib/nitro/adapter/scgi.rb +0 -239
  153. data/lib/nitro/helper/form/builder.rb +0 -144
  154. data/lib/nitro/helper/form/controls.rb +0 -389
  155. data/lib/nitro/helper/rss.rb +0 -72
  156. data/proto/conf/apache.conf +0 -51
  157. data/proto/public/scaffold/advanced_search.xhtml +0 -30
  158. data/proto/public/scaffold/edit.xhtml +0 -11
  159. data/proto/public/scaffold/form.xhtml +0 -1
  160. data/proto/public/scaffold/index.xhtml +0 -20
  161. data/proto/public/scaffold/list.xhtml +0 -32
  162. data/proto/public/scaffold/new.xhtml +0 -11
  163. data/proto/public/scaffold/search.xhtml +0 -29
  164. data/proto/public/scaffold/view.xhtml +0 -8
  165. data/proto/script/scgi_ctl +0 -221
  166. data/proto/script/scgi_service +0 -128
  167. data/setup.rb +0 -1585
  168. data/src/part/admin.rb +0 -16
  169. data/src/part/admin/controller.rb +0 -81
  170. data/src/part/admin/skin.rb +0 -21
  171. data/src/part/admin/system.css +0 -135
  172. data/src/part/admin/template/denied.xhtml +0 -1
  173. data/src/part/admin/template/index.xhtml +0 -43
  174. data/test/nitro/helper/tc_rss.rb +0 -24
@@ -12,7 +12,7 @@ class ScriptAdapter
12
12
 
13
13
  attr_accessor :response
14
14
 
15
- def initialize server
15
+ def initialize(server)
16
16
  @server = server
17
17
  end
18
18
 
@@ -25,7 +25,7 @@ class ScriptAdapter
25
25
  # app.post 'users/login?name=gmosx;password=pass
26
26
  # app.post 'articles/view/1'
27
27
 
28
- def handle uri, options = {}
28
+ def handle(uri, options = {})
29
29
  context = Context.new(@server)
30
30
 
31
31
  begin
@@ -52,14 +52,14 @@ class ScriptAdapter
52
52
 
53
53
  # Perform a programmatic http get request to the web app.
54
54
 
55
- def get uri, options = {}
55
+ def get(uri, options = {})
56
56
  options[:method] = :get
57
57
  handle uri, options
58
58
  end
59
59
 
60
60
  # Perform a programmatic http post request to the web app.
61
61
 
62
- def post uri, options = {}
62
+ def post(uri, options = {})
63
63
  options[:method] = :post
64
64
  handle uri, options
65
65
  end
@@ -67,5 +67,3 @@ class ScriptAdapter
67
67
  end
68
68
 
69
69
  end
70
-
71
- # * George Moschovitis <gm@navel.gr>
@@ -45,9 +45,16 @@ class Webrick
45
45
  ]
46
46
  )
47
47
 
48
- enable_record_mode($record_session_filename) if $record_session_filename
49
- enable_playback_mode($playback_session_filename) if $playback_session_filename
48
+ if $record_session_filename
49
+ require 'nitro/adapter/webrick/vcr'
50
+ VCR.record($record_session_filename)
51
+ end
50
52
 
53
+ if $playback_session_filename
54
+ require 'nitro/adapter/webrick/vcr'
55
+ VCR.playback($playback_session_filename)
56
+ end
57
+
51
58
  @webrick = WEBrick::HTTPServer.new(webrick_options)
52
59
 
53
60
  trap('INT') { stop }
@@ -71,75 +78,6 @@ class Webrick
71
78
  def initialize_webrick(server)
72
79
  end
73
80
 
74
- # Enables session recording. The recorded data can be used
75
- # for automatic app testing by means of the playback mode.
76
-
77
- def enable_record_mode(filename = 'session.yaml')
78
- Logger.info "Recording application server session to '#{filename}'."
79
-
80
- require 'facets/core/file/self/create'
81
-
82
- $record_session = []
83
- $last_record_time = Time.now
84
-
85
- Nitro::WebrickAdapter.class_eval %{
86
- def do_GET(req, res)
87
- record_context(req, res)
88
- handle(req, res)
89
- end
90
- alias_method :do_POST, :do_GET
91
-
92
- def record_context(req, res)
93
- delta = Time.now - $last_record_time
94
- $last_record_time = Time.now
95
- $record_session << [delta, req, res]
96
- end
97
- }
98
-
99
- at_exit do
100
- File.create(filename, YAML.dump($record_session))
101
- end
102
- end
103
-
104
- # Playback a recorded session. Typically used for testing.
105
-
106
- def enable_playback_mode(filename = 'session.yaml')
107
- Logger.info "Playing back application server session from '#{filename}'."
108
-
109
- $playback_session = YAML.load_file(filename)
110
- $playback_exception_count = 0
111
-
112
- WEBrick::HTTPServer.class_eval %{
113
- def start(&block)
114
- run(nil)
115
- end
116
-
117
- def run(sock)
118
- while true
119
- delta, req, res = $playback_session.shift
120
-
121
- if delta
122
- sleep(delta)
123
- begin
124
- service(req, res)
125
- rescue Object => ex
126
- $playback_exception_count += 1
127
- p '---', ex
128
- end
129
- else
130
- return
131
- end
132
- end
133
- end
134
- }
135
-
136
- at_exit do
137
- puts "\n\n"
138
- puts "Playback raised #$playback_exception_count exceptions.\n"
139
- puts "\n"
140
- end
141
- end
142
-
143
81
  end
144
82
 
145
83
  end
@@ -168,6 +106,8 @@ class WebrickAdapter < WEBrick::HTTPServlet::AbstractServlet
168
106
  @server = server
169
107
  @server.options[:HandlerTable] = { 'xhtml' => XhtmlFileHandler }
170
108
 
109
+ @handle_static_files = Server.handle_static_files
110
+
171
111
  # Handles static resources. Useful when running
172
112
  # a stand-alone webrick server.
173
113
 
@@ -181,18 +121,28 @@ class WebrickAdapter < WEBrick::HTTPServlet::AbstractServlet
181
121
  # Handle a static file. Also handles cached pages.
182
122
 
183
123
  def handle_file(req, res)
184
- begin
185
- rewrite(req)
186
- @file_handler.do_GET(req, res)
187
- return true
188
- rescue WEBrick::HTTPStatus::PartialContent, WEBrick::HTTPStatus::NotModified => err
189
- res.set_error(err)
190
- return true
191
- rescue Object => ex
124
+ rewrite(req)
125
+
126
+ # gmosx, FIXME: this is a nasty hack that fixes a really
127
+ # *nasty* caching bug. Find a better solution. When hitting
128
+ # the backend server, if the index method takes parameters
129
+ # the dispatcher considers all static files as parameters.
130
+ # If you have output caching enabled for the index page,
131
+ # all your static files get corrupted.
132
+
133
+ if (@handle_static_files == false) and (req.path_info =~ /\.html$/)
192
134
  return false
193
- ensure
194
- unrewrite(req)
195
135
  end
136
+
137
+ @file_handler.do_GET(req, res)
138
+ return true
139
+ rescue WEBrick::HTTPStatus::PartialContent, WEBrick::HTTPStatus::NotModified => err
140
+ res.set_error(err)
141
+ return true
142
+ rescue Object => ex
143
+ return false
144
+ ensure
145
+ unrewrite(req)
196
146
  end
197
147
 
198
148
  # Handle the request.
@@ -243,7 +193,7 @@ class WebrickAdapter < WEBrick::HTTPServlet::AbstractServlet
243
193
  if req.path_info == '/'
244
194
  req.instance_variable_set(:@path_info, '/index.html')
245
195
  elsif req.path_info =~ /^([^.]+)$/
246
- req.instance_variable_set(:@path_info, "#{$1}/index.html")
196
+ req.instance_variable_set(:@path_info, "#{$1}.html")
247
197
  end
248
198
  end
249
199
 
@@ -252,14 +202,10 @@ class WebrickAdapter < WEBrick::HTTPServlet::AbstractServlet
252
202
  def unrewrite(req)
253
203
  if req.path_info == '/index.html'
254
204
  req.instance_variable_set(:@path_info, '/')
255
- elsif req.path_info =~ /^([^.]+)\/index.html$/
205
+ elsif req.path_info =~ /^([^.]+)\.html$/
256
206
  req.instance_variable_set(:@path_info, $1)
257
207
  end
258
208
  end
259
209
  end
260
210
 
261
211
  end
262
-
263
- # * George Moschovitis <gm@navel.gr>
264
- # * Guillaume Pierronnet <guillaume.pierronnet@laposte.net>
265
- # * Bryan Soto <bryan.a.soto@gmail.com>
@@ -0,0 +1,85 @@
1
+ require 'nitro/adapter/webrick'
2
+
3
+ class Webrick
4
+
5
+ # VCR functionality, typically used for proxy based regression
6
+ # testing.
7
+
8
+ class VCR
9
+
10
+ class << self
11
+
12
+ # Enables session recording. The recorded data can be used
13
+ # for automatic app testing by means of the playback mode.
14
+
15
+ def record(filename = 'session.yaml')
16
+ Logger.info "Recording application server session to '#{filename}'."
17
+
18
+ require 'facets/core/file/self/create'
19
+
20
+ $record_session = []
21
+ $last_record_time = Time.now
22
+
23
+ Nitro::WebrickAdapter.class_eval %{
24
+ def do_GET(req, res)
25
+ record_context(req, res)
26
+ handle(req, res)
27
+ end
28
+ alias_method :do_POST, :do_GET
29
+
30
+ def record_context(req, res)
31
+ delta = Time.now - $last_record_time
32
+ $last_record_time = Time.now
33
+ $record_session << [delta, req, res]
34
+ end
35
+ }
36
+
37
+ at_exit do
38
+ File.create(filename, YAML.dump($record_session))
39
+ end
40
+ end
41
+
42
+ # Playback a recorded session. Typically used for testing.
43
+
44
+ def playback(filename = 'session.yaml')
45
+ Logger.info "Playing back application server session from '#{filename}'."
46
+
47
+ $playback_session = YAML.load_file(filename)
48
+ $playback_exception_count = 0
49
+
50
+ WEBrick::HTTPServer.class_eval %{
51
+ def start(&block)
52
+ run(nil)
53
+ end
54
+
55
+ def run(sock)
56
+ while true
57
+ delta, req, res = $playback_session.shift
58
+
59
+ if delta
60
+ sleep(delta)
61
+ begin
62
+ service(req, res)
63
+ rescue Object => ex
64
+ $playback_exception_count += 1
65
+ p '---', ex
66
+ end
67
+ else
68
+ return
69
+ end
70
+ end
71
+ end
72
+ }
73
+
74
+ at_exit do
75
+ puts "\n\n"
76
+ puts "Playback raised #$playback_exception_count exceptions.\n"
77
+ puts "\n"
78
+ end
79
+ end
80
+
81
+ end
82
+
83
+ end
84
+
85
+ end
@@ -40,5 +40,3 @@ module Caching
40
40
  end
41
41
 
42
42
  end
43
-
44
- # * George Moschovitis <gm@navel.gr>
@@ -68,5 +68,3 @@ module Caching
68
68
  end
69
69
 
70
70
  end
71
-
72
- # * George Moschovitis <gm@navel.gr>
@@ -79,5 +79,3 @@ module Caching
79
79
  end
80
80
 
81
81
  end
82
-
83
- # * George Moschovitis <gm@navel.gr>
@@ -1,17 +1,25 @@
1
1
  require 'fileutils'
2
2
 
3
+ require 'nitro/helper/url'
4
+
3
5
  module Nitro
4
6
 
5
7
  # Adds support for caching.
6
8
 
7
9
  module Caching
8
10
 
11
+ # The directory where cached pages are generated.
12
+ #--
13
+ # TODO: use Server.public_root as default.
14
+ #++
15
+
9
16
  setting :output_cache_root, :default => 'public', :doc => 'The directory where cached pages are generated'
10
17
 
11
18
  # The Output caching subsystem stores whole pages in the
12
19
  # filesystem to be served directly be the front web server
13
20
  # (Lighttpd, Apache, etc) for optimal performance.
14
- #
21
+ # require 'nitro/helper/url'
22
+
15
23
  # Nitro promotes coding your application in such a way as to
16
24
  # allow for output caching to the greatest extend. Output
17
25
  # caching *is your friend*.
@@ -22,6 +30,16 @@ module Caching
22
30
 
23
31
  module Output
24
32
 
33
+ # TODO: something more elegant here.
34
+
35
+ class << self
36
+ # The collection of cached actions.
37
+
38
+ attr_accessor :cached_actions
39
+ end
40
+
41
+ Nitro::Caching::Output.cached_actions = []
42
+
25
43
  def self.included(base) # :nodoc:
26
44
  base.extend(ClassMethods)
27
45
  end
@@ -40,6 +58,11 @@ module Caching
40
58
  def cache_output(*actions)
41
59
  return unless caching_enabled?
42
60
 
61
+ # keep track of cached actions.
62
+ for a in actions
63
+ Nitro::Caching::Output.cached_actions << [self, a]
64
+ end
65
+
43
66
  str = actions.collect { |a| ":#{a}" }.join(', ')
44
67
 
45
68
  module_eval %{
@@ -48,14 +71,22 @@ module Caching
48
71
  end
49
72
 
50
73
  private
51
-
74
+ =begin
52
75
  def output_cache_path(path)
53
76
  filename = ((path.empty? || path == '/') ? 'index.html' : path.dup)
54
- # filename.gsub!(/\/$/, '')
55
77
  filename << '/index.html' unless (filename.split('/').last || filename).include? '.'
56
- return Caching.output_cache_root + '/' + filename
78
+ return File.join(Caching.output_cache_root, filename).squeeze('/')
79
+ end
80
+ =end
81
+ def output_cache_path(path)
82
+ if path.empty? or path == '/'
83
+ filename = 'index.html'
84
+ else
85
+ filename = "#{path}.html"
86
+ end
87
+ return File.join(Caching.output_cache_root, filename).squeeze('/')
57
88
  end
58
-
89
+
59
90
  end
60
91
 
61
92
  private
@@ -70,19 +101,19 @@ module Caching
70
101
  # cache key. The cache key is typically the name of the
71
102
  # top level action responsible for generating the page.
72
103
  #--
73
- # If you change this method, don't forget the CacheSweeper
104
+ # WARNING: If you change this method, don't forget the CacheSweeper
74
105
  # expire method.
106
+ # FIXME: make the above unneeded through refactoring.
75
107
  #++
76
108
 
77
109
  def expire_output(name)
78
- begin
79
- Logger.debug "Expirinig cache file '#{Server.public_root}/#{name}'" if $DBG
80
- FileUtils.rm_rf("#{Server.public_root}/#{name}")
81
- rescue Object => ex
82
- # gmosx: is this the right thing to do?
83
- end
110
+ filename = "#{Server.public_root}/#{name}".squeeze('/')
111
+ Logger.debug "Expiring cache file '#{filename}'" if $DBG
112
+ FileUtils.rm_rf(filename)
113
+ rescue Object => ex
114
+ # ignore any error.
84
115
  end
85
- alias_method :delete_output, :expire_output
116
+ alias delete_output expire_output
86
117
 
87
118
  # Is caching allowed for this action (page)? The default
88
119
  # implementation does not cache post request or request
@@ -91,7 +122,7 @@ module Caching
91
122
  # for 'nice' urls.
92
123
 
93
124
  def caching_allowed?
94
- not (@request.post? or @request.uri =~ /\?/)
125
+ not (request.post? or request.uri =~ /\?/)
95
126
  end
96
127
 
97
128
  end
@@ -99,5 +130,3 @@ module Caching
99
130
  end
100
131
 
101
132
  end
102
-
103
- # * George Moschovitis <gm@navel.gr>
@@ -0,0 +1,49 @@
1
+ require 'nitro/helper/url'
2
+ require 'nitro/caching/output'
3
+
4
+ module Nitro
5
+
6
+ module Caching
7
+
8
+ # A proxy to the caching system. This is typically used from the
9
+ # console.
10
+ #--
11
+ # gmosx: If anyone can suggest a better name, please speak up!
12
+ #++
13
+
14
+ class Proxy
15
+ extend URLHelper
16
+ extend Output
17
+
18
+ class << self
19
+
20
+ def cleanup_output
21
+ dirs = {}
22
+
23
+ for ctrl, a in Nitro::Caching::Output.cached_actions
24
+ file = encode_url(ctrl, a)
25
+
26
+ file << 'index' if file == '/'
27
+
28
+ unless dirs[file]
29
+ puts "Expiring cache directory '#{file}'"
30
+ expire_output(file)
31
+ dirs[file] = true
32
+ end
33
+
34
+ file << '.html'
35
+ puts "Expiring cache file '#{file}'"
36
+ expire_output(file)
37
+ end
38
+
39
+ return true
40
+ end
41
+ alias cleanup cleanup_output
42
+
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+
49
+ end