Class: FileController

Inherits:
ApplicationController show all
Defined in:
app/controllers/file_controller.rb

Overview

Controller that is responsible for serving files and pictures. Disabled in version 0.10

Constant Summary

Constants inherited from ApplicationController

ApplicationController::FILE_TYPES

Instance Method Summary collapse

Methods inherited from ApplicationController

wiki, wiki=

Instance Method Details

#cancel_uploadObject



30
31
32
# File 'app/controllers/file_controller.rb', line 30

def cancel_upload
  return_to_last_remembered
end

#fileObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/file_controller.rb', line 14

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

#importObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/controllers/file_controller.rb', line 50

def import
  return if file_uploads_disabled?

  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[:error] = "Import finished, but some pages were not imported:<li>" + 
          @problems.join('</li><li>') + '</li>'
    end
    return_to_last_remembered
  else
    # to template
  end
end

#picObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/file_controller.rb', line 34

def pic
  check_path
  if @params['file']
    # form supplied
    file_yard.upload_file(@file_name, @params['file'])
    @web.refresh_pages_with_references(@file_name)
    flash[:info] = "Image '#{@file_name}' successfully uploaded"
    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