gitlab-org--gitlab-foss/app/models/pages/lookup_path.rb

43 lines
804 B
Ruby

# frozen_string_literal: true
module Pages
class LookupPath
def initialize(project, trim_prefix: nil, domain: nil)
@project = project
@domain = domain
@trim_prefix = trim_prefix || project.full_path
end
def project_id
project.id
end
def access_control
project.private_pages?
end
def https_only
domain_https = domain ? domain.https? : true
project.pages_https_only? && domain_https
end
def source
{
type: 'file',
path: File.join(project.full_path, 'public/')
}
end
def prefix
if project.pages_group_root?
'/'
else
project.full_path.delete_prefix(trim_prefix) + '/'
end
end
private
attr_reader :project, :trim_prefix, :domain
end
end