vanilla 1.11.1 → 1.11.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/config.example.yml +5 -2
- data/lib/tasks/vanilla.rake +39 -76
- data/lib/vanilla/app.rb +1 -1
- data/lib/vanilla/dynasnips/title.rb +7 -0
- data/lib/vanilla/snips/system.rb +9 -17
- data/test/tmp/soup/current_snip.yml +2 -2
- data/test/tmp/soup/system.yml +2 -2
- metadata +3 -2
data/Rakefile
CHANGED
data/config.example.yml
CHANGED
data/lib/tasks/vanilla.rake
CHANGED
@@ -7,61 +7,11 @@ namespace :vanilla do
|
|
7
7
|
sh "irb -Ilib -rubygems -rvanilla -rvanilla/console"
|
8
8
|
end
|
9
9
|
|
10
|
-
task :clean do
|
11
|
-
# TODO: get the database name from Soup
|
12
|
-
FileUtils.rm "soup.db" if File.exist?("soup.db")
|
13
|
-
end
|
14
|
-
|
15
|
-
task :load_snips do
|
16
|
-
app = Vanilla::App.new(ENV['VANILLA_CONFIG'])
|
17
|
-
print "Preparing soup... "
|
18
|
-
Dynasnip.all.each { |ds| app.soup << ds.snip_attributes }
|
19
|
-
Dir[File.join(File.dirname(__FILE__), '..', 'vanilla', 'snips', '*.rb')].each do |f|
|
20
|
-
load f
|
21
|
-
end
|
22
|
-
puts "the soup is simmering."
|
23
|
-
end
|
24
|
-
|
25
|
-
desc 'Resets the soup to contain the base snips only. Dangerous!'
|
26
|
-
task :reset => [:clean, :load_snips]
|
27
|
-
|
28
|
-
namespace :upgrade do
|
29
|
-
desc 'Upgrade the dynasnips'
|
30
|
-
task :dynasnips do
|
31
|
-
app = Vanilla::App.new(ENV['VANILLA_CONFIG'])
|
32
|
-
Dynasnip.all.each do |dynasnip|
|
33
|
-
print "Upgrading #{dynasnip.snip_name}... "
|
34
|
-
# TODO: our confused Soup interface might return an array.
|
35
|
-
snip = app.soup[dynasnip.snip_name]
|
36
|
-
if snip.empty? || snip.nil?
|
37
|
-
# it's a new dyna
|
38
|
-
app.soup << dynasnip.snip_attributes
|
39
|
-
puts "(new)"
|
40
|
-
elsif snip.created_at == snip.updated_at
|
41
|
-
# it's not been changed, let's upgrade
|
42
|
-
snip.destroy
|
43
|
-
app.soup << dynasnip.snip_attributes
|
44
|
-
puts "(unedited)"
|
45
|
-
else
|
46
|
-
# the dyna exists and has been changed
|
47
|
-
dynasnip.snip_attributes.each do |name, value|
|
48
|
-
unless (existing_value = snip.get_value(name)) == value
|
49
|
-
puts "Conflict in attribute '#{name}':"
|
50
|
-
puts "> Your soup: '#{existing_value}'"
|
51
|
-
puts "> New soup: '#{value}"
|
52
|
-
print "Upgrade? [Y/n]: "
|
53
|
-
upgrade_value = ["Y", "y", ""].include? STDIN.gets.chomp.strip
|
54
|
-
snip.set_value(name, value) if upgrade_value
|
55
|
-
end
|
56
|
-
end
|
57
|
-
snip.save
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
10
|
desc 'Upgrade dynasnips and system snips'
|
64
|
-
task :upgrade
|
11
|
+
task :upgrade do
|
12
|
+
# TODO
|
13
|
+
puts "TODO, but should be easier thanks to multi-space soup."
|
14
|
+
end
|
65
15
|
|
66
16
|
desc 'Add a user (or change an existing password)'
|
67
17
|
task :add_user => :prepare do
|
@@ -107,37 +57,18 @@ namespace :vanilla do
|
|
107
57
|
puts "done; cookies are twice baked. BIS-CUIT!"
|
108
58
|
end
|
109
59
|
|
110
|
-
desc 'Prepare standard files to run Vanilla'
|
111
|
-
task :prepare_files do
|
112
|
-
cp File.expand_path(File.join(File.dirname(__FILE__), *%w[.. .. config.ru])), 'config.ru'
|
113
|
-
cp File.expand_path(File.join(File.dirname(__FILE__), *%w[.. .. config.example.yml])), 'config.yml'
|
114
|
-
cp File.expand_path(File.join(File.dirname(__FILE__), *%w[.. .. README_FOR_APP])), 'README'
|
115
|
-
cp_r File.expand_path(File.join(File.dirname(__FILE__), *%w[.. .. public])), 'public'
|
116
|
-
mkdir 'tmp'
|
117
|
-
File.open("Rakefile", "w") do |f|
|
118
|
-
rakefile =<<-EOF
|
119
|
-
require 'vanilla'
|
120
|
-
load 'tasks/vanilla.rake'
|
121
|
-
|
122
|
-
# Add any other tasks here.
|
123
|
-
EOF
|
124
|
-
f.write rakefile.strip
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
|
129
60
|
desc 'Prepare a new vanilla.rb installation'
|
130
61
|
task :setup do
|
131
62
|
puts <<-EOM
|
132
63
|
____________________.c( Vanilla.rb )o._____________________
|
133
64
|
|
134
|
-
Congratulations! You have elected to try out the weirdest web
|
65
|
+
Congratulations! You have elected to try out the weirdest web
|
135
66
|
thing ever. Lets get started.
|
136
67
|
|
137
68
|
EOM
|
138
|
-
Rake::Task['vanilla:prepare_files'].invoke
|
69
|
+
Rake::Task['vanilla:setup:prepare_files'].invoke
|
139
70
|
Rake::Task['vanilla:generate_secret'].invoke
|
140
|
-
Rake::Task['vanilla:load_snips'].invoke
|
71
|
+
Rake::Task['vanilla:setup:load_snips'].invoke
|
141
72
|
|
142
73
|
puts <<-EOM
|
143
74
|
|
@@ -146,4 +77,36 @@ ___________________.c( You Are Ready )o.___________________
|
|
146
77
|
#{File.readlines('README')[0,16].join}
|
147
78
|
EOM
|
148
79
|
end
|
80
|
+
|
81
|
+
namespace :setup do
|
82
|
+
desc 'Prepare standard files to run Vanilla'
|
83
|
+
task :prepare_files do
|
84
|
+
cp File.expand_path(File.join(File.dirname(__FILE__), *%w[.. .. config.ru])), 'config.ru'
|
85
|
+
cp File.expand_path(File.join(File.dirname(__FILE__), *%w[.. .. config.example.yml])), 'config.yml'
|
86
|
+
cp File.expand_path(File.join(File.dirname(__FILE__), *%w[.. .. README_FOR_APP])), 'README'
|
87
|
+
cp_r File.expand_path(File.join(File.dirname(__FILE__), *%w[.. .. public])), 'public'
|
88
|
+
mkdir 'tmp'
|
89
|
+
File.open("Rakefile", "w") do |f|
|
90
|
+
rakefile =<<-EOF
|
91
|
+
require 'vanilla'
|
92
|
+
load 'tasks/vanilla.rake'
|
93
|
+
|
94
|
+
# Add any other tasks here.
|
95
|
+
EOF
|
96
|
+
f.write rakefile.strip
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
task :load_snips do
|
101
|
+
print "Preparing soup... "
|
102
|
+
system_soup = ::Soup.new(::Soup::Backends::YAMLBackend.new("soup/system"))
|
103
|
+
system_soup << eval(File.read(File.join(File.dirname(__FILE__), '..', 'vanilla', 'snips', 'system.rb')))
|
104
|
+
dynasnip_soup = ::Soup.new(::Soup::Backends::YAMLBackend.new("soup/system/dynasnips"))
|
105
|
+
Dynasnip.all.each { |ds| dynasnip_soup << ds.snip_attributes }
|
106
|
+
Dir[File.join(File.dirname(__FILE__), '..', 'vanilla', 'snips', '{start,tutorial}.rb')].each do |f|
|
107
|
+
load f
|
108
|
+
end
|
109
|
+
puts "the soup is simmering."
|
110
|
+
end
|
111
|
+
end
|
149
112
|
end
|
data/lib/vanilla/app.rb
CHANGED
data/lib/vanilla/snips/system.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
system.main_template = <<-HTML
|
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 => %^
|
6
4
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
7
5
|
<html lang="en">
|
8
6
|
<head>
|
@@ -24,10 +22,8 @@ system.main_template = <<-HTML
|
|
24
22
|
{current_snip}
|
25
23
|
</div>
|
26
24
|
</body>
|
27
|
-
</html
|
28
|
-
|
29
|
-
|
30
|
-
system.login_template = <<-HTML
|
25
|
+
</html>^,
|
26
|
+
:login_template => %^
|
31
27
|
<html>
|
32
28
|
<head><link rel="stylesheet" type="text/css" media="screen" href="/system/css.css" /></head>
|
33
29
|
<body id="login">
|
@@ -38,10 +34,8 @@ system.login_template = <<-HTML
|
|
38
34
|
<button>login</button>
|
39
35
|
</form>
|
40
36
|
</body>
|
41
|
-
</html
|
42
|
-
|
43
|
-
|
44
|
-
system.css = <<-CSS
|
37
|
+
</html>^,
|
38
|
+
:css => %^
|
45
39
|
body {
|
46
40
|
font-family: Helvetica;
|
47
41
|
background-color: #666;
|
@@ -86,7 +80,5 @@ a.new {
|
|
86
80
|
|
87
81
|
a.new:hover {
|
88
82
|
text-decoration: underline;
|
89
|
-
}
|
90
|
-
|
91
|
-
|
92
|
-
system.save
|
83
|
+
}^
|
84
|
+
}
|
@@ -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
|
-
:
|
12
|
+
:created_at: 2010-07-14 13:33:29.054359 +01:00
|
13
13
|
:name: current_snip
|
14
|
-
:
|
14
|
+
:updated_at: 2010-07-14 13:33:29.054361 +01:00
|
15
15
|
:render_as: Ruby
|
data/test/tmp/soup/system.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
--- # Soup attributes
|
2
|
-
:
|
2
|
+
:created_at: 2010-07-14 13:33:29.054848 +01:00
|
3
3
|
:name: system
|
4
|
-
:
|
4
|
+
:updated_at: 2010-07-14 13:33:29.054850 +01:00
|
5
5
|
:main_template: "{current_snip}"
|
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
|
+
- 2
|
9
|
+
version: 1.11.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- James Adam
|
@@ -203,6 +203,7 @@ files:
|
|
203
203
|
- lib/vanilla/dynasnips/pre.rb
|
204
204
|
- lib/vanilla/dynasnips/rand.rb
|
205
205
|
- lib/vanilla/dynasnips/raw.rb
|
206
|
+
- lib/vanilla/dynasnips/title.rb
|
206
207
|
- lib/vanilla/dynasnips/url_to.rb
|
207
208
|
- lib/vanilla/renderers/base.rb
|
208
209
|
- lib/vanilla/renderers/bold.rb
|