files_controller.rb revision 9cfb01db247ca04bb4b5b337bbd77c66b7150e53
a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunningtonclass FilesController < ApplicationController
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster before_filter :check_permissions, only: [:new, :create]
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster #load_and_authorize_resource :except => [:index, :show]
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster @info = repository.path_info(params[:path], @oid)
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster raise Repository::FileNotFoundError, params[:path] if @info.nil?
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster if request.format == 'text/html' || @info[:type] != :file
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster case @info[:type]
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster @file = repository.read_file(@path, params[:oid])
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster # TODO: redirect to ontology view instead of rendering file view
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster @file = repository.read_file(@path, params[:oid])
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster render text: repository.read_file(@path, @oid)[:content],
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster content_type: Mime::Type.lookup('application/force-download')
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings render json: repository.entries_info(@oid, params[:path])
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster @oid = repository.commit_id(params[:oid])[:oid]
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster @changed_files = repository.changed_files(@oid)
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster @oid = repository.commit_id(params[:oid])[:oid]
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster @current_file = repository.read_file(@path, @oid) if @path
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster repository.save_file @file.file.path, @file.filepath, @file.message, current_user
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster flash[:success] = "Successfully saved uploaded file."
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster redirect_to fancy_repository_path(repository, path: @file.path)