Capcode 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +6 -1
- data/doc/rdoc/classes/Capcode.html +226 -226
- data/doc/rdoc/classes/Capcode/Helpers.html +116 -43
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README.html +17 -2
- data/doc/rdoc/files/lib/capcode_rb.html +1 -1
- data/examples/blog-couchdb.rb +4 -3
- data/examples/erb/cf.rhtml +7 -0
- data/examples/erb/cf_layout.rhtml +8 -0
- data/examples/erb/layout.rhtml +8 -0
- data/examples/erb/m_hello.rhtml +1 -5
- data/examples/haml/cf.haml +4 -0
- data/examples/haml/cf_layout.haml +5 -0
- data/examples/haml/layout.haml +5 -0
- data/examples/haml/m_hello.haml +5 -7
- data/examples/sample.rb +36 -13
- data/lib/capcode.rb +45 -7
- data/lib/capcode/render/erb.rb +18 -3
- data/lib/capcode/render/haml.rb +13 -2
- data/lib/capcode/render/json.rb +1 -1
- data/lib/capcode/render/markaby.rb +10 -3
- data/lib/capcode/render/text.rb +7 -0
- data/lib/capcode/version.rb +1 -1
- metadata +9 -2
data/lib/capcode/render/erb.rb
CHANGED
@@ -7,7 +7,11 @@ module Capcode
|
|
7
7
|
@@__ERB_PATH__ = p
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def get_binding
|
11
|
+
binding
|
12
|
+
end
|
13
|
+
|
14
|
+
def render_erb( f, opts ) #:nodoc:
|
11
15
|
f = f.to_s
|
12
16
|
if f.include? '..'
|
13
17
|
return [403, {}, '403 - Invalid path']
|
@@ -22,10 +26,21 @@ module Capcode
|
|
22
26
|
@@__ERB_PATH__ = File.expand_path( File.join(@@__ROOT_DIRECTORY, @@__ERB_PATH__) )
|
23
27
|
end
|
24
28
|
end
|
25
|
-
|
29
|
+
|
30
|
+
layout = opts.delete(:layout)||:layout
|
31
|
+
layout_file = File.join( @@__ERB_PATH__, layout.to_s+".rhtml" )
|
32
|
+
|
26
33
|
f = f + ".rhtml" if File.extname( f ) != ".rhtml"
|
27
34
|
file = File.join( @@__ERB_PATH__, f )
|
28
|
-
|
35
|
+
|
36
|
+
if( File.exist?( layout_file ) )
|
37
|
+
ERB.new(open(layout_file).read).result( get_binding { |*args|
|
38
|
+
@@__ARGS__ = args
|
39
|
+
ERB.new(open(file).read).result(binding)
|
40
|
+
} )
|
41
|
+
else
|
42
|
+
ERB.new(open(file).read).result(binding)
|
43
|
+
end
|
29
44
|
end
|
30
45
|
end
|
31
46
|
end
|
data/lib/capcode/render/haml.rb
CHANGED
@@ -7,7 +7,7 @@ module Capcode
|
|
7
7
|
@@__HAML_PATH__ = p
|
8
8
|
end
|
9
9
|
|
10
|
-
def render_haml( f ) #:nodoc:
|
10
|
+
def render_haml( f, opts ) #:nodoc:
|
11
11
|
f = f.to_s
|
12
12
|
if f.include? '..'
|
13
13
|
return [403, {}, '403 - Invalid path']
|
@@ -23,9 +23,20 @@ module Capcode
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
layout = opts.delete(:layout)||:layout
|
27
|
+
layout_file = File.join( @@__HAML_PATH__, layout.to_s+".haml" )
|
28
|
+
|
26
29
|
f = f + ".haml" if File.extname( f ) != ".haml"
|
27
30
|
file = File.join( @@__HAML_PATH__, f )
|
28
|
-
|
31
|
+
|
32
|
+
if( File.exist?( layout_file ) )
|
33
|
+
Haml::Engine.new( open( layout_file ).read ).to_html(self) { |*args|
|
34
|
+
@@__ARGS__ = args
|
35
|
+
Haml::Engine.new( open( file ).read ).render(self)
|
36
|
+
}
|
37
|
+
else
|
38
|
+
Haml::Engine.new( open( file ).read ).to_html( self )
|
39
|
+
end
|
29
40
|
end
|
30
41
|
end
|
31
42
|
end
|
data/lib/capcode/render/json.rb
CHANGED
@@ -1,16 +1,23 @@
|
|
1
1
|
require "markaby"
|
2
2
|
|
3
|
+
Markaby::Builder.set(:indent, 2)
|
4
|
+
|
3
5
|
module Capcode
|
4
6
|
class Markaby::Builder
|
5
7
|
include Views
|
6
8
|
end
|
7
9
|
|
8
10
|
module Helpers
|
9
|
-
def render_markaby( f ) #:nodoc:
|
11
|
+
def render_markaby( f, opts ) #:nodoc:
|
10
12
|
f = f.to_s
|
13
|
+
layout = opts.delete(:layout)||:layout
|
14
|
+
|
11
15
|
mab = Markaby::Builder.new({}, self) {
|
12
|
-
if self.respond_to?(
|
13
|
-
|
16
|
+
if self.respond_to?(layout)
|
17
|
+
self.send(layout.to_s) { |*args|
|
18
|
+
@@__ARGS__ = args
|
19
|
+
self.send(f)
|
20
|
+
}
|
14
21
|
else
|
15
22
|
self.send(f)
|
16
23
|
end
|
data/lib/capcode/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Capcode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Gr\xC3\xA9goire Lejeune"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-29 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -69,13 +69,20 @@ files:
|
|
69
69
|
- lib/capcode/render/haml.rb
|
70
70
|
- lib/capcode/render/json.rb
|
71
71
|
- lib/capcode/render/markaby.rb
|
72
|
+
- lib/capcode/render/text.rb
|
72
73
|
- lib/capcode/version.rb
|
73
74
|
- lib/capcode.rb
|
74
75
|
- examples/blog-couchdb.rb
|
75
76
|
- examples/blog-couchdb.yml
|
76
77
|
- examples/blog-dm.rb
|
77
78
|
- examples/blog-dm.yml
|
79
|
+
- examples/erb/cf.rhtml
|
80
|
+
- examples/erb/cf_layout.rhtml
|
81
|
+
- examples/erb/layout.rhtml
|
78
82
|
- examples/erb/m_hello.rhtml
|
83
|
+
- examples/haml/cf.haml
|
84
|
+
- examples/haml/cf_layout.haml
|
85
|
+
- examples/haml/layout.haml
|
79
86
|
- examples/haml/m_hello.haml
|
80
87
|
- examples/index.html
|
81
88
|
- examples/my_blog.db
|