files_controller.rb revision 2911e63768f8ef8e57e6a8ba85f8a0016b4a5c2e
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen helper_method :repository, :ref, :oid, :path, :branch_name
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainen before_filter :check_permissions, only: [:new, :create]
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen @info = repository.path_info(params[:path], oid)
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen raise Repository::FileNotFoundError, path if @info.nil?
faed8babca9914257f34fb2e603d74016d563b2dTimo Sirainen if request.format == 'text/html' || @info[:type] != :file
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen where(basepath: File.basepath(@info[:entry][:path])).
bb10ebcf076c959c752f583746d83805d7686df8Timo Sirainen render json: repository.entries_info(oid, path)
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen @changed_files = repository.changed_files(oid)
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen page = @page = params[:page].nil? ? 1 : params[:page].to_i
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen offset = page > 0 ? (page - 1) * @per_page : 0
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen @current_file = repository.read_file(path, oid) if path && !repository.dir?(path)
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen @commits = repository.commits(start_oid: oid, path: path, offset: offset, limit: @per_page)
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen repository.save_file @file.file.path, @file.filepath, @file.message, current_user
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen flash[:success] = "Successfully saved uploaded file."
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen redirect_to fancy_repository_path(repository, path: @file.path)
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen @repository ||= Repository.find_by_path!(params[:repository_id])
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen @file ||= UploadFile.new(params[:upload_file])
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen render text: repository.read_file(path, oid)[:content],
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen content_type: Mime::Type.lookup('application/force-download')