Relax constraints for wiki slug
Since GitHub doesn’t apply these constraints to theirs wiki slug allowing characters like `,`, `:`, `*`, etc, we need to relax our constraints or some wiki pages will not be available after they were imported. For an example the Devise project have a wiki page with the following slug: “How To: Add sign_in, sign_out, and sign_up links to your layout template”
This commit is contained in:
parent
78f5eb94fb
commit
aac6598482
6 changed files with 24 additions and 37 deletions
File diff suppressed because one or more lines are too long
|
@ -169,7 +169,7 @@ class WikiPage
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_attributes
|
def set_attributes
|
||||||
attributes[:slug] = @page.escaped_url_path
|
attributes[:slug] = @page.url_path
|
||||||
attributes[:title] = @page.title
|
attributes[:title] = @page.title
|
||||||
attributes[:format] = @page.format
|
attributes[:format] = @page.format
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,12 +5,9 @@
|
||||||
%a.close{href: "#", "data-dismiss" => "modal"} ×
|
%a.close{href: "#", "data-dismiss" => "modal"} ×
|
||||||
%h3.page-title New Wiki Page
|
%h3.page-title New Wiki Page
|
||||||
.modal-body
|
.modal-body
|
||||||
|
.form-group
|
||||||
= label_tag :new_wiki_path do
|
= label_tag :new_wiki_path do
|
||||||
%span Page slug
|
%span Page slug
|
||||||
= text_field_tag :new_wiki_path, nil, placeholder: 'how-to-setup', class: 'form-control', required: true, :'data-wikis-path' => namespace_project_wikis_path(@project.namespace, @project)
|
= text_field_tag :new_wiki_path, nil, placeholder: 'how-to-setup', class: 'form-control', required: true, :'data-wikis-path' => namespace_project_wikis_path(@project.namespace, @project)
|
||||||
%p.hidden.text-danger{data: { error: "slug" }}
|
|
||||||
The page slug is invalid. Please don't use characters other then: a-z 0-9 _ - and /
|
|
||||||
%p.hint
|
|
||||||
Please don't use spaces.
|
|
||||||
.form-actions
|
.form-actions
|
||||||
= link_to 'Create Page', '#', class: 'build-new-wiki btn btn-create'
|
= link_to 'Create Page', '#', class: 'build-new-wiki btn btn-create'
|
||||||
|
|
|
@ -513,7 +513,7 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
WIKI_SLUG_ID = { id: /[a-zA-Z.0-9_\-\/]+/ } unless defined? WIKI_SLUG_ID
|
WIKI_SLUG_ID = { id: /[\S]+/ } unless defined? WIKI_SLUG_ID
|
||||||
|
|
||||||
scope do
|
scope do
|
||||||
# Order matters to give priority to these matches
|
# Order matters to give priority to these matches
|
||||||
|
|
|
@ -69,11 +69,6 @@ Feature: Project Wiki
|
||||||
And I click on the "Pages" button
|
And I click on the "Pages" button
|
||||||
Then I should see non-escaped link in the pages list
|
Then I should see non-escaped link in the pages list
|
||||||
|
|
||||||
@javascript
|
|
||||||
Scenario: Creating an invalid new page
|
|
||||||
Given I create a New page with an invalid name
|
|
||||||
Then I should see an error message
|
|
||||||
|
|
||||||
@javascript
|
@javascript
|
||||||
Scenario: Edit Wiki page that has a path
|
Scenario: Edit Wiki page that has a path
|
||||||
Given I create a New page with paths
|
Given I create a New page with paths
|
||||||
|
|
|
@ -132,16 +132,6 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps
|
||||||
expect(current_path).to include 'one/two/three'
|
expect(current_path).to include 'one/two/three'
|
||||||
end
|
end
|
||||||
|
|
||||||
step 'I create a New page with an invalid name' do
|
|
||||||
click_on 'New Page'
|
|
||||||
fill_in 'Page slug', with: 'invalid name'
|
|
||||||
click_on 'Create Page'
|
|
||||||
end
|
|
||||||
|
|
||||||
step 'I should see an error message' do
|
|
||||||
expect(page).to have_content "The page slug is invalid"
|
|
||||||
end
|
|
||||||
|
|
||||||
step 'I should see non-escaped link in the pages list' do
|
step 'I should see non-escaped link in the pages list' do
|
||||||
expect(page).to have_xpath("//a[@href='/#{project.path_with_namespace}/wikis/one/two/three']")
|
expect(page).to have_xpath("//a[@href='/#{project.path_with_namespace}/wikis/one/two/three']")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue