2019-12-04 20:38:33 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Pages
|
|
|
|
class LookupPath
|
2019-12-21 20:55:43 +05:30
|
|
|
def initialize(project, trim_prefix: nil, domain: nil)
|
2019-12-04 20:38:33 +05:30
|
|
|
@project = project
|
|
|
|
@domain = domain
|
2019-12-21 20:55:43 +05:30
|
|
|
@trim_prefix = trim_prefix || project.full_path
|
2019-12-04 20:38:33 +05:30
|
|
|
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
|
2019-12-21 20:55:43 +05:30
|
|
|
if project.pages_group_root?
|
|
|
|
'/'
|
|
|
|
else
|
|
|
|
project.full_path.delete_prefix(trim_prefix) + '/'
|
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
attr_reader :project, :trim_prefix, :domain
|
2019-12-04 20:38:33 +05:30
|
|
|
end
|
|
|
|
end
|