Beginnings of a FileController (serving the file upload feature)

This commit is contained in:
Alexey Verkhovsky 2005-01-22 01:35:00 +00:00
parent 71407f9b9f
commit 12a34823a8
5 changed files with 83 additions and 26 deletions

View file

@ -7,7 +7,7 @@ class ApplicationController < ActionController::Base
# implements Instiki's legacy URLs
require 'url_rewriting_hack'
before_filter :set_utf8_http_header
before_filter :set_utf8_http_header, :connect_to_model
after_filter :remember_location
# For injecting a different wiki model implementation. Intended for use in tests
@ -58,4 +58,28 @@ class ApplicationController < ActionController::Base
@response.headers['Content-Type'] = 'text/html; charset=UTF-8'
end
def connect_to_model
@action_name = @params['action'] || 'index'
@web_name = @params['web']
@wiki = wiki
@web = @wiki.webs[@web_name] unless @web_name.nil?
@page_name = @params['id']
@page = @wiki.read_page(@web_name, @page_name) unless @page_name.nil?
@author = cookies['author'] || 'AnonymousCoward'
check_authorization(@action_name)
end
def check_authorization(action_name)
if in_a_web? and
not authorized? and
not %w( login authenticate published ).include?(action_name)
redirect_to :action => 'login'
return false
end
end
def in_a_web?
not @web_name.nil?
end
end