nitro 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +218 -0
- data/INSTALL +3 -0
- data/README +4 -2
- data/Rakefile +150 -8
- data/benchmark/bench.rb +1 -1
- data/doc/AUTHORS +2 -8
- data/doc/RELEASES +63 -1
- data/examples/ajax/controller.rb +2 -2
- data/examples/ajax/public/index.xhtml +3 -1
- data/examples/ajax/run.rb +3 -3
- data/examples/blog/README +8 -0
- data/examples/blog/cache/entriesadmintrue +3 -0
- data/examples/blog/run.rb +38 -40
- data/examples/blog/src/blog.rb +2 -1
- data/examples/blog/src/controller.rb +40 -20
- data/examples/blog/src/mailer.rb +2 -2
- data/examples/blog/src/models/blog.rb +2 -1
- data/examples/blog/src/models/content.rb +4 -33
- data/examples/blog/src/views/error.xhtml +1 -1
- data/examples/blog/src/xsl/style.xsl +1 -1
- data/examples/blog/test/tc_blog.rb +43 -0
- data/examples/flash/run.rb +2 -2
- data/examples/no_xsl_blog/lib/blog.rb +1 -1
- data/examples/no_xsl_blog/lib/blog/controller.rb +26 -17
- data/examples/no_xsl_blog/lib/blog/model.rb +3 -3
- data/examples/no_xsl_blog/lib/blog/template.rb +1 -1
- data/examples/no_xsl_blog/lib/content.rb +3 -7
- data/examples/no_xsl_blog/run.rb +34 -34
- data/examples/tiny/public/deep/dir/hello.xhtml +2 -0
- data/examples/tiny/run.rb +2 -2
- data/examples/wee_style/run.rb +5 -3
- data/examples/why_wiki/run.rb +5 -3
- data/install.rb +1 -1
- data/lib/nitro.rb +10 -9
- data/lib/nitro/adapters/cgi.rb +27 -2
- data/lib/nitro/adapters/fastcgi.rb +6 -2
- data/lib/nitro/adapters/webrick.rb +11 -9
- data/lib/nitro/buffering.rb +2 -2
- data/lib/nitro/builders/atom.rb +78 -0
- data/lib/nitro/builders/form.rb +2 -2
- data/lib/nitro/builders/rss.rb +4 -4
- data/lib/nitro/builders/table.rb +2 -2
- data/lib/nitro/builders/xhtml.rb +5 -8
- data/lib/nitro/builders/xml.rb +38 -14
- data/lib/nitro/caching.rb +2 -2
- data/lib/nitro/caching/actions.rb +2 -2
- data/lib/nitro/caching/fragments.rb +2 -2
- data/lib/nitro/caching/invalidation.rb +2 -28
- data/lib/nitro/caching/output.rb +3 -3
- data/lib/nitro/caching/stores.rb +4 -4
- data/lib/nitro/conf.rb +11 -6
- data/lib/nitro/context.rb +2 -2
- data/lib/nitro/controller.rb +12 -7
- data/lib/nitro/cookie.rb +2 -2
- data/lib/nitro/dispatcher.rb +33 -40
- data/lib/nitro/environment.rb +1 -1
- data/lib/nitro/localization.rb +5 -7
- data/lib/nitro/mail.rb +2 -2
- data/lib/nitro/markup.rb +5 -5
- data/lib/nitro/output.rb +2 -2
- data/lib/nitro/part.rb +8 -5
- data/lib/nitro/render.rb +46 -45
- data/lib/nitro/request.rb +7 -6
- data/lib/nitro/response.rb +14 -5
- data/lib/nitro/routing.rb +2 -2
- data/lib/nitro/runner.rb +57 -17
- data/lib/nitro/scaffold.rb +14 -8
- data/lib/nitro/session.rb +7 -4
- data/lib/nitro/session/drb.rb +2 -2
- data/lib/nitro/session/drbserver.rb +2 -2
- data/lib/nitro/session/memory.rb +2 -2
- data/lib/nitro/shaders.rb +8 -7
- data/lib/nitro/simple.rb +4 -1
- data/lib/nitro/template.rb +8 -8
- data/lib/nitro/testing.rb +6 -0
- data/lib/nitro/testing/assertions.rb +102 -0
- data/lib/nitro/testing/context.rb +52 -0
- data/lib/nitro/testing/testcase.rb +55 -0
- data/lib/nitro/ui/pager.rb +3 -3
- data/lib/nitro/ui/popup.rb +8 -13
- data/lib/nitro/ui/tabs.rb +4 -10
- data/lib/nitro/uri.rb +7 -7
- data/proto/doc/README +1 -0
- data/proto/public/cgi.rb +5 -0
- data/proto/run.rb +2 -4
- data/test/nitro/adapters/tc_cgi.rb +1 -1
- data/test/nitro/adapters/tc_webrick.rb +1 -2
- data/test/nitro/builders/tc_atom.rb +26 -0
- data/test/nitro/builders/tc_rss.rb +3 -2
- data/test/nitro/builders/tc_table.rb +1 -1
- data/test/nitro/builders/tc_xhtml.rb +4 -3
- data/test/nitro/builders/tc_xml.rb +7 -7
- data/test/nitro/tc_context.rb +1 -1
- data/test/nitro/tc_controller.rb +5 -3
- data/test/nitro/tc_dispatcher.rb +19 -18
- data/test/nitro/tc_localization.rb +1 -1
- data/test/nitro/tc_mail.rb +1 -1
- data/test/nitro/tc_session.rb +1 -1
- data/test/nitro/tc_template.rb +1 -1
- data/test/nitro/tc_uri.rb +3 -4
- data/test/nitro/ui/tc_pager.rb +7 -7
- data/test/public/blog/inc1.xhtml +2 -0
- data/test/public/blog/inc2.xhtml +1 -0
- data/test/public/blog/list.xhtml +3 -0
- metadata +180 -203
- data/examples/blog/cache/entriesadmin +0 -12
- data/lib/nitro/cluster.rb +0 -218
- data/lib/nitro/component.rb +0 -15
- data/lib/nitro/filters.rb +0 -215
- data/lib/nitro/ui/date-select.rb +0 -69
- data/test/nitro/tc_filters.rb +0 -111
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
|
3
|
-
# $Id$
|
|
3
|
+
# $Id: webrick.rb 9 2005-04-13 00:08:20Z nasis $
|
|
4
4
|
|
|
5
5
|
require 'webrick'
|
|
6
6
|
require 'stringio'
|
|
@@ -9,7 +9,11 @@ require 'glue/flexob'
|
|
|
9
9
|
require 'nitro/context'
|
|
10
10
|
require 'nitro/dispatcher'
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
# Speeds things up, more comaptible with OSX.
|
|
13
|
+
|
|
14
|
+
Socket.do_not_reverse_lookup = true
|
|
15
|
+
|
|
16
|
+
module Nitro
|
|
13
17
|
|
|
14
18
|
# Helper methods for the WebrickAdapter.
|
|
15
19
|
|
|
@@ -21,9 +25,7 @@ class Webrick
|
|
|
21
25
|
def start(conf)
|
|
22
26
|
conf = Conf.new(conf) unless conf.is_a?(Conf)
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if :none == conf.log and RUBY_PLATFORM !~ /mswin32/
|
|
28
|
+
if RUBY_PLATFORM !~ /mswin32/
|
|
27
29
|
accesslog = WEBrick::BasicLog::new('/dev/null')
|
|
28
30
|
refererlog = WEBrick::BasicLog::new('/dev/null')
|
|
29
31
|
elsif (conf.accesslog || conf.refererlog)
|
|
@@ -64,18 +66,18 @@ class WebrickAdapter < WEBrick::HTTPServlet::AbstractServlet
|
|
|
64
66
|
|
|
65
67
|
# REQUEST_MUTEX = Mutex.new
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
def initialize(server, conf)
|
|
68
70
|
@conf = conf
|
|
69
71
|
|
|
70
72
|
# Handles static resources. Useful when running
|
|
71
73
|
# a stand-alone webrick server.
|
|
72
74
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
@file_handler = WEBrick::HTTPServlet::FileHandler.new(server, conf.dispatcher.public_root, conf.webrick_options || {})
|
|
76
|
+
end
|
|
75
77
|
|
|
76
78
|
# Handle a static file. Also handles cached pages.
|
|
77
79
|
|
|
78
|
-
|
|
80
|
+
def handle_file(req, res)
|
|
79
81
|
begin
|
|
80
82
|
rewrite(req)
|
|
81
83
|
@file_handler.do_GET(req, res)
|
data/lib/nitro/buffering.rb
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
|
3
|
-
# $Id$
|
|
3
|
+
# $Id: buffering.rb 1 2005-04-11 11:04:30Z gmosx $
|
|
4
4
|
|
|
5
5
|
require 'glue/attribute'
|
|
6
6
|
|
|
7
7
|
require 'nitro/shaders'
|
|
8
8
|
|
|
9
|
-
module
|
|
9
|
+
module Nitro
|
|
10
10
|
|
|
11
11
|
# The output buffering mixin. Provides php-style output
|
|
12
12
|
# buffering functionality.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# * George Moschovitis <gm@navel.gr>
|
|
2
|
+
# (c) 2005 Navel, all rights reserved.
|
|
3
|
+
# $Id$
|
|
4
|
+
|
|
5
|
+
# WARNING: unfinished code, do NOT use yet.
|
|
6
|
+
|
|
7
|
+
require 'nitro/builders/xml'
|
|
8
|
+
|
|
9
|
+
module Nitro
|
|
10
|
+
|
|
11
|
+
# Build Atom represenations of ruby object collections.
|
|
12
|
+
# Utilize duck typing to grab the attributes to render.
|
|
13
|
+
# Add this mixin to you classes to support Atom
|
|
14
|
+
# syndication.
|
|
15
|
+
|
|
16
|
+
module AtomBuilderMixin
|
|
17
|
+
include XmlBuilderMixin
|
|
18
|
+
|
|
19
|
+
# Build Atom syndication stream.
|
|
20
|
+
#
|
|
21
|
+
# === Options
|
|
22
|
+
#
|
|
23
|
+
# [+:description+]
|
|
24
|
+
# Description of the feed.
|
|
25
|
+
# [+:encoding+]
|
|
26
|
+
# Character encoding.
|
|
27
|
+
# [+:base+]
|
|
28
|
+
# Base url of the feed.
|
|
29
|
+
# [+:link+]
|
|
30
|
+
# Link of the Feed.
|
|
31
|
+
|
|
32
|
+
def build_atom(objects, options = {})
|
|
33
|
+
c = {
|
|
34
|
+
:description => 'Syndication',
|
|
35
|
+
:encoding => 'utf-8'
|
|
36
|
+
}.update(options)
|
|
37
|
+
|
|
38
|
+
c[:base] ||= c[:link]
|
|
39
|
+
|
|
40
|
+
raise "Option ':base' cannot be infered!" unless c[:base]
|
|
41
|
+
|
|
42
|
+
pi! :xml, :version => '1.0', :encoding => o[:encoding]
|
|
43
|
+
feed(:version => '0.3') do
|
|
44
|
+
for obj in objects
|
|
45
|
+
entry do
|
|
46
|
+
if obj.respond_to?(:author)
|
|
47
|
+
author { name(obj.author) }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
issued obj.create_time.xmlschema
|
|
51
|
+
modified obj.update_time.xmlschema
|
|
52
|
+
title obj.title
|
|
53
|
+
|
|
54
|
+
if obj.respond_to?(:categories)
|
|
55
|
+
for category in categories
|
|
56
|
+
dc :subject => category.name
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Abstract class for the AtomBuilderMixin.
|
|
67
|
+
|
|
68
|
+
class AtomBuilder < String
|
|
69
|
+
include AtomBuilderMixin
|
|
70
|
+
|
|
71
|
+
class << self
|
|
72
|
+
def build(objects, options = {})
|
|
73
|
+
AtomBuilder.new.build_atom(objects, options)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
data/lib/nitro/builders/form.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
|
3
|
-
# $Id: form.rb
|
|
3
|
+
# $Id: form.rb 1 2005-04-11 11:04:30Z gmosx $
|
|
4
4
|
|
|
5
5
|
require 'glue/hash'
|
|
6
6
|
require 'nitro/markup'
|
|
7
7
|
|
|
8
|
-
module
|
|
8
|
+
module Nitro
|
|
9
9
|
|
|
10
10
|
# FormBuilder.
|
|
11
11
|
|
data/lib/nitro/builders/rss.rb
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
|
2
|
-
# (c)
|
|
3
|
-
# $Id: rss.rb
|
|
2
|
+
# (c) 2005 Navel, all rights reserved.
|
|
3
|
+
# $Id: rss.rb 1 2005-04-11 11:04:30Z gmosx $
|
|
4
4
|
|
|
5
5
|
require 'rss/0.9'
|
|
6
6
|
|
|
7
7
|
require 'glue/string'
|
|
8
8
|
|
|
9
|
-
module
|
|
9
|
+
module Nitro
|
|
10
10
|
|
|
11
11
|
# Build RSS represenations of ruby object collections.
|
|
12
12
|
# Utilize duck typing to grab the attributes to render.
|
|
@@ -43,7 +43,7 @@ module RssBuilderMixin
|
|
|
43
43
|
for obj in objects
|
|
44
44
|
item = RSS::Rss::Channel::Item.new
|
|
45
45
|
item.title = obj.title if obj.respond_to?(:title)
|
|
46
|
-
item.description =
|
|
46
|
+
item.description = Glue::StringUtils.head(obj.body, 256) if obj.respond_to?(:body)
|
|
47
47
|
item.link = "#{c[:base]}/#{obj.view_uri}" if obj.respond_to?(:view_uri)
|
|
48
48
|
channel.items << item
|
|
49
49
|
end
|
data/lib/nitro/builders/table.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
|
3
|
-
# $Id: table.rb
|
|
3
|
+
# $Id: table.rb 1 2005-04-11 11:04:30Z gmosx $
|
|
4
4
|
|
|
5
|
-
module
|
|
5
|
+
module Nitro
|
|
6
6
|
|
|
7
7
|
# The TableBuilder is a helper class that automates the creation
|
|
8
8
|
# of tables from collections of objects. The resulting html
|
data/lib/nitro/builders/xhtml.rb
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
|
2
|
-
# (c)
|
|
3
|
-
# $Id$
|
|
2
|
+
# (c) 2005 Navel, all rights reserved.
|
|
3
|
+
# $Id: xhtml.rb 1 2005-04-11 11:04:30Z gmosx $
|
|
4
4
|
|
|
5
5
|
require 'nitro/builders/xml'
|
|
6
6
|
|
|
7
|
-
module
|
|
7
|
+
module Nitro
|
|
8
8
|
|
|
9
9
|
# A helper mixin for programmatically building XHTML
|
|
10
10
|
# blocks.
|
|
11
|
-
#--
|
|
12
|
-
# TODO: add table generator, form generator
|
|
13
|
-
#++
|
|
14
11
|
|
|
15
12
|
module XhtmlBuilderMixin
|
|
16
13
|
|
|
@@ -24,10 +21,10 @@ module XhtmlBuilderMixin
|
|
|
24
21
|
|
|
25
22
|
def select(*args)
|
|
26
23
|
attrs = args.last.is_a?(Hash) ? args.pop : nil
|
|
27
|
-
start_tag('select', attrs)
|
|
24
|
+
start_tag!('select', attrs)
|
|
28
25
|
self << %|<option>#{args.first}</option>| unless args.empty?
|
|
29
26
|
yield
|
|
30
|
-
end_tag('select')
|
|
27
|
+
end_tag!('select')
|
|
31
28
|
end
|
|
32
29
|
|
|
33
30
|
# Render select options.
|
data/lib/nitro/builders/xml.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# George Moschovitis <gm@navel.gr>
|
|
2
2
|
# (c) 2005 Navel, all rights reserved.
|
|
3
|
-
# $Id$
|
|
3
|
+
# $Id: xml.rb 1 2005-04-11 11:04:30Z gmosx $
|
|
4
4
|
|
|
5
|
-
module
|
|
5
|
+
module Nitro
|
|
6
6
|
|
|
7
7
|
# A helper mixin for programmatically building XML
|
|
8
8
|
# blocks.
|
|
@@ -15,15 +15,15 @@ module XmlBuilderMixin
|
|
|
15
15
|
attrs = args.last.is_a?(Hash) ? args.pop : nil
|
|
16
16
|
|
|
17
17
|
if block_given?
|
|
18
|
-
start_tag('#{tag}', attrs)
|
|
18
|
+
start_tag!('#{tag}', attrs)
|
|
19
19
|
yield
|
|
20
|
-
end_tag('#{tag}')
|
|
20
|
+
end_tag!('#{tag}')
|
|
21
21
|
elsif (!args.empty?)
|
|
22
|
-
start_tag('#{tag}', attrs)
|
|
22
|
+
start_tag!('#{tag}', attrs)
|
|
23
23
|
self << args.first
|
|
24
|
-
end_tag('#{tag}')
|
|
24
|
+
end_tag!('#{tag}')
|
|
25
25
|
else
|
|
26
|
-
start_tag('#{tag}', attrs, false)
|
|
26
|
+
start_tag!('#{tag}', attrs, false)
|
|
27
27
|
self << ' />'
|
|
28
28
|
end
|
|
29
29
|
end
|
|
@@ -32,7 +32,9 @@ module XmlBuilderMixin
|
|
|
32
32
|
self.send(tag, *args, &block)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
# Emit the start (opening) tag of an element.
|
|
36
|
+
|
|
37
|
+
def start_tag!(tag, attributes = nil, close = true)
|
|
36
38
|
unless attributes
|
|
37
39
|
if close
|
|
38
40
|
self << "<#{tag}>"
|
|
@@ -54,31 +56,53 @@ module XmlBuilderMixin
|
|
|
54
56
|
return self
|
|
55
57
|
end
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
# Emit the end (closing) tag of an element.
|
|
60
|
+
|
|
61
|
+
def end_tag!(tag)
|
|
58
62
|
self << "</#{tag}>"
|
|
59
63
|
|
|
60
64
|
return self
|
|
61
65
|
end
|
|
62
66
|
|
|
63
|
-
|
|
67
|
+
# Emit a text string.
|
|
68
|
+
|
|
69
|
+
def text!(str)
|
|
64
70
|
self << str
|
|
65
71
|
|
|
66
72
|
return self
|
|
67
73
|
end
|
|
74
|
+
alias_method :print, :text!
|
|
75
|
+
|
|
76
|
+
# Emit a comment.
|
|
68
77
|
|
|
69
|
-
def comment(str)
|
|
78
|
+
def comment!(str)
|
|
70
79
|
self << "<!-- #{str} -->"
|
|
71
80
|
|
|
72
81
|
return self
|
|
73
82
|
end
|
|
74
|
-
|
|
83
|
+
|
|
84
|
+
# Emit a processing instruction.
|
|
85
|
+
|
|
86
|
+
def processing_instruction!(name, attributes = nil)
|
|
87
|
+
unless attributes
|
|
88
|
+
self << "<?#{name} ?>"
|
|
89
|
+
else
|
|
90
|
+
self << "<?#{name} "
|
|
91
|
+
attributes.each do |a, v|
|
|
92
|
+
self << %[#{a}="#{v}" ]
|
|
93
|
+
end
|
|
94
|
+
self << "?>"
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
alias_method :pi!, :processing_instruction!
|
|
98
|
+
|
|
75
99
|
end
|
|
76
100
|
|
|
77
101
|
# A String extension with XML generation
|
|
78
102
|
# functionality.
|
|
79
103
|
|
|
80
104
|
class XmlString < String
|
|
81
|
-
include
|
|
105
|
+
include XmlBuilderMixin
|
|
82
106
|
end
|
|
83
107
|
|
|
84
108
|
# A class that encapsulats the XML generation
|
|
@@ -86,7 +110,7 @@ end
|
|
|
86
110
|
# output to a target buffer.
|
|
87
111
|
|
|
88
112
|
class XmlBuilder
|
|
89
|
-
include
|
|
113
|
+
include XmlBuilderMixin
|
|
90
114
|
|
|
91
115
|
# The target receives the generated xml,
|
|
92
116
|
# should respond_to :<<
|
data/lib/nitro/caching.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
|
3
|
-
# $Id: caching.rb
|
|
3
|
+
# $Id: caching.rb 1 2005-04-11 11:04:30Z gmosx $
|
|
4
4
|
|
|
5
5
|
require 'fileutils'
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ require 'nitro/caching/output'
|
|
|
10
10
|
require 'nitro/caching/actions'
|
|
11
11
|
require 'nitro/caching/fragments'
|
|
12
12
|
|
|
13
|
-
module
|
|
13
|
+
module Nitro
|
|
14
14
|
|
|
15
15
|
# Adds support for caching.
|
|
16
16
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
|
3
|
-
# $Id: actions.rb
|
|
3
|
+
# $Id: actions.rb 1 2005-04-11 11:04:30Z gmosx $
|
|
4
4
|
|
|
5
5
|
require 'fileutils'
|
|
6
6
|
|
|
7
|
-
module
|
|
7
|
+
module Nitro
|
|
8
8
|
|
|
9
9
|
# Adds support for caching.
|
|
10
10
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
|
3
|
-
# $Id: fragments.rb
|
|
3
|
+
# $Id: fragments.rb 1 2005-04-11 11:04:30Z gmosx $
|
|
4
4
|
|
|
5
5
|
require 'fileutils'
|
|
6
6
|
|
|
7
7
|
require 'glue/attribute'
|
|
8
8
|
require 'nitro/caching/stores'
|
|
9
9
|
|
|
10
|
-
module
|
|
10
|
+
module Nitro
|
|
11
11
|
|
|
12
12
|
# Adds support for caching.
|
|
13
13
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
|
3
|
-
# $Id: invalidation.rb
|
|
3
|
+
# $Id: invalidation.rb 1 2005-04-11 11:04:30Z gmosx $
|
|
4
4
|
|
|
5
|
-
module
|
|
5
|
+
module Nitro
|
|
6
6
|
|
|
7
7
|
module Caching
|
|
8
8
|
|
|
@@ -23,29 +23,3 @@ module Caching
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
end
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
__END__
|
|
29
|
-
|
|
30
|
-
class MyController < Controller
|
|
31
|
-
|
|
32
|
-
cache_output :list
|
|
33
|
-
|
|
34
|
-
cache_monitor :on => [ :add, :delete ]
|
|
35
|
-
|
|
36
|
-
def list
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def add
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def delete
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
class Invalidator
|
|
48
|
-
def filter(controller)
|
|
49
|
-
|
|
50
|
-
end
|
|
51
|
-
end
|
data/lib/nitro/caching/output.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
|
3
|
-
# $Id: output.rb
|
|
3
|
+
# $Id: output.rb 9 2005-04-13 00:08:20Z nasis $
|
|
4
4
|
|
|
5
5
|
require 'fileutils'
|
|
6
6
|
|
|
7
|
-
module
|
|
7
|
+
module Nitro
|
|
8
8
|
|
|
9
9
|
# Adds support for caching.
|
|
10
10
|
|
|
@@ -46,7 +46,7 @@ module Caching
|
|
|
46
46
|
private
|
|
47
47
|
|
|
48
48
|
def output_cache_path(path)
|
|
49
|
-
|
|
49
|
+
filename = ((path.empty? || path == '/') ? '/index' : path)
|
|
50
50
|
filename << '.html' unless (name.split('/').last || name).include? '.'
|
|
51
51
|
return output_cache_root + filename
|
|
52
52
|
end
|