fir 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -133,7 +133,7 @@ There's one obvious downside to this approach: you'll lose any dynamic features
133
133
 
134
134
  ## Exporting to HTML Locally ##
135
135
 
136
- You can also export your whole site to static HTML on your local machine. If you To export:
136
+ You can also export your whole site to static HTML on your local machine:
137
137
 
138
138
  rake export dir=~/sites/exported_example
139
139
 
data/lib/fir/admin.rb CHANGED
@@ -58,19 +58,19 @@ module Fir
58
58
  elsif File.exists?(page_path)
59
59
  case env['REQUEST_METHOD'].downcase
60
60
  when 'get'
61
- retrieve_page(page_path)
61
+ return retrieve_page(page_path)
62
62
  when 'delete'
63
- return method_not_allowed('DELETE not yet implemented')
63
+ return delete_page(page_path)
64
64
  else
65
65
  return method_not_allowed('Only GET and POST are allowed')
66
66
  end
67
67
  else
68
- not_found
68
+ return not_found
69
69
  end
70
70
  elsif path.match(/^\/?-admin\/pages$/)
71
- page_index
71
+ return page_index
72
72
  else
73
- not_found
73
+ return not_found
74
74
  end
75
75
  else
76
76
  return @app.call(env)
@@ -79,6 +79,12 @@ module Fir
79
79
 
80
80
  protected
81
81
 
82
+ def delete_page(page_path)
83
+ File.delete(page_path)
84
+ Fir.clear_cache(page_path.sub(File.join(FIR_ROOT, 'pages'), ''))
85
+ [200, {'Content-Type' => 'text/plain'}, "#{page_path} has been deleted."]
86
+ end
87
+
82
88
  def page_index
83
89
  builder = Builder::XmlMarkup.new(:indent => 2)
84
90
  builder.instruct!
data/spec/admin_spec.rb CHANGED
@@ -78,7 +78,7 @@ describe 'admin interface' do
78
78
  last_response.status.should == 401
79
79
  end
80
80
 
81
- context 'with balid login' do
81
+ context 'with valid login' do
82
82
  before :each do
83
83
  authorize 'johndoe', 'foo'
84
84
  get '/-admin/pages/index.markdown'
@@ -115,7 +115,7 @@ describe 'admin interface' do
115
115
  last_response.status.should == 401
116
116
  end
117
117
 
118
- context 'with balid login' do
118
+ context 'with valid login' do
119
119
  before :each do
120
120
  authorize 'johndoe', 'foo'
121
121
  end
@@ -151,7 +151,7 @@ describe 'admin interface' do
151
151
  file.write 'This is a cached page'
152
152
  end
153
153
  post '/-admin/pages/cached-page.markdown', 'content' => 'New page content'
154
- File.exists?(cached_path).should be_false
154
+ cached_path.should_not exist_on_disk
155
155
  ensure
156
156
  File.delete(cached_path) if File.exists?(cached_path)
157
157
  File.delete(page_path) if File.exists?(page_path)
@@ -169,4 +169,64 @@ describe 'admin interface' do
169
169
  end
170
170
  end
171
171
  end
172
+
173
+ describe 'DELETE page/pagename' do
174
+ def deleteable_path
175
+ @deleteable_path ||= File.join(FIR_ROOT, 'pages', 'deleteable.markdown')
176
+ end
177
+
178
+ before :each do
179
+ File.open(deleteable_path, 'w') do |file|
180
+ file.write 'Deleteable'
181
+ end
182
+ end
183
+
184
+ after :each do
185
+ if File.exists?(deleteable_path)
186
+ File.delete(deleteable_path)
187
+ end
188
+ end
189
+
190
+ it 'requires HTTP auth' do
191
+ delete '/-admin/pages/deleteable.markdown'
192
+ last_response.status.should == 401
193
+ end
194
+
195
+ it 'does not accept bad user/pass combos' do
196
+ authorize 'johndoe', 'wrong'
197
+ delete '/-admin/pages/deleteable.markdown'
198
+ last_response.status.should == 401
199
+ end
200
+
201
+ context 'with valid login' do
202
+ before :each do
203
+ authorize 'johndoe', 'foo'
204
+ end
205
+
206
+ it 'deletes the page' do
207
+ delete '/-admin/pages/deleteable.markdown'
208
+ deleteable_path.should_not exist_on_disk
209
+ end
210
+
211
+ it 'deletes the page from the cache' do
212
+ cached_path = File.join(FIR_ROOT, 'public', 'cache', 'deleteable.html')
213
+ begin
214
+ File.open(cached_path, 'w') do |file|
215
+ file.write('Cached deleteable')
216
+ end
217
+ delete '/-admin/pages/deleteable.markdown'
218
+ cached_path.should_not exist_on_disk
219
+ ensure
220
+ if File.exists?(cached_path)
221
+ File.delete(cached_path)
222
+ end
223
+ end
224
+ end
225
+
226
+ it 'returns 200' do
227
+ delete '/-admin/pages/deleteable.markdown'
228
+ last_response.status.should == 200
229
+ end
230
+ end
231
+ end
172
232
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 10
9
- version: 0.0.10
8
+ - 11
9
+ version: 0.0.11
10
10
  platform: ruby
11
11
  authors:
12
12
  - jarrett
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-21 00:00:00 -05:00
17
+ date: 2010-03-22 00:00:00 -05:00
18
18
  default_executable: fir
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency