ramaze 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (304) hide show
  1. data/Rakefile +20 -3
  2. data/bin/ramaze +1 -4
  3. data/doc/AUTHORS +2 -1
  4. data/doc/CHANGELOG +539 -32
  5. data/doc/LEGAL +4 -0
  6. data/doc/meta/announcement.txt +79 -47
  7. data/examples/blog/README +2 -2
  8. data/examples/blog/spec/blog.rb +33 -48
  9. data/examples/blog/src/controller.rb +15 -13
  10. data/examples/blog/src/model.rb +28 -10
  11. data/examples/blog/start.rb +0 -10
  12. data/examples/blog/template/edit.xhtml +1 -1
  13. data/examples/blog/template/index.xhtml +2 -2
  14. data/examples/facebook.rb +152 -0
  15. data/examples/linking.rb +28 -0
  16. data/examples/ramaise.rb +4 -11
  17. data/examples/rammit/spec/rammit.rb +30 -0
  18. data/examples/rammit/src/controller/main.rb +3 -0
  19. data/examples/rammit/src/controller/page.rb +16 -0
  20. data/examples/rammit/src/model.rb +33 -0
  21. data/examples/rammit/start.rb +7 -0
  22. data/examples/rammit/template/index.xhtml +14 -0
  23. data/examples/rammit/template/page/view.xhtml +4 -0
  24. data/examples/rapaste/Rakefile +28 -0
  25. data/examples/rapaste/public/css/active4d.css +114 -0
  26. data/examples/rapaste/public/css/all_hallows_eve.css +72 -0
  27. data/examples/rapaste/public/css/amy.css +147 -0
  28. data/examples/rapaste/public/css/blackboard.css +88 -0
  29. data/examples/rapaste/public/css/brilliance_black.css +605 -0
  30. data/examples/rapaste/public/css/brilliance_dull.css +599 -0
  31. data/examples/rapaste/public/css/cobalt.css +149 -0
  32. data/examples/rapaste/public/css/dawn.css +121 -0
  33. data/examples/rapaste/public/css/display.css +179 -0
  34. data/examples/rapaste/public/css/eiffel.css +121 -0
  35. data/examples/rapaste/public/css/espresso_libre.css +109 -0
  36. data/examples/rapaste/public/css/idle.css +62 -0
  37. data/examples/rapaste/public/css/iplastic.css +80 -0
  38. data/examples/rapaste/public/css/lazy.css +73 -0
  39. data/examples/rapaste/public/css/mac_classic.css +123 -0
  40. data/examples/rapaste/public/css/magicwb_amiga.css +104 -0
  41. data/examples/rapaste/public/css/pastels_on_dark.css +188 -0
  42. data/examples/rapaste/public/css/slush_poppies.css +85 -0
  43. data/examples/rapaste/public/css/spacecadet.css +51 -0
  44. data/examples/rapaste/public/css/sunburst.css +180 -0
  45. data/examples/rapaste/public/css/twilight.css +137 -0
  46. data/examples/rapaste/public/css/zenburnesque.css +91 -0
  47. data/examples/rapaste/public/js/jquery.js +11 -0
  48. data/examples/rapaste/rapaste.sqlite +0 -0
  49. data/examples/rapaste/spec/rapaste.rb +49 -0
  50. data/examples/rapaste/src/controller.rb +69 -0
  51. data/examples/rapaste/src/model.rb +61 -0
  52. data/examples/rapaste/start.rb +20 -0
  53. data/examples/rapaste/template/copy.xhtml +10 -0
  54. data/examples/rapaste/template/index.xhtml +9 -0
  55. data/examples/rapaste/template/layout.xhtml +22 -0
  56. data/examples/rapaste/template/list.xhtml +28 -0
  57. data/examples/rapaste/template/view.xhtml +37 -0
  58. data/examples/sourceview/sourceview.rb +3 -3
  59. data/examples/templates/template_amrita2.rb +1 -3
  60. data/examples/todolist/spec/todolist.rb +15 -18
  61. data/examples/whywiki/spec/whywiki.rb +15 -20
  62. data/examples/whywiki/start.rb +0 -1
  63. data/examples/wikore/spec/wikore.rb +14 -19
  64. data/examples/wiktacular/spec/wiktacular.rb +8 -15
  65. data/lib/proto/{src/controller → controller}/main.rb +4 -4
  66. data/lib/proto/public/css/ramaze_error.css +39 -3
  67. data/lib/proto/public/js/jquery.js +2039 -1020
  68. data/lib/proto/spec/main.rb +27 -0
  69. data/lib/proto/start.rb +5 -5
  70. data/lib/proto/view/error.xhtml +62 -0
  71. data/lib/proto/view/index.xhtml +34 -0
  72. data/lib/proto/view/page.xhtml +15 -0
  73. data/lib/ramaze.rb +9 -7
  74. data/lib/ramaze/action.rb +7 -3
  75. data/lib/ramaze/action/render.rb +15 -5
  76. data/lib/ramaze/adapter.rb +5 -5
  77. data/lib/ramaze/adapter/base.rb +2 -2
  78. data/lib/ramaze/adapter/cgi.rb +1 -1
  79. data/lib/ramaze/adapter/evented_mongrel.rb +1 -1
  80. data/lib/ramaze/adapter/fcgi.rb +2 -2
  81. data/lib/ramaze/adapter/mongrel.rb +1 -1
  82. data/lib/ramaze/adapter/swiftiplied_mongrel.rb +1 -1
  83. data/lib/ramaze/adapter/thin.rb +25 -0
  84. data/lib/ramaze/adapter/webrick.rb +1 -1
  85. data/lib/ramaze/cache.rb +3 -2
  86. data/lib/ramaze/cache/memcached.rb +1 -1
  87. data/lib/ramaze/cache/memory.rb +1 -1
  88. data/lib/ramaze/cache/yaml_store.rb +1 -1
  89. data/lib/ramaze/contrib.rb +1 -1
  90. data/lib/ramaze/contrib/auto_params.rb +12 -5
  91. data/lib/ramaze/contrib/auto_params/get_args.rb +1 -0
  92. data/lib/ramaze/contrib/facebook.rb +23 -0
  93. data/lib/ramaze/contrib/facebook/facebook.rb +168 -0
  94. data/lib/ramaze/contrib/gettext.rb +111 -0
  95. data/lib/ramaze/contrib/gettext/mo.rb +155 -0
  96. data/lib/ramaze/contrib/gettext/po.rb +109 -0
  97. data/lib/ramaze/contrib/gzip_filter.rb +1 -1
  98. data/lib/ramaze/contrib/route.rb +15 -5
  99. data/lib/ramaze/contrib/sequel/fill.rb +1 -1
  100. data/lib/ramaze/controller.rb +10 -4
  101. data/lib/ramaze/controller/error.rb +5 -13
  102. data/lib/ramaze/controller/main.rb +2 -0
  103. data/lib/ramaze/controller/resolve.rb +18 -10
  104. data/lib/ramaze/dispatcher.rb +1 -1
  105. data/lib/ramaze/dispatcher/action.rb +1 -1
  106. data/lib/ramaze/dispatcher/directory.rb +3 -2
  107. data/lib/ramaze/dispatcher/error.rb +5 -5
  108. data/lib/ramaze/dispatcher/file.rb +13 -2
  109. data/lib/ramaze/error.rb +1 -1
  110. data/lib/ramaze/gestalt.rb +2 -2
  111. data/lib/ramaze/global.rb +5 -5
  112. data/lib/ramaze/global/dsl.rb +1 -1
  113. data/lib/ramaze/global/globalstruct.rb +11 -5
  114. data/lib/ramaze/helper.rb +1 -1
  115. data/lib/ramaze/helper/aspect.rb +1 -1
  116. data/lib/ramaze/helper/auth.rb +2 -2
  117. data/lib/ramaze/helper/cache.rb +1 -1
  118. data/lib/ramaze/helper/cgi.rb +1 -1
  119. data/lib/ramaze/helper/file.rb +1 -1
  120. data/lib/ramaze/helper/flash.rb +1 -1
  121. data/lib/ramaze/helper/formatting.rb +1 -1
  122. data/lib/ramaze/helper/identity.rb +1 -1
  123. data/lib/ramaze/helper/inform.rb +1 -1
  124. data/lib/ramaze/helper/link.rb +4 -4
  125. data/lib/ramaze/helper/markaby.rb +1 -1
  126. data/lib/ramaze/helper/nitroform.rb +1 -1
  127. data/lib/ramaze/helper/pager.rb +2 -1
  128. data/lib/ramaze/helper/partial.rb +1 -1
  129. data/lib/ramaze/helper/redirect.rb +6 -1
  130. data/lib/ramaze/helper/sequel.rb +54 -0
  131. data/lib/ramaze/helper/stack.rb +1 -1
  132. data/lib/ramaze/inform.rb +1 -1
  133. data/lib/ramaze/inform/analogger.rb +1 -1
  134. data/lib/ramaze/inform/growl.rb +1 -1
  135. data/lib/ramaze/inform/hub.rb +1 -1
  136. data/lib/ramaze/inform/informer.rb +1 -1
  137. data/lib/ramaze/inform/informing.rb +2 -2
  138. data/lib/ramaze/inform/knotify.rb +1 -1
  139. data/lib/ramaze/inform/syslog.rb +1 -1
  140. data/lib/ramaze/inform/xosd.rb +1 -1
  141. data/lib/ramaze/snippets.rb +1 -1
  142. data/lib/ramaze/snippets/array/put_within.rb +1 -1
  143. data/lib/ramaze/snippets/blankslate.rb +7 -0
  144. data/lib/ramaze/snippets/dictionary.rb +6 -1
  145. data/lib/ramaze/snippets/divide.rb +1 -1
  146. data/lib/ramaze/snippets/kernel/__dir__.rb +1 -1
  147. data/lib/ramaze/snippets/kernel/acquire.rb +39 -0
  148. data/lib/ramaze/snippets/kernel/aquire.rb +1 -34
  149. data/lib/ramaze/snippets/kernel/constant.rb +1 -1
  150. data/lib/ramaze/snippets/kernel/pretty_inspect.rb +1 -1
  151. data/lib/ramaze/snippets/numeric/filesize_format.rb +1 -1
  152. data/lib/ramaze/snippets/object/traits.rb +1 -1
  153. data/lib/ramaze/snippets/ordered_set.rb +12 -7
  154. data/lib/ramaze/snippets/ramaze/caller_info.rb +1 -1
  155. data/lib/ramaze/snippets/ramaze/caller_lines.rb +1 -1
  156. data/lib/ramaze/snippets/string/camel_case.rb +1 -1
  157. data/lib/ramaze/snippets/string/color.rb +2 -4
  158. data/lib/ramaze/snippets/string/each.rb +1 -1
  159. data/lib/ramaze/snippets/string/ord.rb +15 -0
  160. data/lib/ramaze/snippets/string/snake_case.rb +1 -1
  161. data/lib/ramaze/snippets/struct/fill.rb +4 -2
  162. data/lib/ramaze/snippets/struct/values_at.rb +2 -2
  163. data/lib/ramaze/snippets/symbol/to_proc.rb +15 -8
  164. data/lib/ramaze/snippets/thread/into.rb +1 -1
  165. data/lib/ramaze/sourcereload.rb +4 -3
  166. data/lib/ramaze/spec/helper.rb +85 -32
  167. data/lib/ramaze/spec/helper/bacon.rb +7 -0
  168. data/lib/ramaze/spec/helper/browser.rb +1 -2
  169. data/lib/ramaze/spec/helper/mock_http.rb +1 -1
  170. data/lib/ramaze/spec/helper/pretty_output.rb +70 -0
  171. data/lib/ramaze/spec/helper/requester.rb +1 -1
  172. data/lib/ramaze/spec/helper/simple_http.rb +5 -4
  173. data/lib/ramaze/spec/helper/snippets.rb +6 -0
  174. data/lib/ramaze/store/default.rb +1 -1
  175. data/lib/ramaze/template.rb +1 -1
  176. data/lib/ramaze/template/amrita2.rb +6 -5
  177. data/lib/ramaze/template/erubis.rb +1 -1
  178. data/lib/ramaze/template/ezamar.rb +1 -1
  179. data/lib/ramaze/template/ezamar/element.rb +1 -1
  180. data/lib/ramaze/template/ezamar/engine.rb +1 -1
  181. data/lib/ramaze/template/ezamar/morpher.rb +1 -1
  182. data/lib/ramaze/template/ezamar/render_partial.rb +1 -1
  183. data/lib/ramaze/template/haml.rb +1 -1
  184. data/lib/ramaze/template/liquid.rb +1 -1
  185. data/lib/ramaze/template/markaby.rb +1 -1
  186. data/lib/ramaze/template/nagoro.rb +4 -6
  187. data/lib/ramaze/template/none.rb +1 -1
  188. data/lib/ramaze/template/remarkably.rb +1 -1
  189. data/lib/ramaze/template/sass.rb +1 -1
  190. data/lib/ramaze/tool.rb +1 -1
  191. data/lib/ramaze/tool/create.rb +7 -1
  192. data/lib/ramaze/tool/localize.rb +7 -14
  193. data/lib/ramaze/tool/mime.rb +1 -1
  194. data/lib/ramaze/tool/record.rb +1 -1
  195. data/lib/ramaze/trinity.rb +1 -1
  196. data/lib/ramaze/trinity/request.rb +4 -2
  197. data/lib/ramaze/trinity/response.rb +1 -1
  198. data/lib/ramaze/trinity/session.rb +7 -1
  199. data/lib/ramaze/version.rb +3 -3
  200. data/lib/vendor/bacon.rb +317 -0
  201. data/rake_tasks/conf.rake +1 -1
  202. data/rake_tasks/maintenance.rake +7 -5
  203. data/rake_tasks/spec.rake +54 -40
  204. data/spec/contrib/auto_params.rb +21 -4
  205. data/spec/contrib/route.rb +31 -4
  206. data/spec/contrib/sequel/fill.rb +3 -4
  207. data/spec/examples/caching.rb +5 -2
  208. data/spec/examples/css.rb +5 -2
  209. data/spec/examples/element.rb +5 -4
  210. data/spec/examples/hello.rb +1 -0
  211. data/spec/examples/linking.rb +18 -0
  212. data/spec/examples/simple.rb +13 -18
  213. data/spec/examples/templates/template_amrita2.rb +3 -2
  214. data/spec/examples/templates/template_erubis.rb +3 -2
  215. data/spec/examples/templates/template_ezamar.rb +2 -1
  216. data/spec/examples/templates/template_haml.rb +3 -2
  217. data/spec/examples/templates/template_liquid.rb +3 -2
  218. data/spec/examples/templates/template_markaby.rb +3 -2
  219. data/spec/examples/templates/template_remarkably.rb +3 -2
  220. data/spec/ramaze/action/basics.rb +4 -4
  221. data/spec/ramaze/action/cache.rb +11 -13
  222. data/spec/ramaze/action/layout.rb +47 -3
  223. data/spec/ramaze/action/render.rb +3 -3
  224. data/spec/ramaze/action/template/instancevars/layout.xhtml +1 -0
  225. data/spec/ramaze/adapter.rb +7 -7
  226. data/spec/ramaze/adapter/mongrel.rb +1 -1
  227. data/spec/ramaze/adapter/record.rb +7 -7
  228. data/spec/ramaze/adapter/webrick.rb +1 -1
  229. data/spec/ramaze/cache.rb +6 -8
  230. data/spec/ramaze/controller.rb +77 -65
  231. data/spec/ramaze/controller/resolve.rb +2 -1
  232. data/spec/ramaze/controller/template_resolving.rb +3 -4
  233. data/spec/ramaze/dispatcher.rb +3 -4
  234. data/spec/ramaze/dispatcher/directory.rb +35 -35
  235. data/spec/ramaze/dispatcher/file.rb +8 -5
  236. data/spec/ramaze/element.rb +4 -4
  237. data/spec/ramaze/error.rb +13 -11
  238. data/spec/ramaze/gestalt.rb +1 -1
  239. data/spec/ramaze/helper/aspect.rb +2 -1
  240. data/spec/ramaze/helper/auth.rb +4 -2
  241. data/spec/ramaze/helper/cache.rb +10 -9
  242. data/spec/ramaze/helper/cgi.rb +2 -2
  243. data/spec/ramaze/helper/file.rb +1 -0
  244. data/spec/ramaze/helper/flash.rb +5 -4
  245. data/spec/ramaze/helper/formatting.rb +1 -1
  246. data/spec/ramaze/helper/link.rb +3 -3
  247. data/spec/ramaze/helper/pager.rb +44 -80
  248. data/spec/ramaze/helper/partial.rb +2 -3
  249. data/spec/ramaze/helper/redirect.rb +10 -1
  250. data/spec/ramaze/helper/stack.rb +4 -3
  251. data/spec/ramaze/helper/template/loop.xhtml +2 -1
  252. data/spec/ramaze/inform/informer.rb +2 -2
  253. data/spec/ramaze/inform/syslog.rb +1 -1
  254. data/spec/ramaze/localize.rb +26 -26
  255. data/spec/ramaze/morpher.rb +6 -7
  256. data/spec/ramaze/params.rb +7 -8
  257. data/spec/ramaze/request.rb +27 -6
  258. data/spec/ramaze/request/mongrel.rb +1 -1
  259. data/spec/ramaze/request/thin.rb +9 -0
  260. data/spec/ramaze/session.rb +2 -1
  261. data/spec/ramaze/store/default.rb +14 -17
  262. data/spec/ramaze/template.rb +5 -7
  263. data/spec/ramaze/template/amrita2.rb +4 -1
  264. data/spec/ramaze/template/erubis.rb +2 -1
  265. data/spec/ramaze/template/ezamar.rb +2 -3
  266. data/spec/ramaze/template/ezamar/other__index.xhtml +1 -0
  267. data/spec/ramaze/template/haml.rb +2 -1
  268. data/spec/ramaze/template/liquid.rb +4 -2
  269. data/spec/ramaze/template/markaby.rb +4 -2
  270. data/spec/ramaze/template/nagoro.rb +3 -4
  271. data/spec/ramaze/template/remarkably.rb +4 -2
  272. data/spec/ramaze/template/sass.rb +3 -2
  273. data/spec/ramaze/template/xslt.rb +4 -7
  274. data/spec/ramaze/trinity/request.rb +4 -3
  275. data/spec/ramaze/trinity/session.rb +6 -4
  276. data/spec/snippets/array/put_within.rb +3 -2
  277. data/spec/snippets/divide.rb +1 -4
  278. data/spec/snippets/kernel/__dir__.rb +1 -1
  279. data/spec/snippets/kernel/acquire.rb +71 -0
  280. data/spec/snippets/kernel/constant.rb +4 -8
  281. data/spec/snippets/numeric/filesize_format.rb +1 -1
  282. data/spec/snippets/ordered_set.rb +9 -2
  283. data/spec/snippets/ramaze/caller_info.rb +3 -3
  284. data/spec/snippets/ramaze/caller_lines.rb +3 -3
  285. data/spec/snippets/string/camel_case.rb +1 -1
  286. data/spec/snippets/string/color.rb +2 -2
  287. data/spec/snippets/string/snake_case.rb +5 -1
  288. data/spec/snippets/string/unindent.rb +1 -1
  289. data/spec/snippets/struct/fill.rb +14 -15
  290. data/spec/snippets/struct/values_at.rb +15 -10
  291. data/spec/snippets/symbol/to_proc.rb +13 -0
  292. data/spec/snippets/thread/into.rb +3 -4
  293. metadata +458 -386
  294. data/doc/README.html +0 -729
  295. data/doc/changes.txt +0 -5044
  296. data/doc/changes.xml +0 -5046
  297. data/lib/proto/public/error.zmr +0 -61
  298. data/lib/proto/src/element/page.rb +0 -17
  299. data/lib/proto/src/model.rb +0 -6
  300. data/lib/proto/template/index.xhtml +0 -15
  301. data/lib/ramaze/spec/helper/layout.rb +0 -58
  302. data/lib/ramaze/spec/helper/minimal.rb +0 -23
  303. data/lib/ramaze/spec/helper/wrap.rb +0 -198
  304. data/spec/snippets/kernel/aquire.rb +0 -71
@@ -0,0 +1,109 @@
1
+ #! /usr/bin/env ruby
2
+ =begin
3
+ rgettext.rb - Generate a .pot file.
4
+
5
+ Copyright (C) 2003-2006 Masao Mutoh
6
+ Copyright (C) 2001,2002 Yasushi Shoji, Masao Mutoh
7
+
8
+ Yasushi Shoji <yashi at atmark-techno.com>
9
+ Masao Mutoh <mutoh at highway.ne.jp>
10
+
11
+ You may redistribute it and/or modify it under the same
12
+ license terms as Ruby.
13
+ =end
14
+
15
+
16
+ module GetText
17
+
18
+ module RGetText #:nodoc:
19
+ extend GetText
20
+
21
+ MAX_LINE_LEN = 70 unless defined?(MAX_LINE_LEN)
22
+
23
+ module_function
24
+
25
+ def generate_pot_header # :nodoc:
26
+ time = Time.now.strftime("%Y-%m-%d %H:%M")
27
+ off = Time.now.utc_offset
28
+ sign = off <= 0 ? '-' : '+'
29
+ time += sprintf('%s%02d%02d', sign, *(off.abs / 60).divmod(60))
30
+
31
+ <<EOS
32
+ # SOME DESCRIPTIVE TITLE.
33
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
34
+ # This file is distributed under the same license as the PACKAGE package.
35
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
36
+ #
37
+ #, fuzzy
38
+ msgid ""
39
+ msgstr ""
40
+ "Project-Id-Version: PACKAGE VERSION\\n"
41
+ "POT-Creation-Date: #{time}\\n"
42
+ "PO-Revision-Date: #{time}\\n"
43
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
44
+ "Language-Team: LANGUAGE <LL@li.org>\\n"
45
+ "MIME-Version: 1.0\\n"
46
+ "Content-Type: text/plain; charset=UTF-8\\n"
47
+ "Content-Transfer-Encoding: 8bit\\n"
48
+ EOS
49
+ end
50
+
51
+ def generate_pot(ary) # :nodoc:
52
+ str = ""
53
+ result = Array.new
54
+ ary.each do |key|
55
+ msgid = key.shift.dup
56
+ curr_pos = MAX_LINE_LEN
57
+ key.each do |e|
58
+ if curr_pos + e.size > MAX_LINE_LEN
59
+ str << "\n#:"
60
+ curr_pos = 3
61
+ else
62
+ curr_pos += (e.size + 1)
63
+ end
64
+ str << " " << e
65
+ end
66
+ msgid.gsub!(/"/, '\"')
67
+ msgid.gsub!(/\r/, '')
68
+
69
+ str << "\nmsgid \"" << msgid << "\"\n"
70
+ str << "msgstr \"\"\n"
71
+ end
72
+ str
73
+ end
74
+
75
+ def generate_translated_po(hash)
76
+ str = generate_pot_header
77
+ result = Array.new
78
+
79
+ hash.keys.sort.each do |msgid|
80
+ msgid = msgid.dup
81
+ msgstr = hash[msgid]
82
+
83
+ msgid.gsub!(/"/, '\"')
84
+ msgid.gsub!(/\r/, '')
85
+
86
+ if msgstr
87
+ msgstr.gsub!(/"/, '\"')
88
+ msgstr.gsub!(/\r/, '')
89
+ end
90
+
91
+ str << "\nmsgid \"" << msgid << "\"\n"
92
+ str << "msgstr \"" << msgstr << "\"\n"
93
+ end
94
+
95
+ str
96
+ end
97
+
98
+ def generate(array) # :nodoc:
99
+ str = ''
100
+ str << generate_pot_header
101
+ str << generate_pot(array)
102
+ end
103
+ end
104
+ end
105
+
106
+ if $0 == __FILE__
107
+ require 'yaml'
108
+ puts GetText::RGetText.generate_translated_po(YAML.load_file(ARGV[0]))
109
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
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
4
  # gzip_filter.rb
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
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
4
  # Usage:
@@ -31,10 +31,20 @@ module Ramaze
31
31
  class << self
32
32
  def routed(path)
33
33
  routes = Contrib::Route.trait[:routes]
34
- routes.each do |regex, pattern|
35
- if md = path.match(regex)
36
- new_path = pattern % md.to_a[1..-1]
37
- return resolve(new_path, :routed)
34
+ routes.each do |key, val|
35
+ case
36
+ when key.is_a?(Regexp)
37
+ regex, pattern = key, val
38
+ if md = path.match(regex)
39
+ new_path = pattern % md.to_a[1..-1]
40
+ return resolve(new_path, :routed)
41
+ end
42
+ when val.respond_to?(:call)
43
+ if new_path = val.call(path, request)
44
+ return resolve(new_path, :routed)
45
+ end
46
+ else
47
+ Inform.error "Invalid route #{val}"
38
48
  end
39
49
  end
40
50
 
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
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
4
  module Sequel
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
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
4
  require 'ramaze/helper'
@@ -57,9 +57,15 @@ module Ramaze
57
57
 
58
58
  def startup options = {}
59
59
  Inform.dev("found Controllers: #{Global.controllers.inspect}")
60
- tr, pr = Global.template_root, Global.public_root
61
- Inform.warn("Template root: #{tr} doesn't exist") unless File.directory?(tr)
62
- Inform.warn("Public root: #{pr} doesn't exist") unless File.directory?(pr)
60
+
61
+ { 'Template' => Global.template_root,
62
+ 'Public' => Global.public_root }.each do |type, path|
63
+ unless File.directory?(path)
64
+ Inform.warn("#{type} root: #{path} doesn't exist")
65
+ else
66
+ Inform.info("#{type} root: #{File.expand_path path}")
67
+ end
68
+ end
63
69
 
64
70
  if Global.mapping.empty?
65
71
  Inform.warn("No Controllers mapped, will serve /public only.")
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
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
4
  module Ramaze
@@ -20,25 +20,17 @@ module Ramaze
20
20
  return [title, "", error.backtrace].flatten.join("\n")
21
21
  end
22
22
 
23
- @backtrace = error.backtrace[0..20]
24
-
25
- @colors = []
26
- min = 200
27
- max = 255
28
- step = -((max - min) / @backtrace.size).abs
29
- max.step(min, step) do |color|
30
- @colors << color
31
- end
32
-
33
23
  backtrace_size = Ramaze::Global.backtrace_size
34
-
35
- @backtrace.map! do |line|
24
+ @backtrace = error.backtrace[0..20].map do |line|
36
25
  file, lineno, meth = *Ramaze.parse_backtrace(line)
37
26
  lines = Ramaze.caller_lines(file, lineno, backtrace_size)
38
27
 
39
28
  [ lines, lines.object_id.abs, file, lineno, meth ]
40
29
  end
41
30
 
31
+ # for backwards-compat with old error.zmr
32
+ @colors = [255] * @backtrace.size
33
+
42
34
  @title = CGI.escapeHTML(title)
43
35
  @editor = (ENV['EDITOR'] || 'vim')
44
36
  title
@@ -0,0 +1,2 @@
1
+ class MainController < Ramaze::Controller
2
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
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
4
  module Ramaze
@@ -81,7 +81,7 @@ module Ramaze
81
81
  # appropiate template if one exists.
82
82
 
83
83
  def resolve_action(path, *parameter)
84
- path, parameter = path.to_s, parameter.map(&:to_s)
84
+ path, parameter = path.to_s, parameter.map{|e| e.to_s}
85
85
  if alternate_template = trait["#{path}_template"]
86
86
  t_controller, t_path = *alternate_template
87
87
  template = t_controller.resolve_template(t_path)
@@ -116,17 +116,17 @@ module Ramaze
116
116
 
117
117
  # Composes an array with the template-paths to look up in the right order.
118
118
  # Usually this is composed of Global.template_root and the mapping of the
119
- # controller and a second element for Global.public_root, which makes
120
- # it possible to convert CSS on the fly and things like that.
119
+ # controller.
121
120
 
122
121
  def template_paths
123
122
  @template_root ||= Global.template_root / Global.mapping.invert[self]
124
- [ @template_root, Global.public_root ].compact
123
+ [ @template_root ]
125
124
  end
126
125
 
127
126
  # Based on methodname and arity, tries to find the right method on current controller.
128
127
  def resolve_method(name, *params)
129
- if method = [ name, name.gsub('__','/') ].find{|n| action_methods.delete(n) }
128
+ if method = [ name, name.gsub('__','/') ].find{|n|
129
+ cached_action_methods.include?(n) }
130
130
  arity = instance_method(method).arity
131
131
  if params.size == arity or arity < 0
132
132
  return method, params
@@ -135,14 +135,20 @@ module Ramaze
135
135
  return nil, []
136
136
  end
137
137
 
138
+ def cached_action_methods
139
+ Cache.action_methods[self] ||= action_methods
140
+ end
141
+
138
142
  # methodnames that may be used for current controller.
139
143
  def action_methods
140
144
  exclude = Controller.trait[:exclude_action_modules]
141
145
 
142
- ancs = (ancestors - exclude).select{|a| a.is_a?(Module)}
143
- meths = ancs.map{|a| a.instance_methods(false).map(&:to_s)}.flatten.uniq
146
+ ancs = (ancestors - exclude).select{|a| a.is_a?(Module) }
147
+ meths = ancs.map{|a|
148
+ a.instance_methods(false).map{|iv| iv.to_s }
149
+ }.flatten.uniq
144
150
  # fix for facets/more/paramix
145
- meths - ancs.map(&:to_s)
151
+ meths - ancs.map{|a| a.to_s}
146
152
  end
147
153
 
148
154
  # Generate all possible permutations for given path.
@@ -166,7 +172,9 @@ module Ramaze
166
172
 
167
173
  until pattern.empty?
168
174
  args << pattern.shift
169
- patterns << [controller, args.join( '__' ), pattern.dup]
175
+ joined = args.join('__')
176
+ patterns << [controller, joined, pattern.dup]
177
+ patterns << [controller, "#{joined}__index", pattern.dup]
170
178
  end
171
179
  end
172
180
 
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
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
4
  require 'timeout'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
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
4
  module Ramaze
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
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
4
  module Ramaze
@@ -36,7 +36,8 @@ module Ramaze
36
36
  end
37
37
 
38
38
  def list_for(path)
39
- display = path.gsub(/^#{Regexp.escape(Global.public_root)}\/?/, '/')
39
+ root = ::File.expand_path(Global.public_root)
40
+ display = path.gsub(/^#{Regexp.escape(root)}\/?/, '/')
40
41
  wrapper =
41
42
  %(<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
42
43
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
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
4
  module Ramaze
@@ -51,12 +51,12 @@ module Ramaze
51
51
  end
52
52
  end
53
53
 
54
- unless error.message =~ %r(`#{path.split('/').last}')
54
+ if path and Global.error_page and error.message !~ /`#{path}'/
55
55
  response.status = status
56
- return Dispatcher.dispatch_to(path) if path and Global.error_page
56
+ return Dispatcher.dispatch_to(path)
57
+ else
58
+ response.build(error.message, status)
57
59
  end
58
-
59
- response.build(error.message, status)
60
60
  rescue Object => ex
61
61
  Inform.error(ex)
62
62
  response.build(ex.message, status)
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
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
4
  module Ramaze
@@ -8,6 +8,10 @@ module Ramaze
8
8
  # file if found.
9
9
 
10
10
  class File
11
+ # These names are checked for serving from public directory.
12
+ # They take priority over Actions which comes later in the FILTER
13
+ INDICES = %w[index.htm index.xhtml index.html index]
14
+
11
15
  class << self
12
16
  include Trinity
13
17
 
@@ -24,6 +28,7 @@ module Ramaze
24
28
 
25
29
  def open_file(path)
26
30
  file = resolve_path(path)
31
+
27
32
  if ::File.file?(file) or ::File.file?(file=file/'index')
28
33
  response['Content-Type'] = Tool::MIME.type_for(file) unless ::File.extname(file).empty?
29
34
  log(file)
@@ -32,7 +37,13 @@ module Ramaze
32
37
  end
33
38
 
34
39
  def resolve_path(path)
35
- ::File.join(Global.public_root, path)
40
+ joined = ::File.join(Global.public_root, path)
41
+
42
+ if ::File.directory?(joined)
43
+ Dir[joined/"{#{INDICES.join(',')}}"].first || joined
44
+ else
45
+ joined
46
+ end
36
47
  end
37
48
 
38
49
  def log(file)
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
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
4
  module Ramaze
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
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
4
  =begin rdoc
@@ -98,7 +98,7 @@ module Ramaze
98
98
  @out << attr.inject(''){ |s,v| s << %{ #{v[0]}="#{_gestalt_escape_entities(v[1])}"} }
99
99
  if text != [] or block_given?
100
100
  @out << ">"
101
- @out << _gestalt_escape_entities(text.to_s)
101
+ @out << _gestalt_escape_entities([text].join)
102
102
  if block_given?
103
103
  text = yield
104
104
  @out << text.to_str if text != @out and text.respond_to?(:to_str)
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
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
4
  require 'ostruct'
@@ -9,10 +9,10 @@ require 'ramaze/global/dsl'
9
9
  module Ramaze
10
10
  GlobalDSL.option_dsl do
11
11
  o "Set the adapter Ramaze will run on.",
12
- :adapter => :webrick, :cli => [:webrick, :mongrel]
12
+ :adapter => :webrick, :cli => [:webrick, :mongrel, :thin]
13
13
 
14
14
  o "All running threads of Adapter will be collected here.",
15
- :adapters => ThreadGroup.new
15
+ :adapters => Set.new
16
16
 
17
17
  o "Set the size of Backtrace shown.",
18
18
  :backtrace_size => 10, :cli => 10
@@ -77,7 +77,7 @@ module Ramaze
77
77
  :port => 7000, :cli => 7000, :short => :p
78
78
 
79
79
  o "Specify directory to serve static files",
80
- :public_root => APPDIR/'./public', :cli => './template'
80
+ :public_root => 'public', :cli => 'public'
81
81
 
82
82
  o "Record all Request objects by assigning a filtering Proc to me.",
83
83
  :record => false
@@ -104,7 +104,7 @@ module Ramaze
104
104
  :test_connections => true, :cli => true
105
105
 
106
106
  o "Specify directory to serve dynamic files",
107
- :template_root => APPDIR/'./template', :cli => './template'
107
+ :template_root => 'view', :cli => 'view'
108
108
 
109
109
  o "Enable directory listing",
110
110
  :list_directories => false, :cli => false
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
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
4
  module Ramaze