vanilla 1.11.1 → 1.11.2

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 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.1"
27
+ s.version = "1.11.2"
28
28
  s.summary = "A bliki-type web content thing."
29
29
  s.author = "James Adam"
30
30
  s.email = "james@lazyatom.com.com"
data/config.example.yml CHANGED
@@ -1,3 +1,6 @@
1
1
  ---
2
- :soup: soup
3
- :secret: a6bc097eff86cabd92ee72ba4687c3f057b7556deaa3e4a6b284460871056b87ba3e91548c37dcc44fbc10241cee5b386556e6bcc2946fd9b609dc3bc1b24488
2
+ :soups:
3
+ - soup
4
+ - soup/dynasnips
5
+ - soup/system
6
+ - soup/system/dynasnips
@@ -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 => ["upgrade:dynasnips"]
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
@@ -86,7 +86,7 @@ module Vanilla
86
86
  end
87
87
 
88
88
  def snip(attributes)
89
- @soup.new_snip(attributes)
89
+ @soup << attributes
90
90
  end
91
91
 
92
92
  private
@@ -0,0 +1,7 @@
1
+ require 'vanilla/dynasnip'
2
+
3
+ class Title < Dynasnip
4
+ def handle
5
+ app.request.snip.__send__(:title) || app.request.snip.__send__(:name)
6
+ end
7
+ end
@@ -1,8 +1,6 @@
1
- app = Vanilla::App.new(ENV['VANILLA_CONFIG'])
2
- system = app.snip(:name => "system")
3
- system.content = "You're in the system snip now. You probably want to {edit_link system,edit} it though."
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
- HTML
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
- HTML
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
- CSS
91
-
92
- system.save
83
+ }^
84
+ }
@@ -9,7 +9,7 @@ CurrentSnip--- # Soup attributes
9
9
  &#123;current_snip name&#125;
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-07-14 12:51:59.809435 +01:00
12
+ :created_at: 2010-07-14 13:33:29.054359 +01:00
13
13
  :name: current_snip
14
- :created_at: 2010-07-14 12:51:59.809433 +01:00
14
+ :updated_at: 2010-07-14 13:33:29.054361 +01:00
15
15
  :render_as: Ruby
@@ -1,5 +1,5 @@
1
1
  --- # Soup attributes
2
- :updated_at: 2010-07-14 12:51:59.809910 +01:00
2
+ :created_at: 2010-07-14 13:33:29.054848 +01:00
3
3
  :name: system
4
- :created_at: 2010-07-14 12:51:59.809908 +01:00
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
- - 1
9
- version: 1.11.1
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