display images from the file yard

This commit is contained in:
Alexey Verkhovsky 2005-01-23 03:52:07 +00:00
parent d6fe54f4ad
commit 39f854a11e
2 changed files with 33 additions and 6 deletions

View file

@ -7,11 +7,8 @@ class FileController < ApplicationController
layout 'default'
def file
raise Instiki::ValidationError.new("Invalid path: no file name") unless @file_name
raise Instiki::ValidationError.new("Invalid path: no web name") unless @web_name
raise Instiki::ValidationError.new("Invalid path: unknown web name") unless @web
check_path
file_yard = @wiki.file_yard(@web)
if @params['file']
# form supplied
file_yard.upload(@file_name, @params['file'])
@ -29,4 +26,25 @@ class FileController < ApplicationController
return_to_last_remembered
end
def pic
check_path
if file_yard.has_file?(@file_name)
send_file(file_yard.file_path(@file_name))
else
render_text "Image not found: #{@file_name}", '404 Not Found'
end
end
private
def check_path
raise Instiki::ValidationError.new("Invalid path: no file name") unless @file_name
raise Instiki::ValidationError.new("Invalid path: no web name") unless @web_name
raise Instiki::ValidationError.new("Invalid path: unknown web name") unless @web
end
def file_yard
@wiki.file_yard(@web)
end
end