2015-08-25 21:42:46 -04:00
|
|
|
module Ci
|
|
|
|
class ProjectsController < Ci::ApplicationController
|
2016-02-03 05:24:14 -05:00
|
|
|
before_action :project
|
2015-09-14 07:37:18 -04:00
|
|
|
before_action :no_cache, only: [:badge]
|
2016-03-24 03:09:39 -04:00
|
|
|
before_action :authorize_read_project!, except: [:badge, :index]
|
2016-03-01 07:59:19 -05:00
|
|
|
skip_before_action :authenticate_user!, only: [:badge]
|
2015-10-07 08:43:58 -04:00
|
|
|
protect_from_forgery
|
2015-08-25 21:42:46 -04:00
|
|
|
|
2016-03-24 09:16:12 -04:00
|
|
|
def index
|
|
|
|
redirect_to root_path
|
|
|
|
end
|
|
|
|
|
2015-10-17 04:21:01 -04:00
|
|
|
def show
|
|
|
|
# Temporary compatibility with CI badges pointing to CI project page
|
2015-12-04 06:55:23 -05:00
|
|
|
redirect_to namespace_project_path(project.namespace, project)
|
2015-10-17 04:21:01 -04:00
|
|
|
end
|
|
|
|
|
2015-08-25 21:42:46 -04:00
|
|
|
# Project status badge
|
|
|
|
# Image with build status for sha or ref
|
2016-02-05 02:54:23 -05:00
|
|
|
#
|
|
|
|
# This action in DEPRECATED, this is here only for backwards compatibility
|
|
|
|
# with projects migrated from GitLab CI.
|
|
|
|
#
|
2015-08-25 21:42:46 -04:00
|
|
|
def badge
|
2016-02-05 02:55:25 -05:00
|
|
|
return render_404 unless @project
|
2016-03-01 07:59:19 -05:00
|
|
|
|
2015-08-25 21:42:46 -04:00
|
|
|
image = Ci::ImageForBuildService.new.execute(@project, params)
|
2016-06-29 09:16:04 -04:00
|
|
|
send_file image.path, filename: image.name, disposition: 'inline', type: "image/svg+xml"
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def project
|
2015-12-10 11:29:44 -05:00
|
|
|
@project ||= Project.find_by(ci_id: params[:id].to_i)
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def no_cache
|
|
|
|
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
|
|
|
|
response.headers["Pragma"] = "no-cache"
|
|
|
|
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
|
|
|
|
end
|
2016-03-24 03:09:39 -04:00
|
|
|
|
|
|
|
def authorize_read_project!
|
|
|
|
return access_denied! unless can?(current_user, :read_project, project)
|
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
end
|