require 'fileutils' require 'application' require 'instiki_errors' class FileController < ApplicationController layout 'default' before_filter :check_allow_uploads def file check_path if @params['file'] # form supplied file_yard.upload_file(@file_name, @params['file']) flash[:info] = "File '#{@file_name}' successfully uploaded" @web.refresh_pages_with_references(@file_name) return_to_last_remembered elsif file_yard.has_file?(@file_name) send_file(file_yard.file_path(@file_name)) else logger.debug("File not found: #{file_yard.files_path}/#{@file_name}") # go to the template, which is a file upload form end end def cancel_upload return_to_last_remembered end def pic check_path if @params['file'] # form supplied file_yard.upload_file(@file_name, @params['file']) flash[:info] = "Image '#{@file_name}' successfully uploaded" @web.refresh_pages_with_references(@file_name) return_to_last_remembered elsif file_yard.has_file?(@file_name) send_file(file_yard.file_path(@file_name)) else logger.debug("Image not found: #{file_yard.files_path}/#{@file_name}") render_action 'file' end end def import check_authorization if @params['file'] @problems = [] import_file_name = "#{@web.address}-import-#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}.zip" file_yard.upload_file(import_file_name, @params['file']) import_from_archive(file_yard.file_path(import_file_name)) if @problems.empty? flash[:info] = 'Import successfully finished' else flash[:info] = "Import finished, but some pages were not imported: