summaryrefslogtreecommitdiff
path: root/app/models/pages
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-25 09:06:04 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-25 09:06:04 +0000
commit1cfd8874ee6702184d5608f533b30bab722b4f9d (patch)
tree4921070efdc0ad2d1c3c7d8a3a60c73928b57d25 /app/models/pages
parentfbcb36880cda3a29cfa4ebed4d080701c302256b (diff)
downloadgitlab-ce-1cfd8874ee6702184d5608f533b30bab722b4f9d.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/pages')
-rw-r--r--app/models/pages/lookup_path.rb11
-rw-r--r--app/models/pages/virtual_domain.rb7
2 files changed, 12 insertions, 6 deletions
diff --git a/app/models/pages/lookup_path.rb b/app/models/pages/lookup_path.rb
index 1b3183a2a43..51c496c77d3 100644
--- a/app/models/pages/lookup_path.rb
+++ b/app/models/pages/lookup_path.rb
@@ -2,9 +2,10 @@
module Pages
class LookupPath
- def initialize(project, domain: nil)
+ def initialize(project, trim_prefix: nil, domain: nil)
@project = project
@domain = domain
+ @trim_prefix = trim_prefix || project.full_path
end
def project_id
@@ -28,11 +29,15 @@ module Pages
end
def prefix
- '/'
+ if project.pages_group_root?
+ '/'
+ else
+ project.full_path.delete_prefix(trim_prefix) + '/'
+ end
end
private
- attr_reader :project, :domain
+ attr_reader :project, :trim_prefix, :domain
end
end
diff --git a/app/models/pages/virtual_domain.rb b/app/models/pages/virtual_domain.rb
index 3a876dc06a2..7e42b8e6ae2 100644
--- a/app/models/pages/virtual_domain.rb
+++ b/app/models/pages/virtual_domain.rb
@@ -2,8 +2,9 @@
module Pages
class VirtualDomain
- def initialize(projects, domain: nil)
+ def initialize(projects, trim_prefix: nil, domain: nil)
@projects = projects
+ @trim_prefix = trim_prefix
@domain = domain
end
@@ -17,12 +18,12 @@ module Pages
def lookup_paths
projects.map do |project|
- project.pages_lookup_path(domain: domain)
+ project.pages_lookup_path(trim_prefix: trim_prefix, domain: domain)
end.sort_by(&:prefix).reverse
end
private
- attr_reader :projects, :domain
+ attr_reader :projects, :trim_prefix, :domain
end
end