vanilla 1.11.0 → 1.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/lib/vanilla/renderers/base.rb +16 -16
- data/test/snip_reference_test.rb +9 -9
- data/test/test_helper.rb +4 -0
- data/test/tmp/soup/current_snip.yml +3 -3
- data/test/tmp/soup/system.yml +2 -2
- metadata +5 -7
- data/test/soup/whatwhat.yml +0 -2
- data/test/tmp/soup/temp.yml +0 -4
data/Rakefile
CHANGED
@@ -24,7 +24,7 @@ if Object.const_defined?(:Gem)
|
|
24
24
|
|
25
25
|
# Change these as appropriate
|
26
26
|
s.name = "vanilla"
|
27
|
-
s.version = "1.11.
|
27
|
+
s.version = "1.11.1"
|
28
28
|
s.summary = "A bliki-type web content thing."
|
29
29
|
s.author = "James Adam"
|
30
30
|
s.email = "james@lazyatom.com.com"
|
@@ -41,7 +41,7 @@ if Object.const_defined?(:Gem)
|
|
41
41
|
|
42
42
|
# All the other gems we need.
|
43
43
|
s.add_dependency("rack", ">= 0.9.1")
|
44
|
-
s.add_dependency("soup", ">= 0.9.
|
44
|
+
s.add_dependency("soup", ">= 0.9.12")
|
45
45
|
s.add_dependency("ratom", ">= 0.3.5")
|
46
46
|
s.add_dependency("RedCloth", ">= 4.1.1")
|
47
47
|
s.add_dependency("BlueCloth", ">= 1.0.0")
|
@@ -5,31 +5,31 @@ module Vanilla
|
|
5
5
|
module Renderers
|
6
6
|
class Base
|
7
7
|
include Routes
|
8
|
-
|
8
|
+
|
9
9
|
# Render a snip.
|
10
10
|
def self.render(snip, part=:content)
|
11
11
|
new(app).render(snip, part)
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def self.escape_curly_braces(str)
|
15
15
|
str.gsub("{", "{").gsub("}", "}")
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
attr_reader :app
|
19
|
-
|
19
|
+
|
20
20
|
def initialize(app)
|
21
21
|
@app = app
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
# defined for the routes
|
25
25
|
def soup
|
26
26
|
@app.soup
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def self.snip_regexp
|
30
30
|
%r{(\{[\w\-_\d]+(\s+[^\}.]+)?\})}
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
# Default behaviour to include a snip's content
|
34
34
|
def include_snips(content, enclosing_snip)
|
35
35
|
content.gsub(Vanilla::Renderers::Base.snip_regexp) do
|
@@ -38,7 +38,7 @@ module Vanilla
|
|
38
38
|
snip_name = snip_tree.snip
|
39
39
|
snip_attribute = snip_tree.attribute
|
40
40
|
snip_args = snip_tree.arguments
|
41
|
-
|
41
|
+
|
42
42
|
# Render the snip or snip part with the given args, and the current
|
43
43
|
# context, but with the default renderer for that snip. We dispatch
|
44
44
|
# *back* out to the root Vanilla.render method to do this.
|
@@ -53,36 +53,36 @@ module Vanilla
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
def parse_snip_reference(string)
|
58
58
|
@parser ||= SnipReferenceParser.new
|
59
59
|
@parser.parse(string)
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
# Default rendering behaviour. Subclasses shouldn't really need to touch this.
|
63
63
|
def render(snip, part=:content, args=[], enclosing_snip=snip)
|
64
64
|
prepare(snip, part, args, enclosing_snip)
|
65
65
|
processed_text = render_without_including_snips(snip, part)
|
66
66
|
include_snips(processed_text, snip)
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
# Subclasses should override this to perform any actions required before
|
70
70
|
# rendering
|
71
71
|
def prepare(snip, part, args, enclosing_snip)
|
72
72
|
# do nothing, by default
|
73
73
|
end
|
74
|
-
|
74
|
+
|
75
75
|
def render_without_including_snips(snip, part=:content)
|
76
76
|
process_text(raw_content(snip, part))
|
77
77
|
end
|
78
|
-
|
79
|
-
# Handles processing the text of the content.
|
80
|
-
# Subclasses should override this method to do fancy text processing
|
78
|
+
|
79
|
+
# Handles processing the text of the content.
|
80
|
+
# Subclasses should override this method to do fancy text processing
|
81
81
|
# like markdown, or loading the content as Ruby code.
|
82
82
|
def process_text(content)
|
83
83
|
content
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
# Returns the raw content for the selected part of the selected snip
|
87
87
|
def raw_content(snip, part)
|
88
88
|
snip.__send__((part || :content).to_sym)
|
data/test/snip_reference_test.rb
CHANGED
@@ -5,41 +5,41 @@ class SnipReferenceTest < Vanilla::TestCase
|
|
5
5
|
super
|
6
6
|
create_snip :name => "test", :content => "snip content"
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
should "match simple snips" do
|
10
10
|
assert_equal "rendering snip content", render("rendering {test}")
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
should "match snips with an argument" do
|
14
14
|
assert_equal "rendering snip content", render("rendering {test arg1}")
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
should "match snips with several arguments" do
|
18
18
|
assert_equal "rendering snip content", render("rendering {test arg1, arg2}")
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
should "match snips with hyphens" do
|
22
22
|
create_snip :name => "test-snip", :content => "snip content"
|
23
23
|
assert_equal "rendering snip content", render("rendering {test-snip}")
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
should "match snips with underscores" do
|
27
27
|
create_snip :name => "test_snip", :content => "snip content"
|
28
28
|
assert_equal "rendering snip content", render("rendering {test_snip}")
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
should "match snips with numbers" do
|
32
32
|
create_snip :name => "test1", :content => "snip content"
|
33
33
|
assert_equal "rendering snip content", render("rendering {test1}")
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
should "ignore references that are rubyish" do
|
37
37
|
assert_equal "10.times { |x| puts x }", render("10.times { |x| puts x }")
|
38
38
|
assert_equal "10.times {|x| puts x }", render("10.times {|x| puts x }")
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
private
|
42
|
-
|
42
|
+
|
43
43
|
def render(content)
|
44
44
|
snip = create_snip :name => "test-content", :content => content
|
45
45
|
Vanilla::Renderers::Base.new(@app).render(snip)
|
data/test/test_helper.rb
CHANGED
@@ -9,7 +9,7 @@ CurrentSnip--- # Soup attributes
|
|
9
9
|
{current_snip name}
|
10
10
|
|
11
11
|
will output the name of the current snip, or the name of the snip currently being edited.
|
12
|
-
:updated_at: 2010-
|
13
|
-
:render_as: Ruby
|
12
|
+
:updated_at: 2010-07-14 12:51:59.809435 +01:00
|
14
13
|
:name: current_snip
|
15
|
-
:created_at: 2010-
|
14
|
+
:created_at: 2010-07-14 12:51:59.809433 +01:00
|
15
|
+
:render_as: Ruby
|
data/test/tmp/soup/system.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
--- # Soup attributes
|
2
|
-
:updated_at: 2010-
|
2
|
+
:updated_at: 2010-07-14 12:51:59.809910 +01:00
|
3
3
|
:name: system
|
4
|
+
:created_at: 2010-07-14 12:51:59.809908 +01:00
|
4
5
|
:main_template: "{current_snip}"
|
5
|
-
:created_at: 2010-06-10 15:00:13.120123 +01:00
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 11
|
8
|
-
-
|
9
|
-
version: 1.11.
|
8
|
+
- 1
|
9
|
+
version: 1.11.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- James Adam
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-07-14 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -41,8 +41,8 @@ dependencies:
|
|
41
41
|
segments:
|
42
42
|
- 0
|
43
43
|
- 9
|
44
|
-
-
|
45
|
-
version: 0.9.
|
44
|
+
- 12
|
45
|
+
version: 0.9.12
|
46
46
|
type: :runtime
|
47
47
|
version_requirements: *id002
|
48
48
|
- !ruby/object:Gem::Dependency
|
@@ -174,12 +174,10 @@ files:
|
|
174
174
|
- test/ruby_renderer_test.rb
|
175
175
|
- test/snip_reference_parser_test.rb
|
176
176
|
- test/snip_reference_test.rb
|
177
|
-
- test/soup/whatwhat.yml
|
178
177
|
- test/test_helper.rb
|
179
178
|
- test/tmp/config.yml
|
180
179
|
- test/tmp/soup/current_snip.yml
|
181
180
|
- test/tmp/soup/system.yml
|
182
|
-
- test/tmp/soup/temp.yml
|
183
181
|
- test/vanilla_app_test.rb
|
184
182
|
- test/vanilla_presenting_test.rb
|
185
183
|
- test/vanilla_request_test.rb
|
data/test/soup/whatwhat.yml
DELETED
data/test/tmp/soup/temp.yml
DELETED