ramaze 0.1.4 → 0.2.0

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 (192) hide show
  1. data/Rakefile +26 -6
  2. data/bin/ramaze +8 -1
  3. data/doc/AUTHORS +13 -11
  4. data/doc/CHANGELOG +472 -13
  5. data/doc/LEGAL +22 -0
  6. data/doc/README +1 -4
  7. data/doc/TODO +7 -2
  8. data/doc/changes.txt +472 -13
  9. data/doc/changes.xml +472 -13
  10. data/doc/meta/announcement.txt +21 -23
  11. data/doc/readme_chunks/appendix.txt +0 -3
  12. data/doc/readme_chunks/features.txt +1 -1
  13. data/examples/auth/auth.rb +49 -0
  14. data/examples/auth/template/layout.haml +20 -0
  15. data/examples/auth/template/login.haml +16 -0
  16. data/examples/blog/spec/blog.rb +1 -0
  17. data/examples/caching.rb +5 -6
  18. data/examples/css.rb +37 -0
  19. data/examples/layout.rb +3 -17
  20. data/examples/simple_auth.rb +23 -0
  21. data/examples/sourceview/public/images/file.gif +0 -0
  22. data/examples/sourceview/public/images/folder.gif +0 -0
  23. data/examples/sourceview/public/images/tv-collapsable-last.gif +0 -0
  24. data/examples/sourceview/public/images/tv-collapsable.gif +0 -0
  25. data/examples/sourceview/public/images/tv-expandable-last.gif +0 -0
  26. data/examples/sourceview/public/images/tv-expandable.gif +0 -0
  27. data/examples/sourceview/public/images/tv-item-last.gif +0 -0
  28. data/examples/sourceview/public/images/tv-item.gif +0 -0
  29. data/examples/sourceview/public/jquery.js +11 -0
  30. data/examples/sourceview/public/jquery.treeview.css +47 -0
  31. data/examples/sourceview/public/jquery.treeview.js +223 -0
  32. data/examples/sourceview/public/sourceview.js +16 -0
  33. data/examples/sourceview/sourceview.rb +74 -0
  34. data/examples/sourceview/template/index.haml +43 -0
  35. data/examples/templates/template/external.nag +28 -0
  36. data/examples/templates/template/external.xsl +57 -0
  37. data/examples/templates/template_amrita2.rb +2 -4
  38. data/examples/templates/template_erubis.rb +1 -1
  39. data/examples/templates/template_haml.rb +1 -1
  40. data/examples/templates/template_liquid.rb +2 -4
  41. data/examples/templates/template_markaby.rb +2 -4
  42. data/examples/templates/template_nagoro.rb +53 -0
  43. data/examples/templates/template_remarkably.rb +2 -4
  44. data/examples/templates/template_xslt.rb +52 -0
  45. data/examples/whywiki/spec/whywiki.rb +63 -0
  46. data/examples/whywiki/start.rb +11 -13
  47. data/examples/whywiki/template/edit.xhtml +3 -3
  48. data/examples/whywiki/template/show.xhtml +5 -8
  49. data/examples/wikore/spec/wikore.rb +115 -0
  50. data/examples/wikore/src/controller.rb +81 -0
  51. data/examples/wikore/src/model.rb +51 -0
  52. data/examples/wikore/start.rb +6 -0
  53. data/examples/wikore/template/index.xhtml +8 -0
  54. data/examples/wiktacular/spec/wiktacular.rb +1 -0
  55. data/examples/wiktacular/src/controller.rb +1 -1
  56. data/lib/ramaze.rb +6 -3
  57. data/lib/ramaze/action.rb +2 -13
  58. data/lib/ramaze/action/render.rb +36 -18
  59. data/lib/ramaze/adapter.rb +1 -1
  60. data/lib/ramaze/adapter/cgi.rb +0 -3
  61. data/lib/ramaze/adapter/evented_mongrel.rb +7 -0
  62. data/lib/ramaze/adapter/mongrel.rb +4 -13
  63. data/lib/ramaze/adapter/swiftiplied_mongrel.rb +7 -0
  64. data/lib/ramaze/cache.rb +12 -7
  65. data/lib/ramaze/contrib.rb +22 -0
  66. data/lib/ramaze/contrib/auto_params.rb +128 -0
  67. data/lib/ramaze/contrib/auto_params/get_args.rb +56 -0
  68. data/lib/ramaze/contrib/gzip_filter.rb +57 -0
  69. data/lib/ramaze/contrib/route.rb +40 -0
  70. data/lib/ramaze/contrib/sequel/fill.rb +12 -0
  71. data/lib/ramaze/controller.rb +17 -6
  72. data/lib/ramaze/controller/resolve.rb +51 -14
  73. data/lib/ramaze/dispatcher.rb +15 -13
  74. data/lib/ramaze/dispatcher/action.rb +4 -3
  75. data/lib/ramaze/dispatcher/directory.rb +3 -3
  76. data/lib/ramaze/dispatcher/error.rb +1 -1
  77. data/lib/ramaze/dispatcher/file.rb +17 -6
  78. data/lib/ramaze/error.rb +3 -0
  79. data/lib/ramaze/gestalt.rb +28 -8
  80. data/lib/ramaze/global.rb +26 -6
  81. data/lib/ramaze/global/globalstruct.rb +31 -6
  82. data/lib/ramaze/helper.rb +2 -1
  83. data/lib/ramaze/helper/aspect.rb +2 -2
  84. data/lib/ramaze/helper/auth.rb +6 -9
  85. data/lib/ramaze/helper/cache.rb +89 -9
  86. data/lib/ramaze/helper/cgi.rb +2 -2
  87. data/lib/ramaze/helper/formatting.rb +44 -0
  88. data/lib/ramaze/helper/link.rb +7 -5
  89. data/lib/ramaze/helper/partial.rb +6 -4
  90. data/lib/ramaze/helper/redirect.rb +24 -9
  91. data/lib/ramaze/helper/stack.rb +6 -1
  92. data/lib/ramaze/inform/growl.rb +1 -1
  93. data/lib/ramaze/inform/informer.rb +2 -1
  94. data/lib/ramaze/inform/informing.rb +6 -0
  95. data/lib/ramaze/inform/syslog.rb +1 -0
  96. data/lib/ramaze/snippets/array/put_within.rb +24 -0
  97. data/lib/ramaze/snippets/dictionary.rb +499 -0
  98. data/lib/ramaze/snippets/numeric/filesize_format.rb +19 -0
  99. data/lib/ramaze/snippets/ordered_set.rb +31 -0
  100. data/lib/ramaze/snippets/string/DIVIDE.rb +1 -1
  101. data/lib/ramaze/snippets/string/snake_case.rb +1 -1
  102. data/lib/ramaze/snippets/struct/values_at.rb +5 -1
  103. data/lib/ramaze/snippets/thread/into.rb +25 -0
  104. data/lib/ramaze/sourcereload.rb +39 -19
  105. data/lib/ramaze/spec/helper.rb +4 -1
  106. data/lib/ramaze/spec/helper/{context.rb → browser.rb} +3 -0
  107. data/lib/ramaze/spec/helper/layout.rb +3 -0
  108. data/lib/ramaze/spec/helper/minimal.rb +3 -0
  109. data/lib/ramaze/spec/helper/mock_http.rb +8 -5
  110. data/lib/ramaze/spec/helper/requester.rb +4 -1
  111. data/lib/ramaze/spec/helper/wrap.rb +15 -7
  112. data/lib/ramaze/template.rb +5 -1
  113. data/lib/ramaze/template/ezamar/engine.rb +2 -3
  114. data/lib/ramaze/template/ezamar/morpher.rb +26 -45
  115. data/lib/ramaze/template/nagoro.rb +53 -0
  116. data/lib/ramaze/template/none.rb +14 -0
  117. data/lib/ramaze/template/xslt.rb +96 -0
  118. data/lib/ramaze/tool.rb +0 -1
  119. data/lib/ramaze/tool/localize.rb +7 -2
  120. data/lib/ramaze/trinity/request.rb +1 -0
  121. data/lib/ramaze/trinity/session.rb +3 -3
  122. data/lib/ramaze/version.rb +2 -2
  123. data/rake_tasks/conf.rake +1 -2
  124. data/rake_tasks/{maintaince.rake → maintenance.rake} +25 -17
  125. data/spec/contrib/auto_params.rb +97 -0
  126. data/spec/contrib/route.rb +60 -0
  127. data/spec/contrib/sequel/fill.rb +46 -0
  128. data/spec/examples/caching.rb +1 -2
  129. data/spec/examples/css.rb +12 -0
  130. data/spec/examples/element.rb +0 -1
  131. data/spec/examples/hello.rb +0 -1
  132. data/spec/examples/simple.rb +0 -1
  133. data/spec/helper.rb +3 -2
  134. data/spec/ramaze/action/cache.rb +24 -7
  135. data/spec/ramaze/action/layout.rb +19 -11
  136. data/spec/ramaze/action/template/sub/sub_wrapper.xhtml +1 -0
  137. data/spec/ramaze/controller.rb +11 -0
  138. data/spec/ramaze/controller/template_resolving.rb +28 -27
  139. data/spec/ramaze/dispatcher.rb +32 -0
  140. data/spec/ramaze/dispatcher/directory.rb +2 -1
  141. data/spec/ramaze/element.rb +1 -1
  142. data/spec/ramaze/gestalt.rb +28 -0
  143. data/spec/ramaze/helper/aspect.rb +14 -3
  144. data/spec/ramaze/helper/cache.rb +78 -13
  145. data/spec/ramaze/helper/formatting.rb +20 -0
  146. data/spec/ramaze/helper/link.rb +2 -0
  147. data/spec/ramaze/helper/partial.rb +12 -1
  148. data/spec/ramaze/helper/redirect.rb +44 -8
  149. data/spec/ramaze/helper/stack.rb +3 -3
  150. data/spec/ramaze/helper/template/loop.xhtml +3 -0
  151. data/spec/ramaze/helper/template/num.xhtml +1 -0
  152. data/spec/ramaze/helper/template/recursive.xhtml +8 -0
  153. data/spec/ramaze/morpher.rb +25 -6
  154. data/spec/ramaze/params.rb +6 -2
  155. data/spec/ramaze/request.rb +5 -2
  156. data/spec/ramaze/session.rb +19 -0
  157. data/spec/ramaze/template.rb +2 -2
  158. data/spec/ramaze/template/amrita2.rb +2 -2
  159. data/spec/ramaze/template/erubis.rb +2 -2
  160. data/spec/ramaze/template/ezamar.rb +6 -3
  161. data/spec/ramaze/template/haml.rb +3 -3
  162. data/spec/ramaze/template/liquid.rb +1 -1
  163. data/spec/ramaze/template/markaby.rb +1 -1
  164. data/spec/ramaze/template/nagoro.rb +65 -0
  165. data/spec/ramaze/template/nagoro/another/long/action.nag +1 -0
  166. data/spec/ramaze/template/nagoro/combined.nag +1 -0
  167. data/spec/ramaze/template/nagoro/file_only.nag +1 -0
  168. data/spec/ramaze/template/nagoro/index.nag +1 -0
  169. data/spec/ramaze/template/nagoro/nested.nag +1 -0
  170. data/spec/ramaze/template/nagoro/some__long__action.nag +1 -0
  171. data/spec/ramaze/template/nagoro/sum.nag +1 -0
  172. data/spec/ramaze/template/remarkably.rb +1 -1
  173. data/spec/ramaze/template/sass.rb +1 -1
  174. data/spec/ramaze/template/xslt.rb +93 -0
  175. data/spec/ramaze/template/xslt/concat_words.xsl +16 -0
  176. data/spec/ramaze/template/xslt/index.xsl +14 -0
  177. data/spec/ramaze/template/xslt/products.xsl +32 -0
  178. data/spec/ramaze/template/xslt/ruby_version.xsl +14 -0
  179. data/spec/snippets/array/put_within.rb +32 -0
  180. data/spec/snippets/numeric/filesize_format.rb +12 -0
  181. data/spec/snippets/ordered_set.rb +56 -0
  182. data/spec/snippets/ramaze/caller_lines.rb +6 -3
  183. data/spec/snippets/string/snake_case.rb +3 -0
  184. metadata +118 -22
  185. data/doc/README.html +0 -737
  186. data/examples/fcgi.rb +0 -13
  187. data/lib/ramaze/snippets/numeric/human_readable_filesize_format.rb +0 -33
  188. data/lib/ramaze/tool/tidy.rb +0 -104
  189. data/spec/ramaze/controller/template/edit.xhtml +0 -1
  190. data/spec/ramaze/controller/template/edit/content.xhtml +0 -1
  191. data/spec/ramaze/tidy.rb +0 -12
  192. data/spec/snippets/numeric/human_readable_filesize_format.rb +0 -11
@@ -0,0 +1,16 @@
1
+ $(document).ready(function(){
2
+ $('ul.filetree').treeview({
3
+ persist: 'location',
4
+ animated: 'fast',
5
+ unique: true,
6
+ collapsed: true
7
+ });
8
+
9
+ $("span.file").click(function(){
10
+ $('a.selected').removeClass('selected');
11
+ $('#file_contents').load('/source', { file: $(this).attr('name') });
12
+ $('a',this).eq(0).addClass('selected');
13
+ });
14
+
15
+ $('a.selected').parent('span.file').click();
16
+ });
@@ -0,0 +1,74 @@
1
+ require 'rubygems'
2
+ require 'remarkably/engines/html'
3
+ require 'coderay'
4
+ require 'ramaze'
5
+
6
+ # where is the source
7
+ RAMAZE_SRC = File.expand_path(Ramaze::BASEDIR/'..')
8
+
9
+ class MainController < Ramaze::Controller
10
+
11
+ include Remarkably::Common
12
+ helper :partial, :inform, :cache
13
+
14
+ cache :filetree
15
+ engine :None
16
+
17
+ def source
18
+ return if request['file'].nil? or request['file'] =~ /\.{2}/
19
+
20
+ file = RAMAZE_SRC + request['file']
21
+ if FileTest.file? file
22
+ inform :info, "Showing source for #{file}"
23
+ CodeRay.scan_file(file).html(:line_numbers => :inline)
24
+ end
25
+ end
26
+
27
+ def filetree
28
+ ul :class => 'filetree treeview' do
29
+ Dir.chdir(RAMAZE_SRC) do
30
+ Dir['{benchmarks,doc,examples,lib,spec}'].collect do |d|
31
+ dir_listing d
32
+ end
33
+ end
34
+ end.to_s
35
+ end
36
+
37
+ define_method('coderay.css') do
38
+ response['Content-Type'] = 'text/css'
39
+ value_cache[:coderay] ||= CodeRay::Encoders[:html]::CSS.new.stylesheet
40
+ end
41
+
42
+ private
43
+
44
+ def dir_listing dir
45
+ li do
46
+ span dir, :class => 'folder'
47
+ Dir.chdir(dir) do
48
+ if Dir['*'].any?
49
+ ul do
50
+ a '', :href => "##{File.expand_path('.').sub(RAMAZE_SRC,'')}"
51
+ Dir['*'].each do |d|
52
+ if FileTest.directory? d
53
+ dir_listing d
54
+ else
55
+ file = File.expand_path(d).sub(RAMAZE_SRC,'')
56
+ li do
57
+ span :class => 'file', :name => file do
58
+ a d, :href => "##{file}"
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+ end
70
+
71
+ Ramaze.start :adapter => :mongrel,
72
+ :load_engines => :Haml,
73
+ :boring => /(js|gif|css)$/,
74
+ :port => 3000
@@ -0,0 +1,43 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %title Ramaze Source Browser
5
+
6
+ %link{ :rel => 'stylesheet', :type => 'text/css', :href => '/jquery.treeview.css' }/
7
+ %link{ :rel => 'stylesheet', :type => 'text/css', :href => '/coderay.css' }/
8
+ %style{ :type => 'text/css' }
9
+ :sass
10
+ body
11
+ :font-family sans-serif
12
+ :margin 1.5em
13
+
14
+ a
15
+ :text-decoration none
16
+ :color #000
17
+ &.selected
18
+ :color #f00
19
+
20
+ #dir_listing
21
+ :float left
22
+
23
+ .filetree
24
+ span.folder, span.file
25
+ :padding-left 19px
26
+ :margin-left 2px
27
+
28
+ #file_contents
29
+ :margin-left 290px
30
+ :white-space pre
31
+ :font-size 11pt
32
+
33
+ %body
34
+ #dir_listing
35
+ = render_partial('/filetree')
36
+ #file_contents.CodeRay
37
+ %span{ :style => 'text-align: center' }
38
+ %h1 Welcome to the Ramaze source code browser
39
+ %h3 pick a file on the left to view its contents
40
+
41
+ %script{ :type => 'text/javascript', :src => '/jquery.js' }=""
42
+ %script{ :type => 'text/javascript', :src => '/jquery.treeview.js' }=""
43
+ %script{ :type => 'text/javascript', :src => '/sourceview.js' }=""
@@ -0,0 +1,28 @@
1
+ <html>
2
+ <head>
3
+ <title>Template::Nagoro external</title>
4
+ </head>
5
+ <body>
6
+ <h1>The external Template for Nagoro</h1>
7
+ #{A 'Home', :href => :/}
8
+ <p>
9
+ Here you can pass some stuff if you like, parameters are just passed like this:<br />
10
+ #{A("external/one")}<br />
11
+ #{A("external/one/two/three")}<br />
12
+ #{A("external/one?foo=bar")}<br />
13
+ </p>
14
+ <div>
15
+ The arguments you have passed to this action are:
16
+ <?r if @args.empty? ?>
17
+ none
18
+ <?r else ?>
19
+ <?r @args.each do |arg| ?>
20
+ <span>#{arg}</span>
21
+ <?r end ?>
22
+ <?r end ?>
23
+ </div>
24
+ <div>
25
+ #{request.params.inspect}
26
+ </div>
27
+ </body>
28
+ </html>
@@ -0,0 +1,57 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <xsl:stylesheet version="1.0"
3
+ xmlns="http://www.w3.org/1999/xhtml"
4
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5
+ exclude-result-prefixes="xsl">
6
+
7
+ <xsl:output method="xml"
8
+ version="1.0"
9
+ encoding="utf-8"
10
+ doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
11
+ doctype-system="DTD/xhtml1-strict.dtd"
12
+ indent="yes"/>
13
+
14
+ <xsl:template match="/page">
15
+ <html>
16
+ <head>
17
+ <title>
18
+ <xsl:value-of select="@title"/>
19
+ </title>
20
+ </head>
21
+ <body>
22
+ <xsl:apply-templates/>
23
+ </body>
24
+ </html>
25
+ </xsl:template>
26
+
27
+ <xsl:template match="heading">
28
+ <h1>
29
+ <xsl:apply-templates/>
30
+ </h1>
31
+ </xsl:template>
32
+
33
+ <xsl:template match="list">
34
+ <ul>
35
+ <xsl:apply-templates/>
36
+ </ul>
37
+ </xsl:template>
38
+
39
+ <xsl:template match="list/item">
40
+ <li>
41
+ <xsl:apply-templates/>
42
+ </li>
43
+ </xsl:template>
44
+
45
+ <xsl:template match="link">
46
+ <a href="{@href}">
47
+ <xsl:apply-templates/>
48
+ </a>
49
+ </xsl:template>
50
+
51
+ <xsl:template match="text">
52
+ <p>
53
+ <xsl:apply-templates/>
54
+ </p>
55
+ </xsl:template>
56
+
57
+ </xsl:stylesheet>
@@ -3,14 +3,12 @@
3
3
 
4
4
  require 'ramaze'
5
5
 
6
- include Ramaze
7
-
8
6
  # TODO:
9
7
  # - implement the amrita2 example, man, this engine is awkward :P
10
8
 
11
- class MainController < Controller
9
+ class MainController < Ramaze::Controller
12
10
  template_root __DIR__/:template
13
- trait :engine => Template::Amrita2
11
+ engine :Amrita2
14
12
 
15
13
  def index
16
14
  %{ #{A(Rs())} | #{Rs(:internal)} | #{Rs(:external)} }
@@ -5,7 +5,7 @@ require 'ramaze'
5
5
 
6
6
  class MainController < Ramaze::Controller
7
7
  template_root __DIR__/:template
8
- trait :engine => Ramaze::Template::Erubis
8
+ engine :Erubis
9
9
 
10
10
  def index
11
11
  %{ #{A('Home', :href => :/)} | #{A(:internal)} | #{A(:external)} }
@@ -5,7 +5,7 @@ require 'ramaze'
5
5
 
6
6
  class MainController < Ramaze::Controller
7
7
  template_root __DIR__/:template
8
- trait :engine => Ramaze::Template::Haml
8
+ engine :Haml
9
9
 
10
10
  def index
11
11
  %{ #{A 'Home', :href => :/} | #{A(:internal)} | #{A(:external)} }
@@ -3,11 +3,9 @@
3
3
 
4
4
  require 'ramaze'
5
5
 
6
- include Ramaze
7
-
8
- class MainController < Controller
6
+ class MainController < Ramaze::Controller
9
7
  template_root __DIR__/:template
10
- trait :engine => Template::Liquid
8
+ engine :Liquid
11
9
 
12
10
  def index
13
11
  %{ #{A 'Home', :href => :/} | #{A(:internal)} | #{A(:external)} }
@@ -3,11 +3,9 @@
3
3
 
4
4
  require 'ramaze'
5
5
 
6
- include Ramaze
7
-
8
- class MainController < Controller
6
+ class MainController < Ramaze::Controller
9
7
  template_root __DIR__/'template'
10
- trait :engine => Template::Markaby
8
+ engine :Markaby
11
9
 
12
10
  helper :markaby
13
11
 
@@ -0,0 +1,53 @@
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
+ require 'ramaze'
5
+
6
+ class MainController < Ramaze::Controller
7
+ template_root __DIR__/:template
8
+ engine :Nagoro
9
+
10
+ def index
11
+ %{ #{A 'Home', :href => :/} | #{A(:internal)} | #{A(:external)} }
12
+ end
13
+
14
+ def internal *args
15
+ @args = args
16
+ %q{
17
+ <html>
18
+ <head>
19
+ <title>Template::Nagoro internal</title>
20
+ </head>
21
+ <body>
22
+ <h1>The internal Template for Nagoro</h1>
23
+ #{A 'Home', :href => :/}
24
+ <p>
25
+ Here you can pass some stuff if you like, parameters are just passed like this:<br />
26
+ #{A("internal/one")}<br />
27
+ #{A("internal/one/two/three")}<br />
28
+ #{A("internal/one?foo=bar")}<br />
29
+ </p>
30
+ <div>
31
+ The arguments you have passed to this action are:
32
+ <?r if @args.empty? ?>
33
+ none
34
+ <?r else ?>
35
+ <?r @args.each do |arg| ?>
36
+ <span>#{arg}</span>
37
+ <?r end ?>
38
+ <?r end ?>
39
+ </div>
40
+ <div>
41
+ #{request.params.inspect}
42
+ </div>
43
+ </body>
44
+ </html>
45
+ }
46
+ end
47
+
48
+ def external *args
49
+ @args = args
50
+ end
51
+ end
52
+
53
+ Ramaze.start
@@ -3,11 +3,9 @@
3
3
 
4
4
  require 'ramaze'
5
5
 
6
- include Ramaze
7
-
8
- class MainController < Controller
6
+ class MainController < Ramaze::Controller
9
7
  template_root __DIR__/:template
10
- trait :engine => Template::Remarkably
8
+ engine :Remarkably
11
9
 
12
10
  include Remarkably::Common
13
11
 
@@ -0,0 +1,52 @@
1
+ # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
2
+ # Copyright (c) 2007 Stephan Maka stephan@spaceboyz.net
3
+ # All files in this distribution are subject to the terms of the Ruby license.
4
+
5
+ require 'ramaze'
6
+ require 'ramaze/gestalt'
7
+
8
+ class MainController < Ramaze::Controller
9
+ template_root __DIR__/:template
10
+ engine :XSLT
11
+
12
+ def index
13
+ redirect R(:external)
14
+ end
15
+
16
+ def external *args
17
+ r = lambda { |*a| R(*a) }
18
+ response['Content-Type'] = 'application/xhtml+xml'
19
+
20
+ #options = {:place => :internal, :action => 'internal',
21
+ # :args => args, :request => request, :this => self}
22
+ Ramaze::Gestalt.build do
23
+ page(:title=>"Template::XSLT") do
24
+ heading "The external Template for XSLT"
25
+ text "Here you can pass some stuff if you like, parameters are just passed like this:"
26
+ list do
27
+ item {
28
+ link(:href => r.call(@this, :external, :one)) { "external/one" }
29
+ }
30
+ item {
31
+ link(:href => r.call(@this, :external, :one, :two, :three)) { "external/one/two/three" }
32
+ }
33
+ item {
34
+ link(:href => r.call(@this, :external, :one, :foo => :bar)) { "external/one?foo=bar" }
35
+ }
36
+ end
37
+ text "The arguments you have passed to this action are:"
38
+ if args.empty?
39
+ text "none"
40
+ else
41
+ list {
42
+ args.each do |arg|
43
+ item arg
44
+ end
45
+ }
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ Ramaze.start
@@ -0,0 +1,63 @@
1
+ require 'ramaze'
2
+ require 'ramaze/spec/helper'
3
+
4
+ # if these libraries are missing there is no sense in running the tests,
5
+ # cause they won't work at all.
6
+ testcase_requires 'bluecloth', 'hpricot', 'nagoro'
7
+
8
+ $:.unshift 'examples/whywiki'
9
+
10
+ Db = Ramaze::YAMLStoreCache.new('testwiki.yaml')
11
+ require 'start'
12
+
13
+ class WikiController < Ramaze::Controller
14
+ template_root __DIR__ / '../template'
15
+ end
16
+
17
+ describe WikiController do
18
+ after :all do
19
+ FileUtils.rm('testwiki.yaml')
20
+ end
21
+
22
+ def page(name)
23
+ page = get('/'+name)
24
+ page.status.should == 200
25
+ page.body.should_not be_nil
26
+
27
+ doc = Hpricot(page.body)
28
+ title = doc.at('title').inner_html
29
+
30
+ body = doc.at('body')
31
+ return title, body
32
+ end
33
+
34
+ it 'should start' do
35
+ ramaze :public_root => '.', :port => 7001
36
+ get('/').status.should == 303
37
+ end
38
+
39
+ it 'should have main page' do
40
+ t,body = page('/show/Home')
41
+ t.should match(/^MicroWiki Home$/)
42
+ body.at('h1').inner_html.should == 'Home'
43
+ body.at('a[@href=/edit/Home]').inner_html.should == 'Create Home'
44
+ end
45
+
46
+ it 'should have edit page' do
47
+ t,body = page('/edit/Home')
48
+ t.should match(/^MicroWiki Edit Home$/)
49
+
50
+ body.at('a[@href=/]').inner_html.should == '&lt; Home'
51
+ body.at('h1').inner_html.should == 'Edit Home'
52
+ body.at('form[@action=/save]>textarea[@name=text]').should_not be_nil
53
+ end
54
+
55
+ it 'should create pages' do
56
+ post('/save','text'=>'the text','page'=>'ThePage').status.should == 303
57
+ page = Hpricot(get('/show/ThePage').body)
58
+ body = page.at('body>div')
59
+ body.should_not be_nil
60
+ body.at('a[@href=/edit/ThePage]').inner_html.should =='Edit ThePage'
61
+ body.at('p').inner_html.should == 'the text'
62
+ end
63
+ end