vanilla 1.2 → 1.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +61 -60
- data/bin/vanilla +6 -35
- data/config.example.yml +6 -0
- data/config.ru +10 -0
- data/lib/defensio.rb +59 -0
- data/lib/tasks/vanilla.rake +173 -0
- data/lib/vanilla.rb +3 -10
- data/lib/vanilla/app.rb +48 -104
- data/lib/vanilla/console.rb +5 -19
- data/lib/vanilla/dynasnips/comments.rb +108 -0
- data/lib/vanilla/dynasnips/current_snip.rb +32 -0
- data/{pristine_app/soups → lib/vanilla}/dynasnips/debug.rb +3 -5
- data/lib/vanilla/dynasnips/edit.rb +60 -0
- data/lib/vanilla/dynasnips/edit_link.rb +20 -0
- data/{pristine_app/soups → lib/vanilla}/dynasnips/index.rb +2 -4
- data/{pristine_app/soups/extras → lib/vanilla/dynasnips}/kind.rb +12 -14
- data/{pristine_app/soups → lib/vanilla}/dynasnips/link_to.rb +0 -2
- data/lib/vanilla/dynasnips/link_to_current_snip.rb +16 -0
- data/lib/vanilla/dynasnips/login.rb +56 -0
- data/lib/vanilla/dynasnips/new.rb +14 -0
- data/lib/vanilla/dynasnips/notes.rb +42 -0
- data/{pristine_app/soups → lib/vanilla}/dynasnips/pre.rb +4 -6
- data/{pristine_app/soups/extras → lib/vanilla/dynasnips}/rand.rb +0 -2
- data/{pristine_app/soups → lib/vanilla}/dynasnips/raw.rb +5 -8
- data/{pristine_app/soups/extras → lib/vanilla/dynasnips}/url_to.rb +0 -0
- data/lib/vanilla/renderers/base.rb +22 -32
- data/lib/vanilla/renderers/bold.rb +2 -0
- data/lib/vanilla/renderers/erb.rb +2 -0
- data/lib/vanilla/renderers/markdown.rb +2 -0
- data/lib/vanilla/renderers/raw.rb +2 -0
- data/lib/vanilla/renderers/ruby.rb +5 -9
- data/lib/vanilla/renderers/textile.rb +2 -0
- data/lib/vanilla/request.rb +15 -16
- data/lib/vanilla/routes.rb +18 -5
- data/lib/vanilla/snip_reference.rb +534 -0
- data/lib/vanilla/snip_reference.treetop +48 -0
- data/lib/vanilla/snip_reference_parser.rb +99 -82
- data/lib/vanilla/snips/start.rb +28 -0
- data/lib/vanilla/snips/system.rb +77 -0
- data/lib/vanilla/snips/tutorial.rb +244 -0
- data/lib/vanilla/soup_with_timestamps.rb +21 -0
- data/public/hatch.png +0 -0
- data/public/javascripts/jquery.autogrow-textarea.js +54 -0
- data/public/javascripts/jquery.js +4376 -0
- data/public/javascripts/vanilla.js +22 -0
- data/spec/dynasnip_spec.rb +28 -0
- data/spec/renderers/base_renderer_spec.rb +40 -0
- data/spec/renderers/erb_renderer_spec.rb +27 -0
- data/spec/renderers/markdown_renderer_spec.rb +29 -0
- data/spec/renderers/raw_renderer_spec.rb +21 -0
- data/spec/renderers/ruby_renderer_spec.rb +59 -0
- data/spec/renderers/vanilla_app_detecting_renderer_spec.rb +35 -0
- data/spec/spec_helper.rb +70 -0
- data/spec/tmp/config.yml +2 -0
- data/spec/tmp/soup/current_snip.yml +15 -0
- data/spec/tmp/soup/system.yml +5 -0
- data/spec/vanilla_app_spec.rb +38 -0
- data/spec/vanilla_presenting_spec.rb +84 -0
- data/spec/vanilla_request_spec.rb +73 -0
- metadata +79 -170
- data/lib/vanilla/renderers.rb +0 -12
- data/lib/vanilla/renderers/haml.rb +0 -13
- data/lib/vanilla/static.rb +0 -28
- data/pristine_app/Gemfile +0 -3
- data/pristine_app/Gemfile.lock +0 -32
- data/pristine_app/README +0 -47
- data/pristine_app/config.ru +0 -26
- data/pristine_app/public/vanilla.css +0 -15
- data/pristine_app/soups/base/layout.snip +0 -18
- data/pristine_app/soups/base/start.snip +0 -19
- data/pristine_app/soups/dynasnips/current_snip.rb +0 -29
- data/pristine_app/soups/dynasnips/link_to_current_snip.rb +0 -14
- data/pristine_app/soups/dynasnips/page_title.rb +0 -9
- data/pristine_app/soups/extras/comments.rb +0 -78
- data/pristine_app/soups/tutorial/bad_dynasnip.snip +0 -8
- data/pristine_app/soups/tutorial/hello_world.snip +0 -20
- data/pristine_app/soups/tutorial/markdown_example.snip +0 -13
- data/pristine_app/soups/tutorial/snip.snip +0 -9
- data/pristine_app/soups/tutorial/soup.snip +0 -3
- data/pristine_app/soups/tutorial/test.snip +0 -30
- data/pristine_app/soups/tutorial/textile_example.snip +0 -11
- data/pristine_app/soups/tutorial/tutorial-another-snip.snip +0 -1
- data/pristine_app/soups/tutorial/tutorial-basic-snip-inclusion.snip +0 -1
- data/pristine_app/soups/tutorial/tutorial-dynasnips.snip.markdown +0 -56
- data/pristine_app/soups/tutorial/tutorial-layout.snip +0 -56
- data/pristine_app/soups/tutorial/tutorial-links.snip +0 -4
- data/pristine_app/soups/tutorial/tutorial-renderers.snip.markdown +0 -77
- data/pristine_app/soups/tutorial/tutorial.snip.markdown +0 -69
- data/pristine_app/soups/tutorial/vanilla-rb.snip +0 -16
- data/pristine_app/soups/tutorial/vanilla.snip +0 -8
- data/test/dynasnip_test.rb +0 -42
- data/test/dynasnips/link_to_current_snip_test.rb +0 -19
- data/test/dynasnips/link_to_test.rb +0 -27
- data/test/dynasnips/page_title_test.rb +0 -19
- data/test/renderers/base_renderer_test.rb +0 -43
- data/test/renderers/erb_renderer_test.rb +0 -29
- data/test/renderers/haml_renderer_test.rb +0 -35
- data/test/renderers/markdown_renderer_test.rb +0 -31
- data/test/renderers/raw_renderer_test.rb +0 -23
- data/test/renderers/ruby_renderer_test.rb +0 -59
- data/test/snip_inclusion_test.rb +0 -56
- data/test/snip_reference_parser_test.rb +0 -123
- data/test/test_helper.rb +0 -75
- data/test/vanilla_app_test.rb +0 -83
- data/test/vanilla_presenting_test.rb +0 -125
- data/test/vanilla_request_test.rb +0 -87
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
require "test_helper"
|
|
2
|
-
|
|
3
|
-
context "When presenting" do
|
|
4
|
-
setup do
|
|
5
|
-
set_main_template "<tag>{current_snip}</tag>"
|
|
6
|
-
create_snip :name => "test", :content => "blah {other_snip}", :part => 'part content'
|
|
7
|
-
create_snip :name => "other_snip", :content => "blah!"
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
context "HTML" do
|
|
11
|
-
should "render the snip's content in the system template if no format or part is given" do
|
|
12
|
-
assert_response_body "<tag>blah blah!</tag>", "/test"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
should "render the snip's content in the system template if the HTML format is given" do
|
|
16
|
-
assert_response_body "<tag>blah blah!</tag>", "/test.html"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
should "render the requested part within the main template when a part is given" do
|
|
20
|
-
assert_response_body "<tag>part content</tag>", "/test/part"
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
should "have a response code of 200" do
|
|
24
|
-
assert_equal 200, response_code_for("/test")
|
|
25
|
-
assert_equal 200, response_code_for("/test.html")
|
|
26
|
-
assert_equal 200, response_code_for("/test/part")
|
|
27
|
-
assert_equal 200, response_code_for("/test/part.html")
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
should "not allow rendering of the layout to produce infinite recursion" do
|
|
31
|
-
assert_response_body "Rendering of the current layout would result in infinite recursion.", "/layout"
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
context "as text" do
|
|
36
|
-
should "render the snip's content outside of the main template with its default renderer" do
|
|
37
|
-
assert_response_body "blah blah!", "/test.text"
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
should "render the snip part outside the main template when a format is given" do
|
|
41
|
-
assert_response_body "part content", "/test/part.text"
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
should "have a response code of 200" do
|
|
45
|
-
assert_equal 200, response_code_for("/test.text")
|
|
46
|
-
assert_equal 200, response_code_for("/test/part.text")
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
context "raw content" do
|
|
51
|
-
should "render the snips contents exactly as they are" do
|
|
52
|
-
assert_response_body "blah {other_snip}", "/test.raw"
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
should "render the snip content exactly even if a render_as attribute exists" do
|
|
56
|
-
assert_response_body "CurrentSnip", "/current_snip.raw"
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
should "render a snips part if requested" do
|
|
60
|
-
assert_response_body "part content", "/test/part.raw"
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
should "have a response code of 200" do
|
|
64
|
-
assert_equal 200, response_code_for("/test.raw")
|
|
65
|
-
assert_equal 200, response_code_for("/test/part.raw")
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
context "a snip with a custom layout" do
|
|
70
|
-
should "render the snips contents within that layout" do
|
|
71
|
-
create_snip :name => "custom-layout", :content => "<custom>{current_snip}</custom>"
|
|
72
|
-
create_snip :name => "test", :content => "this is a test", :layout => "custom-layout"
|
|
73
|
-
assert_response_body "<custom>this is a test</custom>", "/test"
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
class CustomRenderer < ::Vanilla::Renderers::Base
|
|
78
|
-
def default_layout_snip
|
|
79
|
-
soup['custom-layout']
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
context "a snip using a renderer that specifies a template" do
|
|
84
|
-
setup do
|
|
85
|
-
@app.register_renderer CustomRenderer, "custom"
|
|
86
|
-
create_snip :name => "custom-layout", :content => "<custom>{current_snip}</custom>"
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
should "use the renderer's specified layout" do
|
|
90
|
-
create_snip :name => "test", :content => "this is a test", :render_as => "custom"
|
|
91
|
-
assert_response_body "<custom>this is a test</custom>", "/test"
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
should "use the snips layout when given" do
|
|
95
|
-
create_snip :name => "snip-custom-layout", :content => "<snipcustom>{current_snip}</snipcustom>"
|
|
96
|
-
create_snip :name => "test", :content => "this is a test", :render_as => "custom", :layout => "snip-custom-layout"
|
|
97
|
-
assert_response_body "<snipcustom>this is a test</snipcustom>", "/test"
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
context "and a custom default renderer has been provided" do
|
|
102
|
-
should "use that renderer" do
|
|
103
|
-
@app = Vanilla::App.new(:soup => soup_path, :default_renderer => ::Vanilla::Renderers::Bold)
|
|
104
|
-
create_snip :name => "layout", :content => "{test}", :render_as => "base"
|
|
105
|
-
create_snip :name => "test", :content => "test"
|
|
106
|
-
assert_response_body "<b>test</b>", "/test"
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
context "and a missing snip is requested" do
|
|
111
|
-
should "render missing snip content in the main template" do
|
|
112
|
-
assert_response_body %{<tag>Couldn't find snip "missing_snip"</tag>}, "/missing_snip"
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
should "have a 404 response code" do
|
|
116
|
-
assert_equal 404, response_code_for("/missing_snip")
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
context "requesting an unknown format" do
|
|
121
|
-
should "return a 500 status code" do
|
|
122
|
-
assert_equal 500, response_code_for("/test.monkey")
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
end
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
require "test_helper"
|
|
2
|
-
|
|
3
|
-
describe Vanilla::Request do
|
|
4
|
-
context "when requesting the root" do
|
|
5
|
-
setup { @request = Vanilla::Request.new(mock_env_for_url("/"), @app) }
|
|
6
|
-
|
|
7
|
-
should "set snip to 'start' by default" do
|
|
8
|
-
assert_equal "start", @request.snip_name
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
should "set format to 'html'" do
|
|
12
|
-
assert_equal "html", @request.format
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
context "when requesting urls" do
|
|
17
|
-
setup { @request = Vanilla::Request.new(mock_env_for_url("/snip"), @app) }
|
|
18
|
-
|
|
19
|
-
should "use the first segement as the snip name" do
|
|
20
|
-
assert_equal "snip", @request.snip_name
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
should "try to load the snip based on the snip name" do
|
|
24
|
-
@app.soup.expects(:[]).with('snip').returns(:snip)
|
|
25
|
-
assert_equal :snip, @request.snip
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
should "have no part if the url contains only a single segment" do
|
|
29
|
-
assert_equal nil, @request.part
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
should "have a default format of html" do
|
|
33
|
-
assert_equal 'html', @request.format
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
should "determine the request method" do
|
|
37
|
-
assert_equal 'get', @request.method
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
context "when requesting a snip part" do
|
|
42
|
-
setup { @request = Vanilla::Request.new(mock_env_for_url("/snip/part"), @app) }
|
|
43
|
-
|
|
44
|
-
should "use the first segment as the snip, and the second segment as the part" do
|
|
45
|
-
assert_equal "snip", @request.snip_name
|
|
46
|
-
assert_equal "part", @request.part
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
should "have a default format of html" do
|
|
50
|
-
assert_equal "html", @request.format
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
context "when requesting a snip with a format" do
|
|
55
|
-
setup { @request = Vanilla::Request.new(mock_env_for_url("/snip.raw"), @app) }
|
|
56
|
-
|
|
57
|
-
should "use the extension as the format" do
|
|
58
|
-
assert_equal "raw", @request.format
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
should "retain the filename part of the path as the snip" do
|
|
62
|
-
assert_equal "snip", @request.snip_name
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
context "when requesting a snip part with a format" do
|
|
67
|
-
setup { @request = Vanilla::Request.new(mock_env_for_url("/snip/part.raw"), @app) }
|
|
68
|
-
|
|
69
|
-
should "use the extension as the format" do
|
|
70
|
-
assert_equal "raw", @request.format
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
should "retain the first segment of the path as the snip" do
|
|
74
|
-
assert_equal "snip", @request.snip_name
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
should "use the filename part of the second segment as the snip part" do
|
|
78
|
-
assert_equal "part", @request.part
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
context "when requested with a _method parameter" do
|
|
83
|
-
should "return the method using the parameter" do
|
|
84
|
-
assert_equal 'put', Vanilla::Request.new(mock_env_for_url("/snip?_method=put"), @app).method
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|