Capcode 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/README.rdoc +72 -1
  2. data/doc/rdoc/classes/Capcode.html +549 -444
  3. data/doc/rdoc/classes/Capcode/Helpers.html +293 -133
  4. data/doc/rdoc/classes/Capcode/Helpers/Authorization.html +60 -29
  5. data/doc/rdoc/created.rid +1 -1
  6. data/doc/rdoc/files/README_rdoc.html +94 -8
  7. data/doc/rdoc/files/lib/capcode/configuration_rb.html +101 -0
  8. data/doc/rdoc/files/lib/capcode/helpers/auth_rb.html +1 -32
  9. data/doc/rdoc/files/lib/capcode/render/erb_rb.html +1 -1
  10. data/doc/rdoc/files/lib/capcode/render/haml_rb.html +1 -1
  11. data/doc/rdoc/files/lib/capcode/render/markaby_rb.html +1 -1
  12. data/doc/rdoc/files/lib/capcode/render/sass_rb.html +1 -1
  13. data/doc/rdoc/files/lib/capcode/render/text_rb.html +1 -1
  14. data/doc/rdoc/files/lib/capcode_rb.html +8 -1
  15. data/doc/rdoc/fr_file_index.html +1 -0
  16. data/doc/rdoc/fr_method_index.html +19 -11
  17. data/examples/blog-couchdb.rb +4 -3
  18. data/examples/erb/cf.rhtml +1 -0
  19. data/examples/haml/cf.haml +4 -1
  20. data/examples/render-erb.rb +4 -1
  21. data/examples/render-haml_sass.rb +6 -2
  22. data/examples/render-image.rb +70 -0
  23. data/examples/render-static.rb +4 -1
  24. data/examples/render-static.ru +0 -2
  25. data/examples/render-use.rb +31 -0
  26. data/examples/static/coderay.css +131 -0
  27. data/examples/static/index.html +19 -0
  28. data/lib/capcode.rb +125 -76
  29. data/lib/capcode/configuration.rb +39 -0
  30. data/lib/capcode/helpers/auth.rb +22 -23
  31. data/lib/capcode/render/erb.rb +25 -18
  32. data/lib/capcode/render/haml.rb +28 -19
  33. data/lib/capcode/render/markaby.rb +2 -1
  34. data/lib/capcode/render/sass.rb +19 -13
  35. data/lib/capcode/render/text.rb +1 -1
  36. data/lib/capcode/version.rb +1 -1
  37. metadata +8 -2
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Fri Sep 04 20:07:29 +0200 2009</td>
59
+ <td>Wed Oct 21 13:05:57 +0200 2009</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Sun Jul 19 19:34:25 +0200 2009</td>
59
+ <td>Mon Oct 19 10:33:08 +0200 2009</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Fri Oct 09 23:00:41 +0200 2009</td>
59
+ <td>Wed Oct 21 16:34:53 +0200 2009</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -68,6 +68,12 @@
68
68
 
69
69
  <div id="contextContent">
70
70
 
71
+ <div id="description">
72
+ <p>
73
+ Please read the README.rdoc file !
74
+ </p>
75
+
76
+ </div>
71
77
 
72
78
  <div id="requires-list">
73
79
  <h3 class="section-bar">Required files</h3>
@@ -84,6 +90,7 @@
84
90
  capcode/core_ext&nbsp;&nbsp;
85
91
  capcode/helpers/auth&nbsp;&nbsp;
86
92
  capcode/render/text&nbsp;&nbsp;
93
+ capcode/configuration&nbsp;&nbsp;
87
94
  mongrel&nbsp;&nbsp;
88
95
  </div>
89
96
  </div>
@@ -25,6 +25,7 @@
25
25
  <a href="files/README_rdoc.html">README.rdoc</a><br />
26
26
  <a href="files/lib/capcode_rb.html">lib/capcode.rb</a><br />
27
27
  <a href="files/lib/capcode/base/db_rb.html">lib/capcode/base/db.rb</a><br />
28
+ <a href="files/lib/capcode/configuration_rb.html">lib/capcode/configuration.rb</a><br />
28
29
  <a href="files/lib/capcode/helpers/auth_rb.html">lib/capcode/helpers/auth.rb</a><br />
29
30
  <a href="files/lib/capcode/render/erb_rb.html">lib/capcode/render/erb.rb</a><br />
30
31
  <a href="files/lib/capcode/render/haml_rb.html">lib/capcode/render/haml.rb</a><br />
@@ -21,23 +21,31 @@
21
21
  <h1 class="section-bar">Methods</h1>
22
22
  <div id="index-entries">
23
23
  <a href="classes/Capcode.html#M000001">Route (Capcode)</a><br />
24
- <a href="classes/Capcode/Helpers.html#M000014">URL (Capcode::Helpers)</a><br />
25
- <a href="classes/Capcode.html#M000009">application (Capcode)</a><br />
26
- <a href="classes/Capcode/Helpers.html#M000015">content_for (Capcode::Helpers)</a><br />
24
+ <a href="classes/Capcode/Helpers.html#M000019">URL (Capcode::Helpers)</a><br />
25
+ <a href="classes/Capcode.html#M000010">application (Capcode)</a><br />
26
+ <a href="classes/Capcode/Helpers.html#M000014">args (Capcode::Helpers)</a><br />
27
+ <a href="classes/Capcode/Helpers.html#M000015">args= (Capcode::Helpers)</a><br />
28
+ <a href="classes/Capcode.html#M000013">config (Capcode)</a><br />
29
+ <a href="classes/Capcode/Helpers.html#M000020">content_for (Capcode::Helpers)</a><br />
27
30
  <a href="classes/Capcode.html#M000003">env (Capcode)</a><br />
28
- <a href="classes/Capcode.html#M000008">http_authentication (Capcode)</a><br />
29
- <a href="classes/Capcode/Helpers/Authorization.html#M000018">http_authentication (Capcode::Helpers::Authorization)</a><br />
30
- <a href="classes/Capcode/Helpers.html#M000012">json (Capcode::Helpers)</a><br />
31
+ <a href="classes/Capcode/Helpers.html#M000022">erb_path= (Capcode::Helpers)</a><br />
32
+ <a href="classes/Capcode/Helpers.html#M000023">haml_path= (Capcode::Helpers)</a><br />
33
+ <a href="classes/Capcode.html#M000009">http_authentication (Capcode)</a><br />
34
+ <a href="classes/Capcode/Helpers/Authorization.html#M000026">http_authentication (Capcode::Helpers::Authorization)</a><br />
35
+ <a href="classes/Capcode/Helpers.html#M000017">json (Capcode::Helpers)</a><br />
31
36
  <a href="classes/Capcode.html#M000007">map (Capcode)</a><br />
32
37
  <a href="classes/Capcode.html#M000002">params (Capcode)</a><br />
33
- <a href="classes/Capcode/Helpers.html#M000013">redirect (Capcode::Helpers)</a><br />
34
- <a href="classes/Capcode/Helpers.html#M000011">render (Capcode::Helpers)</a><br />
35
- <a href="classes/Capcode/Helpers.html#M000017">render_webdav (Capcode::Helpers)</a><br />
38
+ <a href="classes/Capcode/Helpers.html#M000018">redirect (Capcode::Helpers)</a><br />
39
+ <a href="classes/Capcode/Helpers.html#M000016">render (Capcode::Helpers)</a><br />
40
+ <a href="classes/Capcode/Helpers.html#M000025">render_webdav (Capcode::Helpers)</a><br />
36
41
  <a href="classes/Capcode.html#M000005">request (Capcode)</a><br />
37
42
  <a href="classes/Capcode.html#M000006">response (Capcode)</a><br />
38
- <a href="classes/Capcode.html#M000010">run (Capcode)</a><br />
43
+ <a href="classes/Capcode.html#M000011">run (Capcode)</a><br />
44
+ <a href="classes/Capcode/Helpers.html#M000024">sass_path= (Capcode::Helpers)</a><br />
39
45
  <a href="classes/Capcode.html#M000004">session (Capcode)</a><br />
40
- <a href="classes/Capcode/Helpers.html#M000016">static (Capcode::Helpers)</a><br />
46
+ <a href="classes/Capcode.html#M000012">set (Capcode)</a><br />
47
+ <a href="classes/Capcode/Helpers.html#M000021">static (Capcode::Helpers)</a><br />
48
+ <a href="classes/Capcode.html#M000008">use (Capcode)</a><br />
41
49
  </div>
42
50
  </div>
43
51
  </body>
@@ -85,8 +85,9 @@ module Capcode
85
85
  redirect( Index )
86
86
  end
87
87
  end
88
- def post
89
- story = Story.find( params['id'] )
88
+ def post( id )
89
+ # story = Story.find( params['id'] )
90
+ story = Story.find( id )
90
91
  story.title = params['title']
91
92
  story.body = params['body']
92
93
  story.save
@@ -143,7 +144,7 @@ module Capcode::Views
143
144
  input :type => "text", :name => "title", :value => @story.title; br
144
145
  textarea :name => "body" do; @story.body; end; br
145
146
  input :type => "submit"
146
- input :type => "hidden", :name => "id", :value => @story.id
147
+ # input :type => "hidden", :name => "id", :value => @story.id
147
148
  end
148
149
  end
149
150
 
@@ -4,4 +4,5 @@
4
4
 
5
5
  <% content_for( :content ) do %>
6
6
  <p>this is the content!</p>
7
+ <p>Time : <%= @time %>
7
8
  <% end %>
@@ -1,4 +1,7 @@
1
1
  - content_for( :header ) do
2
2
  %title This is the title!
3
3
  - content_for( :content ) do
4
- %p this is the content!
4
+ %p this is the content!
5
+ %p
6
+ Time :
7
+ = @time
@@ -1,11 +1,14 @@
1
1
  $:.unshift( "../lib" )
2
2
  require 'capcode'
3
3
  require 'capcode/render/erb'
4
- Capcode::Helpers.erb_path="erb"
4
+ #Capcode::Helpers.erb_path="erb"
5
5
 
6
6
  module Capcode
7
+ set :erb, "erb"
8
+
7
9
  class Index < Route '/'
8
10
  def get
11
+ @time = Time.now
9
12
  render :erb => :cf, :layout => :cf_layout
10
13
  end
11
14
  end
@@ -2,12 +2,16 @@ $:.unshift( "../lib" )
2
2
  require 'capcode'
3
3
  require 'capcode/render/haml'
4
4
  require 'capcode/render/sass'
5
- Capcode::Helpers.haml_path="haml"
6
- Capcode::Helpers.sass_path="haml"
5
+ #Capcode::Helpers.haml_path="haml"
6
+ #Capcode::Helpers.sass_path="haml"
7
7
 
8
8
  module Capcode
9
+ set :haml, "haml"
10
+ set :sass, "haml"
11
+
9
12
  class Index < Route '/'
10
13
  def get
14
+ @time = Time.now
11
15
  render :haml => :cf, :layout => :cf_layout
12
16
  end
13
17
  end
@@ -0,0 +1,70 @@
1
+ $:.unshift( "../lib" )
2
+ require 'capcode'
3
+ require 'capcode/render/markaby'
4
+ require 'rubygems'
5
+ require 'graphviz'
6
+ require 'base64'
7
+
8
+ def hello( path )
9
+ g = GraphViz::new( "G" ) { |g|
10
+ g.hello << g.world
11
+ g.bonjour - g.monde
12
+ g.hola > g.mundo
13
+ g.holla >> g.welt
14
+ }
15
+
16
+ r = nil
17
+ if path.nil?
18
+ r = g.output( :png => String )
19
+ else
20
+ r = g.output( :png => String, :path => "/#{path}" )
21
+ end
22
+
23
+ return r
24
+ end
25
+
26
+ module Capcode
27
+ class Index < Route '/'
28
+ def get
29
+ render :markaby => :index
30
+ end
31
+ end
32
+
33
+ class Image < Route '/image/(.*)'
34
+ def get(path)
35
+ r = hello( path )
36
+
37
+ render :content_type => "image/png", :text => r
38
+ end
39
+ end
40
+
41
+ class Inline < Route '/inline/(.*)'
42
+ def get(path)
43
+ @image = Base64.b64encode(hello(path))
44
+
45
+ render :markaby => :inline
46
+ end
47
+ end
48
+ end
49
+
50
+ module Capcode::Views
51
+ def glop
52
+ html do
53
+ body do
54
+ yield
55
+ end
56
+ end
57
+ end
58
+
59
+ def index
60
+ h1 "Image :"
61
+ img :src => URL(Capcode::Image)
62
+ end
63
+
64
+ def inline
65
+ h1 "Inline image :"
66
+ img :src => "data:image/png;base64,#{@image}"
67
+ end
68
+ end
69
+
70
+ Capcode.run( )
@@ -3,6 +3,9 @@ require 'capcode'
3
3
  require 'capcode/render/static'
4
4
 
5
5
  module Capcode
6
+ set :static, "static"
7
+ set :verbose, true
8
+
6
9
  class Index < Route '/'
7
10
  def get
8
11
  render :static => "index.html"
@@ -15,4 +18,4 @@ module Capcode
15
18
  end
16
19
  end
17
20
 
18
- Capcode.run( :static => "static", :verbose => true )
21
+ Capcode.run( )
@@ -15,7 +15,5 @@ module Capcode
15
15
  end
16
16
  end
17
17
 
18
- puts __FILE__
19
-
20
18
  ## WARNING : when using rackup, :root default is the rackup directory (eg. /usr/bin or something like that) !
21
19
  run Capcode.application( :static => "static", :verbose => true, :root => File.expand_path(File.dirname(__FILE__)) )
@@ -0,0 +1,31 @@
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
+
12
+ use Rack::Codehighlighter, :coderay, :element => "pre", :pattern => /\A:::(\w+)\s*\n/, :logging => false
13
+
14
+ class Index < Route '/'
15
+ def get
16
+ render :static => "index.html"
17
+ end
18
+ end
19
+ class Path < Route '/path'
20
+ def get
21
+ render :static => "index.html", :exact_path => false
22
+ end
23
+ end
24
+ class Style < Route '/style'
25
+ def get
26
+ render :static => "coderay.css", :exact_path => false
27
+ end
28
+ end
29
+ end
30
+
31
+ Capcode.run( )
@@ -0,0 +1,131 @@
1
+ .CodeRay {
2
+ background-color: #f8f8f8;
3
+ border: 1px solid silver;
4
+ font-family: 'Courier New', 'Terminal', monospace;
5
+ color: #000;
6
+ }
7
+ .CodeRay pre { margin: 0px }
8
+
9
+ div.CodeRay { }
10
+
11
+ span.CodeRay { white-space: pre; border: 0px; padding: 2px }
12
+
13
+ table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px }
14
+ table.CodeRay td { padding: 2px 4px; vertical-align: top }
15
+
16
+ .CodeRay .line_numbers, .CodeRay .no {
17
+ background-color: #def;
18
+ color: gray;
19
+ text-align: right;
20
+ }
21
+ .CodeRay .line_numbers tt { font-weight: bold }
22
+ .CodeRay .line_numbers .highlighted { color: red }
23
+ .CodeRay .no { padding: 0px 4px }
24
+ .CodeRay .code { width: 100% }
25
+
26
+ ol.CodeRay { font-size: 10pt }
27
+ ol.CodeRay li { white-space: pre }
28
+
29
+ .CodeRay .code pre { overflow: auto }
30
+
31
+ .CodeRay .debug { color:white ! important; background:blue ! important; }
32
+
33
+ .CodeRay .af { color:#00C }
34
+ .CodeRay .an { color:#007 }
35
+ .CodeRay .at { color:#f08 }
36
+ .CodeRay .av { color:#700 }
37
+ .CodeRay .aw { color:#C00 }
38
+ .CodeRay .bi { color:#509; font-weight:bold }
39
+ .CodeRay .c { color:#888; }
40
+
41
+ .CodeRay .ch { color:#04D }
42
+ .CodeRay .ch .k { color:#04D }
43
+ .CodeRay .ch .dl { color:#039 }
44
+
45
+ .CodeRay .cl { color:#B06; font-weight:bold }
46
+ .CodeRay .cm { color:#A08; font-weight:bold }
47
+ .CodeRay .co { color:#036; font-weight:bold }
48
+ .CodeRay .cr { color:#0A0 }
49
+ .CodeRay .cv { color:#369 }
50
+ .CodeRay .de { color:#B0B; }
51
+ .CodeRay .df { color:#099; font-weight:bold }
52
+ .CodeRay .di { color:#088; font-weight:bold }
53
+ .CodeRay .dl { color:black }
54
+ .CodeRay .do { color:#970 }
55
+ .CodeRay .dt { color:#34b }
56
+ .CodeRay .ds { color:#D42; font-weight:bold }
57
+ .CodeRay .e { color:#666; font-weight:bold }
58
+ .CodeRay .en { color:#800; font-weight:bold }
59
+ .CodeRay .er { color:#F00; background-color:#FAA }
60
+ .CodeRay .ex { color:#F00; font-weight:bold }
61
+ .CodeRay .fl { color:#60E; font-weight:bold }
62
+ .CodeRay .fu { color:#06B; font-weight:bold }
63
+ .CodeRay .gv { color:#d70; font-weight:bold }
64
+ .CodeRay .hx { color:#058; font-weight:bold }
65
+ .CodeRay .i { color:#00D; font-weight:bold }
66
+ .CodeRay .ic { color:#B44; font-weight:bold }
67
+
68
+ .CodeRay .il { background: #ddd; color: black }
69
+ .CodeRay .il .il { background: #ccc }
70
+ .CodeRay .il .il .il { background: #bbb }
71
+ .CodeRay .il .idl { background: #ddd; font-weight: bold; color: #666 }
72
+ .CodeRay .idl { background-color: #bbb; font-weight: bold; color: #666; }
73
+
74
+ .CodeRay .im { color:#f00; }
75
+ .CodeRay .in { color:#B2B; font-weight:bold }
76
+ .CodeRay .iv { color:#33B }
77
+ .CodeRay .la { color:#970; font-weight:bold }
78
+ .CodeRay .lv { color:#963 }
79
+ .CodeRay .oc { color:#40E; font-weight:bold }
80
+ .CodeRay .of { color:#000; font-weight:bold }
81
+ .CodeRay .op { }
82
+ .CodeRay .pc { color:#038; font-weight:bold }
83
+ .CodeRay .pd { color:#369; font-weight:bold }
84
+ .CodeRay .pp { color:#579; }
85
+ .CodeRay .ps { color:#00C; font-weight: bold; }
86
+ .CodeRay .pt { color:#349; font-weight:bold }
87
+ .CodeRay .r, .kw { color:#080; font-weight:bold }
88
+
89
+ .CodeRay .ke { color: #808; }
90
+ .CodeRay .ke .dl { color: #606; }
91
+ .CodeRay .ke .ch { color: #80f; }
92
+ .CodeRay .vl { color: #088; }
93
+
94
+ .CodeRay .rx { background-color:#fff0ff }
95
+ .CodeRay .rx .k { color:#808 }
96
+ .CodeRay .rx .dl { color:#404 }
97
+ .CodeRay .rx .mod { color:#C2C }
98
+ .CodeRay .rx .fu { color:#404; font-weight: bold }
99
+
100
+ .CodeRay .s { background-color:#fff0f0; color: #D20; }
101
+ .CodeRay .s .s { background-color:#ffe0e0 }
102
+ .CodeRay .s .s .s { background-color:#ffd0d0 }
103
+ .CodeRay .s .k { }
104
+ .CodeRay .s .ch { color: #b0b; }
105
+ .CodeRay .s .dl { color: #710; }
106
+
107
+ .CodeRay .sh { background-color:#f0fff0; color:#2B2 }
108
+ .CodeRay .sh .k { }
109
+ .CodeRay .sh .dl { color:#161 }
110
+
111
+ .CodeRay .sy { color:#A60 }
112
+ .CodeRay .sy .k { color:#A60 }
113
+ .CodeRay .sy .dl { color:#630 }
114
+
115
+ .CodeRay .ta { color:#070 }
116
+ .CodeRay .tf { color:#070; font-weight:bold }
117
+ .CodeRay .ts { color:#D70; font-weight:bold }
118
+ .CodeRay .ty { color:#339; font-weight:bold }
119
+ .CodeRay .v { color:#036 }
120
+ .CodeRay .xt { color:#444 }
121
+
122
+ .CodeRay .ins { background: #afa; }
123
+ .CodeRay .del { background: #faa; }
124
+ .CodeRay .chg { color: #aaf; background: #007; }
125
+ .CodeRay .head { color: #f8f; background: #505 }
126
+
127
+ .CodeRay .ins .ins { color: #080; font-weight:bold }
128
+ .CodeRay .del .del { color: #800; font-weight:bold }
129
+ .CodeRay .chg .chg { color: #66f; }
130
+ .CodeRay .head .head { color: #f4f; }
131
+
@@ -1,5 +1,24 @@
1
1
  <html>
2
+ <head>
3
+ <link href="/style" media="screen" rel="Stylesheet" type="text/css" />
4
+ </head>
2
5
  <body>
3
6
  <h1>Capcode hello !</h1>
7
+
8
+ <p>
9
+ Code :
10
+ <pre>:::ruby
11
+ # In an object instance variable (denoted with '@'), remember a block.
12
+ def remember(&a_block)
13
+ @block = a_block
14
+ end
15
+
16
+ # Invoke the above method, giving it a block which takes a name.
17
+ remember {|name| puts "Hello, #{name}!"}
18
+
19
+ # When the time is right (for the object) -- call the closure!
20
+ @block.call("Jon")
21
+ # => "Hello, Jon!"</pre>
22
+ </p>
4
23
  </body>
5
24
  </html>