files_controller.rb revision c28fc8aa2cdf7f9c9ae76899354350473d155981
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainenclass FilesController < InheritedResources::Base
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen helper_method :repository, :ref, :oid, :path, :branch_name
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen before_filter :check_write_permissions, only: [:new, :create, :update]
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen # TODO: the query_string check should be done in the iri router
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen ontology = resource.ontologies.first.children.where(name: request.query_string).first
d8552f9f65e5ff64be5de9faf9a8171799a0bbecTimo Sirainen render json: repository.entries_info(oid, path)
c0e5c6a86e1de5d4f5591d39b4aa921a23c807d7Timo Sirainen @repository_file = resource_class.build(params.merge(user: current_user))
d8552f9f65e5ff64be5de9faf9a8171799a0bbecTimo Sirainen @repository_file = resource_class.create(params.merge(user: current_user))
d8552f9f65e5ff64be5de9faf9a8171799a0bbecTimo Sirainen flash[:success] = "Successfully saved the uploaded file."
d8552f9f65e5ff64be5de9faf9a8171799a0bbecTimo Sirainen if ontology = repository.ontologies.with_path(resource.target_path).without_parent.first
d8552f9f65e5ff64be5de9faf9a8171799a0bbecTimo Sirainen redirect_to edit_repository_ontology_path(repository, ontology)
d8552f9f65e5ff64be5de9faf9a8171799a0bbecTimo Sirainen redirect_to fancy_repository_path(repository, path: resource.target_path)
d8552f9f65e5ff64be5de9faf9a8171799a0bbecTimo Sirainen @repository_file = resource_class.create(params.merge(user: current_user))
d8552f9f65e5ff64be5de9faf9a8171799a0bbecTimo Sirainen flash[:success] = "Successfully changed the file."
d8552f9f65e5ff64be5de9faf9a8171799a0bbecTimo Sirainen redirect_to fancy_repository_path(repository, path: resource.target_path)
d8552f9f65e5ff64be5de9faf9a8171799a0bbecTimo Sirainen @repository_file ||= resource_class.find_with_path(params)
d8552f9f65e5ff64be5de9faf9a8171799a0bbecTimo Sirainen @repository ||= Repository.active.find_by_path!(params[:repository_id])
c0e5c6a86e1de5d4f5591d39b4aa921a23c807d7Timo Sirainen render text: repository.get_file(path, oid).content,
d8552f9f65e5ff64be5de9faf9a8171799a0bbecTimo Sirainen content_type: Mime::Type.lookup('application/force-download')
d8552f9f65e5ff64be5de9faf9a8171799a0bbecTimo Sirainen @commit_id ||= repository.commit_id(params[:ref])
d8552f9f65e5ff64be5de9faf9a8171799a0bbecTimo Sirainen @oid ||= commit_id[:oid] unless commit_id.nil?
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen # OWL API sends those two http accept headers in different requests:
55bc6a7a0940ec48a68558ef70838991c5d301d2Timo Sirainen # application/rdf+xml, application/xml; q=0.5, text/xml; q=0.3, */*; q=0.2
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen # text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen # The latter conflicts with what browsers send.
55bc6a7a0940ec48a68558ef70838991c5d301d2Timo Sirainen (accepts.present? && accepts.first != Mime::HTML) ||
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen accepts[0..2] == [Mime::HTML, Mime::GIF, Mime::JPEG]