diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb index f02ccd9e55e8ccacced293df6876d3903d3510f5..48c96203921c4198c88cf92e292baa67fab61406 100644 --- a/app/models/project_wiki.rb +++ b/app/models/project_wiki.rb @@ -58,7 +58,7 @@ def http_url_to_repo end def wiki_base_path - [Gitlab.config.gitlab.relative_url_root, '/', @project.full_path, '/wikis'].join('') + [Gitlab.config.gitlab.relative_url_root, '/', @project.full_path, '/-', '/wikis'].join('') end # Returns the Gitlab::Git::Wiki object. diff --git a/changelogs/unreleased/dz-move-wiki-route.yml b/changelogs/unreleased/dz-move-wiki-route.yml new file mode 100644 index 0000000000000000000000000000000000000000..f4fa96d88221305526e28c1119d5b50c002bd1b7 --- /dev/null +++ b/changelogs/unreleased/dz-move-wiki-route.yml @@ -0,0 +1,5 @@ +--- +title: Move wiki routing under /-/ scope +merge_request: 21185 +author: +type: deprecated diff --git a/config/routes/project.rb b/config/routes/project.rb index 8a5e20c8effc4ea5261ca82e69021a6871c615fd..2cc04da6f35fd5aa6dc8eada23e4b72619350be7 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -258,6 +258,10 @@ post :list_projects end end + + # The wiki routing contains wildcard characters so + # its preferable to keep it below all other project routes + draw :wiki end # End of the /-/ scope. @@ -523,9 +527,8 @@ post :web_ide_clientside_preview end - # Since both wiki and repository routing contains wildcard characters + # The repository routing contains wildcard characters so # its preferable to keep it below all other project routes - draw :wiki draw :repository # All new routes should go under /-/ scope. @@ -542,7 +545,7 @@ :forks, :group_links, :import, :avatar, :mirror, :cycle_analytics, :mattermost, :variables, :triggers, :environments, :protected_environments, :error_tracking, - :serverless, :clusters, :audit_events) + :serverless, :clusters, :audit_events, :wikis) end # rubocop: disable Cop/PutProjectRoutesUnderScope diff --git a/doc/user/project/integrations/webhooks.md b/doc/user/project/integrations/webhooks.md index f027fb6915712a67eddf928a1a3a8eb87a58b67c..3a0cedc1d1a6fc2177e9b0ff7339980db751b2ed 100644 --- a/doc/user/project/integrations/webhooks.md +++ b/doc/user/project/integrations/webhooks.md @@ -969,7 +969,7 @@ X-Gitlab-Event: Wiki Page Hook "http_url": "http://example.com/root/awesome-project.git" }, "wiki": { - "web_url": "http://example.com/root/awesome-project/wikis/home", + "web_url": "http://example.com/root/awesome-project/-/wikis/home", "git_ssh_url": "git@example.com:root/awesome-project.wiki.git", "git_http_url": "http://example.com/root/awesome-project.wiki.git", "path_with_namespace": "root/awesome-project.wiki", @@ -981,7 +981,7 @@ X-Gitlab-Event: Wiki Page Hook "format": "markdown", "message": "adding an awesome page to the wiki", "slug": "awesome", - "url": "http://example.com/root/awesome-project/wikis/awesome", + "url": "http://example.com/root/awesome-project/-/wikis/awesome", "action": "create" } } diff --git a/spec/features/projects/wiki/markdown_preview_spec.rb b/spec/features/projects/wiki/markdown_preview_spec.rb index 5c6b04a7141687dcde41522d70154268a5669597..331ba58d0678a56edd2e9981ef50ee2d7b4a7448 100644 --- a/spec/features/projects/wiki/markdown_preview_spec.rb +++ b/spec/features/projects/wiki/markdown_preview_spec.rb @@ -29,11 +29,11 @@ expect(page).to have_content("regular link") - expect(page.html).to include("regular link") - expect(page.html).to include("relative link 1") - expect(page.html).to include("relative link 2") - expect(page.html).to include("relative link 3") - expect(page.html).to include("spaced link") + expect(page.html).to include("regular link") + expect(page.html).to include("relative link 1") + expect(page.html).to include("relative link 2") + expect(page.html).to include("relative link 3") + expect(page.html).to include("spaced link") end end @@ -43,11 +43,11 @@ expect(page).to have_content("regular link") - expect(page.html).to include("regular link") - expect(page.html).to include("relative link 1") - expect(page.html).to include("relative link 2") - expect(page.html).to include("relative link 3") - expect(page.html).to include("spaced link") + expect(page.html).to include("regular link") + expect(page.html).to include("relative link 1") + expect(page.html).to include("relative link 2") + expect(page.html).to include("relative link 3") + expect(page.html).to include("spaced link") end end @@ -57,11 +57,11 @@ expect(page).to have_content("regular link") - expect(page.html).to include("regular link") - expect(page.html).to include("relative link 1") - expect(page.html).to include("relative link 2") - expect(page.html).to include("relative link 3") - expect(page.html).to include("spaced link") + expect(page.html).to include("regular link") + expect(page.html).to include("relative link 1") + expect(page.html).to include("relative link 2") + expect(page.html).to include("relative link 3") + expect(page.html).to include("spaced link") end end end @@ -77,11 +77,11 @@ expect(page).to have_content("regular link") - expect(page.html).to include("regular link") - expect(page.html).to include("relative link 1") - expect(page.html).to include("relative link 2") - expect(page.html).to include("relative link 3") - expect(page.html).to include("spaced link") + expect(page.html).to include("regular link") + expect(page.html).to include("relative link 1") + expect(page.html).to include("relative link 2") + expect(page.html).to include("relative link 3") + expect(page.html).to include("spaced link") end end @@ -95,11 +95,11 @@ expect(page).to have_content("regular link") - expect(page.html).to include("regular link") - expect(page.html).to include("relative link 1") - expect(page.html).to include("relative link 2") - expect(page.html).to include("relative link 3") - expect(page.html).to include("spaced link") + expect(page.html).to include("regular link") + expect(page.html).to include("relative link 1") + expect(page.html).to include("relative link 2") + expect(page.html).to include("relative link 3") + expect(page.html).to include("spaced link") end end @@ -113,11 +113,11 @@ expect(page).to have_content("regular link") - expect(page.html).to include("regular link") - expect(page.html).to include("relative link 1") - expect(page.html).to include("relative link 2") - expect(page.html).to include("relative link 3") - expect(page.html).to include("spaced link") + expect(page.html).to include("regular link") + expect(page.html).to include("relative link 1") + expect(page.html).to include("relative link 2") + expect(page.html).to include("relative link 3") + expect(page.html).to include("spaced link") end end diff --git a/spec/features/projects/wiki/user_creates_wiki_page_spec.rb b/spec/features/projects/wiki/user_creates_wiki_page_spec.rb index 56d0518015d41d89c9360cbfcab5a586d0d13677..499c459621adef2c5017935c0efcc10afbeedfe1 100644 --- a/spec/features/projects/wiki/user_creates_wiki_page_spec.rb +++ b/spec/features/projects/wiki/user_creates_wiki_page_spec.rb @@ -55,7 +55,7 @@ end expect(current_path).to include("one/two/three-test") - expect(page).to have_xpath("//a[@href='/#{project.full_path}/wikis/one/two/three-test']") + expect(page).to have_xpath("//a[@href='/#{project.full_path}/-/wikis/one/two/three-test']") end it "has `Create home` as a commit message", :js do diff --git a/spec/helpers/wiki_helper_spec.rb b/spec/helpers/wiki_helper_spec.rb index bcc2bd71da1243605a140177eef922cbcead43bf..1aab01281c639e7e853a61c9bf0275d982102e57 100644 --- a/spec/helpers/wiki_helper_spec.rb +++ b/spec/helpers/wiki_helper_spec.rb @@ -27,7 +27,7 @@ let(:classes) { "btn btn-default has-tooltip reverse-sort-btn qa-reverse-sort rspec-reverse-sort" } def expected_link(sort, direction, icon_class) - path = "/#{project.full_path}/wikis/pages?direction=#{direction}&sort=#{sort}" + path = "/#{project.full_path}/-/wikis/pages?direction=#{direction}&sort=#{sort}" helper.link_to(path, type: 'button', class: classes, title: 'Sort direction') do helper.sprite_icon("sort-#{icon_class}", size: 16) diff --git a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb index 26f2b0b0acf37892ad04382b4578eedeafd14287..e1814ea403e29a89ec21e959e8b260073a0426cf 100644 --- a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb @@ -72,14 +72,14 @@ markdown = "[Page](./page)" output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/wikis/nested/twice/page\"") + expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/nested/twice/page\"") end it "rewrites file links to be at the scope of the current directory" do markdown = "[Link to Page](./page.md)" output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/wikis/nested/twice/page.md\"") + expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/nested/twice/page.md\"") end end @@ -88,14 +88,14 @@ markdown = "[Link to Page](../page)" output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/wikis/nested/page\"") + expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/nested/page\"") end it "rewrites file links to be at the scope of the parent directory" do markdown = "[Link to Page](../page.md)" output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/wikis/nested/page.md\"") + expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/nested/page.md\"") end end @@ -104,14 +104,14 @@ markdown = "[Link to Page](./subdirectory/page)" output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/wikis/nested/twice/subdirectory/page\"") + expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/nested/twice/subdirectory/page\"") end it "rewrites file links to be at the scope of the sub-directory" do markdown = "[Link to Page](./subdirectory/page.md)" output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/wikis/nested/twice/subdirectory/page.md\"") + expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/nested/twice/subdirectory/page.md\"") end end @@ -120,35 +120,35 @@ markdown = "[Link to Page](page)" output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/wikis/page\"") + expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/page\"") end it 'rewrites non-file links (with spaces) to be at the scope of the wiki root' do markdown = "[Link to Page](page slug)" output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/wikis/page%20slug\"") + expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/page%20slug\"") end it "rewrites file links to be at the scope of the current directory" do markdown = "[Link to Page](page.md)" output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/wikis/nested/twice/page.md\"") + expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/nested/twice/page.md\"") end it 'rewrites links with anchor' do markdown = '[Link to Header](start-page#title)' output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/wikis/start-page#title\"") + expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/start-page#title\"") end it 'rewrites links (with spaces) with anchor' do markdown = '[Link to Header](start page#title)' output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/wikis/start%20page#title\"") + expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/start%20page#title\"") end end @@ -157,14 +157,14 @@ markdown = "[Link to Page](/page)" output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/wikis/page\"") + expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/page\"") end it 'rewrites file links to be at the scope of the wiki root' do markdown = "[Link to Page](/page.md)" output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/wikis/page.md\"") + expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/page.md\"") end end end @@ -270,28 +270,28 @@ markdown = "![video_file](video_file_name.mp4)" output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug) - expect(output).to include('