vanilla 1.0.2 → 1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/Rakefile +112 -109
  2. data/bin/vanilla +35 -6
  3. data/lib/vanilla.rb +10 -14
  4. data/lib/vanilla/app.rb +109 -41
  5. data/lib/vanilla/console.rb +22 -2
  6. data/lib/vanilla/dynasnip.rb +4 -36
  7. data/lib/vanilla/renderers.rb +12 -0
  8. data/lib/vanilla/renderers/base.rb +58 -34
  9. data/lib/vanilla/renderers/bold.rb +0 -2
  10. data/lib/vanilla/renderers/erb.rb +1 -3
  11. data/lib/vanilla/renderers/haml.rb +13 -0
  12. data/lib/vanilla/renderers/markdown.rb +0 -2
  13. data/lib/vanilla/renderers/raw.rb +0 -2
  14. data/lib/vanilla/renderers/ruby.rb +12 -6
  15. data/lib/vanilla/renderers/textile.rb +0 -2
  16. data/lib/vanilla/request.rb +19 -17
  17. data/lib/vanilla/routes.rb +9 -20
  18. data/lib/vanilla/snip_reference_parser.rb +94 -0
  19. data/lib/vanilla/static.rb +28 -0
  20. data/pristine_app/Gemfile +3 -0
  21. data/pristine_app/Gemfile.lock +32 -0
  22. data/pristine_app/README +47 -0
  23. data/pristine_app/config.ru +26 -0
  24. data/pristine_app/public/vanilla.css +15 -0
  25. data/pristine_app/soups/base/layout.snip +18 -0
  26. data/pristine_app/soups/base/start.snip +19 -0
  27. data/pristine_app/soups/dynasnips/current_snip.rb +29 -0
  28. data/{lib/vanilla → pristine_app/soups}/dynasnips/debug.rb +5 -3
  29. data/pristine_app/soups/dynasnips/index.rb +12 -0
  30. data/{lib/vanilla → pristine_app/soups}/dynasnips/link_to.rb +4 -2
  31. data/pristine_app/soups/dynasnips/link_to_current_snip.rb +14 -0
  32. data/pristine_app/soups/dynasnips/page_title.rb +9 -0
  33. data/{lib/vanilla → pristine_app/soups}/dynasnips/pre.rb +7 -5
  34. data/{lib/vanilla → pristine_app/soups}/dynasnips/raw.rb +8 -5
  35. data/pristine_app/soups/extras/comments.rb +78 -0
  36. data/{lib/vanilla/dynasnips → pristine_app/soups/extras}/kind.rb +19 -17
  37. data/{lib/vanilla/dynasnips → pristine_app/soups/extras}/rand.rb +2 -0
  38. data/pristine_app/soups/extras/url_to.rb +7 -0
  39. data/pristine_app/soups/tutorial/bad_dynasnip.snip +8 -0
  40. data/pristine_app/soups/tutorial/hello_world.snip +20 -0
  41. data/pristine_app/soups/tutorial/markdown_example.snip +13 -0
  42. data/pristine_app/soups/tutorial/snip.snip +9 -0
  43. data/pristine_app/soups/tutorial/soup.snip +3 -0
  44. data/pristine_app/soups/tutorial/test.snip +30 -0
  45. data/pristine_app/soups/tutorial/textile_example.snip +11 -0
  46. data/pristine_app/soups/tutorial/tutorial-another-snip.snip +1 -0
  47. data/pristine_app/soups/tutorial/tutorial-basic-snip-inclusion.snip +1 -0
  48. data/pristine_app/soups/tutorial/tutorial-dynasnips.snip.markdown +56 -0
  49. data/pristine_app/soups/tutorial/tutorial-layout.snip +56 -0
  50. data/pristine_app/soups/tutorial/tutorial-links.snip +4 -0
  51. data/pristine_app/soups/tutorial/tutorial-renderers.snip.markdown +77 -0
  52. data/pristine_app/soups/tutorial/tutorial.snip.markdown +69 -0
  53. data/pristine_app/soups/tutorial/vanilla-rb.snip +16 -0
  54. data/pristine_app/soups/tutorial/vanilla.snip +8 -0
  55. data/test/dynasnip_test.rb +42 -0
  56. data/test/dynasnips/link_to_current_snip_test.rb +19 -0
  57. data/test/dynasnips/link_to_test.rb +27 -0
  58. data/test/dynasnips/page_title_test.rb +19 -0
  59. data/test/renderers/base_renderer_test.rb +43 -0
  60. data/test/renderers/erb_renderer_test.rb +29 -0
  61. data/test/renderers/haml_renderer_test.rb +35 -0
  62. data/test/renderers/markdown_renderer_test.rb +31 -0
  63. data/test/renderers/raw_renderer_test.rb +23 -0
  64. data/test/renderers/ruby_renderer_test.rb +59 -0
  65. data/test/snip_inclusion_test.rb +56 -0
  66. data/test/snip_reference_parser_test.rb +123 -0
  67. data/test/test_helper.rb +75 -0
  68. data/test/vanilla_app_test.rb +83 -0
  69. data/test/vanilla_presenting_test.rb +125 -0
  70. data/test/vanilla_request_test.rb +87 -0
  71. metadata +179 -78
  72. data/config.example.yml +0 -5
  73. data/config.ru +0 -9
  74. data/lib/defensio.rb +0 -59
  75. data/lib/tasks/vanilla.rake +0 -177
  76. data/lib/vanilla/dynasnips/comments.rb +0 -108
  77. data/lib/vanilla/dynasnips/current_snip.rb +0 -32
  78. data/lib/vanilla/dynasnips/edit.rb +0 -63
  79. data/lib/vanilla/dynasnips/edit_link.rb +0 -24
  80. data/lib/vanilla/dynasnips/index.rb +0 -11
  81. data/lib/vanilla/dynasnips/link_to_current_snip.rb +0 -16
  82. data/lib/vanilla/dynasnips/login.rb +0 -56
  83. data/lib/vanilla/dynasnips/new.rb +0 -14
  84. data/lib/vanilla/dynasnips/notes.rb +0 -42
  85. data/lib/vanilla/dynasnips/url_to.rb +0 -7
  86. data/lib/vanilla/snip_handling.rb +0 -33
  87. data/lib/vanilla/snips/start.rb +0 -27
  88. data/lib/vanilla/snips/system.rb +0 -76
  89. data/lib/vanilla/snips/tutorial.rb +0 -157
  90. data/lib/vanilla/test_snips.rb +0 -85
  91. data/public/hatch.png +0 -0
  92. data/public/javascripts/jquery.js +0 -3549
  93. data/public/javascripts/vanilla.js +0 -21
  94. data/spec/dynasnip_spec.rb +0 -31
  95. data/spec/renderers/base_renderer_spec.rb +0 -40
  96. data/spec/renderers/erb_renderer_spec.rb +0 -27
  97. data/spec/renderers/markdown_renderer_spec.rb +0 -29
  98. data/spec/renderers/raw_renderer_spec.rb +0 -21
  99. data/spec/renderers/ruby_renderer_spec.rb +0 -42
  100. data/spec/renderers/vanilla_app_detecting_renderer_spec.rb +0 -35
  101. data/spec/spec_helper.rb +0 -64
  102. data/spec/vanilla_app_spec.rb +0 -38
  103. data/spec/vanilla_presenting_spec.rb +0 -84
  104. data/spec/vanilla_request_spec.rb +0 -73
  105. data/spec/vanilla_snip_finding_spec.rb +0 -28
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vanilla
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ hash: 11
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 2
9
+ version: "1.2"
5
10
  platform: ruby
6
11
  authors:
7
12
  - James Adam
@@ -9,69 +14,149 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-05-06 00:00:00 -07:00
17
+ date: 2011-05-03 00:00:00 +01:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
- name: rack
21
+ prerelease: false
17
22
  type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ name: rack
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - ">="
22
28
  - !ruby/object:Gem::Version
29
+ hash: 57
30
+ segments:
31
+ - 0
32
+ - 9
33
+ - 1
23
34
  version: 0.9.1
24
- version:
35
+ requirement: *id001
25
36
  - !ruby/object:Gem::Dependency
26
- name: soup
37
+ prerelease: false
27
38
  type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
39
+ name: soup
40
+ version_requirements: &id002 !ruby/object:Gem::Requirement
41
+ none: false
30
42
  requirements:
31
43
  - - ">="
32
44
  - !ruby/object:Gem::Version
33
- version: 0.2.1
34
- version:
45
+ hash: 27
46
+ segments:
47
+ - 1
48
+ - 0
49
+ - 6
50
+ version: 1.0.6
51
+ requirement: *id002
35
52
  - !ruby/object:Gem::Dependency
36
- name: ratom
53
+ prerelease: false
37
54
  type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
55
+ name: ratom
56
+ version_requirements: &id003 !ruby/object:Gem::Requirement
57
+ none: false
40
58
  requirements:
41
59
  - - ">="
42
60
  - !ruby/object:Gem::Version
61
+ hash: 25
62
+ segments:
63
+ - 0
64
+ - 3
65
+ - 5
43
66
  version: 0.3.5
44
- version:
67
+ requirement: *id003
45
68
  - !ruby/object:Gem::Dependency
46
- name: RedCloth
69
+ prerelease: false
47
70
  type: :runtime
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
71
+ name: RedCloth
72
+ version_requirements: &id004 !ruby/object:Gem::Requirement
73
+ none: false
50
74
  requirements:
51
75
  - - ">="
52
76
  - !ruby/object:Gem::Version
77
+ hash: 57
78
+ segments:
79
+ - 4
80
+ - 1
81
+ - 1
53
82
  version: 4.1.1
54
- version:
83
+ requirement: *id004
55
84
  - !ruby/object:Gem::Dependency
56
- name: BlueCloth
85
+ prerelease: false
57
86
  type: :runtime
58
- version_requirement:
59
- version_requirements: !ruby/object:Gem::Requirement
87
+ name: BlueCloth
88
+ version_requirements: &id005 !ruby/object:Gem::Requirement
89
+ none: false
60
90
  requirements:
61
91
  - - ">="
62
92
  - !ruby/object:Gem::Version
93
+ hash: 23
94
+ segments:
95
+ - 1
96
+ - 0
97
+ - 0
63
98
  version: 1.0.0
64
- version:
99
+ requirement: *id005
65
100
  - !ruby/object:Gem::Dependency
66
- name: rspec
101
+ prerelease: false
102
+ type: :runtime
103
+ name: haml
104
+ version_requirements: &id006 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ hash: 3
110
+ segments:
111
+ - 0
112
+ version: "0"
113
+ requirement: *id006
114
+ - !ruby/object:Gem::Dependency
115
+ prerelease: false
116
+ type: :runtime
117
+ name: parslet
118
+ version_requirements: &id007 !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ hash: 31
124
+ segments:
125
+ - 1
126
+ - 2
127
+ - 0
128
+ version: 1.2.0
129
+ requirement: *id007
130
+ - !ruby/object:Gem::Dependency
131
+ prerelease: false
67
132
  type: :development
68
- version_requirement:
69
- version_requirements: !ruby/object:Gem::Requirement
133
+ name: kintama
134
+ version_requirements: &id008 !ruby/object:Gem::Requirement
135
+ none: false
70
136
  requirements:
71
137
  - - ">="
72
138
  - !ruby/object:Gem::Version
139
+ hash: 23
140
+ segments:
141
+ - 0
142
+ - 1
143
+ - 6
144
+ version: 0.1.6
145
+ requirement: *id008
146
+ - !ruby/object:Gem::Dependency
147
+ prerelease: false
148
+ type: :development
149
+ name: mocha
150
+ version_requirements: &id009 !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ hash: 3
156
+ segments:
157
+ - 0
73
158
  version: "0"
74
- version:
159
+ requirement: *id009
75
160
  description:
76
161
  email: james@lazyatom.com.com
77
162
  executables:
@@ -81,71 +166,81 @@ extensions: []
81
166
  extra_rdoc_files:
82
167
  - README
83
168
  files:
84
- - config.example.yml
85
- - config.ru
86
169
  - Rakefile
87
170
  - README
88
- - spec/dynasnip_spec.rb
89
- - spec/renderers
90
- - spec/renderers/base_renderer_spec.rb
91
- - spec/renderers/erb_renderer_spec.rb
92
- - spec/renderers/markdown_renderer_spec.rb
93
- - spec/renderers/raw_renderer_spec.rb
94
- - spec/renderers/ruby_renderer_spec.rb
95
- - spec/renderers/vanilla_app_detecting_renderer_spec.rb
96
- - spec/spec_helper.rb
97
- - spec/vanilla_app_spec.rb
98
- - spec/vanilla_presenting_spec.rb
99
- - spec/vanilla_request_spec.rb
100
- - spec/vanilla_snip_finding_spec.rb
101
- - lib/defensio.rb
102
- - lib/tasks
103
- - lib/tasks/vanilla.rake
104
- - lib/vanilla
171
+ - test/dynasnip_test.rb
172
+ - test/dynasnips/link_to_current_snip_test.rb
173
+ - test/dynasnips/link_to_test.rb
174
+ - test/dynasnips/page_title_test.rb
175
+ - test/renderers/base_renderer_test.rb
176
+ - test/renderers/erb_renderer_test.rb
177
+ - test/renderers/haml_renderer_test.rb
178
+ - test/renderers/markdown_renderer_test.rb
179
+ - test/renderers/raw_renderer_test.rb
180
+ - test/renderers/ruby_renderer_test.rb
181
+ - test/snip_inclusion_test.rb
182
+ - test/snip_reference_parser_test.rb
183
+ - test/test_helper.rb
184
+ - test/vanilla_app_test.rb
185
+ - test/vanilla_presenting_test.rb
186
+ - test/vanilla_request_test.rb
105
187
  - lib/vanilla/app.rb
106
188
  - lib/vanilla/console.rb
107
189
  - lib/vanilla/dynasnip.rb
108
- - lib/vanilla/dynasnips
109
- - lib/vanilla/dynasnips/comments.rb
110
- - lib/vanilla/dynasnips/current_snip.rb
111
- - lib/vanilla/dynasnips/debug.rb
112
- - lib/vanilla/dynasnips/edit.rb
113
- - lib/vanilla/dynasnips/edit_link.rb
114
- - lib/vanilla/dynasnips/index.rb
115
- - lib/vanilla/dynasnips/kind.rb
116
- - lib/vanilla/dynasnips/link_to.rb
117
- - lib/vanilla/dynasnips/link_to_current_snip.rb
118
- - lib/vanilla/dynasnips/login.rb
119
- - lib/vanilla/dynasnips/new.rb
120
- - lib/vanilla/dynasnips/notes.rb
121
- - lib/vanilla/dynasnips/pre.rb
122
- - lib/vanilla/dynasnips/rand.rb
123
- - lib/vanilla/dynasnips/raw.rb
124
- - lib/vanilla/dynasnips/url_to.rb
125
- - lib/vanilla/renderers
126
190
  - lib/vanilla/renderers/base.rb
127
191
  - lib/vanilla/renderers/bold.rb
128
192
  - lib/vanilla/renderers/erb.rb
193
+ - lib/vanilla/renderers/haml.rb
129
194
  - lib/vanilla/renderers/markdown.rb
130
195
  - lib/vanilla/renderers/raw.rb
131
196
  - lib/vanilla/renderers/ruby.rb
132
197
  - lib/vanilla/renderers/textile.rb
198
+ - lib/vanilla/renderers.rb
133
199
  - lib/vanilla/request.rb
134
200
  - lib/vanilla/routes.rb
135
- - lib/vanilla/snip_handling.rb
136
- - lib/vanilla/snips
137
- - lib/vanilla/snips/start.rb
138
- - lib/vanilla/snips/system.rb
139
- - lib/vanilla/snips/tutorial.rb
140
- - lib/vanilla/test_snips.rb
201
+ - lib/vanilla/snip_reference_parser.rb
202
+ - lib/vanilla/static.rb
141
203
  - lib/vanilla.rb
142
204
  - bin/vanilla
143
- - public/hatch.png
144
- - public/javascripts
145
- - public/javascripts/jquery.js
146
- - public/javascripts/vanilla.js
205
+ - pristine_app/config.ru
206
+ - pristine_app/Gemfile
207
+ - pristine_app/Gemfile.lock
208
+ - pristine_app/public/vanilla.css
209
+ - pristine_app/README
210
+ - pristine_app/soups/base/layout.snip
211
+ - pristine_app/soups/base/start.snip
212
+ - pristine_app/soups/dynasnips/current_snip.rb
213
+ - pristine_app/soups/dynasnips/debug.rb
214
+ - pristine_app/soups/dynasnips/index.rb
215
+ - pristine_app/soups/dynasnips/link_to.rb
216
+ - pristine_app/soups/dynasnips/link_to_current_snip.rb
217
+ - pristine_app/soups/dynasnips/page_title.rb
218
+ - pristine_app/soups/dynasnips/pre.rb
219
+ - pristine_app/soups/dynasnips/raw.rb
220
+ - pristine_app/soups/extras/comments.rb
221
+ - pristine_app/soups/extras/kind.rb
222
+ - pristine_app/soups/extras/rand.rb
223
+ - pristine_app/soups/extras/url_to.rb
224
+ - pristine_app/soups/tutorial/bad_dynasnip.snip
225
+ - pristine_app/soups/tutorial/hello_world.snip
226
+ - pristine_app/soups/tutorial/markdown_example.snip
227
+ - pristine_app/soups/tutorial/snip.snip
228
+ - pristine_app/soups/tutorial/soup.snip
229
+ - pristine_app/soups/tutorial/test.snip
230
+ - pristine_app/soups/tutorial/textile_example.snip
231
+ - pristine_app/soups/tutorial/tutorial-another-snip.snip
232
+ - pristine_app/soups/tutorial/tutorial-basic-snip-inclusion.snip
233
+ - pristine_app/soups/tutorial/tutorial-dynasnips.snip.markdown
234
+ - pristine_app/soups/tutorial/tutorial-layout.snip
235
+ - pristine_app/soups/tutorial/tutorial-links.snip
236
+ - pristine_app/soups/tutorial/tutorial-renderers.snip.markdown
237
+ - pristine_app/soups/tutorial/tutorial.snip.markdown
238
+ - pristine_app/soups/tutorial/vanilla-rb.snip
239
+ - pristine_app/soups/tutorial/vanilla.snip
147
240
  has_rdoc: true
148
241
  homepage: http://github.com/lazyatom/vanilla-rb
242
+ licenses: []
243
+
149
244
  post_install_message:
150
245
  rdoc_options:
151
246
  - --main
@@ -153,23 +248,29 @@ rdoc_options:
153
248
  require_paths:
154
249
  - lib
155
250
  required_ruby_version: !ruby/object:Gem::Requirement
251
+ none: false
156
252
  requirements:
157
253
  - - ">="
158
254
  - !ruby/object:Gem::Version
255
+ hash: 3
256
+ segments:
257
+ - 0
159
258
  version: "0"
160
- version:
161
259
  required_rubygems_version: !ruby/object:Gem::Requirement
260
+ none: false
162
261
  requirements:
163
262
  - - ">="
164
263
  - !ruby/object:Gem::Version
264
+ hash: 3
265
+ segments:
266
+ - 0
165
267
  version: "0"
166
- version:
167
268
  requirements: []
168
269
 
169
270
  rubyforge_project: vanilla
170
- rubygems_version: 1.3.1
271
+ rubygems_version: 1.3.7
171
272
  signing_key:
172
- specification_version: 2
273
+ specification_version: 3
173
274
  summary: A bliki-type web content thing.
174
275
  test_files: []
175
276
 
@@ -1,5 +0,0 @@
1
- ---
2
- :filename: config.example.yml
3
- :secret: a6bc097eff86cabd92ee72ba4687c3f057b7556deaa3e4a6b284460871056b87ba3e91548c37dcc44fbc10241cee5b386556e6bcc2946fd9b609dc3bc1b24488
4
- :credentials:
5
- admin: 5f4dcc3b5aa765d61d8327deb882cf99
data/config.ru DELETED
@@ -1,9 +0,0 @@
1
- require 'vanilla'
2
-
3
- app = Vanilla::App.new(ENV['VANILLA_CONFIG'])
4
- use Rack::Session::Cookie, :key => 'vanilla.session',
5
- :path => '/',
6
- :expire_after => 2592000,
7
- :secret => app.config[:secret]
8
- use Rack::Static, :urls => ["/public"], :root => File.join(File.dirname(__FILE__))
9
- run app
@@ -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,177 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..')))
2
- require 'vanilla'
3
-
4
- namespace :vanilla do
5
- desc "Open an irb session preloaded with this library"
6
- task :console do
7
- sh "irb -Ilib -rubygems -rvanilla -rvanilla/console"
8
- end
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 :prepare do
16
- Soup.prepare
17
- end
18
-
19
- task :load_snips => :prepare do
20
- Dynasnip.persist_all!(overwrite=true)
21
-
22
- Dir[File.join(File.dirname(__FILE__), '..', 'vanilla', 'snips', '*.rb')].each do |f|
23
- load f
24
- end
25
-
26
- load File.join(File.dirname(__FILE__), *%w[.. vanilla test_snips.rb])
27
-
28
- puts "The soup is simmering. Loaded #{Soup.tuple_class.count} tuples"
29
- end
30
-
31
- desc 'Resets the soup to contain the base snips only. Dangerous!'
32
- task :reset => [:clean, :load_snips]
33
-
34
- namespace :upgrade do
35
- desc 'Upgrade the dynasnips'
36
- task :dynasnips => :prepare do
37
- Dynasnip.all.each do |dynasnip|
38
- print "Upgrading #{dynasnip.snip_name}... "
39
- # TODO: our confused Soup interface might return an array.
40
- snip = Soup[dynasnip.snip_name]
41
- if snip.empty? || snip.nil?
42
- # it's a new dyna
43
- Soup << dynasnip.snip_attributes
44
- puts "(new)"
45
- elsif snip.created_at == snip.updated_at
46
- # it's not been changed, let's upgrade
47
- snip.destroy
48
- Soup << dynasnip.snip_attributes
49
- puts "(unedited)"
50
- else
51
- # the dyna exists and has been changed
52
- dynasnip.snip_attributes.each do |name, value|
53
- unless (existing_value = snip.get_value(name)) == value
54
- puts "Conflict in attribute '#{name}':"
55
- puts "> Your soup: '#{existing_value}'"
56
- puts "> New soup: '#{value}"
57
- print "Upgrade? [Y/n]: "
58
- upgrade_value = ["Y", "y", ""].include? STDIN.gets.chomp.strip
59
- snip.set_value(name, value) if upgrade_value
60
- end
61
- end
62
- snip.save
63
- end
64
- end
65
- end
66
- end
67
-
68
- desc 'Upgrade dynasnips and system snips'
69
- task :upgrade => ["upgrade:dynasnips"]
70
-
71
- desc 'Add a user (or change an existing password)'
72
- task :add_user => :prepare do
73
- puts "Adding a new user"
74
- # config_file = ENV['VANILLA_CONFIG'] || 'config.yml'
75
- # config_file = YAML.load(File.open(config_file)) rescue {}
76
- app = Vanilla::App.new(ENV['VANILLA_CONFIG'])
77
- print "Username: "
78
- username = STDIN.gets.chomp.strip
79
- print "Password: "
80
- password = STDIN.gets.chomp.strip
81
- print "Confirm password: "
82
- confirm_password = STDIN.gets.chomp.strip
83
- if password != confirm_password
84
- raise "Passwords don't match!"
85
- else
86
- app.config[:credentials] ||= {}
87
- app.config[:credentials][username] = MD5.md5(password).to_s
88
- app.config.save!
89
- puts "User '#{username}' added."
90
- end
91
- end
92
-
93
- desc 'Generate file containing secret for cookie-based session storage'
94
- task :generate_secret do
95
- # Adapted from old rails secret generator.
96
- require 'openssl'
97
- if !File.exist?("/dev/urandom")
98
- # OpenSSL transparently seeds the random number generator with
99
- # data from /dev/urandom. On platforms where that is not
100
- # available, such as Windows, we have to provide OpenSSL with
101
- # our own seed. Unfortunately there's no way to provide a
102
- # secure seed without OS support, so we'll have to do with
103
- # rand() and Time.now.usec().
104
- OpenSSL::Random.seed(rand(0).to_s + Time.now.usec.to_s)
105
- end
106
- data = OpenSSL::BN.rand(2048, -1, false).to_s
107
- secret = OpenSSL::Digest::SHA1.new(data).hexdigest
108
- app = Vanilla::App.new(ENV['VANILLA_CONFIG'])
109
- app.config[:secret] = secret
110
- app.config.save!
111
- puts "Secret generated."
112
- end
113
-
114
- desc 'Prepare standard files to run Vanilla'
115
- task :prepare_files do
116
- cp File.expand_path(File.join(File.dirname(__FILE__), *%w[.. .. config.ru])), 'config.ru'
117
- cp_r File.expand_path(File.join(File.dirname(__FILE__), *%w[.. .. public])), 'public'
118
- mkdir 'tmp'
119
- File.open("Rakefile", "w") do |f|
120
- rakefile =<<-EOF
121
- require 'vanilla'
122
- load 'tasks/vanilla.rake'
123
-
124
- # Add any other tasks here.
125
- EOF
126
- f.write rakefile.strip
127
- end
128
- end
129
-
130
-
131
- desc 'Prepare a new vanilla.rb installation'
132
- task :setup do
133
- puts <<-EOM
134
-
135
- ===================~ Vanilla.rb ~====================
136
-
137
- Congratulations! You have elected to try out the weirdest web thing ever.
138
- Lets get started. Firstly, I'm going to cook you some soup:
139
-
140
-
141
- EOM
142
- Rake::Task['vanilla:load_snips'].invoke
143
-
144
- puts <<-EOM
145
-
146
- Now I'm going to generate your configuration. This will be stored either in
147
- 'config.yml' in the current directory, or in the path you provide via the
148
- environment variable VANILLA_CONFIG.
149
-
150
- Generating the secret for cookie-based session storage.
151
- EOM
152
- Rake::Task['vanilla:prepare_files'].invoke
153
- Rake::Task['vanilla:generate_secret'].invoke
154
-
155
- puts <<-EOM
156
-
157
-
158
- Now that we've got our broth, you'll want to add a user, so you can edit stuff.
159
- Lets do that now:
160
-
161
-
162
- EOM
163
- Rake::Task['vanilla:add_user'].invoke
164
- puts <<-EOM
165
-
166
-
167
- OK! You're ready to go. To start vanilla.rb, you'll want to get it running under
168
- a webserver that supports Rack. The easiest way to do this locally is via 'rackup':
169
-
170
- $ rackup
171
-
172
- Then go to http://localhost:9292
173
-
174
- I'm going now, Goodbye!
175
- EOM
176
- end
177
- end