Class: Pages::LookupPath
- Inherits:
-
Object
- Object
- Pages::LookupPath
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- app/models/pages/lookup_path.rb
Instance Attribute Summary collapse
-
#access_control ⇒ Object
Returns the value of attribute access_control.
Instance Method Summary collapse
- #https_only ⇒ Object
-
#initialize(deployment:, root_namespace_id:, domain: nil, trim_prefix: nil, access_control: false) ⇒ LookupPath
constructor
A new instance of LookupPath.
- #prefix ⇒ Object
- #primary_domain ⇒ Object
- #project_id ⇒ Object
- #root_directory ⇒ Object
- #source ⇒ Object
- #unique_host ⇒ Object
Constructor Details
#initialize(deployment:, root_namespace_id:, domain: nil, trim_prefix: nil, access_control: false) ⇒ LookupPath
Returns a new instance of LookupPath.
7 8 9 10 11 12 13 14 |
# File 'app/models/pages/lookup_path.rb', line 7 def initialize(deployment:, root_namespace_id:, domain: nil, trim_prefix: nil, access_control: false) @deployment = deployment @project = deployment.project @root_namespace_id = root_namespace_id @domain = domain @trim_prefix = trim_prefix || @project.full_path @access_control = access_control end |
Instance Attribute Details
#access_control ⇒ Object
Returns the value of attribute access_control.
16 17 18 |
# File 'app/models/pages/lookup_path.rb', line 16 def access_control @access_control end |
Instance Method Details
#https_only ⇒ Object
23 24 25 26 |
# File 'app/models/pages/lookup_path.rb', line 23 def https_only domain_https = domain ? domain.https? : true project.pages_https_only? && domain_https end |
#prefix ⇒ Object
47 48 49 |
# File 'app/models/pages/lookup_path.rb', line 47 def prefix ensure_leading_and_trailing_slash(prefix_value) end |
#primary_domain ⇒ Object
70 71 72 |
# File 'app/models/pages/lookup_path.rb', line 70 def primary_domain project&.project_setting&.pages_primary_domain end |
#project_id ⇒ Object
18 19 20 |
# File 'app/models/pages/lookup_path.rb', line 18 def project_id project.id end |
#root_directory ⇒ Object
63 64 65 66 67 |
# File 'app/models/pages/lookup_path.rb', line 63 def root_directory return unless deployment deployment.root_directory end |
#source ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/models/pages/lookup_path.rb', line 29 def source return unless deployment&.file global_id = ::Gitlab::GlobalId.build(deployment, id: deployment.id).to_s { type: 'zip', path: deployment.file.url_or_file_path( expire_at: ::Gitlab::Pages::DEPLOYMENT_EXPIRATION.from_now ), global_id: global_id, sha256: deployment.file_sha256, file_size: deployment.size, file_count: deployment.file_count } end |
#unique_host ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'app/models/pages/lookup_path.rb', line 52 def unique_host # When serving custom domain we don't present the unique host to avoid # GitLab Pages auto-redirect to the unique domain instead of keeping serving # from the custom domain. # https://gitlab.com/gitlab-org/gitlab/-/issues/426435 return if domain.present? project.pages_url_builder.unique_host end |