ramaze 0.3.5 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. data/Rakefile +5 -20
  2. data/bin/ramaze +0 -4
  3. data/doc/AUTHORS +5 -0
  4. data/doc/meta/announcement.txt +2 -1
  5. data/doc/tutorial/todolist.html +20 -21
  6. data/doc/tutorial/todolist.mkd +10 -9
  7. data/examples/blog/{src/controller.rb → controller/main.rb} +2 -0
  8. data/examples/blog/{src/model.rb → model/entry.rb} +0 -0
  9. data/examples/blog/spec/blog.rb +3 -3
  10. data/examples/blog/start.rb +2 -3
  11. data/examples/blog/view/edit.xhtml +17 -0
  12. data/examples/blog/view/index.xhtml +17 -0
  13. data/examples/blog/view/layout.xhtml +11 -0
  14. data/examples/blog/view/new.xhtml +16 -0
  15. data/examples/facebook.rb +15 -8
  16. data/examples/identity.rb +1 -1
  17. data/examples/memleak_detector.rb +1 -1
  18. data/examples/rammit/src/model.rb +1 -1
  19. data/examples/rapaste/controller/paste.rb +7 -7
  20. data/examples/rapaste/model/paste.rb +1 -3
  21. data/examples/rapaste/public/css/display.css +2 -1
  22. data/examples/rapaste/start.rb +2 -3
  23. data/examples/sourceview/sourceview.rb +1 -1
  24. data/examples/templates/template/external.tenjin +28 -0
  25. data/examples/templates/template_amrita2.rb +0 -3
  26. data/examples/templates/template_tenjin.rb +57 -0
  27. data/examples/todolist/spec/todolist.rb +13 -2
  28. data/examples/todolist/src/controller/main.rb +1 -1
  29. data/examples/todolist/template/index.xhtml +1 -1
  30. data/examples/wiktacular/spec/wiktacular.rb +18 -0
  31. data/examples/wiktacular/src/controller.rb +2 -2
  32. data/examples/wiktacular/src/model.rb +8 -2
  33. data/lib/proto/public/css/ramaze_error.css +4 -0
  34. data/lib/proto/public/dispatch.fcgi +11 -0
  35. data/lib/proto/spec/main.rb +1 -1
  36. data/lib/proto/start.ru +8 -0
  37. data/lib/proto/view/error.xhtml +2 -0
  38. data/lib/ramaze.rb +28 -5
  39. data/lib/ramaze/action.rb +9 -2
  40. data/lib/ramaze/action/render.rb +40 -24
  41. data/lib/ramaze/adapter.rb +10 -17
  42. data/lib/ramaze/adapter/base.rb +8 -12
  43. data/lib/ramaze/adapter/cgi.rb +14 -13
  44. data/lib/ramaze/adapter/ebb.rb +34 -0
  45. data/lib/ramaze/adapter/evented_mongrel.rb +1 -1
  46. data/lib/ramaze/adapter/fcgi.rb +14 -14
  47. data/lib/ramaze/adapter/lsws.rb +15 -11
  48. data/lib/ramaze/adapter/mongrel.rb +2 -1
  49. data/lib/ramaze/adapter/scgi.rb +24 -0
  50. data/lib/ramaze/adapter/swiftiplied_mongrel.rb +1 -1
  51. data/lib/ramaze/adapter/thin.rb +4 -5
  52. data/lib/ramaze/adapter/webrick.rb +5 -5
  53. data/lib/ramaze/cache.rb +1 -1
  54. data/lib/ramaze/cache/memcached.rb +1 -1
  55. data/lib/ramaze/contrib.rb +70 -10
  56. data/lib/ramaze/contrib/auto_params.rb +1 -1
  57. data/lib/ramaze/contrib/email.rb +15 -15
  58. data/lib/ramaze/contrib/facebook.rb +2 -2
  59. data/lib/ramaze/contrib/facebook/facebook.rb +7 -4
  60. data/lib/ramaze/contrib/file_cache.rb +65 -0
  61. data/lib/ramaze/contrib/gettext.rb +56 -55
  62. data/lib/ramaze/contrib/profiling.rb +36 -0
  63. data/lib/ramaze/contrib/sequel_cache.rb +92 -0
  64. data/lib/ramaze/controller.rb +80 -47
  65. data/lib/ramaze/controller/error.rb +10 -5
  66. data/lib/ramaze/controller/resolve.rb +36 -48
  67. data/lib/ramaze/current.rb +70 -0
  68. data/lib/ramaze/{trinity → current}/request.rb +62 -15
  69. data/lib/ramaze/current/response.rb +19 -0
  70. data/lib/ramaze/{trinity → current}/session.rb +32 -110
  71. data/lib/ramaze/current/session/flash.rb +67 -0
  72. data/lib/ramaze/current/session/hash.rb +65 -0
  73. data/lib/ramaze/dispatcher.rb +1 -28
  74. data/lib/ramaze/dispatcher/action.rb +6 -3
  75. data/lib/ramaze/dispatcher/directory.rb +1 -1
  76. data/lib/ramaze/dispatcher/error.rb +26 -5
  77. data/lib/ramaze/dispatcher/file.rb +13 -2
  78. data/lib/ramaze/gestalt.rb +3 -1
  79. data/lib/ramaze/global.rb +6 -3
  80. data/lib/ramaze/global/globalstruct.rb +3 -1
  81. data/lib/ramaze/helper.rb +66 -20
  82. data/lib/ramaze/helper/aspect.rb +25 -17
  83. data/lib/ramaze/helper/auth.rb +4 -3
  84. data/lib/ramaze/helper/cache.rb +5 -4
  85. data/lib/ramaze/helper/cgi.rb +11 -9
  86. data/lib/ramaze/helper/flash.rb +28 -3
  87. data/lib/ramaze/helper/formatting.rb +1 -3
  88. data/lib/ramaze/helper/identity.rb +2 -3
  89. data/lib/ramaze/helper/inform.rb +7 -6
  90. data/lib/ramaze/helper/link.rb +15 -17
  91. data/lib/ramaze/helper/markaby.rb +2 -4
  92. data/lib/ramaze/helper/maruku.rb +1 -1
  93. data/lib/ramaze/helper/nitroform.rb +4 -4
  94. data/lib/ramaze/helper/pager.rb +4 -6
  95. data/lib/ramaze/helper/partial.rb +24 -21
  96. data/lib/ramaze/helper/redirect.rb +8 -5
  97. data/lib/ramaze/helper/{file.rb → sendfile.rb} +1 -3
  98. data/lib/ramaze/helper/sequel.rb +1 -3
  99. data/lib/ramaze/helper/stack.rb +1 -3
  100. data/lib/ramaze/helper/tagz.rb +19 -0
  101. data/lib/ramaze/helper/user.rb +63 -0
  102. data/lib/ramaze/inform.rb +2 -24
  103. data/lib/ramaze/log.rb +28 -0
  104. data/lib/ramaze/{inform → log}/analogger.rb +3 -3
  105. data/lib/ramaze/{inform → log}/growl.rb +2 -2
  106. data/lib/ramaze/{inform → log}/hub.rb +4 -6
  107. data/lib/ramaze/{inform → log}/informer.rb +4 -4
  108. data/lib/ramaze/{inform → log}/knotify.rb +2 -2
  109. data/lib/ramaze/log/logger.rb +22 -0
  110. data/lib/ramaze/{inform/informing.rb → log/logging.rb} +16 -16
  111. data/lib/ramaze/{inform → log}/syslog.rb +0 -0
  112. data/lib/ramaze/{inform → log}/xosd.rb +2 -2
  113. data/lib/ramaze/route.rb +64 -36
  114. data/lib/ramaze/snippets/array/put_within.rb +13 -0
  115. data/lib/ramaze/snippets/binding/locals.rb +13 -0
  116. data/lib/ramaze/snippets/kernel/__dir__.rb +10 -8
  117. data/lib/ramaze/snippets/kernel/aquire.rb +1 -1
  118. data/lib/ramaze/snippets/kernel/constant.rb +1 -1
  119. data/lib/ramaze/snippets/object/pretty.rb +6 -0
  120. data/lib/ramaze/snippets/object/scope.rb +11 -0
  121. data/lib/ramaze/snippets/object/thread_accessor.rb +5 -0
  122. data/lib/ramaze/snippets/ordered_set.rb +1 -1
  123. data/lib/ramaze/snippets/proc/locals.rb +11 -0
  124. data/lib/ramaze/snippets/ramaze/thread_accessor.rb +44 -0
  125. data/lib/ramaze/snippets/string/esc.rb +29 -0
  126. data/lib/ramaze/snippets/string/start_with.rb +7 -0
  127. data/lib/ramaze/snippets/string/unindent.rb +6 -1
  128. data/lib/ramaze/snippets/struct/values_at.rb +1 -5
  129. data/lib/ramaze/sourcereload.rb +16 -14
  130. data/lib/ramaze/spec.rb +1 -0
  131. data/lib/ramaze/spec/helper.rb +11 -3
  132. data/lib/ramaze/spec/helper/browser.rb +25 -1
  133. data/lib/ramaze/spec/helper/pretty_output.rb +11 -11
  134. data/lib/ramaze/template.rb +5 -4
  135. data/lib/ramaze/template/amrita2.rb +2 -3
  136. data/lib/ramaze/template/ezamar/element.rb +2 -3
  137. data/lib/ramaze/template/ezamar/morpher.rb +1 -2
  138. data/lib/ramaze/template/ezamar/render_partial.rb +1 -1
  139. data/lib/ramaze/template/haml.rb +5 -2
  140. data/lib/ramaze/template/markaby.rb +2 -0
  141. data/lib/ramaze/template/tagz.rb +79 -0
  142. data/lib/ramaze/template/tenjin.rb +34 -0
  143. data/lib/ramaze/tool/create.rb +0 -3
  144. data/lib/ramaze/tool/localize.rb +107 -105
  145. data/lib/ramaze/tool/mime.rb +0 -2
  146. data/lib/ramaze/trinity.rb +1 -26
  147. data/lib/ramaze/version.rb +1 -1
  148. data/lib/vendor/bacon.rb +47 -41
  149. data/rake_tasks/conf.rake +18 -0
  150. data/rake_tasks/darcs.rake +5 -0
  151. data/rake_tasks/maintenance.rake +37 -24
  152. data/rake_tasks/spec.rake +1 -1
  153. data/spec/contrib/auto_params.rb +3 -1
  154. data/spec/contrib/profiling.rb +26 -0
  155. data/spec/examples/templates/template_redcloth.rb +1 -1
  156. data/spec/examples/templates/template_tenjin.rb +28 -0
  157. data/spec/helper.rb +0 -1
  158. data/spec/ramaze/action/layout.rb +28 -0
  159. data/spec/ramaze/controller/actionless_templates.rb +32 -0
  160. data/spec/ramaze/controller/template/other_wrapper.xhtml +1 -0
  161. data/spec/ramaze/controller/template_resolving.rb +37 -0
  162. data/spec/ramaze/{trinity → current}/request.rb +12 -2
  163. data/spec/ramaze/current/session.rb +97 -0
  164. data/spec/ramaze/dispatcher/directory.rb +2 -1
  165. data/spec/ramaze/dispatcher/file.rb +8 -3
  166. data/spec/ramaze/dispatcher/public/file name.txt +1 -0
  167. data/spec/ramaze/gestalt.rb +11 -0
  168. data/spec/ramaze/helper/aspect.rb +28 -22
  169. data/spec/ramaze/helper/cgi.rb +2 -2
  170. data/spec/ramaze/helper/flash.rb +33 -15
  171. data/spec/ramaze/helper/formatting.rb +2 -2
  172. data/spec/ramaze/helper/link.rb +46 -18
  173. data/spec/ramaze/helper/pager.rb +8 -5
  174. data/spec/ramaze/helper/partial.rb +8 -1
  175. data/spec/ramaze/helper/template/recursive_local_ivars.xhtml +7 -0
  176. data/spec/ramaze/helper/user.rb +46 -0
  177. data/spec/ramaze/{inform → log}/informer.rb +0 -0
  178. data/spec/ramaze/{inform → log}/syslog.rb +1 -1
  179. data/spec/ramaze/request.rb +14 -10
  180. data/spec/ramaze/route.rb +23 -0
  181. data/spec/ramaze/template.rb +48 -1
  182. data/spec/ramaze/template/haml.rb +6 -16
  183. data/spec/ramaze/template/haml/locals.haml +2 -1
  184. data/spec/ramaze/template/tagz.rb +62 -0
  185. data/spec/ramaze/template/tagz/external.tagz +8 -0
  186. data/spec/ramaze/template/tagz/sum.tagz +1 -0
  187. data/spec/ramaze/template/tenjin.rb +49 -0
  188. data/spec/ramaze/template/tenjin/external.tenjin +1 -0
  189. data/spec/snippets/string/unindent.rb +15 -0
  190. metadata +509 -475
  191. data/doc/README.html +0 -729
  192. data/doc/changes.txt +0 -5757
  193. data/doc/changes.xml +0 -5759
  194. data/examples/blog/src/view.rb +0 -16
  195. data/examples/blog/template/edit.xhtml +0 -19
  196. data/examples/blog/template/index.xhtml +0 -19
  197. data/examples/blog/template/new.xhtml +0 -18
  198. data/examples/wiktacular/mkd/newpagename/current.mkd +0 -1
  199. data/examples/wiktacular/mkd/newpagename/current.mkd.bak +0 -1
  200. data/lib/ramaze/contrib/email.rb-darcs-backup0 +0 -81
  201. data/lib/ramaze/template/bijou.rb +0 -39
  202. data/lib/ramaze/trinity/response.rb +0 -32
  203. data/spec/ramaze/template/bijou.rb +0 -25
  204. data/spec/ramaze/trinity/session.rb +0 -29
@@ -8,9 +8,10 @@ module Ramaze
8
8
  # A simple way to do authentication. Please have a look at the docs for the
9
9
  # check_auth method for detailed information
10
10
 
11
- module AuthHelper
11
+ module Helper::Auth
12
+ Helper::LOOKUP << self
12
13
 
13
- # add AspectHelper and StackHelper on inclusion of AuthHelper
14
+ # add Helper::Aspect and Helper::Stack on inclusion of Helper::Auth
14
15
 
15
16
  def self.included(klass)
16
17
  klass.send(:helper, :aspect, :stack)
@@ -37,7 +38,7 @@ module Ramaze
37
38
  end
38
39
  %{
39
40
  #{open_element}
40
- <form method="POST" action="#{Rs(:login)}>"
41
+ <form method="POST" action="#{Rs(:login)}">
41
42
  <ul style="list-style:none;">
42
43
  <li>Username: <input type="text" name="username" /></li>
43
44
  <li>Password: <input type="password" name="password" /></li>
@@ -6,11 +6,12 @@ module Ramaze
6
6
  # This helper is providing easy access to a couple of Caches to use for
7
7
  # smaller amounts of data.
8
8
 
9
- module CacheHelper
9
+ module Helper::Cache
10
+ C = Ramaze::Cache
10
11
 
11
12
  # Create the Cache.value_cache on inclusion if it doesn't exist yet.
12
13
  def self.included(klass)
13
- Cache.add(:value_cache) unless Cache::CACHES.has_key?(:value_cache)
14
+ C.add(:value_cache) unless C::CACHES.has_key?(:value_cache)
14
15
  end
15
16
 
16
17
  # Example:
@@ -59,7 +60,7 @@ module Ramaze
59
60
  # for example heavy calculations or time-consuming queries.
60
61
 
61
62
  def value_cache
62
- Cache.value_cache
63
+ C.value_cache
63
64
  end
64
65
 
65
66
  # action_cache holds rendered output of actions for which caching is enabled.
@@ -123,7 +124,7 @@ module Ramaze
123
124
  # action_cache.delete '/path/to/action'
124
125
 
125
126
  def action_cache
126
- Cache.actions
127
+ C.actions
127
128
  end
128
129
 
129
130
  # This refers to the class-trait of cached actions, you can
@@ -5,37 +5,39 @@ module Ramaze
5
5
 
6
6
  # Shortcuts to some CGI methods
7
7
 
8
- module CgiHelper
9
- private
10
-
8
+ module Helper::CGI
11
9
  # shortcut for CGI.escape
12
10
 
13
11
  def url_encode(*args)
14
- CGI.escape(*args)
12
+ ::CGI.escape(*args.map{|arg| arg.to_s})
15
13
  end
16
14
 
17
15
  # shortcut for CGI.unescape
18
16
 
19
17
  def url_decode(*args)
20
- CGI.unescape(*args)
18
+ ::CGI.unescape(*args.map{|arg| arg.to_s})
21
19
  end
22
20
 
23
21
  # shortcut for CGI.escapeHTML
24
22
 
25
23
  def html_escape(string)
26
- CGI.escapeHTML(string)
24
+ ::CGI.escapeHTML(string.to_s)
27
25
  end
28
26
 
29
27
  # shortcut for CGI.unescapeHTML
30
28
 
31
29
  def html_unescape(string)
32
- CGI.unescapeHTML(string)
30
+ ::CGI.unescapeHTML(string.to_s)
31
+ end
32
+
33
+ # safely escape all HTML and code
34
+ def c(string)
35
+ ::CGI.escapeHTML(string.to_s).gsub(/#/, '&#35;')
33
36
  end
34
37
 
35
38
  # one-letter versions help in case like #{h foo.inspect}
36
39
  # ERb/ERuby/Rails compatible
37
- alias h html_escape
38
40
  alias u url_encode
39
-
41
+ alias h c
40
42
  end
41
43
  end
@@ -22,13 +22,38 @@ module Ramaze
22
22
  #
23
23
  # On the request after this, flash[:error] is gone.
24
24
 
25
- module FlashHelper
26
- private
27
-
25
+ module Helper::Flash
26
+ trait :tag => "<div class='flash' id='flash_%key'>%value</div>"
28
27
  # answers with Session.current.flash
29
28
 
30
29
  def flash
31
30
  Session.current.flash
32
31
  end
32
+
33
+ # Use in your template to display all flash messages that may be stored.
34
+ # For example, given you stored:
35
+ #
36
+ # flash # => { :error => 'Pleae enter your name'
37
+ # :info => 'Do you see the fnords?' }
38
+ #
39
+ # Then a flashbox would display:
40
+ #
41
+ # <div class='flash' id='flash_error'>Please enter your name</div>
42
+ # <div class='flash' id='flash_info'>Do you see the fnords?</div>
43
+ #
44
+ # This is designed to be customized permanently or per usage:
45
+ #
46
+ # flashbox("<div class='flash_%key'>%value</div>")
47
+ #
48
+ # Where any occurrence of %key and %value will be replaced by the actual
49
+ # contents of each element of flash
50
+
51
+ def flashbox(tag = Helper::Flash.trait[:tag])
52
+ flash.map{|key, value|
53
+ [key.to_s, value.to_s]
54
+ }.sort.map{|(key, value)|
55
+ tag.gsub(/%key/, key.to_s).gsub(/%value/, value.to_s)
56
+ }.join("\n")
57
+ end
33
58
  end
34
59
  end
@@ -2,9 +2,7 @@
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
4
  module Ramaze
5
- module FormattingHelper
6
- private
7
-
5
+ module Helper::Formatting
8
6
  def number_format(n, delimiter = ',')
9
7
  delim_l, delim_r = delimiter == ',' ? %w[, .] : %w[. ,]
10
8
  h, r = n.to_s.split('.')
@@ -1,14 +1,13 @@
1
1
  # Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
- require 'tmpdir'
5
4
  require 'openid'
6
5
  require 'openid/store/filesystem'
7
6
  require 'openid/extensions/pape'
8
7
 
9
8
  module Ramaze
10
9
 
11
- openid_store_file = File.join(Dir.tmpdir, 'openid-store')
10
+ openid_store_file = ::File.join(Dir.tmpdir, 'openid-store')
12
11
 
13
12
  # Constant for storing meta-information persistent
14
13
  OpenIDStore = OpenID::Store::Filesystem.new(openid_store_file)
@@ -17,7 +16,7 @@ module Ramaze
17
16
  # It provides a nice and simple way to provide and control access over the
18
17
  # OpenID authentication model.
19
18
 
20
- module IdentityHelper
19
+ module Helper::Identity
21
20
 
22
21
  # Simple form for use or overwriting.
23
22
  # Has to provide the same functionality when overwritten or directly
@@ -3,11 +3,10 @@
3
3
 
4
4
  module Ramaze
5
5
 
6
- # Easy access to Inform
6
+ # Easy access to Log
7
7
 
8
- module InformHelper
9
-
10
- private
8
+ module Helper::Log
9
+ L = Ramaze::Log
11
10
 
12
11
  # The various (default) tags you can use are:
13
12
  #
@@ -32,8 +31,10 @@ module Ramaze
32
31
  # # [2007-04-04 23:40:59] ERROR hello.rb:23:in `index'
33
32
  # # ... rest of backtrace ...
34
33
 
35
- def inform tag, *args
36
- Inform.send(tag, *args)
34
+ def log tag, *args
35
+ L.warn "Helper::Log is being deprecated, use Log directly instead"
36
+ L.send(tag, *args)
37
37
  end
38
+ alias inform log
38
39
  end
39
40
  end
@@ -2,43 +2,40 @@
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
4
  module Ramaze
5
- # LinkHelper is included into the Controller by default
5
+ # Helper::Link is included into the Controller by default
6
6
  #
7
7
  # Usage is shown in spec/ramaze/helper/link.rb and the rdocs below.
8
8
 
9
- module LinkHelper
10
-
11
- private
9
+ module Helper::Link
10
+ private
12
11
 
13
12
  # Builds a basic <a> tag.
14
13
  #
15
- # `title` is mandatory, the second hash of options will be transformed into
14
+ # `text` is mandatory, the second hash of options will be transformed into
16
15
  # arguments of the tag, :href is a special case and its segments will be
17
16
  # CGI.escaped.
18
17
  #
19
- # If you pass no :href, the title will be run through Rs and its result is
18
+ # If you pass no :href, the text will be run through Rs and its result is
20
19
  # used instead. If you really want an empty href, use :href => ''
21
20
  #
22
21
  # Usage:
23
- # A('title') #> <a href="/title">title</a>
22
+ # A('text') #> <a href="/text">text</a>
24
23
  # A('foo/bar') #> <a href="/foo/bar">foo/bar</a>
25
24
  # A('/foo?x=y') #> <a href="/foo?x=y">/foo?x=y</a>
26
- # A('title', :href => '/foo?x=y') #> <a href="/foo?x=y">title</a>
25
+ # A('text', :href => '/foo?x=y') #> <a href="/foo?x=y">text</a>
27
26
  # A('Home', :href => Rs(:/)) #> <a href="/foo/bar">Home</a>
28
27
 
29
28
  def A(*args)
30
29
  hash = args.last.respond_to?(:to_hash) ? args.pop : {}
31
30
 
32
31
  hash[:href] ||= Rs(*args)
33
- title = hash.delete(:title) ||
34
- (args.last.respond_to?(:to_s) ? args.last : nil) ||
35
- hash[:href]
36
- hash[:href].to_s.sub!(/\A[^\/?]+/) {|m| CGI.escape(m) }
32
+ text = hash.delete(:text) || args.last || hash[:title] || hash[:href]
33
+ hash[:href] = hash[:href].to_s.gsub(/[^\/?;=]+/) {|m| CGI.escape(m) }
37
34
 
38
35
  args = ['']
39
36
  hash.each {|k,v| args << %(#{k}="#{v}") if k and v }
40
37
 
41
- %(<a#{args.join(' ')}>#{title}</a>)
38
+ %(<a#{args.join(' ')}>#{text}</a>)
42
39
  end
43
40
 
44
41
  # Builds links out of segments.
@@ -63,18 +60,19 @@ module Ramaze
63
60
  args = args.flatten.inject{|s,v| s.merge!(v) }
64
61
 
65
62
  map = Global.mapping.invert
63
+
66
64
  atoms.map! do |atom|
67
65
  if atom.is_a?(Ramaze::Controller)
68
- map[atom.class] || atom
66
+ map[atom.class]
69
67
  else
70
- map[atom] || atom
71
- end
68
+ map[atom]
69
+ end or atom.to_s
72
70
  end
73
71
 
74
72
  front = atoms.join('/').squeeze('/')
75
73
 
76
74
  if args
77
- rear = args.inject('?'){|s,(k,v)| s << "#{k}=#{v};"}[0..-2]
75
+ rear = args.inject('?'){|s,(k,v)| s << "#{CGI.escape k.to_s}=#{CGI.escape v.to_s};"}[0..-2]
78
76
  front + rear
79
77
  else
80
78
  front
@@ -5,9 +5,7 @@ module Ramaze
5
5
 
6
6
  # Allows you to use some shortcuts for markaby in your Controller.
7
7
 
8
- module MarkabyHelper
9
- private
10
-
8
+ module Helper::Markaby
11
9
  # use this inside your controller to directly build Markaby
12
10
  # Refer to the Markaby-documentation and testsuite for more examples.
13
11
  # Usage:
@@ -16,7 +14,7 @@ module Ramaze
16
14
 
17
15
  def markaby(ivs = {}, helpers = nil, &block)
18
16
  builder = ::Markaby::Builder
19
- builder.extend(Ramaze::Helper)
17
+ builder.extend(Ramaze::Helper::Methods)
20
18
  builder.send(:helper, :link)
21
19
 
22
20
  iv_hash = {}
@@ -1,5 +1,5 @@
1
1
  module Ramaze
2
- module MarukuHelper
2
+ module Helper::Maruku
3
3
  def maruku(text)
4
4
  Maruku.new(text).to_html
5
5
  end
@@ -4,11 +4,11 @@
4
4
  require 'nitro/helper/form'
5
5
 
6
6
  module Ramaze
7
+ module Helper
7
8
 
8
- # This helper simply includes the Nitro::FormHelper so you can use its methods
9
- # in your Controller.
9
+ # This helper simply includes the Nitro::FormHelper so you can use its methods
10
+ # in your Controller.
10
11
 
11
- module NitroformHelper
12
- include ::Nitro::FormHelper
12
+ Nitroform = ::Nitro::FormHelper
13
13
  end
14
14
  end
@@ -82,7 +82,7 @@ module Ramaze
82
82
  # .pager li.active {}
83
83
 
84
84
  class Pager
85
- include Ramaze::LinkHelper
85
+ include Ramaze::Helper::Link
86
86
 
87
87
  # Items per page.
88
88
 
@@ -116,7 +116,7 @@ class Pager
116
116
  # key:: key used for getting the current page from GET paramaters
117
117
  #
118
118
  # Note: You never have to create this class yourself, use the `paginate()`
119
- # convenience method from the PagerHelper.
119
+ # convenience method from the Helper::Pager.
120
120
 
121
121
  def initialize(request, limit, total_count, key = trait[:key])
122
122
  raise 'limit should be > 0' unless limit > 0
@@ -255,7 +255,7 @@ private
255
255
 
256
256
  def target_uri(page)
257
257
  params = @request.params.merge(@key => page)
258
- Rs(Action.current.method, params)
258
+ Rs(Action.current.name, params)
259
259
  end
260
260
 
261
261
  # Generate link for the first page.
@@ -309,9 +309,7 @@ end
309
309
 
310
310
  # Pager related helper methods.
311
311
 
312
- module PagerHelper
313
-
314
- private
312
+ module Helper::Pager
315
313
 
316
314
  # Helper method that generates a collection of items and the
317
315
  # associated pager object.
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Ramaze
5
5
 
6
- # = PartialHelper
6
+ # = Helper::Partial
7
7
  #
8
8
  # === Example Usage
9
9
  #
@@ -24,9 +24,7 @@ module Ramaze
24
24
  # </body>
25
25
  # </html>
26
26
 
27
- module PartialHelper
28
-
29
- private
27
+ module Helper::Partial
30
28
  module_function
31
29
 
32
30
  # Renders a url 'inline'.
@@ -37,46 +35,51 @@ module Ramaze
37
35
  def render_partial(url, options = {})
38
36
  saved = {}
39
37
  options.keys.each {|x| saved[x] = Request.current.params[x] }
40
- saved_action = Action.current
41
38
 
42
39
  Request.current.params.update(options)
43
40
 
44
41
  Controller.handle(url)
45
42
  ensure
46
- Thread.current[:action] = saved_action
47
43
  options.keys.each {|x| Request.current.params[x] = saved[x] }
48
44
  end
49
45
 
50
46
  # Render the template file in template_root of the
51
47
  # current controller.
52
48
 
53
- def render_template(file, locals = {})
49
+ def render_template(file, vars = {})
54
50
  current = Action.current
55
51
  options = { :controller => current.controller,
56
52
  :instance => current.instance.dup }
57
53
 
58
- filename = options[:controller].template_root/file
54
+ roots = [options[:controller].template_paths].flatten
59
55
 
60
- if File.exist?(filename)
61
- options[:template] = filename
62
- elsif files = Dir["#{filename}.*"] and files.any?
63
- options[:template] = files.first
56
+ if (files = Dir["{#{roots.join(',')}}"/"{#{file},#{file}.*}"]).any?
57
+ options[:template] = files.first.squeeze '/'
64
58
  else
65
- Inform.warn "render_template: #{filename} does not exist"
59
+ Log.warn "render_template: #{file} does not exist in the following directories: #{roots.join(',')}."
66
60
  return ''
67
61
  end
68
62
 
69
- # use method_missing to provide access to locals, if any exist
70
- options[:instance].meta_def(:method_missing) { |sym, *args|
71
- return locals[sym] if locals.key?(sym)
72
- super
73
- } if locals.any?
63
+ binding = options[:instance].scope
64
+
65
+ vars.each do |name, value|
66
+ options[:instance].instance_variable_set("@#{name}", value)
74
67
 
75
- options[:binding] = options[:instance].instance_eval{ binding }
68
+ value = "ObjectSpace._id2ref(#{ value.object_id })"
69
+ eval "#{ name } = #{ value }", binding
70
+ end
71
+
72
+ options[:binding] = binding
76
73
 
77
74
  Ramaze::Action(options).render
78
- ensure
79
- Thread.current[:action] = current
80
75
  end
76
+
77
+ # shortcut to render_partial, accepts a method and contructs a link to the
78
+ # current controller, then calls render_partial on that
79
+
80
+ def render_action method, *params
81
+ render_partial(Rs(method), *params)
82
+ end
83
+
81
84
  end
82
85
  end