Capcode 0.8.9 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/README.rdoc +13 -1
  2. data/doc/rdoc/classes/Capcode.html +410 -545
  3. data/doc/rdoc/classes/Capcode/Configuration.html +263 -0
  4. data/doc/rdoc/classes/Capcode/Helpers.html +154 -345
  5. data/doc/rdoc/classes/Capcode/Helpers/Authorization.html +6 -6
  6. data/doc/rdoc/created.rid +1 -1
  7. data/doc/rdoc/files/README_rdoc.html +42 -2
  8. data/doc/rdoc/files/lib/capcode/configuration_rb.html +1 -1
  9. data/doc/rdoc/files/lib/capcode/render/text_rb.html +1 -1
  10. data/doc/rdoc/files/lib/capcode_rb.html +14 -1
  11. data/doc/rdoc/fr_class_index.html +1 -1
  12. data/doc/rdoc/fr_file_index.html +0 -13
  13. data/doc/rdoc/fr_method_index.html +12 -14
  14. data/examples/render-image.rb +1 -1
  15. data/examples/render-text.rb +4 -1
  16. data/examples/rest.rb +1 -0
  17. data/examples/sample.rb +5 -3
  18. data/examples/upload.rb +1 -0
  19. data/lib/capcode.rb +45 -61
  20. data/lib/capcode/configuration.rb +69 -34
  21. data/lib/capcode/render/text.rb +1 -1
  22. data/lib/capcode/version.rb +1 -1
  23. metadata +31 -106
  24. data/doc/rdoc/classes/Capcode/Mab.html +0 -118
  25. data/doc/rdoc/files/lib/capcode/render/binary_rb.html +0 -101
  26. data/doc/rdoc/files/lib/capcode/render/email_rb.html +0 -108
  27. data/doc/rdoc/files/lib/capcode/render/erb_rb.html +0 -108
  28. data/doc/rdoc/files/lib/capcode/render/haml_rb.html +0 -108
  29. data/doc/rdoc/files/lib/capcode/render/json_rb.html +0 -108
  30. data/doc/rdoc/files/lib/capcode/render/markaby_rb.html +0 -108
  31. data/doc/rdoc/files/lib/capcode/render/mustache_rb.html +0 -108
  32. data/doc/rdoc/files/lib/capcode/render/none_rb.html +0 -101
  33. data/doc/rdoc/files/lib/capcode/render/redirect_rb.html +0 -101
  34. data/doc/rdoc/files/lib/capcode/render/sass_rb.html +0 -108
  35. data/doc/rdoc/files/lib/capcode/render/static_rb.html +0 -101
  36. data/doc/rdoc/files/lib/capcode/render/webdav_rb.html +0 -124
  37. data/doc/rdoc/files/lib/capcode/render/xml_rb.html +0 -101
  38. data/examples/auth-webdav.rb +0 -29
  39. data/examples/blog-ar.rb +0 -81
  40. data/examples/blog-ar.yml +0 -3
  41. data/examples/blog-couchdb-run.rb +0 -10
  42. data/examples/blog-couchdb.rb +0 -314
  43. data/examples/blog-couchdb.ru +0 -12
  44. data/examples/blog-couchdb.yml +0 -2
  45. data/examples/blog-dm.rb +0 -63
  46. data/examples/blog-dm.yml +0 -2
  47. data/examples/blog-mongodb-run.rb +0 -10
  48. data/examples/blog-mongodb.rb +0 -304
  49. data/examples/blog-mongodb.yml +0 -3
  50. data/examples/blog-sq.rb +0 -82
  51. data/examples/blog-sq.yml +0 -3
  52. data/examples/mail/mail_html.rhtml +0 -1
  53. data/examples/mail/mail_text.rhtml +0 -1
  54. data/examples/mail/ok.rhtml +0 -1
  55. data/examples/mail/rubyfr.png +0 -0
  56. data/examples/mustache/with_class.mustache +0 -8
  57. data/examples/mustache/without_class.mustache +0 -1
  58. data/examples/render-binary.rb +0 -46
  59. data/examples/render-email.rb +0 -68
  60. data/examples/render-erb.rb +0 -19
  61. data/examples/render-haml_sass.rb +0 -26
  62. data/examples/render-json.rb +0 -13
  63. data/examples/render-markaby.rb +0 -29
  64. data/examples/render-mustache.rb +0 -30
  65. data/examples/render-redirect.rb +0 -19
  66. data/examples/render-static.rb +0 -21
  67. data/examples/render-static.ru +0 -19
  68. data/examples/render-use.rb +0 -32
  69. data/examples/render-webdav.rb +0 -26
  70. data/examples/render-xml.rb +0 -24
  71. data/examples/rss.rb +0 -48
  72. data/examples/static/coderay.css +0 -131
  73. data/examples/static/index.html +0 -24
  74. data/examples/test/index.html +0 -1
  75. data/lib/capcode/base/ar.rb +0 -54
  76. data/lib/capcode/base/couchdb.rb +0 -23
  77. data/lib/capcode/base/dm.rb +0 -33
  78. data/lib/capcode/base/mongodb.rb +0 -27
  79. data/lib/capcode/base/sq.rb +0 -58
  80. data/lib/capcode/render/binary.rb +0 -8
  81. data/lib/capcode/render/email.rb +0 -73
  82. data/lib/capcode/render/erb.rb +0 -59
  83. data/lib/capcode/render/haml.rb +0 -60
  84. data/lib/capcode/render/json.rb +0 -14
  85. data/lib/capcode/render/markaby.rb +0 -38
  86. data/lib/capcode/render/mustache.rb +0 -37
  87. data/lib/capcode/render/none.rb +0 -7
  88. data/lib/capcode/render/redirect.rb +0 -7
  89. data/lib/capcode/render/sass.rb +0 -48
  90. data/lib/capcode/render/static.rb +0 -14
  91. data/lib/capcode/render/webdav.rb +0 -49
  92. data/lib/capcode/render/xml.rb +0 -119
@@ -1,3 +0,0 @@
1
- host: localhost
2
- port: 27017
3
- database: my_blog
@@ -1,82 +0,0 @@
1
- $:.unshift( "../lib" )
2
- require 'rubygems'
3
- require 'capcode'
4
- require 'capcode/base/sq'
5
-
6
- class Basic < Capcode::Model 1.0
7
- def up
8
- create_table :stories do
9
- primary_key :id
10
- String :title
11
- String :body
12
- String :date
13
- end
14
- end
15
- end
16
-
17
- class UpdateBasic < Capcode::Model 1.1
18
- def up
19
- create_table :users do
20
- String :name
21
- String :password
22
- end
23
- end
24
-
25
- def down
26
- drop_table :users
27
- end
28
- end
29
-
30
- class Story < Capcode::Base
31
- include Capcode::Resource
32
- end
33
-
34
- module Capcode
35
- class HTTPError
36
- def r404(f)
37
- "Pas glop !!! #{f} est inconnu !!!"
38
- end
39
- end
40
-
41
- class Index < Route '/'
42
- def get
43
- r = "<html><body>"
44
-
45
- story = Story.all
46
-
47
- story.each do |s|
48
- r += "<h2>#{s[:title]}</h2><small>#{s[:date]} - <a href='#{URL( Remove, s[:id] )}'>Delete this entry</a></small><p>#{s[:body]}</p>"
49
- end
50
-
51
- r+"<hr /><a href='#{URL(Add)}'>Add a new entry</a></body></html>"
52
- end
53
- end
54
-
55
- class Remove < Route '/remove/([^\/]*)'
56
- def get( id )
57
- Story.filter(:id => id).delete
58
- redirect( Index )
59
- end
60
- end
61
-
62
- class Add < Route '/add'
63
- def get
64
- '
65
- <html><body>
66
- <h1>Add a new entry</h1>
67
- <form method="POST">
68
- Titre : <input type="text" name="title"><br />
69
- <textarea name="body"></textarea><br />
70
- <input type="submit">
71
- </form>
72
- </body></html>
73
- '
74
- end
75
- def post
76
- Story.insert( :title => params['title'], :body => params['body'], :date => Time.now.to_s )
77
- redirect( Index )
78
- end
79
- end
80
- end
81
-
82
- Capcode.run( :port => 3001, :host => "localhost", :db_config => "blog-sq.yml" )
@@ -1,3 +0,0 @@
1
- adapter: sqlite3
2
- database: sq_blog.db
3
- schema_version: 1.0
@@ -1 +0,0 @@
1
- This mail was send at <b><%= @time %></b>
@@ -1 +0,0 @@
1
- This mail was send at <%= @time %>
@@ -1 +0,0 @@
1
- Mail <b>send !!!</b>
Binary file
@@ -1,8 +0,0 @@
1
- <html>
2
- <head>
3
- <title>Capcode render with mustache ;)</title>
4
- </head>
5
- <body>
6
- Bonjour, il est {{time}}
7
- </body>
8
- </html>
@@ -1 +0,0 @@
1
- Bonjour, il est {{time}}
@@ -1,46 +0,0 @@
1
- $:.unshift( "../lib" )
2
- require 'capcode'
3
- require 'capcode/render/markaby'
4
- require 'capcode/render/binary'
5
- require 'rubygems'
6
- require 'graphviz'
7
-
8
- module Capcode
9
- class Index < Route '/'
10
- def get
11
- render :markaby => :index
12
- end
13
- end
14
-
15
- class Image < Route '/image'
16
- def get
17
- render :binary => :image, :content_type => "image/png"
18
- end
19
- end
20
- end
21
-
22
- module Capcode::Views
23
- def glop
24
- html do
25
- body do
26
- yield
27
- end
28
- end
29
- end
30
-
31
- def index
32
- h1 "Hello !"
33
- img :src => URL(Capcode::Image)
34
- end
35
-
36
- def image
37
- GraphViz::new( "G" ) { |g|
38
- g.hello << g.world
39
- g.bonjour - g.monde
40
- g.hola > g.mundo
41
- g.holla >> g.welt
42
- }.output( :png => String )
43
- end
44
- end
45
-
46
- Capcode.run( )
@@ -1,68 +0,0 @@
1
- $:.unshift( "../lib" )
2
- require 'capcode'
3
- require 'rubygems'
4
- require 'capcode/render/email'
5
- require 'capcode/render/markaby'
6
- require 'capcode/render/erb'
7
- require 'capcode/render/static'
8
- require 'graphviz'
9
-
10
- module Capcode
11
- set :smtp, { :server => '127.0.0.1', :port => 25 }
12
- set :erb, "mail"
13
- set :static, "mail"
14
-
15
- class Index < Route '/'
16
- def get
17
- render :markaby => :index
18
- end
19
- end
20
-
21
- class SendMail < Route '/send'
22
- def get
23
- @time = Time.now
24
- render :email => {
25
- :from => 'you@yourdomain.com',
26
- :to => 'friend@hisdomain.com',
27
- :subject => "Mail renderer example...",
28
-
29
- :body => {
30
- :text => { :erb => :mail_text },
31
- :html => { :erb => :mail_html, :content_type => 'text/html; charset=UTF-8' }
32
- },
33
- :file => [
34
- { :data => :image, :filename => "hello.png", :mime_type => "image/png" },
35
- "rubyfr.png"
36
- ],
37
- :ok => { :erb => :ok },
38
- :error => { :redirect => Index }
39
- }
40
- end
41
- end
42
- end
43
-
44
- module Capcode::Views
45
- def glop
46
- html do
47
- body do
48
- yield
49
- end
50
- end
51
- end
52
-
53
- def index
54
- h1 "Send me an email"
55
- a "Send mail", :href => URL(Capcode::SendMail)
56
- end
57
-
58
- def image
59
- GraphViz::new( "G" ) { |g|
60
- g.hello << g.world
61
- g.bonjour - g.monde
62
- g.hola > g.mundo
63
- g.holla >> g.welt
64
- }.output( :png => String )
65
- end
66
- end
67
-
68
- Capcode.run( )
@@ -1,19 +0,0 @@
1
- $:.unshift( "../lib" )
2
- require 'capcode'
3
- require 'capcode/render/erb'
4
- #Capcode::Helpers.erb_path="erb"
5
- require 'rack/bug'
6
-
7
- module Capcode
8
- set :erb, "erb"
9
- use Rack::Bug
10
-
11
- class Index < Route '/'
12
- def get
13
- @time = Time.now
14
- render :erb => :cf, :layout => :cf_layout
15
- end
16
- end
17
- end
18
-
19
- Capcode.run( )
@@ -1,26 +0,0 @@
1
- $:.unshift( "../lib" )
2
- require 'capcode'
3
- require 'capcode/render/haml'
4
- require 'capcode/render/sass'
5
- #Capcode::Helpers.haml_path="haml"
6
- #Capcode::Helpers.sass_path="haml"
7
-
8
- module Capcode
9
- set :haml, "haml"
10
- set :sass, "haml"
11
-
12
- class Index < Route '/'
13
- def get
14
- @time = Time.now
15
- render :haml => :cf, :layout => :cf_layout
16
- end
17
- end
18
-
19
- class CSS < Route '/style.css'
20
- def get
21
- render :sass => :style
22
- end
23
- end
24
- end
25
-
26
- Capcode.run( )
@@ -1,13 +0,0 @@
1
- $:.unshift( "../lib" )
2
- require 'capcode'
3
- require 'capcode/render/json'
4
-
5
- module Capcode
6
- class Index < Route '/'
7
- def get
8
- render :json => { :hello => "Hello World", :values => [1, 2, 3] }
9
- end
10
- end
11
- end
12
-
13
- Capcode.run( )
@@ -1,29 +0,0 @@
1
- $:.unshift( "../lib" )
2
- require 'capcode'
3
- require 'capcode/render/markaby'
4
-
5
- module Capcode
6
- class Index < Route '/'
7
- def get
8
- @time = Time.now()
9
- render :markaby => :index, :layout => :glop
10
- end
11
- end
12
- end
13
-
14
- module Capcode::Views
15
- def glop
16
- html do
17
- body do
18
- yield
19
- end
20
- end
21
- end
22
-
23
- def index
24
- h1 "Hello !"
25
- p "il est #{@time}"
26
- end
27
- end
28
-
29
- Capcode.run( )
@@ -1,30 +0,0 @@
1
- $:.unshift( "../lib" )
2
- require 'capcode'
3
- require 'capcode/render/mustache'
4
-
5
- module Capcode
6
- set :mustache, "mustache"
7
-
8
- class Index < Route '/'
9
- def get
10
- @time = Time.now
11
- render :mustache => :with_class
12
- end
13
- end
14
-
15
- class WithoutClass < Route '/without'
16
- def get
17
- render :mustache => :without_class, :time => Time.now
18
- end
19
- end
20
- end
21
-
22
- module Capcode::Views
23
- class WithClass < Mustache
24
- def time
25
- @time
26
- end
27
- end
28
- end
29
-
30
- Capcode.run( )
@@ -1,19 +0,0 @@
1
- $:.unshift( "../lib" )
2
- require 'capcode'
3
- require 'capcode/render/redirect'
4
-
5
- module Capcode
6
- class Index < Route '/'
7
- def get
8
- render :redirect => Hello
9
- end
10
- end
11
-
12
- class Hello < Route '/hello'
13
- def get
14
- render :text => "Hello World!"
15
- end
16
- end
17
- end
18
-
19
- Capcode.run( )
@@ -1,21 +0,0 @@
1
- $:.unshift( "../lib" )
2
- require 'capcode'
3
- require 'capcode/render/static'
4
-
5
- module Capcode
6
- set :static, "static"
7
- set :verbose, true
8
-
9
- class Index < Route '/'
10
- def get
11
- render :static => "index.html"
12
- end
13
- end
14
- class Path < Route '/path'
15
- def get
16
- render :static => "index.html", :exact_path => false
17
- end
18
- end
19
- end
20
-
21
- Capcode.run( )
@@ -1,19 +0,0 @@
1
- $:.unshift( "../lib" )
2
- require 'capcode'
3
- require 'capcode/render/static'
4
-
5
- module Capcode
6
- class Index < Route '/'
7
- def get
8
- render :static => "index.html"
9
- end
10
- end
11
- class Path < Route '/path'
12
- def get
13
- render :static => "index.html", :exact_path => false
14
- end
15
- end
16
- end
17
-
18
- ## WARNING : when using rackup, :root default is the rackup directory (eg. /usr/bin or something like that) !
19
- run Capcode.application( :static => "static", :verbose => true, :root => File.expand_path(File.dirname(__FILE__)) )
@@ -1,32 +0,0 @@
1
- $:.unshift( "../lib" )
2
- require 'capcode'
3
- require 'capcode/render/static'
4
-
5
- require 'coderay'
6
- require 'rack/codehighlighter'
7
-
8
- module Capcode
9
- set :static, "static"
10
- set :verbose, true
11
- set :server, :thin
12
-
13
- use Rack::Codehighlighter, :coderay, :element => "pre", :pattern => /\A:::(\w+)\s*\n/, :logging => false
14
-
15
- class Index < Route '/'
16
- def get
17
- render :static => "index.html"
18
- end
19
- end
20
- class Path < Route '/path'
21
- def get
22
- render :static => "index.html", :exact_path => false
23
- end
24
- end
25
- class Style < Route '/style'
26
- def get
27
- render :static => "coderay.css", :exact_path => false
28
- end
29
- end
30
- end
31
-
32
- Capcode.run( )