ramaze 0.3.0 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/Rakefile +3 -2
  2. data/bin/ramaze +9 -3
  3. data/doc/AUTHORS +6 -2
  4. data/doc/CHANGELOG +272 -66
  5. data/doc/GPL +12 -13
  6. data/doc/README.html +729 -0
  7. data/doc/changes.txt +5757 -0
  8. data/doc/changes.xml +5759 -0
  9. data/doc/meta/announcement.txt +48 -39
  10. data/doc/tutorial/todolist.mkd +10 -12
  11. data/examples/blog/start.rb +1 -0
  12. data/examples/caching.rb +1 -0
  13. data/examples/element.rb +3 -0
  14. data/examples/hello.rb +1 -3
  15. data/examples/identity.rb +5 -8
  16. data/examples/layout.rb +1 -0
  17. data/examples/linking.rb +1 -0
  18. data/examples/memleak_detector.rb +1 -0
  19. data/examples/nitro_form.rb +1 -0
  20. data/examples/rammit/start.rb +1 -0
  21. data/examples/rapaste/Rakefile +7 -0
  22. data/examples/rapaste/{src/controller.rb → controller/paste.rb} +28 -3
  23. data/examples/rapaste/{src/model.rb → model/paste.rb} +0 -4
  24. data/examples/rapaste/public/css/display.css +17 -0
  25. data/examples/rapaste/spec/rapaste.rb +2 -2
  26. data/examples/rapaste/start.rb +9 -4
  27. data/examples/rapaste/{template → view}/copy.xhtml +0 -0
  28. data/examples/rapaste/{template → view}/index.xhtml +0 -0
  29. data/examples/rapaste/{template → view}/layout.xhtml +3 -0
  30. data/examples/rapaste/{template → view}/list.xhtml +4 -3
  31. data/examples/rapaste/view/search.xhtml +41 -0
  32. data/examples/rapaste/{template → view}/view.xhtml +0 -0
  33. data/examples/simple.rb +3 -3
  34. data/examples/templates/template/external.amrita +9 -9
  35. data/examples/templates/template/external.redcloth +19 -0
  36. data/examples/templates/template_amrita2.rb +40 -7
  37. data/examples/templates/template_erubis.rb +3 -3
  38. data/examples/templates/template_ezamar.rb +1 -3
  39. data/examples/templates/template_haml.rb +1 -3
  40. data/examples/templates/template_liquid.rb +3 -3
  41. data/examples/templates/template_markaby.rb +1 -3
  42. data/examples/templates/template_nagoro.rb +1 -3
  43. data/examples/templates/template_redcloth.rb +59 -0
  44. data/examples/templates/template_remarkably.rb +1 -3
  45. data/examples/templates/template_xslt.rb +1 -4
  46. data/examples/todolist/src/controller/main.rb +1 -1
  47. data/examples/todolist/start.rb +1 -2
  48. data/examples/upload/start.rb +19 -0
  49. data/examples/upload/view/index.xhtml +25 -0
  50. data/examples/whywiki/start.rb +1 -3
  51. data/examples/wikore/start.rb +3 -0
  52. data/examples/wiktacular/mkd/newpagename/current.mkd +1 -0
  53. data/examples/wiktacular/mkd/newpagename/current.mkd.bak +1 -0
  54. data/examples/wiktacular/start.rb +1 -0
  55. data/lib/proto/controller/main.rb +0 -3
  56. data/lib/proto/public/js/jquery.js +106 -93
  57. data/lib/proto/spec/main.rb +2 -5
  58. data/lib/proto/start.rb +0 -3
  59. data/lib/ramaze.rb +3 -2
  60. data/lib/ramaze/action.rb +6 -10
  61. data/lib/ramaze/adapter/lsws.rb +19 -0
  62. data/lib/ramaze/contrib/email.rb +84 -0
  63. data/lib/ramaze/contrib/email.rb-darcs-backup0 +81 -0
  64. data/lib/ramaze/contrib/gettext.rb +1 -0
  65. data/lib/ramaze/contrib/gettext/parser.rb +46 -0
  66. data/lib/ramaze/contrib/route.rb +3 -36
  67. data/lib/ramaze/controller.rb +4 -6
  68. data/lib/ramaze/controller/resolve.rb +28 -1
  69. data/lib/ramaze/dispatcher.rb +1 -1
  70. data/lib/ramaze/dispatcher/file.rb +17 -0
  71. data/lib/ramaze/global/globalstruct.rb +7 -4
  72. data/lib/ramaze/helper/auth.rb +1 -1
  73. data/lib/ramaze/helper/identity.rb +25 -15
  74. data/lib/ramaze/helper/link.rb +29 -8
  75. data/lib/ramaze/helper/maruku.rb +7 -0
  76. data/lib/ramaze/helper/partial.rb +25 -10
  77. data/lib/ramaze/route.rb +56 -0
  78. data/lib/ramaze/snippets/metaid.rb +17 -0
  79. data/lib/ramaze/spec/helper.rb +0 -2
  80. data/lib/ramaze/spec/helper/mock_http.rb +6 -0
  81. data/lib/ramaze/spec/helper/pretty_output.rb +5 -1
  82. data/lib/ramaze/store/default.rb +3 -1
  83. data/lib/ramaze/template.rb +1 -1
  84. data/lib/ramaze/template/amrita2.rb +21 -15
  85. data/lib/ramaze/template/bijou.rb +39 -0
  86. data/lib/ramaze/template/builder.rb +28 -0
  87. data/lib/ramaze/template/redcloth.rb +24 -0
  88. data/lib/ramaze/template/sass.rb +3 -1
  89. data/lib/ramaze/tool/create.rb +2 -1
  90. data/lib/ramaze/tool/localize.rb +6 -1
  91. data/lib/ramaze/trinity/request.rb +8 -0
  92. data/lib/ramaze/trinity/session.rb +8 -5
  93. data/lib/ramaze/version.rb +1 -1
  94. data/rake_tasks/gem.rake +0 -1
  95. data/rake_tasks/maintenance.rake +4 -1
  96. data/spec/contrib/route.rb +14 -63
  97. data/spec/examples/linking.rb +2 -2
  98. data/spec/examples/templates/template_redcloth.rb +28 -0
  99. data/spec/ramaze/controller/subclass.rb +21 -0
  100. data/spec/ramaze/dispatcher/file.rb +31 -0
  101. data/spec/ramaze/helper/link.rb +46 -0
  102. data/spec/ramaze/helper/partial.rb +22 -1
  103. data/spec/ramaze/helper/template/locals.xhtml +1 -0
  104. data/spec/ramaze/helper/template/recursive_locals.xhtml +7 -0
  105. data/spec/ramaze/params.rb +8 -0
  106. data/spec/ramaze/request.rb +14 -0
  107. data/spec/ramaze/route.rb +107 -0
  108. data/spec/ramaze/session.rb +4 -2
  109. data/spec/ramaze/template/amrita2.rb +21 -7
  110. data/spec/ramaze/template/amrita2/external.amrita +6 -0
  111. data/spec/ramaze/template/amrita2/sum.amrita +1 -1
  112. data/spec/ramaze/template/bijou.rb +25 -0
  113. data/spec/ramaze/template/builder.rb +55 -0
  114. data/spec/ramaze/template/builder/external.rxml +3 -0
  115. data/spec/ramaze/template/haml.rb +15 -0
  116. data/spec/ramaze/template/haml/locals.haml +1 -0
  117. data/spec/ramaze/template/redcloth.rb +38 -0
  118. data/spec/ramaze/template/redcloth/external.redcloth +1 -0
  119. metadata +472 -442
  120. data/examples/rapaste/rapaste.sqlite +0 -0
  121. data/spec/ramaze/template/amrita2/data.amrita +0 -6
  122. data/spec/ramaze/template/amrita2/index.amrita +0 -1
@@ -1,9 +1,9 @@
1
- This time we are proud to announce Version 0.3.0 of Ramaze, the light and
1
+ This time we are proud to announce Version 0.3.5 of Ramaze, the light and
2
2
  modular open source web framework.
3
3
 
4
4
  This release features a lot of work directly from our community and we are
5
5
  really greatful for everybody who helped in testing, patching and contributing
6
- new exciting features.
6
+ exciting new features.
7
7
 
8
8
  Our extensive set of specs and docs now covers almost every detail of
9
9
  implementation and usage. Ramaze is under development by a growing community
@@ -34,45 +34,54 @@ Simple example:
34
34
 
35
35
  Special (alphabetic) thanks go to:
36
36
 
37
- Aman 'tmm1' Gupta - lots of patches and friendly support
38
- Antonio Cangiano - Article: http://tiny.cc/tRLfm
39
- Carlo Zottmann - First patch!
40
- Jonathan 'Kashia' Buch - patches for gettext and Og support
41
- Pistos - PR through awesome screencasts
37
+ Aman 'tmm1' Gupta - patches and support
38
+ Carlo Zottmann - first patch!
39
+ Chris 'celldee' Duncan - first patch!
40
+ Gabriele 'riffraff' Renzi - patches for file dispatcher
41
+ jeedee - new Ramaze logo
42
+ Jonathan 'Kashia' Buch - patches and support
43
+ Keita Yamaguchi - first patch!
44
+ Pistos - lots of friendly support
45
+ skaar - first patch!
46
+
47
+
48
+ Selected summary of the 62 patches from 0.3.0 to 0.3.5:
49
+
50
+ Core
51
+ - Ramaze::Contrib::Route made available by default as Ramaze::Route (backwards compatibility retained)
52
+ - Support added for ETag and If-Modified-Since in Dispatcher::File
53
+ - Adapter for LiteSpeed webserver added
54
+ - Added ability to set default session cookie options using Session::COOKIE
55
+ - Support added for Content-Language based localization and gettext
56
+
57
+ Templates
58
+ - Support added for passing in locals to render_template
59
+ - Added support for symbol argument to template_root
60
+ - render_template no longer requires template extensions
61
+ - Dots allowed in template extensions (template.html.erb)
62
+
63
+ Templating Engines
64
+ - Builder templating engine added to produce XML
65
+ - RedCloth templating engine added
66
+ - Amrita2 templating engine updated to latest release
67
+
68
+ Helpers
69
+ - Simple EmailHelper added
70
+ - IdentityHelper updated for latest ruby-openid
71
+ - MarukuHelper added
72
+ - AuthHelper cleaned up
73
+ - LinkHelper improved: A(), R(), Rs() and breadcrumbs
74
+
75
+ Examples
76
+ - All examples were standardized to include rubygems
77
+ - Simple file upload example added
78
+ - Search and diff functionality added to Rapaste
79
+
80
+ Misc
81
+ - Read and read/write issues fixed in Ramaze::Store
82
+ - Fix applied for running Ramaze apps within IDEs on Windows
42
83
 
43
84
 
44
- Selected summary of the 118 patches from 0.2.1 to 0.3.0:
45
-
46
- - Specs switched from RSpec to bacon; Ramaze now runs on Ruby 1.9.
47
-
48
- - /lib/proto (pregenerated base source code) updated to a new structure.
49
-
50
- - Oddities in gem version of bin/ramaze fixed (hopefully? :) )
51
-
52
- - Layouts fixed so the method on the right controller is called.
53
-
54
- - contrib/facebook and simple facebook app example added.
55
-
56
- - Lambda router support added to contrib/route.
57
-
58
- - examples/rapaste added.
59
-
60
- - gettext contrib added; localize ramaze via gettext.
61
-
62
- - Adapter for Thin Ruby webserver added.
63
-
64
- - Index files can now be put into public directories and subdirectories.
65
-
66
- - examples/blog switched from Og to Sequel.
67
-
68
- - view/ is now the subdirectory for templates; if not found, Ramaze falls
69
- back to template/.
70
-
71
- - Default error pages updated: colour gradient removed; textmate link added;
72
- Javascript optimized; CSS tweaked.
73
-
74
- - Templates are no longer searched for in public/.
75
-
76
85
  A complete Changelog is available at
77
86
  http://darcs.ramaze.net/ramaze/doc/CHANGELOG
78
87
 
@@ -50,16 +50,14 @@ Ramaze comes at the moment only with a simple wrapper of the YAML::Store.
50
50
  So we are going to base this on the tools available, you can just do the same
51
51
  with your ORM or database-library of choice.
52
52
 
53
- So first, edit the `src/model.rb` to fit better into our application:
53
+ So first, create a `model/todolist.rb` for our application:
54
54
 
55
55
  TodoList = Store::Default.new('todolist.yaml')
56
56
 
57
57
  Let's add some items as well to have a base to start from.
58
58
 
59
- {
60
- 'Laundry' => {:done => false},
59
+ { 'Laundry' => {:done => false},
61
60
  'Wash dishes' => {:done => false},
62
-
63
61
  }.each do |title, value|
64
62
  TodoList[title] = value
65
63
  end
@@ -69,7 +67,7 @@ Let's add some items as well to have a base to start from.
69
67
 
70
68
  Now let's get our hands dirty and just edit the templates for our to-do list.
71
69
 
72
- Start with editing `template/index.xhtml`, it is using the default templating
70
+ Start with editing `view/index.xhtml`, it is using the default templating
73
71
  of Ramaze, called Ezamar.
74
72
 
75
73
  The index.xhtml currently contains a default welcome page, remove the contents.
@@ -142,7 +140,7 @@ application and secondly provides excellent ways of changing the complete
142
140
  Structure of the Model or View independent from each other.
143
141
 
144
142
  OK, enough of the theory, you will see the benefits in an instant. Go on and
145
- edit the file `src/controller/main.rb`.
143
+ edit the file `controller/main.rb`.
146
144
 
147
145
  The contents of it are like following:
148
146
 
@@ -208,12 +206,12 @@ Some things you should know:
208
206
  We set out to build the ultimate to-do list, but there are still some things
209
207
  missing. First off, we want to add new tasks, so let's get that done.
210
208
 
211
- Add a link on the `template/index.xhtml` like this:
209
+ Add a link on the `view/index.xhtml` like this:
212
210
 
213
211
  <h1>TodoList</h1>
214
212
  <a href="/new">New Task</a>
215
213
 
216
- Open a new file `template/new.xhtml` with a form to add a new task.
214
+ Open a new file `view/new.xhtml` with a form to add a new task.
217
215
 
218
216
  <html>
219
217
  <head>
@@ -267,7 +265,7 @@ Now you can create as many tasks as you want, please don't get overworked ;)
267
265
  Since the nature of tasks is to be done eventually
268
266
  we will need some way to mark it as done or open tasks again.
269
267
 
270
- Jump into `template/index.xhtml` and do the following:
268
+ Jump into `view/index.xhtml` and do the following:
271
269
 
272
270
 
273
271
  <?r @tasks.each do |title, status, toggle| ?>
@@ -369,7 +367,7 @@ and an corresponding method while we're at it:
369
367
  redirect Rs()
370
368
  end
371
369
 
372
- Now jumping to `template/index.xhtml` again, change it so it shows the link:
370
+ Now jumping to `view/index.xhtml` again, change it so it shows the link:
373
371
 
374
372
  <?r @tasks.each do |title, status, toggle, delete| ?>
375
373
  <li>
@@ -459,7 +457,7 @@ Please note that instance variables reflecting the parameters are set.
459
457
 
460
458
  And let's change our templates as well.
461
459
 
462
- First the `template/index.xhtml`
460
+ First the `view/index.xhtml`
463
461
 
464
462
  <Page title="TodoList">
465
463
  <a href="/new">New Task</a>
@@ -476,7 +474,7 @@ First the `template/index.xhtml`
476
474
  <?r end ?>
477
475
  </Page>
478
476
 
479
- and the `template/new.xhtml`
477
+ and the `view/new.xhtml`
480
478
 
481
479
  <Page title="New Task">
482
480
  <a href="/">Back to TodoList</a>
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'ramaze'
2
3
 
3
4
  require 'src/model'
data/examples/caching.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'ramaze'
2
3
 
3
4
  class MainController < Ramaze::Controller
data/examples/element.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'ramaze'
2
3
 
3
4
  class Page < Ezamar::Element
@@ -40,3 +41,5 @@ class MainController < Ramaze::Controller
40
41
  }
41
42
  end
42
43
  end
44
+
45
+ Ramaze.start
data/examples/hello.rb CHANGED
@@ -1,6 +1,4 @@
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
-
1
+ require 'rubygems'
4
2
  require 'ramaze'
5
3
 
6
4
  # you can access it now with http://localhost:7000/
data/examples/identity.rb CHANGED
@@ -1,6 +1,4 @@
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
-
1
+ require 'rubygems'
4
2
  require 'ramaze'
5
3
 
6
4
  class MainController < Ramaze::Controller
@@ -8,14 +6,13 @@ class MainController < Ramaze::Controller
8
6
 
9
7
  def index
10
8
  if session[:openid_identity]
11
- %{
12
- <h1>#{flash[:success]}</h1>
13
- <p>You are logged in as #{session[:openid_identity]}</p>
14
- }
9
+ %{<h1>#{flash[:success]}</h1>
10
+ <p>You are logged in as #{session[:openid_identity]}</p>}
15
11
  else
16
12
  openid_login_form
17
13
  end
18
14
  end
19
15
  end
20
16
 
21
- Ramaze.start
17
+ Ramaze::Inform.loggers.each{|l| l.log_levels << :dev }
18
+ Ramaze.start :adapter => :mongrel
data/examples/layout.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'ramaze'
2
3
 
3
4
  class MainController < Ramaze::Controller
data/examples/linking.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'ramaze'
2
3
 
3
4
  class LinkingController < Ramaze::Controller
@@ -1,6 +1,7 @@
1
1
  # Copyright (c) 2006 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 'rubygems'
4
5
  require 'ramaze'
5
6
 
6
7
  # you can access it now with http://localhost:7000/
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'ramaze'
2
3
 
3
4
  gem 'facets', '=1.4.5'
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'ramaze'
2
3
 
3
4
  require 'src/model'
@@ -26,3 +26,10 @@ task :fill do
26
26
  end
27
27
  end
28
28
  end
29
+
30
+ desc 'run specs'
31
+ task :spec do
32
+ sh 'ruby spec/rapaste.rb'
33
+ end
34
+
35
+ task :default => :spec
@@ -17,7 +17,16 @@ class PasteController < Ramaze::Controller
17
17
  @paginated = ordered.paginate(start.to_i, 10)
18
18
  @pager = paginator(@paginated, '/list/page')
19
19
  @pastes = @paginated
20
- @style = session[ :theme ] || STYLE
20
+ @style = style
21
+ end
22
+
23
+ def search
24
+ if needle = request['substring'] and not needle.empty?
25
+ limit = 50
26
+ @pastes = Paste.where( "text LIKE '%' || ? || '%'", request[ 'substring' ] ).limit( limit ).order( :created.DESC ).all
27
+ @hit_limit = ( @pastes.size == limit )
28
+ @style = session[ :theme ] || STYLE
29
+ end
21
30
  end
22
31
 
23
32
  def save
@@ -40,8 +49,7 @@ class PasteController < Ramaze::Controller
40
49
  def view(id, format)
41
50
  @paste, @format = paste_for(id), format
42
51
  @syntax = @paste.syntax_name
43
- @style = session[ :theme ] || STYLE
44
- @formatted = @paste.view(format, @style)
52
+ @formatted = @paste.view(format, style)
45
53
 
46
54
  ordered = Paste.order(:created.DESC)
47
55
  @paginated = ordered.paginate(id.to_i, 1)
@@ -60,10 +68,27 @@ class PasteController < Ramaze::Controller
60
68
  session[ :theme ] = theme_name
61
69
  end
62
70
 
71
+ def diff(from, to)
72
+ paste1, paste2 = Paste[from], Paste[to]
73
+ cs1 = Digest::MD5.hexdigest(paste1.text)
74
+ cs2 = Digest::MD5.hexdigest(paste2.text)
75
+ File.open(f1 = Dir.tmpdir/cs1, 'w+'){|io| io.puts(paste1.text) }
76
+ File.open(f2 = Dir.tmpdir/cs2, 'w+'){|io| io.puts(paste2.text) }
77
+ diff = `diff -up #{f1} #{f2}`.strip
78
+ FileUtils.rm(f1)
79
+ FileUtils.rm(f2)
80
+
81
+ Uv.parse(diff, 'xhtml', 'diff', true, style)
82
+ end
83
+
63
84
  private
64
85
 
65
86
  def paste_for(id)
66
87
  redirect Rs() unless paste = Paste[:id => id.to_i]
67
88
  paste
68
89
  end
90
+
91
+ def style
92
+ @style ||= session[ :theme ] || STYLE
93
+ end
69
94
  end
@@ -1,7 +1,3 @@
1
- require 'sequel'
2
-
3
- DB = Sequel('sqlite:///rapaste.sqlite')
4
-
5
1
  class Paste < Sequel::Model(:paste)
6
2
  set_schema do
7
3
  primary_key :id
@@ -81,6 +81,12 @@ div.item_meta span.syntax {
81
81
  border-right: 1px solid #ccc;
82
82
  }
83
83
 
84
+ div.item_meta span.paste_id {
85
+ background: #fff;
86
+ padding: 0em 0.5em 0em 0.5em;
87
+ border-right: 1px solid #ccc;
88
+ }
89
+
84
90
  div.item pre {
85
91
  margin: 0.5em;
86
92
  padding: 0.5em;
@@ -177,3 +183,14 @@ div#menu {
177
183
  background: #ddd;
178
184
  text-align: center;
179
185
  }
186
+
187
+ form#search {
188
+ position: absolute;
189
+ top: 0px;
190
+ right: 0px;
191
+ font-size: 0.9em;
192
+ }
193
+
194
+ form#search input {
195
+ font-size: 0.9em;
196
+ }
@@ -9,7 +9,7 @@ require 'start'
9
9
  describe 'RaPaste' do
10
10
  behaves_like 'http'
11
11
  ramaze :public_root => base/:public,
12
- :template_root => base/:template
12
+ :template_root => base/:view
13
13
 
14
14
  it 'should show an empty list on the list page' do
15
15
  page = get('/list')
@@ -24,7 +24,7 @@ describe 'RaPaste' do
24
24
 
25
25
  it 'should show a new paste form' do
26
26
  page = get('/')
27
- form = Hpricot(page.body).at(:form)
27
+ form = Hpricot(page.body).at('form#new_paste')
28
28
  form[:action].should == '/save'
29
29
  form[:method].should == 'POST'
30
30
  form.at(:textarea)[:name].should == 'text'
@@ -1,4 +1,8 @@
1
+ require 'rubygems'
2
+ require 'tmpdir'
3
+
1
4
  require 'ramaze'
5
+ require 'sequel'
2
6
  require 'uv'
3
7
 
4
8
  Ramaze::Inform.debug "Initializing UltraViolet..."
@@ -11,10 +15,11 @@ UV_PRIORITY_NAMES = %w[ ruby plain_text html css javascript yaml diff ]
11
15
  STYLE = 'iplastic'
12
16
 
13
17
  Ramaze::Inform.debug "done."
14
-
15
18
  Ramaze.contrib :route
16
19
 
17
- require 'src/model'
18
- require 'src/controller'
20
+ DB = Sequel.sqlite
21
+
22
+ require 'model/paste'
23
+ require 'controller/paste'
19
24
 
20
- Ramaze.start :adapter => :mongrel, :port => 9952
25
+ Ramaze.start
File without changes
File without changes
@@ -12,6 +12,9 @@
12
12
  <div id="menu">
13
13
  <a href="/">New</a>
14
14
  <a href="/list">List</a>
15
+ <form id="search" action="/search" method="GET">
16
+ Search: <input type="text" name="substring"/>
17
+ </form>
15
18
  </div>
16
19
  #@content
17
20
  <div id="footer">