nitro 0.15.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/CHANGELOG +218 -0
  2. data/INSTALL +3 -0
  3. data/README +4 -2
  4. data/Rakefile +150 -8
  5. data/benchmark/bench.rb +1 -1
  6. data/doc/AUTHORS +2 -8
  7. data/doc/RELEASES +63 -1
  8. data/examples/ajax/controller.rb +2 -2
  9. data/examples/ajax/public/index.xhtml +3 -1
  10. data/examples/ajax/run.rb +3 -3
  11. data/examples/blog/README +8 -0
  12. data/examples/blog/cache/entriesadmintrue +3 -0
  13. data/examples/blog/run.rb +38 -40
  14. data/examples/blog/src/blog.rb +2 -1
  15. data/examples/blog/src/controller.rb +40 -20
  16. data/examples/blog/src/mailer.rb +2 -2
  17. data/examples/blog/src/models/blog.rb +2 -1
  18. data/examples/blog/src/models/content.rb +4 -33
  19. data/examples/blog/src/views/error.xhtml +1 -1
  20. data/examples/blog/src/xsl/style.xsl +1 -1
  21. data/examples/blog/test/tc_blog.rb +43 -0
  22. data/examples/flash/run.rb +2 -2
  23. data/examples/no_xsl_blog/lib/blog.rb +1 -1
  24. data/examples/no_xsl_blog/lib/blog/controller.rb +26 -17
  25. data/examples/no_xsl_blog/lib/blog/model.rb +3 -3
  26. data/examples/no_xsl_blog/lib/blog/template.rb +1 -1
  27. data/examples/no_xsl_blog/lib/content.rb +3 -7
  28. data/examples/no_xsl_blog/run.rb +34 -34
  29. data/examples/tiny/public/deep/dir/hello.xhtml +2 -0
  30. data/examples/tiny/run.rb +2 -2
  31. data/examples/wee_style/run.rb +5 -3
  32. data/examples/why_wiki/run.rb +5 -3
  33. data/install.rb +1 -1
  34. data/lib/nitro.rb +10 -9
  35. data/lib/nitro/adapters/cgi.rb +27 -2
  36. data/lib/nitro/adapters/fastcgi.rb +6 -2
  37. data/lib/nitro/adapters/webrick.rb +11 -9
  38. data/lib/nitro/buffering.rb +2 -2
  39. data/lib/nitro/builders/atom.rb +78 -0
  40. data/lib/nitro/builders/form.rb +2 -2
  41. data/lib/nitro/builders/rss.rb +4 -4
  42. data/lib/nitro/builders/table.rb +2 -2
  43. data/lib/nitro/builders/xhtml.rb +5 -8
  44. data/lib/nitro/builders/xml.rb +38 -14
  45. data/lib/nitro/caching.rb +2 -2
  46. data/lib/nitro/caching/actions.rb +2 -2
  47. data/lib/nitro/caching/fragments.rb +2 -2
  48. data/lib/nitro/caching/invalidation.rb +2 -28
  49. data/lib/nitro/caching/output.rb +3 -3
  50. data/lib/nitro/caching/stores.rb +4 -4
  51. data/lib/nitro/conf.rb +11 -6
  52. data/lib/nitro/context.rb +2 -2
  53. data/lib/nitro/controller.rb +12 -7
  54. data/lib/nitro/cookie.rb +2 -2
  55. data/lib/nitro/dispatcher.rb +33 -40
  56. data/lib/nitro/environment.rb +1 -1
  57. data/lib/nitro/localization.rb +5 -7
  58. data/lib/nitro/mail.rb +2 -2
  59. data/lib/nitro/markup.rb +5 -5
  60. data/lib/nitro/output.rb +2 -2
  61. data/lib/nitro/part.rb +8 -5
  62. data/lib/nitro/render.rb +46 -45
  63. data/lib/nitro/request.rb +7 -6
  64. data/lib/nitro/response.rb +14 -5
  65. data/lib/nitro/routing.rb +2 -2
  66. data/lib/nitro/runner.rb +57 -17
  67. data/lib/nitro/scaffold.rb +14 -8
  68. data/lib/nitro/session.rb +7 -4
  69. data/lib/nitro/session/drb.rb +2 -2
  70. data/lib/nitro/session/drbserver.rb +2 -2
  71. data/lib/nitro/session/memory.rb +2 -2
  72. data/lib/nitro/shaders.rb +8 -7
  73. data/lib/nitro/simple.rb +4 -1
  74. data/lib/nitro/template.rb +8 -8
  75. data/lib/nitro/testing.rb +6 -0
  76. data/lib/nitro/testing/assertions.rb +102 -0
  77. data/lib/nitro/testing/context.rb +52 -0
  78. data/lib/nitro/testing/testcase.rb +55 -0
  79. data/lib/nitro/ui/pager.rb +3 -3
  80. data/lib/nitro/ui/popup.rb +8 -13
  81. data/lib/nitro/ui/tabs.rb +4 -10
  82. data/lib/nitro/uri.rb +7 -7
  83. data/proto/doc/README +1 -0
  84. data/proto/public/cgi.rb +5 -0
  85. data/proto/run.rb +2 -4
  86. data/test/nitro/adapters/tc_cgi.rb +1 -1
  87. data/test/nitro/adapters/tc_webrick.rb +1 -2
  88. data/test/nitro/builders/tc_atom.rb +26 -0
  89. data/test/nitro/builders/tc_rss.rb +3 -2
  90. data/test/nitro/builders/tc_table.rb +1 -1
  91. data/test/nitro/builders/tc_xhtml.rb +4 -3
  92. data/test/nitro/builders/tc_xml.rb +7 -7
  93. data/test/nitro/tc_context.rb +1 -1
  94. data/test/nitro/tc_controller.rb +5 -3
  95. data/test/nitro/tc_dispatcher.rb +19 -18
  96. data/test/nitro/tc_localization.rb +1 -1
  97. data/test/nitro/tc_mail.rb +1 -1
  98. data/test/nitro/tc_session.rb +1 -1
  99. data/test/nitro/tc_template.rb +1 -1
  100. data/test/nitro/tc_uri.rb +3 -4
  101. data/test/nitro/ui/tc_pager.rb +7 -7
  102. data/test/public/blog/inc1.xhtml +2 -0
  103. data/test/public/blog/inc2.xhtml +1 -0
  104. data/test/public/blog/list.xhtml +3 -0
  105. metadata +180 -203
  106. data/examples/blog/cache/entriesadmin +0 -12
  107. data/lib/nitro/cluster.rb +0 -218
  108. data/lib/nitro/component.rb +0 -15
  109. data/lib/nitro/filters.rb +0 -215
  110. data/lib/nitro/ui/date-select.rb +0 -69
  111. 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: drb.rb 264 2005-02-23 13:46:55Z gmosx $
3
+ # $Id: drb.rb 1 2005-04-11 11:04:30Z gmosx $
4
4
 
5
5
  require 'drb'
6
6
 
@@ -9,7 +9,7 @@ require 'nitro/session'
9
9
 
10
10
  Logger.debug 'Using Drb sessions.'
11
11
 
12
- module N
12
+ module Nitro
13
13
 
14
14
  class Session
15
15
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # * George Moschovitis <gm@navel.gr>
4
4
  # (c) 2004-2005 Navel, all rights reserved.
5
- # $Id: drbserver.rb 264 2005-02-23 13:46:55Z gmosx $
5
+ # $Id: drbserver.rb 1 2005-04-11 11:04:30Z gmosx $
6
6
 
7
7
  require 'drb'
8
8
  require 'optparse'
@@ -49,7 +49,7 @@ rescue OptionParser::InvalidOption
49
49
  exit
50
50
  end
51
51
 
52
- sessions = N::SafeHash.new
52
+ sessions = Glue::SafeHash.new
53
53
 
54
54
  if debug
55
55
 
@@ -1,12 +1,12 @@
1
1
  # * George Moschovitis <gm@navel.gr>
2
2
  # (c) 2004-2005 Navel, all rights reserved.
3
- # $Id: memory.rb 264 2005-02-23 13:46:55Z gmosx $
3
+ # $Id: memory.rb 1 2005-04-11 11:04:30Z gmosx $
4
4
 
5
5
  require 'glue/hash'
6
6
 
7
7
  Logger.debug 'Using In-Memory sessions.'
8
8
 
9
- module N
9
+ module Nitro
10
10
 
11
11
  Session.store = SafeHash.new
12
12
 
@@ -1,10 +1,10 @@
1
1
  # George Moschovitis <gm@navel.gr>
2
2
  # (c) 2004-2005 Navel, all rights reserved.
3
- # $Id: shaders.rb 202 2005-01-17 10:44:13Z gmosx $
3
+ # $Id: shaders.rb 1 2005-04-11 11:04:30Z gmosx $
4
4
 
5
5
  require 'nitro/template'
6
6
 
7
- module N
7
+ module Nitro
8
8
 
9
9
  # A shader defines a transformation-pipeline that tansforms
10
10
  # the .xhtml files to actual ruby code ready for evaluation
@@ -59,7 +59,6 @@ class RubyShader < Shader
59
59
 
60
60
  # Convert the xhtml script to actual Ruby code, ready
61
61
  # to be evaluated.
62
- #
63
62
  #--
64
63
  # Investigate:
65
64
  # perhaps xl:href should be used to be XLink compatible?
@@ -107,8 +106,10 @@ class XSLTShader < Shader
107
106
  attr :mtime
108
107
 
109
108
  def initialize(xsl_filename, next_stage = nil)
109
+
110
110
  # leave this require here. only inlcude the xslt
111
111
  # library if the project needs it.
112
+
112
113
  require "xml/xslt"
113
114
 
114
115
  @name = File.basename(xsl_filename, '.*')
@@ -123,7 +124,7 @@ class XSLTShader < Shader
123
124
  parse_xsl()
124
125
  @xslt.xml = text
125
126
  hash += @name
126
-
127
+ Logger.debug "Applying xsl '#{@xsl_filename}' to template" if $DBG
127
128
  process_next(hash, xslt.serve)
128
129
  end
129
130
 
@@ -165,7 +166,7 @@ class MorphingShader < Shader
165
166
  # <tag if="x">..</tag>
166
167
  # <tag unless="x">..</tag>
167
168
 
168
- text.gsub!(/<(\w*?)([^>]*?)(if|unless)="(.*?)"(.*?)>(.*?)<\/\1>/m) do |match|
169
+ text.gsub!(/<(\w*?)([^>]*?)(if|unless)=["|'](.*?)["|'](.*?)>(.*?)<\/\1>/m) do |match|
169
170
  %{<?r #$3 #$4 ?>
170
171
  <#$1#$2#$5>#$6</#$1>
171
172
  <?r end ?>}
@@ -173,7 +174,7 @@ class MorphingShader < Shader
173
174
 
174
175
  # <tag times="x">..</tag>
175
176
 
176
- text.gsub!(/<(\w*?)([^>]*?)times="(.*?)"(.*?)>(.*?)<\/\1>/m) do |match|
177
+ text.gsub!(/<(\w*?)([^>]*?)times=["|'](.*?)["|'](.*?)>(.*?)<\/\1>/m) do |match|
177
178
  %{<?r #$3.times do ?>
178
179
  <#$1#$2#$4>#$5</#$1>
179
180
  <?r end ?>}
@@ -181,7 +182,7 @@ class MorphingShader < Shader
181
182
 
182
183
  # <tag each="x">..</tag>
183
184
 
184
- text.gsub!(/<(\w*?)([^>]*?)each="(.*?)"(.*?)>(.*?)<\/\1>/m) do |match|
185
+ text.gsub!(/<(\w*?)([^>]*?)each=["|'](.*?)["|'](.*?)>(.*?)<\/\1>/m) do |match|
185
186
  %{<?r for #$3 ?>
186
187
  <#$1#$2#$4>#$5</#$1>
187
188
  <?r end ?>}
@@ -3,6 +3,9 @@ require 'nitro/controller'
3
3
  # A simple controller, only handles templates.
4
4
  # Useful to implement php/asp/jsp style applications.
5
5
  # Dispatcher uses this as the default Controller.
6
+ #--
7
+ # gmosx, FIXME: this is a nasty hack, remove!
8
+ #++
6
9
 
7
- class SimpleController < N::Controller;
10
+ class SimpleController < Nitro::Controller;
8
11
  end
@@ -1,10 +1,10 @@
1
1
  # * George Moschovitis <gm@navel.gr>
2
2
  # (c) 2004-2005 Navel, all rights reserved.
3
- # $Id: template.rb 332 2005-03-29 11:31:52Z gmosx $
3
+ # $Id: template.rb 9 2005-04-13 00:08:20Z nasis $
4
4
 
5
5
  require 'glue/flexob'
6
6
 
7
- module N
7
+ module Nitro
8
8
 
9
9
  # A template is a text file with embeded Ruby code. The template
10
10
  # processor converts the original text file to ruby code and
@@ -41,7 +41,7 @@ module TemplateMixin
41
41
  # Example:
42
42
  # <?include href="root/myfile.sx" ?>
43
43
 
44
- text.gsub!(/<\?include href="(.*?)"(.*)\?>/) do |match|
44
+ text.gsub!(/<\?include href=["|'](.*?)["|'](.*)\?>/) do |match|
45
45
  text = File.read("#{base_dir}/#$1")
46
46
  text.gsub!(/<\?xml.*\?>/, '')
47
47
  text.gsub!(/<\/?root(.*?)>/m, ' ');
@@ -51,22 +51,22 @@ module TemplateMixin
51
51
  # Transform include instructions <include href="xxx" />
52
52
  # must be transformed before the processinc instructions.
53
53
  # Useful to include fragments cached on disk
54
- #
54
+ #
55
55
  # gmosx, FIXME: NOT TESTED! test and add caching.
56
56
  # add load_statically_included fixes.
57
57
 
58
- text.gsub!(/<include href="(.*?)"(.*)(.?)\/>/) do |match|
58
+ text.gsub!(/<include href=["|'](.*?)["|'](.*)(.?)\/>/) do |match|
59
59
  "<?r File.read( '\#\{@dispatcher.root\}/#$1' ?>"
60
60
  end
61
61
 
62
62
  # xform render/inject instructions <render href="xxx" />
63
63
  # must be transformed before the processinc instructions.
64
64
 
65
- text.gsub!(/<inject href="(.*?)"(.*)(.?)\/>/) do |match|
65
+ text.gsub!(/<inject href=["|'](.*?)["|'](.*)(.?)\/>/) do |match|
66
66
  "<?r render '/#$1' ?>"
67
67
  end
68
68
 
69
- text.gsub!(/<render href="(.*?)"(.*)(.?)\/>/) do |match|
69
+ text.gsub!(/<render href=["|'](.*?)["|'](.*)(.?)\/>/) do |match|
70
70
  "<?r render '/#$1' ?>"
71
71
  end
72
72
 
@@ -93,7 +93,7 @@ module TemplateMixin
93
93
 
94
94
  text.gsub!(/%>/, "\n#{buffer} << %^")
95
95
  text.gsub!(/<%/, "^\n")
96
-
96
+
97
97
  # Alterative versions of interpolation.
98
98
  # (very useful in xsl stylesheets)
99
99
 
@@ -0,0 +1,6 @@
1
+ # * George Moschovitis <gm@navel.gr>
2
+ # (c) 2004-2005 Navel, all rights reserved.
3
+ # $Id: testing.rb 1 2005-04-11 11:04:30Z gmosx $
4
+
5
+ require 'nitro/testing/assertions'
6
+ require 'nitro/testing/testcase'
@@ -0,0 +1,102 @@
1
+ # * George Moschovitis <gm@navel.gr>
2
+ # (c) 2004-2005 Navel, all rights reserved.
3
+ # $Id: assertions.rb 1 2005-04-11 11:04:30Z gmosx $
4
+
5
+ require 'test/unit'
6
+ require 'test/unit/assertions'
7
+ require 'rexml/document'
8
+
9
+ module Test::Unit::Assertions
10
+
11
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
12
+ # :section: General assertions.
13
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
14
+
15
+ def assert_status_ok(msg = nil)
16
+ msg = format_msg("Status not ok", msg)
17
+ assert_block(msg) { @context.status_ok? }
18
+ end
19
+
20
+ def assert_output_match(re, msg = nil)
21
+ msg = format_msg("Rendered output does not match '#{re}'", msg)
22
+ assert_block(msg) { @context.out =~ Regexp.new(re) }
23
+ end
24
+ alias_method :assert_output_contains, :assert_output_match
25
+
26
+ def assert_output_no_match(re, msg = nil)
27
+ msg = format_msg("Rendered output matches '#{re}'", msg)
28
+ assert_block(msg) { @context.out =~ Regexp.new(re) }
29
+ end
30
+ alias_method :assert_output_contains_no, :assert_output_no_match
31
+
32
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
33
+ # :section: Session related assertions.
34
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
35
+
36
+ def assert_session_has(key, msg = nil)
37
+ msg = format_msg("Object '#{key}' not found in session", msg)
38
+ assert_block(msg) { @context.session[key] }
39
+ end
40
+
41
+ def assert_session_has_no(key, msg = nil)
42
+ msg = format_msg("Unexpected object '#{key}' found in session", msg)
43
+ assert_block(msg) { !@context.session[key] }
44
+ end
45
+ alias_method :assert_session_has_not, :assert_session_has_no
46
+
47
+ def assert_session_equal(key, value, msg = nil)
48
+ msg = format_msg("The value of session object '#{key}' is '#{@context.session[key]}' but was expected '#{value}'", msg)
49
+ assert_block(msg) { @context.session[key] == value }
50
+ end
51
+
52
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
53
+ # :section: Cookies related assertions.
54
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
55
+
56
+ def assert_has_cookie(name, msg = nil)
57
+ msg = format_msg("Cookie '#{name}' not found", msg)
58
+ assert_block(msg) { @context.response_cookie(name) }
59
+ end
60
+
61
+ def assert_has_no_cookie(name, msg = nil)
62
+ msg = format_msg("Unexpected cookie '#{name}' found", msg)
63
+ assert_block(msg) { !@context.response_cookie(name) }
64
+ end
65
+
66
+ def assert_cookie_equal(name, value, msg = nil)
67
+ unless cookie = @context.response_cookie(name)
68
+ msg = format_msg("Cookie '#{name}' not found", msg)
69
+ assert_block(msg) { false }
70
+ end
71
+ msg = format_msg("The value of cookie '#{name}' is '#{cookie.value}' but was expected '#{value}'", msg)
72
+ assert_block(msg) { cookie.value == value }
73
+ end
74
+
75
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
76
+ # :section: Template related assertions.
77
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
78
+
79
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
80
+ # :section: Redirection assertions.
81
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
82
+
83
+ def assert_redirect(msg = nil)
84
+ msg = format_msg("No redirection (status = #{@context.status})", msg)
85
+ assert_block(msg) { @context.redirect? }
86
+ end
87
+
88
+ def assert_no_redirect(msg = nil)
89
+ msg = format_msg("Unexpected redirection (location = '#{@context.response_headers['location']}')", msg)
90
+ assert_block(msg) { !@context.redirect? }
91
+ end
92
+
93
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
94
+ # :section: Utility methods
95
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
96
+
97
+ def format_msg(message, extra) # :nodoc:
98
+ extra += ', ' if extra
99
+ return "#{extra}#{message}"
100
+ end
101
+
102
+ end
@@ -0,0 +1,52 @@
1
+ # * George Moschovitis <gm@navel.gr>
2
+ # (c) 2004-2005 Navel, all rights reserved.
3
+ # $Id: context.rb 1 2005-04-11 11:04:30Z gmosx $
4
+
5
+ require 'test/unit'
6
+ require 'test/unit/assertions'
7
+ require 'rexml/document'
8
+
9
+ require 'nitro/context'
10
+
11
+ module Nitro
12
+
13
+ # Override the default Request implementation
14
+ # to include methods useful for testing.
15
+
16
+ module Request
17
+ end
18
+
19
+ # Override the default Response implementation
20
+ # to include methods useful for testing.
21
+
22
+ module Response
23
+
24
+ def status_ok?
25
+ @status == 200
26
+ end
27
+
28
+ def redirect?
29
+ (300..399).include?(@status)
30
+ end
31
+
32
+ def redirect_url
33
+ @response_headers['location']
34
+ end
35
+
36
+ def response_cookie(name)
37
+ return nil unless @response_cookies
38
+ @response_cookies.find { |c| c.name == name }
39
+ end
40
+
41
+ end
42
+
43
+ # Override the default Response implementation
44
+ # to include methods useful for testing.
45
+
46
+ class Context
47
+ def session
48
+ @session || @session = {}
49
+ end
50
+ end
51
+
52
+ end
@@ -0,0 +1,55 @@
1
+ # * George Moschovitis <gm@navel.gr>
2
+ # (c) 2004-2005 Navel, all rights reserved.
3
+ # $Id: testcase.rb 1 2005-04-11 11:04:30Z gmosx $
4
+
5
+ require 'test/unit'
6
+ require 'test/unit/assertions'
7
+ require 'rexml/document'
8
+
9
+ require 'glue'
10
+ require 'glue/logger'
11
+ require 'nitro/conf'
12
+ require 'nitro/testing/context'
13
+
14
+ module Test::Unit
15
+
16
+ class TestCase
17
+ include Nitro
18
+
19
+ attr_accessor :conf
20
+ attr_accessor :context
21
+
22
+ def handle(path, request = {}, session = nil, headers = {})
23
+ @conf ||= Conf.new({})
24
+ @conf.public_root ||= File.join(File.dirname(__FILE__), '..', 'public')
25
+ @conf.template_root ||= File.join(File.dirname(__FILE__), '..', 'public')
26
+
27
+ begin
28
+ Og.db.get_connection if defined?(Og) and Og.db
29
+
30
+ context = Context.new(@conf)
31
+
32
+ # context.in = StringIO.new(req.body || "")
33
+
34
+ context.params = request
35
+ context.headers ||= headers
36
+ context.session = session if session
37
+
38
+ context.headers['REQUEST_URI'] = path
39
+ # CgiUtils.parse_params(context)
40
+ # CgiUtils.parse_cookies(context)
41
+
42
+ context.render(path)
43
+
44
+ @context = context
45
+
46
+ return context
47
+ ensure
48
+ Og.db.put_connection if defined?(Og) and Og.db
49
+ end
50
+ end
51
+ alias_method :process, :handle
52
+
53
+ end
54
+
55
+ end
@@ -1,10 +1,10 @@
1
1
  # * George Moschovitis <gm@navel.gr>
2
2
  # (c) 2004-2005 Navel, all rights reserved.
3
- # $Id: pager.rb 266 2005-02-28 14:50:48Z gmosx $
3
+ # $Id: pager.rb 1 2005-04-11 11:04:30Z gmosx $
4
4
 
5
5
  require 'nitro/uri'
6
6
 
7
- module N; module UI
7
+ module Nitro; module UI
8
8
 
9
9
  # Displays a collection of entitities in multiple pages.
10
10
  #
@@ -198,7 +198,7 @@ class Pager < Array
198
198
  #
199
199
  def target_uri(page)
200
200
  params = {"__pg#{@name}" => page}
201
- return N::UriUtils.update_query_string(@request.uri.to_s, params)
201
+ return UriUtils.update_query_string(@request.uri.to_s, params)
202
202
  end
203
203
 
204
204
  end
@@ -1,20 +1,16 @@
1
- # code:
2
1
  # * George Moschovitis <gm@navel.gr>
3
- #
4
- # (c) 2004 Navel, all rights reserved.
5
- # $Id: popup.rb 99 2004-10-22 09:50:28Z gmosx $
2
+ # (c) 2004-2005 Navel, all rights reserved.
3
+ # $Id: popup.rb 1 2005-04-11 11:04:30Z gmosx $
6
4
 
7
- module N; module UI
5
+ module Nitro
8
6
 
9
- # = Popup
10
- #
11
7
  # Display a popup window.
12
- #
8
+
13
9
  class Popup
14
10
 
15
11
  # Emit the needed javascript.
16
12
  # Alternatively use this code: <script src="/r/js/std.js">#{}</script>
17
- #
13
+
18
14
  def self.script
19
15
  %[
20
16
  function newWin(url, name, w, h, scroll) {
@@ -30,17 +26,16 @@ function newWin(url, name, w, h, scroll) {
30
26
  end
31
27
 
32
28
  # gmosx: keep the leading / to be IE friendly.
33
- #
29
+
34
30
  def self.onclick(uri, width, height, title = "Popup", type="PAGE", options = "scrollbars=yes,resizable", container = "/p/glue/popup.sx")
35
31
  %[javascript: var pwl = (screen.width - #{width}) / 2; var pwt = (screen.height - #{height}) / 2; window.open('#{container}?uri=#{uri};type=#{type}', '#{title}', 'width=#{width},height=#{height},top='+pwt+',left='+pwl+', #{options}'); return false"]
36
32
  end
37
33
 
38
34
  # gmosx: keep the leading / to be IE friendly.
39
- #
35
+
40
36
  def self.link(uri, width, height, link = "link", title = "Popup", type="PAGE", options = "scrollbars=yes,resizable", container = "/p/glue/popup.sx")
41
37
  %[<a href="#" onclick="#{self.onclick(uri, width, height, title, type, options, container)}">#{link}</a>]
42
38
  end
43
39
  end
44
40
 
45
- end; end # module
46
-
41
+ end