ramaze 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. data/Rakefile +14 -29
  2. data/bin/ramaze +2 -3
  3. data/doc/AUTHORS +5 -2
  4. data/doc/CHANGELOG +262 -9
  5. data/doc/FAQ +6 -6
  6. data/doc/meta/announcement.txt +5 -19
  7. data/doc/tutorial/todolist.html +47 -57
  8. data/doc/tutorial/todolist.mkd +47 -55
  9. data/examples/memleak_detector.rb +31 -0
  10. data/examples/todolist/src/controller/main.rb +14 -13
  11. data/examples/todolist/src/element/page.rb +2 -2
  12. data/examples/todolist/src/model.rb +2 -2
  13. data/examples/todolist/todolist.db +0 -4
  14. data/examples/whywiki/main.rb +2 -2
  15. data/examples/whywiki/template/edit.xhtml +1 -1
  16. data/examples/whywiki/template/show.xhtml +3 -3
  17. data/lib/proto/src/controller/main.rb +18 -1
  18. data/lib/proto/template/index.xhtml +11 -2
  19. data/lib/ramaze.rb +1 -1
  20. data/lib/ramaze/action.rb +104 -5
  21. data/lib/ramaze/action/render.rb +54 -0
  22. data/lib/ramaze/adapter.rb +2 -1
  23. data/lib/ramaze/adapter/mongrel.rb +13 -4
  24. data/lib/ramaze/cache.rb +17 -8
  25. data/lib/ramaze/cache/memcached.rb +1 -5
  26. data/lib/ramaze/controller.rb +51 -18
  27. data/lib/ramaze/controller/resolve.rb +19 -14
  28. data/lib/ramaze/dispatcher.rb +13 -16
  29. data/lib/ramaze/dispatcher/action.rb +2 -3
  30. data/lib/ramaze/dispatcher/error.rb +8 -3
  31. data/lib/ramaze/dispatcher/file.rb +1 -4
  32. data/lib/ramaze/error.rb +5 -5
  33. data/lib/ramaze/global.rb +7 -1
  34. data/lib/ramaze/global/globalstruct.rb +1 -3
  35. data/lib/ramaze/helper/aspect.rb +8 -10
  36. data/lib/ramaze/helper/cgi.rb +21 -3
  37. data/lib/ramaze/helper/identity.rb +4 -6
  38. data/lib/ramaze/helper/link.rb +4 -4
  39. data/lib/ramaze/helper/pager.rb +316 -0
  40. data/lib/ramaze/helper/partial.rb +37 -0
  41. data/lib/ramaze/helper/stack.rb +1 -1
  42. data/lib/ramaze/inform.rb +9 -0
  43. data/lib/ramaze/inform/hub.rb +5 -0
  44. data/lib/ramaze/inform/informer.rb +12 -6
  45. data/lib/ramaze/inform/informing.rb +32 -7
  46. data/lib/ramaze/inform/knotify.rb +21 -0
  47. data/lib/ramaze/inform/xosd.rb +58 -24
  48. data/lib/ramaze/sourcereload.rb +30 -1
  49. data/lib/ramaze/template.rb +33 -12
  50. data/lib/ramaze/template/amrita2.rb +21 -20
  51. data/lib/ramaze/template/erubis.rb +18 -14
  52. data/lib/ramaze/template/ezamar.rb +15 -26
  53. data/lib/ramaze/template/ezamar/element.rb +1 -1
  54. data/lib/ramaze/template/ezamar/engine.rb +45 -36
  55. data/lib/ramaze/template/ezamar/morpher.rb +3 -3
  56. data/lib/ramaze/template/ezamar/render_partial.rb +26 -0
  57. data/lib/ramaze/template/haml.rb +23 -18
  58. data/lib/ramaze/template/liquid.rb +5 -3
  59. data/lib/ramaze/template/markaby.rb +14 -11
  60. data/lib/ramaze/template/remarkably.rb +11 -5
  61. data/lib/ramaze/tool/localize.rb +12 -4
  62. data/lib/ramaze/tool/tidy.rb +26 -23
  63. data/lib/ramaze/trinity/request.rb +11 -7
  64. data/lib/ramaze/trinity/session.rb +24 -8
  65. data/lib/ramaze/version.rb +1 -1
  66. data/rake_tasks/maintaince.rake +136 -11
  67. data/spec/examples/templates/template_liquid.rb +6 -3
  68. data/spec/examples/todolist.rb +1 -2
  69. data/spec/helper/minimal.rb +7 -7
  70. data/spec/ramaze/action/basics.rb +19 -0
  71. data/spec/ramaze/action/render.rb +18 -0
  72. data/spec/ramaze/controller.rb +1 -1
  73. data/spec/ramaze/controller/template_resolving.rb +1 -1
  74. data/spec/ramaze/dispatcher/file.rb +24 -0
  75. data/spec/ramaze/error.rb +28 -29
  76. data/spec/ramaze/helper/cgi.rb +43 -0
  77. data/spec/ramaze/helper/pager.rb +27 -0
  78. data/spec/ramaze/helper/partial.rb +38 -0
  79. data/spec/ramaze/helper/template/partial.xhtml +1 -0
  80. data/spec/ramaze/inform/informer.rb +1 -1
  81. data/spec/ramaze/localize.rb +1 -1
  82. data/spec/ramaze/morpher.rb +3 -3
  83. data/spec/ramaze/request.rb +1 -3
  84. data/spec/ramaze/template.rb +9 -7
  85. data/spec/ramaze/template/haml.rb +2 -1
  86. metadata +21 -7
  87. data/examples/todolist/public/404.jpg +0 -0
  88. data/examples/todolist/public/error.xhtml +0 -74
  89. data/lib/ramaze/controller/render.rb +0 -90
@@ -1,74 +0,0 @@
1
- <html>
2
- <head>
3
- <title>#{@title}</title>
4
- <link rel="stylesheet" href="/css/coderay.css" />
5
- <link rel="stylesheet" href="/css/ramaze_error.css" />
6
- <script type="text/javascript" src="/js/jquery.js"></script>
7
- </head>
8
- <body>
9
- <img id="logo" alt="Ramaze" src="/ramaze.png" />
10
-
11
- <h1>#{@title}</h1>
12
-
13
- <table class="main">
14
- <tr class="head">
15
- <td>File</td><td>Line</td><td>Method</td>
16
- </tr>
17
- <?r @backtrace.each do |lines, hash, file, lineno, meth| ?>
18
- <tr id="line_#{hash}" style="background:rgb(#{@colors.shift},70,60);">
19
- <td>#{file}</td><td>#{lineno}</td><td>#{meth}</td>
20
- </tr>
21
- <tr id="source_#{hash}" style="display:none;">
22
- <td colspan="3">
23
- <div class="source">
24
- <table style="width:100%;">
25
- <tr>
26
- <td colspan="2">vim #{file} +#{lineno}</td>
27
- </tr>
28
- <?r
29
- if @coderay
30
- code = lines.map{|no, code, cur| code}.join("\n")
31
- line = lines.first[0]
32
- options = {
33
- :wrap => :div,
34
- :line_numbers => :inline,
35
- :line_number_start => line
36
- }
37
- ?>
38
- #{CodeRay.scan(code, :ruby).html(options)}
39
- <?r else ?>
40
- <?r lines.each do |llineno, lcode, lcurrent| ?>
41
- <tr class="source" #{'style="background:#faa;"' if lcurrent}>
42
- <td>#{llineno}</td>
43
- <td>#{lcode.rstrip}</td>
44
- </tr>
45
- <?r end ?>
46
- <?r end ?>
47
- </table>
48
- </div>
49
- <script type="text/javascript">
50
- $("tr#line_#{hash}").click(function(){$("tr#source_#{hash}").toggle()});
51
- </script>
52
- </td>
53
- </tr>
54
- <?r end ?>
55
- </table>
56
- <?r
57
- {
58
- 'Session' => Thread.current[:session],
59
- 'Request' => Thread.current[:request],
60
- 'Response' => Thread.current[:response],
61
- 'Global' => Global,
62
- }.each do |title, content|
63
- hash = [title, content].object_id.abs
64
- ?>
65
- <div class="additional">
66
- <h3 id="show_#{hash}">#{title}</h3>
67
- <pre style="display:none" id="is_#{hash}">#{content.pretty_inspect}</pre>
68
- <script type="text/javascript">
69
- $("h3#show_#{hash}").click(function(){$("pre#is_#{hash}").toggle()});
70
- </script>
71
- </div>
72
- <?r end ?>
73
- </body>
74
- </html>
@@ -1,90 +0,0 @@
1
- # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
2
- # All files in this distribution are subject to the terms of the Ruby license.
3
-
4
- module Ramaze
5
- class Controller
6
- class << self
7
- def render(action = {})
8
- action = Action.fill(action) if action.is_a?(Hash)
9
- Inform.debug("The Action: #{action}")
10
-
11
- action.method = action.method.to_s if action.method
12
- action.params.compact!
13
-
14
- if cached?(action)
15
- cached_render(action)
16
- else
17
- uncached_render(action)
18
- end
19
- end
20
-
21
- def cached?(action)
22
- actions_cached = trait[:actions_cached]
23
-
24
- [ Global.cache_all,
25
- trait[:cache_all],
26
- actions_cached.map{|k| k.to_s}.include?(action.method),
27
- ].any?
28
- end
29
-
30
- def uncached_render(action)
31
- controller = self.new
32
- controller.instance_variable_set('@action', action)
33
- Thread.current[:controller] = controller
34
-
35
- action.binding = controller.instance_eval{ binding }
36
- action.controller = controller
37
-
38
- before = before_process(action)
39
-
40
- engine = select_engine(action.template)
41
- answer = engine.transform(action)
42
-
43
- after = after_process(action)
44
- [before, answer, after].join
45
- end
46
-
47
- def before_process(action)
48
- ''
49
- end
50
-
51
- def after_process(action)
52
- ''
53
- end
54
-
55
- def cached_render action
56
- action_cache = Cache.actions
57
-
58
- if out = action_cache[action]
59
- Inform.debug("Using Cached version for #{action}")
60
- return out
61
- end
62
-
63
- Inform.debug("Compiling Action: #{action}")
64
- action_cache[action] = uncached_render(action)
65
- end
66
-
67
- def select_engine(file)
68
- trait_engine = class_trait[:engine]
69
- default = [trait_engine, Template::Ezamar].compact.first
70
- return default unless file
71
-
72
- engines = Controller.trait[:template_extensions]
73
- return default if engines.empty?
74
-
75
- ext = File.extname(file).gsub(/^\./, '')
76
- ext_engine = engines[ext]
77
- return ext_engine ? ext_engine : default
78
- end
79
-
80
- # This method is called by templating-engines to register themselves with
81
- # a list of extensions that will be looked up on #render of an action.
82
-
83
- def register_engine engine, *extensions
84
- extensions.flatten.each do |ext|
85
- trait[:template_extensions][ext] = engine
86
- end
87
- end
88
- end
89
- end
90
- end