Capcode 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/README.rdoc +58 -0
  2. data/doc/rdoc/classes/Capcode.html +938 -0
  3. data/doc/rdoc/classes/Capcode/Base.html +136 -0
  4. data/doc/rdoc/classes/Capcode/HTTPError.html +134 -0
  5. data/doc/rdoc/classes/Capcode/Helpers.html +608 -0
  6. data/doc/rdoc/classes/Capcode/Helpers/Authorization.html +188 -0
  7. data/doc/rdoc/classes/Capcode/Mab.html +118 -0
  8. data/doc/rdoc/classes/Capcode/Resource.html +111 -0
  9. data/doc/rdoc/classes/Capcode/Views.html +112 -0
  10. data/doc/rdoc/created.rid +1 -0
  11. data/doc/rdoc/files/AUTHORS.html +107 -0
  12. data/doc/rdoc/files/COPYING.html +531 -0
  13. data/doc/rdoc/files/README_rdoc.html +601 -0
  14. data/doc/rdoc/files/lib/capcode/base/db_rb.html +101 -0
  15. data/doc/rdoc/files/lib/capcode/helpers/auth_rb.html +132 -0
  16. data/doc/rdoc/files/lib/capcode/render/erb_rb.html +108 -0
  17. data/doc/rdoc/files/lib/capcode/render/haml_rb.html +108 -0
  18. data/doc/rdoc/files/lib/capcode/render/json_rb.html +108 -0
  19. data/doc/rdoc/files/lib/capcode/render/markaby_rb.html +108 -0
  20. data/doc/rdoc/files/lib/capcode/render/sass_rb.html +108 -0
  21. data/doc/rdoc/files/lib/capcode/render/static_rb.html +101 -0
  22. data/doc/rdoc/files/lib/capcode/render/text_rb.html +101 -0
  23. data/doc/rdoc/files/lib/capcode/render/webdav_rb.html +124 -0
  24. data/doc/rdoc/files/lib/capcode/render/xml_rb.html +101 -0
  25. data/doc/rdoc/files/lib/capcode_rb.html +119 -0
  26. data/doc/rdoc/fr_class_index.html +34 -0
  27. data/doc/rdoc/fr_file_index.html +41 -0
  28. data/doc/rdoc/fr_method_index.html +44 -0
  29. data/doc/rdoc/index.html +24 -0
  30. data/doc/rdoc/rdoc-style.css +208 -0
  31. data/examples/auth-basic.rb +46 -0
  32. data/examples/auth-digest.rb +47 -0
  33. data/examples/auth-webdav.rb +29 -0
  34. data/examples/blog-couchdb-run.rb +10 -0
  35. data/examples/blog-couchdb.rb +8 -8
  36. data/examples/blog-couchdb.ru +12 -0
  37. data/examples/render-static.rb +1 -1
  38. data/examples/render-static.ru +21 -0
  39. data/examples/render-webdav.rb +26 -0
  40. data/examples/rest-run.rb +3 -0
  41. data/examples/rest.rb +1 -1
  42. data/examples/rest.ru +3 -0
  43. data/lib/capcode.rb +196 -100
  44. data/lib/capcode/helpers/auth.rb +130 -0
  45. data/lib/capcode/render/webdav.rb +45 -0
  46. data/lib/capcode/version.rb +1 -1
  47. metadata +45 -3
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
5
+
6
+ <!--
7
+
8
+ Capcode, the Documentation
9
+
10
+ -->
11
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
12
+ <head>
13
+ <title>Capcode, the Documentation</title>
14
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
15
+ </head>
16
+ <frameset rows="20%, 80%">
17
+ <frameset cols="25%,35%,45%">
18
+ <frame src="fr_file_index.html" title="Files" name="Files" />
19
+ <frame src="fr_class_index.html" name="Classes" />
20
+ <frame src="fr_method_index.html" name="Methods" />
21
+ </frameset>
22
+ <frame src="files/README_rdoc.html" name="docwin" />
23
+ </frameset>
24
+ </html>
@@ -0,0 +1,208 @@
1
+
2
+ body {
3
+ font-family: Verdana,Arial,Helvetica,sans-serif;
4
+ font-size: 90%;
5
+ margin: 0;
6
+ margin-left: 40px;
7
+ padding: 0;
8
+ background: white;
9
+ }
10
+
11
+ h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
12
+ h1 { font-size: 150%; }
13
+ h2,h3,h4 { margin-top: 1em; }
14
+
15
+ a { background: #eef; color: #039; text-decoration: none; }
16
+ a:hover { background: #039; color: #eef; }
17
+
18
+ /* Override the base stylesheet's Anchor inside a table cell */
19
+ td > a {
20
+ background: transparent;
21
+ color: #039;
22
+ text-decoration: none;
23
+ }
24
+
25
+ /* and inside a section title */
26
+ .section-title > a {
27
+ background: transparent;
28
+ color: #eee;
29
+ text-decoration: none;
30
+ }
31
+
32
+ /* === Structural elements =================================== */
33
+
34
+ div#index {
35
+ margin: 0;
36
+ margin-left: -40px;
37
+ padding: 0;
38
+ font-size: 90%;
39
+ }
40
+
41
+
42
+ div#index a {
43
+ margin-left: 0.7em;
44
+ }
45
+
46
+ div#index .section-bar {
47
+ margin-left: 0px;
48
+ padding-left: 0.7em;
49
+ background: #ccc;
50
+ font-size: small;
51
+ }
52
+
53
+
54
+ div#classHeader, div#fileHeader {
55
+ width: auto;
56
+ color: white;
57
+ padding: 0.5em 1.5em 0.5em 1.5em;
58
+ margin: 0;
59
+ margin-left: -40px;
60
+ border-bottom: 3px solid #006;
61
+ }
62
+
63
+ div#classHeader a, div#fileHeader a {
64
+ background: inherit;
65
+ color: white;
66
+ }
67
+
68
+ div#classHeader td, div#fileHeader td {
69
+ background: inherit;
70
+ color: white;
71
+ }
72
+
73
+
74
+ div#fileHeader {
75
+ background: #057;
76
+ }
77
+
78
+ div#classHeader {
79
+ background: #048;
80
+ }
81
+
82
+
83
+ .class-name-in-header {
84
+ font-size: 180%;
85
+ font-weight: bold;
86
+ }
87
+
88
+
89
+ div#bodyContent {
90
+ padding: 0 1.5em 0 1.5em;
91
+ }
92
+
93
+ div#description {
94
+ padding: 0.5em 1.5em;
95
+ background: #efefef;
96
+ border: 1px dotted #999;
97
+ }
98
+
99
+ div#description h1,h2,h3,h4,h5,h6 {
100
+ color: #125;;
101
+ background: transparent;
102
+ }
103
+
104
+ div#validator-badges {
105
+ text-align: center;
106
+ }
107
+ div#validator-badges img { border: 0; }
108
+
109
+ div#copyright {
110
+ color: #333;
111
+ background: #efefef;
112
+ font: 0.75em sans-serif;
113
+ margin-top: 5em;
114
+ margin-bottom: 0;
115
+ padding: 0.5em 2em;
116
+ }
117
+
118
+
119
+ /* === Classes =================================== */
120
+
121
+ table.header-table {
122
+ color: white;
123
+ font-size: small;
124
+ }
125
+
126
+ .type-note {
127
+ font-size: small;
128
+ color: #DEDEDE;
129
+ }
130
+
131
+ .xxsection-bar {
132
+ background: #eee;
133
+ color: #333;
134
+ padding: 3px;
135
+ }
136
+
137
+ .section-bar {
138
+ color: #333;
139
+ border-bottom: 1px solid #999;
140
+ margin-left: -20px;
141
+ }
142
+
143
+
144
+ .section-title {
145
+ background: #79a;
146
+ color: #eee;
147
+ padding: 3px;
148
+ margin-top: 2em;
149
+ margin-left: -30px;
150
+ border: 1px solid #999;
151
+ }
152
+
153
+ .top-aligned-row { vertical-align: top }
154
+ .bottom-aligned-row { vertical-align: bottom }
155
+
156
+ /* --- Context section classes ----------------------- */
157
+
158
+ .context-row { }
159
+ .context-item-name { font-family: monospace; font-weight: bold; color: black; }
160
+ .context-item-value { font-size: small; color: #448; }
161
+ .context-item-desc { color: #333; padding-left: 2em; }
162
+
163
+ /* --- Method classes -------------------------- */
164
+ .method-detail {
165
+ background: #efefef;
166
+ padding: 0;
167
+ margin-top: 0.5em;
168
+ margin-bottom: 1em;
169
+ border: 1px dotted #ccc;
170
+ }
171
+ .method-heading {
172
+ color: black;
173
+ background: #ccc;
174
+ border-bottom: 1px solid #666;
175
+ padding: 0.2em 0.5em 0 0.5em;
176
+ }
177
+ .method-signature { color: black; background: inherit; }
178
+ .method-name { font-weight: bold; }
179
+ .method-args { font-style: italic; }
180
+ .method-description { padding: 0 0.5em 0 0.5em; }
181
+
182
+ /* --- Source code sections -------------------- */
183
+
184
+ a.source-toggle { font-size: 90%; }
185
+ div.method-source-code {
186
+ background: #262626;
187
+ color: #ffdead;
188
+ margin: 1em;
189
+ padding: 0.5em;
190
+ border: 1px dashed #999;
191
+ overflow: hidden;
192
+ }
193
+
194
+ div.method-source-code pre { color: #ffdead; overflow: hidden; }
195
+
196
+ /* --- Ruby keyword styles --------------------- */
197
+
198
+ .standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
199
+
200
+ .ruby-constant { color: #7fffd4; background: transparent; }
201
+ .ruby-keyword { color: #00ffff; background: transparent; }
202
+ .ruby-ivar { color: #eedd82; background: transparent; }
203
+ .ruby-operator { color: #00ffee; background: transparent; }
204
+ .ruby-identifier { color: #ffdead; background: transparent; }
205
+ .ruby-node { color: #ffa07a; background: transparent; }
206
+ .ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
207
+ .ruby-regexp { color: #ffa07a; background: transparent; }
208
+ .ruby-value { color: #7fffd4; background: transparent; }
@@ -0,0 +1,46 @@
1
+ $:.unshift( "../lib" )
2
+ require 'capcode'
3
+
4
+ module Capcode
5
+
6
+ http_authentication( :type => :basic, :realm => "Private part", :routes => "/noauth/private" ) {
7
+ {
8
+ "greg" => "toto",
9
+ "mu" => "maia"
10
+ }
11
+ }
12
+
13
+ class Index < Route '/admin'
14
+ def get
15
+ # Basic HTTP Authentication
16
+ http_authentication( :type => :basic, :realm => "Admin part" ) {
17
+ {
18
+ "greg" => "toto",
19
+ "mu" => "maia"
20
+ }
21
+ }
22
+ render "Success !"
23
+ end
24
+ end
25
+
26
+ class Noauth < Route '/noauth'
27
+ def get
28
+ render "You don't need any special authorization here !"
29
+ end
30
+ end
31
+
32
+ class Private < Route '/noauth/private'
33
+ def get
34
+ render "Welcome in the private part !"
35
+ end
36
+ end
37
+
38
+ class Private2 < Route '/noauth/private/again'
39
+ def get
40
+ render "Welcome in the private/again part !"
41
+ end
42
+ end
43
+
44
+ end
45
+
46
+ Capcode.run( )
@@ -0,0 +1,47 @@
1
+ $:.unshift( "../lib" )
2
+ require 'capcode'
3
+ require 'digest/md5'
4
+
5
+ module Capcode
6
+ OPAQUE = Digest::MD5.hexdigest( Time.now.to_s )
7
+ http_authentication( :type => :digest, :opaque => OPAQUE, :realm => "Private part", :routes => "/noauth/private" ) {
8
+ {
9
+ "greg" => "toto",
10
+ "mu" => "maia"
11
+ }
12
+ }
13
+
14
+ class Index < Route '/admin'
15
+ def get
16
+ # Basic HTTP Authentication
17
+ http_authentication( :type => :digest, :opaque => OPAQUE, :realm => "Admin part" ) {
18
+ {
19
+ "greg" => "toto",
20
+ "mu" => "maia"
21
+ }
22
+ }
23
+ render "Welcome in admin part #{request.env['REMOTE_USER']}"
24
+ end
25
+ end
26
+
27
+ class Noauth < Route '/noauth'
28
+ def get
29
+ render "You don't need any special authorization here !"
30
+ end
31
+ end
32
+
33
+ class Private < Route '/noauth/private'
34
+ def get
35
+ render "Welcome in the private part #{request.env['REMOTE_USER']}"
36
+ end
37
+ end
38
+
39
+ class Private2 < Route '/noauth/private/again'
40
+ def get
41
+ render "Welcome in the private/again part #{request.env['REMOTE_USER']}"
42
+ end
43
+ end
44
+
45
+ end
46
+
47
+ Capcode.run( )
@@ -0,0 +1,29 @@
1
+ $:.unshift( "../lib" )
2
+ require 'capcode'
3
+ require 'capcode/render/webdav'
4
+
5
+ module Capcode
6
+
7
+ # Render file from /Users/greg/temp !!!
8
+ class WebDav < Route '/temp'
9
+ def get
10
+ http_authentication( :type => :digest, :realm => "My WebDAV Directory !!!" ) {
11
+ {"greg" => "toto"}
12
+ }
13
+ render :webdav => "/Users/greg"
14
+ end
15
+
16
+ def method_missing(id, *a, &b)
17
+ get
18
+ end
19
+ end
20
+
21
+ class Index < Route '/'
22
+ def get
23
+ render "WebDav server acces : <a href='#{URL(Capcode::WebDav)}'>#{URL(Capcode::WebDav)}</a>"
24
+ end
25
+ end
26
+
27
+ end
28
+
29
+ Capcode.run( )
@@ -0,0 +1,10 @@
1
+ require 'blog-couchdb'
2
+
3
+ Capcode.run( :port => 3001, :host => "localhost", :db_config => "blog-couchdb.yml" ) do |c|
4
+ admin = User.find_by_login( "admin" )
5
+ if admin.nil?
6
+ puts "Create admin user..."
7
+ admin = User.create( :login => "admin", :passwd => "admin" )
8
+ end
9
+ puts "Admin user : \n\tlogin = #{admin.login}\n\tpassword = #{admin.passwd}"
10
+ end
@@ -203,14 +203,14 @@ module Capcode::Views
203
203
 
204
204
  end
205
205
 
206
- Capcode.run( :port => 3001, :host => "localhost", :db_config => "blog-couchdb.yml" ) do |c|
207
- admin = User.find_by_login( "admin" )
208
- if admin.nil?
209
- puts "Create admin user..."
210
- admin = User.create( :login => "admin", :passwd => "admin" )
211
- end
212
- puts "Admin user : \n\tlogin = #{admin.login}\n\tpassword = #{admin.passwd}"
213
- end
206
+ #Capcode.run( :port => 3001, :host => "localhost", :db_config => "blog-couchdb.yml" ) do |c|
207
+ # admin = User.find_by_login( "admin" )
208
+ # if admin.nil?
209
+ # puts "Create admin user..."
210
+ # admin = User.create( :login => "admin", :passwd => "admin" )
211
+ # end
212
+ # puts "Admin user : \n\tlogin = #{admin.login}\n\tpassword = #{admin.passwd}"
213
+ #end
214
214
 
215
215
  __END__
216
216
  * {
@@ -0,0 +1,12 @@
1
+ require 'blog-couchdb'
2
+
3
+ app = Capcode.application( :db_config => "blog-couchdb.yml" ) do |c|
4
+ admin = User.find_by_login( "admin" )
5
+ if admin.nil?
6
+ puts "Create admin user..."
7
+ admin = User.create( :login => "admin", :passwd => "admin" )
8
+ end
9
+ puts "Log as admin with : \n\tlogin = #{admin.login}\n\tpassword = #{admin.passwd}"
10
+ end
11
+
12
+ run app
@@ -15,4 +15,4 @@ module Capcode
15
15
  end
16
16
  end
17
17
 
18
- Capcode.run( :static => "static" )
18
+ Capcode.run( :static => "static", :verbose => true )
@@ -0,0 +1,21 @@
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
+ puts __FILE__
19
+
20
+ ## WARNING : when using rackup, :root default is the rackup directory (eg. /usr/bin or something like that) !
21
+ run Capcode.application( :static => "static", :verbose => true, :root => File.expand_path(File.dirname(__FILE__)) )
@@ -0,0 +1,26 @@
1
+ $:.unshift( "../lib" )
2
+ require 'capcode'
3
+ require 'capcode/render/webdav'
4
+
5
+ module Capcode
6
+
7
+ # Render file from /Users/greg/temp !!!
8
+ class WebDav < Route '/temp'
9
+ def get
10
+ render :webdav => "/Users/greg"
11
+ end
12
+
13
+ def method_missing(id, *a, &b)
14
+ get
15
+ end
16
+ end
17
+
18
+ class Index < Route '/'
19
+ def get
20
+ render "WebDav server acces : <a href='#{URL(Capcode::WebDav)}'>#{URL(Capcode::WebDav)}</a>"
21
+ end
22
+ end
23
+
24
+ end
25
+
26
+ Capcode.run( )