summaryrefslogtreecommitdiff
path: root/app/models/pages/lookup_path.rb
blob: 1b3183a2a4352b613cb6c231d8d3af8ee68603ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true

module Pages
  class LookupPath
    def initialize(project, domain: nil)
      @project = project
      @domain = domain
    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
      '/'
    end

    private

    attr_reader :project, :domain
  end
end