vanilla 1.12.5 → 1.13.1
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 +3 -4
- data/config.example.yml +1 -0
- data/config.ru +0 -14
- data/lib/tasks/vanilla.rake +13 -50
- data/lib/vanilla/app.rb +0 -3
- data/lib/vanilla/dynasnips/comments.rb +16 -47
- data/lib/vanilla/dynasnips/index.rb +2 -2
- data/lib/vanilla/request.rb +0 -16
- data/lib/vanilla/snips/system/layout.snip +19 -0
- data/lib/vanilla/snips/{start.rb → system/start.snip} +3 -6
- data/lib/vanilla/snips/system/system.snip +17 -0
- data/lib/vanilla/snips/tutorial/bad_dynasnip.snip +8 -0
- data/lib/vanilla/snips/tutorial/hello_world.snip +20 -0
- data/lib/vanilla/snips/tutorial/markdown_example.snip +13 -0
- data/lib/vanilla/snips/tutorial/snip.snip +9 -0
- data/lib/vanilla/snips/tutorial/soup.snip +5 -0
- data/lib/vanilla/snips/tutorial/test.snip +30 -0
- data/lib/vanilla/snips/tutorial/textile_example.snip +11 -0
- data/lib/vanilla/snips/tutorial/tutorial-another-snip.snip +1 -0
- data/lib/vanilla/snips/tutorial/tutorial-basic-snip-inclusion.snip +1 -0
- data/lib/vanilla/snips/tutorial/vanilla-rb-tutorial.snip +73 -0
- data/lib/vanilla/snips/tutorial/vanilla-rb.snip +16 -0
- data/lib/vanilla/snips/tutorial/vanilla.snip +8 -0
- data/lib/vanilla.rb +4 -0
- data/test/tmp/config.yml +1 -1
- data/test/tmp/soup/current_snip.snip +2 -2
- metadata +28 -42
- data/lib/defensio.rb +0 -59
- data/lib/vanilla/authentication/warden.rb +0 -58
- data/lib/vanilla/authentication.rb +0 -24
- data/lib/vanilla/dynasnips/edit.rb +0 -59
- data/lib/vanilla/dynasnips/edit_link.rb +0 -20
- data/lib/vanilla/dynasnips/logout.rb +0 -8
- data/lib/vanilla/dynasnips/new.rb +0 -12
- data/lib/vanilla/snips/system.rb +0 -84
- data/lib/vanilla/snips/tutorial.rb +0 -244
- data/public/javascripts/jquery.autogrow-textarea.js +0 -54
- data/public/javascripts/jquery.js +0 -4376
- data/public/javascripts/vanilla.js +0 -22
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vanilla
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 33
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 13
|
9
|
+
- 1
|
10
|
+
version: 1.13.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- James Adam
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-02-22 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -42,12 +42,12 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
45
|
+
hash: 17
|
46
46
|
segments:
|
47
47
|
- 1
|
48
48
|
- 0
|
49
|
-
-
|
50
|
-
version: 1.0.
|
49
|
+
- 3
|
50
|
+
version: 1.0.3
|
51
51
|
type: :runtime
|
52
52
|
version_requirements: *id002
|
53
53
|
- !ruby/object:Gem::Dependency
|
@@ -115,19 +115,17 @@ dependencies:
|
|
115
115
|
type: :runtime
|
116
116
|
version_requirements: *id006
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
|
-
name:
|
118
|
+
name: haml
|
119
119
|
prerelease: false
|
120
120
|
requirement: &id007 !ruby/object:Gem::Requirement
|
121
121
|
none: false
|
122
122
|
requirements:
|
123
123
|
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
hash:
|
125
|
+
hash: 3
|
126
126
|
segments:
|
127
127
|
- 0
|
128
|
-
|
129
|
-
- 2
|
130
|
-
version: 0.5.2
|
128
|
+
version: "0"
|
131
129
|
type: :runtime
|
132
130
|
version_requirements: *id007
|
133
131
|
- !ruby/object:Gem::Dependency
|
@@ -158,20 +156,6 @@ dependencies:
|
|
158
156
|
version: "0"
|
159
157
|
type: :development
|
160
158
|
version_requirements: *id009
|
161
|
-
- !ruby/object:Gem::Dependency
|
162
|
-
name: haml
|
163
|
-
prerelease: false
|
164
|
-
requirement: &id010 !ruby/object:Gem::Requirement
|
165
|
-
none: false
|
166
|
-
requirements:
|
167
|
-
- - ">="
|
168
|
-
- !ruby/object:Gem::Version
|
169
|
-
hash: 3
|
170
|
-
segments:
|
171
|
-
- 0
|
172
|
-
version: "0"
|
173
|
-
type: :development
|
174
|
-
version_requirements: *id010
|
175
159
|
description:
|
176
160
|
email: james@lazyatom.com.com
|
177
161
|
executables:
|
@@ -202,24 +186,17 @@ files:
|
|
202
186
|
- test/vanilla_app_test.rb
|
203
187
|
- test/vanilla_presenting_test.rb
|
204
188
|
- test/vanilla_request_test.rb
|
205
|
-
- lib/defensio.rb
|
206
189
|
- lib/tasks/vanilla.rake
|
207
190
|
- lib/vanilla/app.rb
|
208
|
-
- lib/vanilla/authentication/warden.rb
|
209
|
-
- lib/vanilla/authentication.rb
|
210
191
|
- lib/vanilla/console.rb
|
211
192
|
- lib/vanilla/dynasnip.rb
|
212
193
|
- lib/vanilla/dynasnips/comments.rb
|
213
194
|
- lib/vanilla/dynasnips/current_snip.rb
|
214
195
|
- lib/vanilla/dynasnips/debug.rb
|
215
|
-
- lib/vanilla/dynasnips/edit.rb
|
216
|
-
- lib/vanilla/dynasnips/edit_link.rb
|
217
196
|
- lib/vanilla/dynasnips/index.rb
|
218
197
|
- lib/vanilla/dynasnips/kind.rb
|
219
198
|
- lib/vanilla/dynasnips/link_to.rb
|
220
199
|
- lib/vanilla/dynasnips/link_to_current_snip.rb
|
221
|
-
- lib/vanilla/dynasnips/logout.rb
|
222
|
-
- lib/vanilla/dynasnips/new.rb
|
223
200
|
- lib/vanilla/dynasnips/pre.rb
|
224
201
|
- lib/vanilla/dynasnips/rand.rb
|
225
202
|
- lib/vanilla/dynasnips/raw.rb
|
@@ -238,16 +215,25 @@ files:
|
|
238
215
|
- lib/vanilla/snip_reference.rb
|
239
216
|
- lib/vanilla/snip_reference.treetop
|
240
217
|
- lib/vanilla/snip_reference_parser.rb
|
241
|
-
- lib/vanilla/snips/
|
242
|
-
- lib/vanilla/snips/system.
|
243
|
-
- lib/vanilla/snips/
|
218
|
+
- lib/vanilla/snips/system/layout.snip
|
219
|
+
- lib/vanilla/snips/system/start.snip
|
220
|
+
- lib/vanilla/snips/system/system.snip
|
221
|
+
- lib/vanilla/snips/tutorial/bad_dynasnip.snip
|
222
|
+
- lib/vanilla/snips/tutorial/hello_world.snip
|
223
|
+
- lib/vanilla/snips/tutorial/markdown_example.snip
|
224
|
+
- lib/vanilla/snips/tutorial/snip.snip
|
225
|
+
- lib/vanilla/snips/tutorial/soup.snip
|
226
|
+
- lib/vanilla/snips/tutorial/test.snip
|
227
|
+
- lib/vanilla/snips/tutorial/textile_example.snip
|
228
|
+
- lib/vanilla/snips/tutorial/tutorial-another-snip.snip
|
229
|
+
- lib/vanilla/snips/tutorial/tutorial-basic-snip-inclusion.snip
|
230
|
+
- lib/vanilla/snips/tutorial/vanilla-rb-tutorial.snip
|
231
|
+
- lib/vanilla/snips/tutorial/vanilla-rb.snip
|
232
|
+
- lib/vanilla/snips/tutorial/vanilla.snip
|
244
233
|
- lib/vanilla/static.rb
|
245
234
|
- lib/vanilla.rb
|
246
235
|
- bin/vanilla
|
247
236
|
- public/hatch.png
|
248
|
-
- public/javascripts/jquery.autogrow-textarea.js
|
249
|
-
- public/javascripts/jquery.js
|
250
|
-
- public/javascripts/vanilla.js
|
251
237
|
has_rdoc: true
|
252
238
|
homepage: http://github.com/lazyatom/vanilla-rb
|
253
239
|
licenses: []
|
@@ -279,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
279
265
|
requirements: []
|
280
266
|
|
281
267
|
rubyforge_project: vanilla
|
282
|
-
rubygems_version: 1.
|
268
|
+
rubygems_version: 1.4.1
|
283
269
|
signing_key:
|
284
270
|
specification_version: 3
|
285
271
|
summary: A bliki-type web content thing.
|
data/lib/defensio.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
class Defensio
|
2
|
-
class << self
|
3
|
-
attr_accessor :format
|
4
|
-
attr_accessor :service_type
|
5
|
-
attr_accessor :api_version
|
6
|
-
attr_accessor :api_key
|
7
|
-
attr_accessor :owner_url
|
8
|
-
end
|
9
|
-
|
10
|
-
self.format = :xml
|
11
|
-
self.service_type = :app # Can be :blog
|
12
|
-
self.api_version = '1.2'
|
13
|
-
|
14
|
-
def self.configure(confhash)
|
15
|
-
if confhash['test']
|
16
|
-
@mock = true
|
17
|
-
self.owner_url = 'http://www.example.com'
|
18
|
-
return
|
19
|
-
else
|
20
|
-
confhash.each do |prop, val|
|
21
|
-
self.send("#{prop}=", val)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.method_missing(name, *args)
|
27
|
-
self.post(name.to_s.dasherize, *args)
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
def self.connection
|
32
|
-
uri = URI.parse('http://api.defensio.com/')
|
33
|
-
Net::HTTP.start(uri.host, uri.port)
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.post(action, params = {})
|
37
|
-
resp = connection.post(real_path(action), params_from_hash(params))
|
38
|
-
raise "Problem with request: #{action}" unless resp.code == '200'
|
39
|
-
parse_response(resp.body)
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.real_path(action)
|
43
|
-
"/#{service_type}/#{api_version}/#{action}/#{api_key}.#{format}"
|
44
|
-
end
|
45
|
-
|
46
|
-
def self.params_from_hash(params = {})
|
47
|
-
# Thanks Net::HTTPHeader
|
48
|
-
params.stringify_keys.merge('owner-url' => owner_url).map {|k,v| "#{CGI.escape(k.dasherize.to_s)}=#{CGI.escape(v.to_s)}" }.join('&')
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.parse_response(body)
|
52
|
-
case format
|
53
|
-
when :yaml
|
54
|
-
YAML.load(body)
|
55
|
-
when :xml
|
56
|
-
Hash.from_xml(body)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'warden'
|
2
|
-
require 'md5'
|
3
|
-
|
4
|
-
module Vanilla
|
5
|
-
module Authentication
|
6
|
-
class Warden < Base
|
7
|
-
def initialize(app)
|
8
|
-
super
|
9
|
-
::Warden::Strategies.add(:vanilla, Vanilla::Authentication::Warden::Strategy)
|
10
|
-
end
|
11
|
-
|
12
|
-
def authenticated?
|
13
|
-
@app.request.env['warden'].authenticated?
|
14
|
-
end
|
15
|
-
|
16
|
-
def user
|
17
|
-
@app.request.env['warden'].user
|
18
|
-
end
|
19
|
-
|
20
|
-
def authenticate!
|
21
|
-
@app.request.env['warden'].authenticate!
|
22
|
-
end
|
23
|
-
|
24
|
-
def logout
|
25
|
-
@app.request.env['warden'].logout
|
26
|
-
end
|
27
|
-
|
28
|
-
class Strategy < ::Warden::Strategies::Base
|
29
|
-
def valid?
|
30
|
-
params["name"] || params["password"]
|
31
|
-
end
|
32
|
-
|
33
|
-
def authenticate!
|
34
|
-
if env['vanilla.app'].config[:credentials][params["name"]] == MD5.md5(params["password"]).to_s
|
35
|
-
# clear these so they don't interfere with the request
|
36
|
-
env['vanilla.app'].request.params.delete(:name)
|
37
|
-
env['vanilla.app'].request.params.delete(:password)
|
38
|
-
success!(params["name"])
|
39
|
-
else
|
40
|
-
fail! "Sorry, you couldn't be logged in with those details"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
class FailApp
|
46
|
-
def call(env)
|
47
|
-
[401, {"Content-Type" => "text/html"}, [login_form(env)]]
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def login_form(env)
|
53
|
-
env['vanilla.app'].soup["system"].login_template.gsub("MESSAGE", env['warden'].message || "Please log in")
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Vanilla
|
2
|
-
module Authentication
|
3
|
-
# A pass-through authenticator, which never
|
4
|
-
# requires a login
|
5
|
-
class Base
|
6
|
-
def initialize(app)
|
7
|
-
@app = app
|
8
|
-
end
|
9
|
-
|
10
|
-
def authenticated?
|
11
|
-
true
|
12
|
-
end
|
13
|
-
|
14
|
-
def user
|
15
|
-
end
|
16
|
-
|
17
|
-
def authenticate!
|
18
|
-
end
|
19
|
-
|
20
|
-
def logout
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'vanilla/dynasnip'
|
2
|
-
|
3
|
-
# The edit dyna will load the snip given in the 'snip_to_edit' part of the
|
4
|
-
# params
|
5
|
-
class EditSnip < Dynasnip
|
6
|
-
snip_name "edit"
|
7
|
-
|
8
|
-
def get(snip_name=nil)
|
9
|
-
app.request.authenticate!
|
10
|
-
|
11
|
-
snip = app.soup[snip_name || app.request.params[:name]]
|
12
|
-
edit(snip)
|
13
|
-
end
|
14
|
-
|
15
|
-
def post(*args)
|
16
|
-
app.request.authenticate!
|
17
|
-
|
18
|
-
snip_attributes = cleaned_params
|
19
|
-
snip_attributes.delete(:save_button)
|
20
|
-
return 'no params' if snip_attributes.empty?
|
21
|
-
snip = app.soup[snip_attributes[:name]]
|
22
|
-
snip_attributes.each do |name, value|
|
23
|
-
snip.__send__("#{name}=", value)
|
24
|
-
end
|
25
|
-
snip.save
|
26
|
-
%{Saved snip #{link_to snip_attributes[:name]} ok}
|
27
|
-
rescue Exception => e
|
28
|
-
app.soup << snip_attributes
|
29
|
-
%{Created snip #{link_to snip_attributes[:name]} ok}
|
30
|
-
end
|
31
|
-
|
32
|
-
def edit(snip)
|
33
|
-
renderer = Vanilla::Renderers::Erb.new(app)
|
34
|
-
renderer.instance_eval { @snip_to_edit = snip } # hacky!
|
35
|
-
snip_in_edit_template = renderer.render_without_including_snips(app.soup['edit'], :template)
|
36
|
-
prevent_snip_inclusion(snip_in_edit_template)
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def prevent_snip_inclusion(content)
|
42
|
-
content.gsub("{", "{").gsub("}" ,"}")
|
43
|
-
end
|
44
|
-
|
45
|
-
attribute :template, %{
|
46
|
-
<form action="<%= url_to 'edit' %>" method="post">
|
47
|
-
<dl class="attributes">
|
48
|
-
<% @snip_to_edit.attributes.each do |name, value| %>
|
49
|
-
<dt><%= name %></dt>
|
50
|
-
<dd><textarea name="<%= name %>" class="<%= name %>"><%=h value %></textarea></dd>
|
51
|
-
<% end %>
|
52
|
-
<dt><input class="attribute_name" type="text"></dt>
|
53
|
-
<dd><textarea></textarea></dd>
|
54
|
-
</dl>
|
55
|
-
<a href="#" id="add">Add</a>
|
56
|
-
<button name='save_button'>Save</button>
|
57
|
-
</form>
|
58
|
-
}
|
59
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'vanilla/dynasnip'
|
2
|
-
|
3
|
-
class EditLink < Dynasnip
|
4
|
-
usage %|
|
5
|
-
You can use the edit_link snip to insert links for editing other snips. For example:
|
6
|
-
|
7
|
-
{edit_link blah}
|
8
|
-
|
9
|
-
would insert a link to an editor for the blah snip.
|
10
|
-
|
11
|
-
You can also give a custom piece of text for the link, like this:
|
12
|
-
|
13
|
-
{edit_link blah,link-name}|
|
14
|
-
|
15
|
-
def handle(*args)
|
16
|
-
snip_name = args[0] || app.request.snip_name
|
17
|
-
link_text = args[1] || "Edit"
|
18
|
-
edit_link(snip_name, link_text)
|
19
|
-
end
|
20
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'vanilla/dynasnip'
|
2
|
-
|
3
|
-
class NewSnip < Dynasnip
|
4
|
-
snip_name :new
|
5
|
-
|
6
|
-
def handle(*arg)
|
7
|
-
app.request.authenticate!
|
8
|
-
|
9
|
-
base_params = {:render_as => '', :content => '', :author => current_user}.update(app.request.params)
|
10
|
-
editor = EditSnip.new(app).edit(Soup::Snip.new(base_params))
|
11
|
-
end
|
12
|
-
end
|
data/lib/vanilla/snips/system.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
{:name => "system",
|
2
|
-
:content => "You're in the system snip now. You probably want to {edit_link system,edit} it though.",
|
3
|
-
:main_template => %^
|
4
|
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
5
|
-
<html lang="en">
|
6
|
-
<head>
|
7
|
-
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
8
|
-
<title>{title}</title>
|
9
|
-
<script language="javascript" src="/javascripts/jquery.js"></script>
|
10
|
-
<script language="javascript" src="/javascripts/jquery.autogrow-textarea.js"></script>
|
11
|
-
<script language="javascript" src="/javascripts/vanilla.js"></script>
|
12
|
-
<link rel="stylesheet" type="text/css" media="screen" href="<%= url_to("system", "css.css") %>" />
|
13
|
-
</head>
|
14
|
-
<body>
|
15
|
-
<div id="content">
|
16
|
-
<div id="controls">
|
17
|
-
<strong><a href="/">home</a></strong>,
|
18
|
-
<%= new_link %> ::
|
19
|
-
<strong>{link_to_current_snip}</strong> →
|
20
|
-
{edit_link}
|
21
|
-
</div>
|
22
|
-
{current_snip}
|
23
|
-
</div>
|
24
|
-
</body>
|
25
|
-
</html>^,
|
26
|
-
:login_template => %^
|
27
|
-
<html>
|
28
|
-
<head><link rel="stylesheet" type="text/css" media="screen" href="/system/css.css" /></head>
|
29
|
-
<body id="login">
|
30
|
-
<form action='' method='post'>
|
31
|
-
<h1>Login</h1><p class="message">MESSAGE</p>
|
32
|
-
<label>Name: <input type="text" name="login[username]"></input></label>
|
33
|
-
<label>Password: <input type="password" name="login[password]"></input></label>
|
34
|
-
<button>login</button>
|
35
|
-
</form>
|
36
|
-
</body>
|
37
|
-
</html>^,
|
38
|
-
:css => %^
|
39
|
-
body {
|
40
|
-
font-family: Helvetica;
|
41
|
-
background-color: #666;
|
42
|
-
margin: 0;
|
43
|
-
padding: 0;
|
44
|
-
}
|
45
|
-
|
46
|
-
div#content {
|
47
|
-
width: 800px;
|
48
|
-
margin: 0 auto;
|
49
|
-
background-color: #fff;
|
50
|
-
padding: 1em;
|
51
|
-
}
|
52
|
-
|
53
|
-
div#controls {
|
54
|
-
font-size: 80%;
|
55
|
-
padding-bottom: 1em;
|
56
|
-
margin-bottom: 1em;
|
57
|
-
border-bottom: 1px solid #999;
|
58
|
-
}
|
59
|
-
|
60
|
-
textarea {
|
61
|
-
width: 100%;
|
62
|
-
}
|
63
|
-
|
64
|
-
textarea.content {
|
65
|
-
min-height: 10em;
|
66
|
-
}
|
67
|
-
|
68
|
-
pre {
|
69
|
-
background-color: #f6f6f6;
|
70
|
-
border: 1px solid #ccc;
|
71
|
-
padding: 1em;
|
72
|
-
}
|
73
|
-
|
74
|
-
a.new {
|
75
|
-
background-color: #f0f0f0;
|
76
|
-
text-decoration: none;
|
77
|
-
color: #999;
|
78
|
-
padding: 0.2em;
|
79
|
-
}
|
80
|
-
|
81
|
-
a.new:hover {
|
82
|
-
text-decoration: underline;
|
83
|
-
}^
|
84
|
-
}
|