ramaze 2011.01.30 → 2011.07.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. data/.gitignore +2 -1
  2. data/.mailmap +2 -0
  3. data/.rvmrc +1 -0
  4. data/README.md +119 -197
  5. data/Rakefile +14 -97
  6. data/bin/ramaze +6 -14
  7. data/doc/AUTHORS +8 -4
  8. data/doc/CHANGELOG +3784 -3339
  9. data/examples/app/chat/start.rb +2 -2
  10. data/lib/proto/app.rb +2 -3
  11. data/lib/proto/config.ru +4 -5
  12. data/lib/proto/controller/init.rb +11 -4
  13. data/lib/proto/controller/main.rb +12 -7
  14. data/lib/proto/layout/default.xhtml +56 -23
  15. data/lib/proto/model/init.rb +3 -1
  16. data/lib/proto/public/css/grid.css +107 -0
  17. data/lib/proto/public/css/layout.css +81 -0
  18. data/lib/proto/public/css/reset.css +123 -0
  19. data/lib/proto/public/css/text.css +109 -0
  20. data/lib/proto/public/images/bg.png +0 -0
  21. data/lib/proto/spec/main.rb +2 -2
  22. data/lib/proto/start.rb +11 -1
  23. data/lib/proto/view/index.xhtml +27 -23
  24. data/lib/ramaze.rb +0 -1
  25. data/lib/ramaze/app.rb +85 -12
  26. data/lib/ramaze/app_graph.rb +107 -0
  27. data/lib/ramaze/bin/console.rb +87 -0
  28. data/lib/ramaze/bin/create.rb +94 -0
  29. data/lib/ramaze/bin/helper.rb +107 -0
  30. data/lib/ramaze/bin/restart.rb +95 -0
  31. data/lib/ramaze/bin/runner.rb +141 -0
  32. data/lib/ramaze/bin/start.rb +206 -0
  33. data/lib/ramaze/bin/status.rb +152 -0
  34. data/lib/ramaze/bin/stop.rb +112 -0
  35. data/lib/ramaze/cache.rb +9 -4
  36. data/lib/ramaze/cache/localmemcache.rb +10 -13
  37. data/lib/ramaze/cache/lru.rb +49 -7
  38. data/lib/ramaze/cache/memcache.rb +170 -92
  39. data/lib/ramaze/cache/sequel.rb +301 -118
  40. data/lib/ramaze/controller.rb +108 -9
  41. data/lib/ramaze/controller/default.rb +15 -2
  42. data/lib/ramaze/current.rb +14 -2
  43. data/lib/ramaze/dependencies.rb +46 -0
  44. data/lib/ramaze/files.rb +38 -3
  45. data/lib/ramaze/gestalt.rb +12 -12
  46. data/lib/ramaze/helper.rb +0 -2
  47. data/lib/ramaze/helper/auth.rb +30 -23
  48. data/lib/ramaze/helper/blue_form.rb +175 -126
  49. data/lib/ramaze/helper/csrf.rb +76 -91
  50. data/lib/ramaze/helper/email.rb +105 -0
  51. data/lib/ramaze/helper/erector.rb +16 -15
  52. data/lib/ramaze/helper/gestalt.rb +2 -2
  53. data/lib/ramaze/helper/layout.rb +89 -73
  54. data/lib/ramaze/helper/link.rb +7 -6
  55. data/lib/ramaze/helper/localize.rb +6 -5
  56. data/lib/ramaze/helper/markaby.rb +25 -23
  57. data/lib/ramaze/helper/maruku.rb +3 -3
  58. data/lib/ramaze/helper/paginate.rb +19 -27
  59. data/lib/ramaze/helper/remarkably.rb +3 -3
  60. data/lib/ramaze/helper/request_accessor.rb +3 -3
  61. data/lib/ramaze/helper/send_file.rb +12 -8
  62. data/lib/ramaze/helper/simple_captcha.rb +5 -6
  63. data/lib/ramaze/helper/stack.rb +7 -4
  64. data/lib/ramaze/helper/tagz.rb +10 -11
  65. data/lib/ramaze/helper/thread.rb +19 -16
  66. data/lib/ramaze/helper/ultraviolet.rb +7 -4
  67. data/lib/ramaze/helper/user.rb +40 -21
  68. data/lib/ramaze/helper/xhtml.rb +29 -20
  69. data/lib/ramaze/log.rb +3 -11
  70. data/lib/ramaze/log/analogger.rb +5 -4
  71. data/lib/ramaze/log/growl.rb +9 -7
  72. data/lib/ramaze/log/hub.rb +3 -5
  73. data/lib/ramaze/log/informer.rb +15 -12
  74. data/lib/ramaze/log/knotify.rb +3 -5
  75. data/lib/ramaze/log/logger.rb +3 -5
  76. data/lib/ramaze/log/logging.rb +6 -8
  77. data/lib/ramaze/log/rotatinginformer.rb +27 -17
  78. data/lib/ramaze/log/syslog.rb +7 -7
  79. data/lib/ramaze/log/xosd.rb +3 -5
  80. data/lib/ramaze/middleware_compiler.rb +27 -4
  81. data/lib/ramaze/reloader.rb +50 -12
  82. data/lib/ramaze/reloader/watch_inotify.rb +4 -5
  83. data/lib/ramaze/reloader/watch_stat.rb +3 -3
  84. data/lib/ramaze/request.rb +18 -8
  85. data/lib/ramaze/response.rb +38 -7
  86. data/lib/ramaze/rest.rb +36 -0
  87. data/lib/ramaze/setup.rb +101 -31
  88. data/lib/ramaze/spec.rb +1 -1
  89. data/lib/ramaze/spec/bacon.rb +6 -3
  90. data/lib/ramaze/spec/helper/bacon.rb +0 -1
  91. data/lib/ramaze/version.rb +1 -1
  92. data/lib/ramaze/view.rb +2 -11
  93. data/lib/ramaze/view/erector.rb +46 -31
  94. data/lib/ramaze/view/erubis.rb +7 -3
  95. data/lib/ramaze/view/ezamar.rb +7 -3
  96. data/lib/ramaze/view/gestalt.rb +9 -3
  97. data/lib/ramaze/view/haml.rb +7 -3
  98. data/lib/ramaze/view/liquid.rb +3 -3
  99. data/lib/ramaze/view/lokar.rb +7 -3
  100. data/lib/ramaze/view/mustache.rb +11 -5
  101. data/lib/ramaze/view/nagoro.rb +3 -3
  102. data/lib/ramaze/view/sass.rb +1 -1
  103. data/lib/ramaze/view/slippers.rb +40 -13
  104. data/lib/ramaze/view/tagz.rb +9 -5
  105. data/ramaze.gemspec +23 -128
  106. data/spec/helper.rb +5 -0
  107. data/spec/ramaze/bin/app/config.ru +11 -0
  108. data/spec/ramaze/bin/create.rb +28 -0
  109. data/spec/ramaze/bin/runner.rb +30 -0
  110. data/spec/ramaze/bin/start.rb +38 -0
  111. data/spec/ramaze/cache/memcache.rb +10 -3
  112. data/spec/ramaze/cache/sequel.rb +7 -0
  113. data/spec/ramaze/controller/provide_inheritance.rb +0 -10
  114. data/spec/ramaze/dispatcher/file.rb +19 -15
  115. data/spec/ramaze/helper/auth.rb +10 -9
  116. data/spec/ramaze/helper/blue_form.rb +121 -68
  117. data/spec/ramaze/helper/email.rb +69 -0
  118. data/spec/ramaze/helper/layout.rb +12 -15
  119. data/spec/ramaze/helper/layout/alternative.xhtml +5 -0
  120. data/spec/ramaze/helper/user.rb +2 -0
  121. data/spec/ramaze/log/growl.rb +14 -1
  122. data/spec/{contrib → ramaze}/rest.rb +1 -1
  123. data/spec/ramaze/session/memcache.rb +2 -2
  124. data/spec/ramaze/view/sass.rb +1 -1
  125. data/tasks/bacon.rake +3 -3
  126. data/tasks/gem.rake +17 -18
  127. data/tasks/rcov.rake +2 -3
  128. data/tasks/release.rake +8 -65
  129. data/tasks/setup.rake +10 -8
  130. data/tasks/todo.rake +9 -5
  131. data/tasks/yard.rake +3 -2
  132. metadata +105 -397
  133. data/MANIFEST +0 -532
  134. data/TODO.md +0 -19
  135. data/benchmark/bench_templates/bench.rb +0 -67
  136. data/benchmark/bench_templates/view/large.erb +0 -79
  137. data/benchmark/bench_templates/view/large.haml +0 -41
  138. data/benchmark/bench_templates/view/large.lok +0 -79
  139. data/benchmark/bench_templates/view/large.xhtml +0 -79
  140. data/benchmark/bench_templates/view/small.erb +0 -21
  141. data/benchmark/bench_templates/view/small.haml +0 -12
  142. data/benchmark/bench_templates/view/small.lok +0 -21
  143. data/benchmark/bench_templates/view/small.xhtml +0 -21
  144. data/benchmark/results.txt +0 -131
  145. data/benchmark/run.rb +0 -355
  146. data/benchmark/suite/minimal.rb +0 -11
  147. data/benchmark/suite/no_informer.rb +0 -7
  148. data/benchmark/suite/no_sessions.rb +0 -9
  149. data/benchmark/suite/no_template.rb +0 -7
  150. data/benchmark/suite/simple.rb +0 -5
  151. data/benchmark/suite/template_erubis.rb +0 -8
  152. data/benchmark/suite/template_etanni.rb +0 -8
  153. data/benchmark/suite/template_ezamar.rb +0 -8
  154. data/benchmark/suite/template_haml.rb +0 -13
  155. data/benchmark/suite/template_liquid.rb +0 -11
  156. data/benchmark/suite/template_markaby.rb +0 -9
  157. data/benchmark/suite/template_nagoro.rb +0 -8
  158. data/benchmark/suite/template_redcloth.rb +0 -13
  159. data/benchmark/suite/template_tenjin.rb +0 -8
  160. data/benchmark/test.rb +0 -35
  161. data/doc/FAQ +0 -92
  162. data/doc/INSTALL +0 -92
  163. data/doc/TODO +0 -29
  164. data/doc/meta/announcement.txt +0 -119
  165. data/doc/meta/configuration.txt +0 -163
  166. data/doc/meta/internals.txt +0 -278
  167. data/doc/meta/users.kml +0 -64
  168. data/doc/tutorial/todolist.html +0 -1512
  169. data/doc/tutorial/todolist.txt +0 -920
  170. data/examples/app/sourceview/public/coderay.css +0 -104
  171. data/examples/app/sourceview/public/images/file.gif +0 -0
  172. data/examples/app/sourceview/public/images/folder.gif +0 -0
  173. data/examples/app/sourceview/public/images/tv-collapsable-last.gif +0 -0
  174. data/examples/app/sourceview/public/images/tv-collapsable.gif +0 -0
  175. data/examples/app/sourceview/public/images/tv-expandable-last.gif +0 -0
  176. data/examples/app/sourceview/public/images/tv-expandable.gif +0 -0
  177. data/examples/app/sourceview/public/images/tv-item-last.gif +0 -0
  178. data/examples/app/sourceview/public/images/tv-item.gif +0 -0
  179. data/examples/app/sourceview/public/jquery.js +0 -11
  180. data/examples/app/sourceview/public/jquery.treeview.css +0 -48
  181. data/examples/app/sourceview/public/jquery.treeview.js +0 -223
  182. data/examples/app/sourceview/public/sourceview.js +0 -52
  183. data/examples/app/sourceview/start.rb +0 -79
  184. data/examples/app/sourceview/view/index.haml +0 -59
  185. data/examples/helpers/httpdigest.rb +0 -107
  186. data/lib/proto/public/css/screen.css +0 -30
  187. data/lib/proto/public/js/jquery.js +0 -7179
  188. data/lib/ramaze/contrib/addressable_route.rb +0 -56
  189. data/lib/ramaze/contrib/app_graph.rb +0 -64
  190. data/lib/ramaze/contrib/email.rb +0 -88
  191. data/lib/ramaze/contrib/facebook.rb +0 -23
  192. data/lib/ramaze/contrib/facebook/facebook.rb +0 -171
  193. data/lib/ramaze/contrib/gettext.rb +0 -113
  194. data/lib/ramaze/contrib/gettext/mo.rb +0 -155
  195. data/lib/ramaze/contrib/gettext/parser.rb +0 -46
  196. data/lib/ramaze/contrib/gettext/po.rb +0 -109
  197. data/lib/ramaze/contrib/gzip_filter.rb +0 -1
  198. data/lib/ramaze/contrib/maruku_uv.rb +0 -59
  199. data/lib/ramaze/contrib/profiling.rb +0 -36
  200. data/lib/ramaze/contrib/rest.rb +0 -23
  201. data/lib/ramaze/contrib/sequel/create_join.rb +0 -26
  202. data/lib/ramaze/contrib/sequel/form_field.rb +0 -129
  203. data/lib/ramaze/contrib/sequel/image.rb +0 -196
  204. data/lib/ramaze/contrib/sequel/relation.rb +0 -98
  205. data/lib/ramaze/helper/httpdigest.rb +0 -96
  206. data/lib/ramaze/tool/bin.rb +0 -340
  207. data/lib/ramaze/tool/create.rb +0 -48
  208. data/lib/ramaze/tool/project_creator.rb +0 -120
  209. data/lib/ramaze/view/less.rb +0 -12
  210. data/lib/ramaze/view/maruku.rb +0 -15
  211. data/lib/ramaze/view/redcloth.rb +0 -21
  212. data/spec/contrib/addressable_route.rb +0 -30
  213. data/spec/examples/helpers/httpdigest.rb +0 -64
  214. data/spec/examples/templates/template_redcloth.rb +0 -13
  215. data/spec/ramaze/bin/ramaze.rb +0 -96
  216. data/spec/ramaze/helper/httpdigest.rb +0 -176
  217. data/spec/ramaze/view/less.rb +0 -60
  218. data/spec/ramaze/view/less/file.css.less +0 -8
  219. data/spec/ramaze/view/redcloth.rb +0 -66
  220. data/spec/ramaze/view/redcloth/external.redcloth +0 -8
  221. data/tasks/copyright.rake +0 -21
  222. data/tasks/gem_setup.rake +0 -112
  223. data/tasks/git.rake +0 -46
  224. data/tasks/grancher.rake +0 -12
  225. data/tasks/jquery.rake +0 -15
  226. data/tasks/manifest.rake +0 -4
  227. data/tasks/metric_changes.rake +0 -24
  228. data/tasks/reversion.rake +0 -8
  229. data/tasks/traits.rake +0 -21
@@ -1,97 +1,113 @@
1
1
  module Ramaze
2
2
  module Helper
3
-
3
+ ##
4
4
  # Provides wrapper methods for a higher-level approach than the core layout
5
- # method. These are useful for simpler layout needs, particularly:
5
+ # method. The layout() method that comes with Innate/Ramaze is fairly basic
6
+ # as it only allows you to specify a single layout to always use or a block
7
+ # giving you some extra flexibility. The latter however is still a bit of a
8
+ # pain when dealing with many custom layouts in a single controller. Meet
9
+ # the Layout helper. This helper provides a single method (since April 2011,
10
+ # it used to provide more) called "set_layout". This method allows you to
11
+ # specify a number of layouts and the methods for which these layouts should
12
+ # be used.
13
+ #
14
+ # == Examples
15
+ #
16
+ # The most basic example is simply setting a layout as you would do with the
17
+ # layout() method:
18
+ #
19
+ # set_layout 'default'
6
20
  #
7
- # * layout all actions
8
- # * layout a whitelist of actions
9
- # * layout all but a blacklist of actions
21
+ # This of course is very boring, time to add some more spices to our code:
10
22
  #
11
- # As with the core layout method, the layout rules apply only to the
12
- # controller on which they are applied. Furthermore, multiple layout
13
- # definitions are not combined; only the last definition will be used.
23
+ # set_layout 'default' => [:index]
14
24
  #
15
- # This helper is one of the default helpers, so no explicit helper call
16
- # is necessary before using it in your controllers.
25
+ # Woah! What just happened? It's quite easy actually, we merely defined that
26
+ # the layout called "default" should be used for the index method *only*.
27
+ # Pretty sweet huh? It gets even better:
17
28
  #
18
- # Usage:
29
+ # set_layout 'default' => [:index, :edit], 'alternative' => [:add, :process]
19
30
  #
20
- # class MainController < Controller
21
- # # Apply the default layout (e.g. ./layout/default.xhtml) to all
22
- # # three actions.
23
- # set_layout 'default'
24
- # def action1; end
25
- # def action2; end
26
- # def action3; end
27
- # end
31
+ # A few things changed. First of all there are now two key/value groups.
32
+ # Each group defines a layout (the key) and a set of methods (the value) for
33
+ # which each layout should be used. In this case the layout "default" will
34
+ # be used for index() and edit() but the layout "alternative" will be used
35
+ # for add() and process().
28
36
  #
29
- # class MainController < Controller
30
- # # These two layout definitions accomplish the same thing. The
31
- # # first uses a whitelist, the second uses a blacklist.
32
- # set_layout 'default' => [:laid_out1, :laid_out2]
33
- # set_layout_except 'default' => [:not_laid_out1, :not_laid_out2]
37
+ # Last but not least, multiple calls to set_layout will no longer override
38
+ # any existing settings *unless* you actually specify the same method with a
39
+ # different layout. This is possible because the set_layout method stores
40
+ # all these details in an instance variable called "_ramaze_layouts".
34
41
  #
35
- # def laid_out1; end
36
- # def laid_out2; end
42
+ # @author Yorick Peterse
43
+ # @author Michael Fellinger
44
+ # @author Pistos
37
45
  #
38
- # def not_laid_out1; end
39
- # def not_laid_out2; end
40
- # end
41
46
  module Layout
47
+
48
+ ##
49
+ # Extends the class that included this module so that the methods that
50
+ # this helper provides can be called outside of instance of class methods.
51
+ #
52
+ # @param [Object] into The class that included this module.
53
+ # @author Michael Fellinger
54
+ # @author Pistos
55
+ #
42
56
  def self.included(into)
43
57
  into.extend SingletonMethods
44
58
  end
45
59
 
46
60
  module SingletonMethods
47
- # @param [String Hash] Either a layout name, or a single-element Hash
48
- # which maps a layout name to an Array containing a whitelist of
49
- # action names
50
- # @see set_layout_except Innate::Node::layout
51
- # @author Pistos, manveru
52
- # @example Use a layout named 'default' on all actions of the controller:
53
- # set_layout 'default'
54
- # @example Use a layout named 'default' on just the index and admin actions:
55
- # set_layout 'default' => [ :index, :admin ]
56
- def set_layout(hash_or_the_layout)
57
- if hash_or_the_layout.respond_to?(:to_hash)
58
- f = hash_or_the_layout.to_hash.find{|k,v| k && v }
59
- the_layout = f[0]
60
- whitelist = f[1].map{|action| action.to_s }
61
- else
62
- the_layout = hash_or_the_layout
63
- end
61
+ ##
62
+ # The set_layout method allows you to specify a number of methods and
63
+ # their layout. This allows you to use layout A for methods 1, 2 and 3
64
+ # but layout B for method 4.
65
+ #
66
+ # @example
67
+ # # The key is the layout, the value an array of methods
68
+ # set_layout 'default' => [:method_1], 'alternative' => [:method_2]
69
+ #
70
+ # # We can combine this method with layout()
71
+ # layout 'default'
72
+ # set_layout 'alternative' => [:method_1]
73
+ #
74
+ # # This is also perfectly fine
75
+ # set_layout 'default'
76
+ #
77
+ # @param [String, Symbol, #to_hash] hash_or_layout
78
+ # In case it's a String or Symbol it will directly be used as the
79
+ # layout.
80
+ # When setting a Hash this hash should have it's keys set to the
81
+ # layouts and it's values to an array of methods that use the
82
+ # specific layout. For more information see the examples.
83
+ #
84
+ # @author Yorick Peterse
85
+ # @author Michael Fellinger
86
+ # @author Pistos
87
+ # @since 2011-04-07
88
+ def set_layout(hash_or_layout)
89
+ @_ramaze_layouts ||= {}
64
90
 
65
- layout do |path, wish|
66
- if whitelist.nil? || whitelist.include?(path.to_s)
67
- the_layout
91
+ # Extract the layout to use
92
+ if hash_or_layout.respond_to?(:to_hash)
93
+ # Invert the method/layout hash and save them so they don't get lost
94
+ hash_or_layout.to_hash.each do |layout, layout_methods|
95
+ layout_methods.each do |layout_method|
96
+ @_ramaze_layouts[layout_method.to_s] = layout.to_s
97
+ end
68
98
  end
69
- end
70
- end
71
99
 
72
- # @param [String Hash] Either a layout name, or a single-element Hash
73
- # which maps a layout name to an Array containing a blacklist of
74
- # action names
75
- # @see set_layout Innate::Node::layout
76
- # @author Pistos, manveru
77
- # @example Use a layout named 'default' on all actions except the user_data action:
78
- # set_layout_except 'default' => [ :user_data ]
79
- def set_layout_except(hash_or_the_layout)
80
- if hash_or_the_layout.respond_to?(:to_hash)
81
- f = hash_or_the_layout.to_hash.find{|k,v| k && v }
82
- the_layout = f[0]
83
- blacklist = f[1].map{|action| action.to_s }
100
+ layout{|path| @_ramaze_layouts[path.to_s] }
84
101
  else
85
- the_layout = hash_or_the_layout
102
+ layout{|path| hash_or_layout }
86
103
  end
104
+ end
87
105
 
88
- layout do |path, wish|
89
- if blacklist.nil? || !blacklist.include?(path.to_s)
90
- the_layout
91
- end
92
- end
106
+ # @deprecated because it's not longer useful
107
+ def set_layout_except(hash_or_layout)
108
+ Ramaze.deprecated('set_layout_except', 'set_layout')
93
109
  end
94
- end
95
- end
96
- end
97
- end
110
+ end # SingletonMethods
111
+ end # Layout
112
+ end # Helper
113
+ end # Ramaze
@@ -16,9 +16,10 @@ module Ramaze
16
16
  [prefix, location].join('/')
17
17
  end
18
18
 
19
- # Give it a path with character to split at and one to join the crumbs with.
20
- # It will generate a list of links that act as pointers to previous pages on
21
- # this path.
19
+ ##
20
+ # Give it a path with character to split at and one to join the crumbs
21
+ # with. It will generate a list of links that act as pointers to previous
22
+ # pages on this path.
22
23
  #
23
24
  # @example usage
24
25
  # breadcrumbs('/path/to/somewhere')
@@ -51,6 +52,6 @@ module Ramaze
51
52
  end
52
53
  bread.join(join)
53
54
  end
54
- end
55
- end
56
- end
55
+ end # Link
56
+ end # Helper
57
+ end # Ramaze
@@ -4,8 +4,9 @@ require 'locale'
4
4
  module Ramaze
5
5
  module Helper
6
6
  ##
7
- # The localization helper can be used to output translated strings.
8
- # This enables your application to use multiple language files for English, Dutch and so on.
7
+ # The localization helper can be used to output translated strings. This
8
+ # enables your application to use multiple language files for English, Dutch
9
+ # and so on.
9
10
  #
10
11
  module Localize
11
12
  include Traited
@@ -137,6 +138,6 @@ module Ramaze
137
138
  ::Locale::Tag.parse(lang) }
138
139
  end
139
140
  end
140
- end
141
- end
142
- end
141
+ end # Localize
142
+ end # Helper
143
+ end # Ramaze
@@ -2,30 +2,32 @@
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
4
  module Ramaze
5
+ module Helper
6
+ # Allows you to use some shortcuts for markaby in your Controller.
7
+ module Markaby
8
+ ##
9
+ # use this inside your controller to directly build Markaby
10
+ # Refer to the Markaby-documentation and testsuite for more examples.
11
+ #
12
+ # @example
13
+ # mab { h1 "Apples & Oranges"} #=> "<h1>Apples &amp; Oranges</h1>"
14
+ # mab { h1 'Apples', :class => 'fruits&floots' }
15
+ #
16
+ def markaby(ivs = {}, helpers = nil, &block)
17
+ builder = ::Markaby::Builder
18
+ builder.extend(Ramaze::Helper::Methods)
19
+ builder.send(:helper, :link)
5
20
 
6
- # Allows you to use some shortcuts for markaby in your Controller.
21
+ iv_hash = {}
22
+ instance_variables.each do |iv|
23
+ key, value = iv.gsub('@', '').to_sym, instance_variable_get(iv)
24
+ iv_hash[key] = value
25
+ end
7
26
 
8
- module Helper::Markaby
9
- # use this inside your controller to directly build Markaby
10
- # Refer to the Markaby-documentation and testsuite for more examples.
11
- # Usage:
12
- # mab { h1 "Apples & Oranges"} #=> "<h1>Apples &amp; Oranges</h1>"
13
- # mab { h1 'Apples', :class => 'fruits&floots' } #=> "<h1 class=\"fruits&amp;floots\">Apples</h1>"
14
-
15
- def markaby(ivs = {}, helpers = nil, &block)
16
- builder = ::Markaby::Builder
17
- builder.extend(Ramaze::Helper::Methods)
18
- builder.send(:helper, :link)
19
-
20
- iv_hash = {}
21
- instance_variables.each do |iv|
22
- key, value = iv.gsub('@', '').to_sym, instance_variable_get(iv)
23
- iv_hash[key] = value
27
+ builder.new(iv_hash.merge(ivs), helpers, &block).to_s
24
28
  end
25
29
 
26
- builder.new(iv_hash.merge(ivs), helpers, &block).to_s
27
- end
28
-
29
- alias mab markaby
30
- end
31
- end
30
+ alias mab markaby
31
+ end # Markaby
32
+ end # Helper
33
+ end # Ramaze
@@ -11,6 +11,6 @@ module Ramaze
11
11
  def maruku(text)
12
12
  ::Maruku.new(text.to_str).to_html
13
13
  end
14
- end
15
- end
16
- end
14
+ end # Maruku
15
+ end # Helper
16
+ end # Ramaze
@@ -2,23 +2,21 @@ require 'ramaze/gestalt'
2
2
 
3
3
  module Ramaze
4
4
  module Helper
5
-
6
5
  # Helper for pagination and pagination-navigation.
7
6
  #
8
7
  # See detailed API docs for Paginator below.
9
8
  # Also have a look at the examples/helpers/paginate.rb
10
-
11
9
  module Paginate
12
10
  include Traited
13
11
 
14
12
  # Define default options in your Controller, they are being retrieved by
15
13
  # ancestral_trait, so you can also put it into a common superclass
16
-
17
14
  trait :paginate => {
18
15
  :limit => 10,
19
16
  :var => 'pager',
20
17
  }
21
18
 
19
+ ##
22
20
  # Returns a new Paginator instance.
23
21
  #
24
22
  # Note that the pagination relies on being inside a Ramaze request to
@@ -53,18 +51,17 @@ module Ramaze
53
51
  # :page The page you are currently on, if not given it will be
54
52
  # retrieved from current request variables. Defaults to 1 if
55
53
  # neither exists.
56
-
54
+ #
57
55
  def paginate(dataset, options = {})
58
56
  options = ancestral_trait[:paginate].merge(options)
59
57
  limit = options[:limit]
60
58
  var = options[:var]
61
59
  page = options[:page] || (request[var] || 1).to_i
62
-
60
+
63
61
  Paginator.new(dataset, page, limit, var)
64
62
  end
65
63
 
66
64
  # Provides easy pagination and navigation
67
-
68
65
  class Paginator
69
66
  include Ramaze::Helper
70
67
  helper :link, :cgi
@@ -76,6 +73,7 @@ module Ramaze
76
73
  @pager = pager_for(data)
77
74
  end
78
75
 
76
+ ##
79
77
  # Returns String with navigation div.
80
78
  #
81
79
  # This cannot be customized very nicely, but you can style it easily
@@ -100,8 +98,7 @@ module Ramaze
100
98
  # <span class="next grey">&gt;</span>
101
99
  # <span class="last grey">&gt;&gt;</span>
102
100
  # </div>
103
-
104
-
101
+ #
105
102
  def navigation(limit = 8)
106
103
  g = Ramaze::Gestalt.new
107
104
  g.div :class => :pager do
@@ -140,24 +137,22 @@ module Ramaze
140
137
  end
141
138
 
142
139
  # Useful to omit pager if it's of no use.
143
-
144
140
  def needed?
145
141
  @pager.page_count > 1
146
142
  end
147
143
 
148
144
  # these methods are actually on the pager, but we def them here for
149
145
  # convenience (method_missing in helper is evil and even slower)
150
-
151
- def page_count; @pager.page_count end
152
- def each(&block) @pager.each(&block) end
153
- def first_page?; @pager.first_page?; end
154
- def prev_page; @pager.prev_page; end
146
+ def page_count ; @pager.page_count ; end
147
+ def each(&block); @pager.each(&block); end
148
+ def first_page? ; @pager.first_page? ; end
149
+ def prev_page ; @pager.prev_page ; end
155
150
  def current_page; @pager.current_page; end
156
- def last_page; @pager.last_page; end
157
- def last_page?; @pager.last_page?; end
158
- def next_page; @pager.next_page; end
159
- def empty?; @pager.empty?; end
160
- def count; @pager.count; end
151
+ def last_page ; @pager.last_page ; end
152
+ def last_page? ; @pager.last_page? ; end
153
+ def next_page ; @pager.next_page ; end
154
+ def empty? ; @pager.empty? ; end
155
+ def count ; @pager.count ; end
161
156
 
162
157
  private
163
158
 
@@ -185,7 +180,6 @@ module Ramaze
185
180
  end
186
181
 
187
182
  # Wrapper for Array to behave like the Sequel pagination
188
-
189
183
  class ArrayPager
190
184
  def initialize(array, page, limit)
191
185
  @array, @page, @limit = array, page, limit
@@ -257,10 +251,8 @@ module Ramaze
257
251
  def empty?
258
252
  size == 0
259
253
  end
260
-
261
- end
262
-
263
- end
264
- end
265
- end
266
- end
254
+ end # DataMapperPager
255
+ end # Paginator
256
+ end # Paginate
257
+ end # Helper
258
+ end # Ramaze
@@ -9,6 +9,6 @@ module Ramaze
9
9
  def a(*args, &block)
10
10
  method_missing(:a, *args, &block)
11
11
  end
12
- end
13
- end
14
- end
12
+ end # Remarkably
13
+ end # Helper
14
+ end # Ramaze
@@ -11,6 +11,6 @@ module Ramaze
11
11
  eval("def %s(*a) request.%s(*a); end" % [method, method])
12
12
  end
13
13
  end
14
- end
15
- end
16
- end
14
+ end # RequestAccessor
15
+ end # Helper
16
+ end # Ramaze
@@ -2,16 +2,20 @@ module Ramaze
2
2
  module Helper
3
3
  ##
4
4
  # The SendFile module can be used to stream a file to the user's computer.
5
- # While the performance of the module isn't optimal it's convenient and relatively easy to use.
5
+ # While the performance of the module isn't optimal it's convenient and
6
+ # relatively easy to use.
6
7
  #
7
8
  module SendFile
8
9
  ##
9
10
  # The send_file method streams the specified file to the user's browser.
10
11
  #
11
- # @param [String] filename The name or path to the file which will be streamed to the user.
12
- # @param [String] content_type The type of file we're dealing with. For example, if we want to stream
13
- # a JPG image we'd set this variable to 'image/jpg'.
14
- # @param [String] content_disposition Value for the Content-Disposition header.
12
+ # @param [String] filename The name or path to the file which will be
13
+ # streamed to the user.
14
+ # @param [String] content_type The type of file we're dealing with. For
15
+ # example, if we want to stream a JPG image we'd set this variable to
16
+ # 'image/jpg'.
17
+ # @param [String] content_disposition Value for the Content-Disposition
18
+ # header.
15
19
  #
16
20
  def send_file(filename, content_type = nil, content_disposition = nil)
17
21
  content_type ||= Rack::Mime.mime_type(::File.extname(filename))
@@ -25,6 +29,6 @@ module Ramaze
25
29
 
26
30
  throw(:respond, response)
27
31
  end
28
- end
29
- end
30
- end
32
+ end # SendFile
33
+ end # Helper
34
+ end # Ramaze