Commit bca528a57c9276c0cd815d67fed4a72c514d53a2

Authored by Hiroyuki Sato
1 parent 03472b4f

Better title format for wiki page

The title format for wiki page may be unintelligible.
For example 'GitLab' is converted to 'Git Lab', 'MySQL' is converted to
'My Sql', etc.
app/models/wiki_page.rb
@@ -47,7 +47,11 @@ class WikiPage @@ -47,7 +47,11 @@ class WikiPage
47 47
48 # The formatted title of this page. 48 # The formatted title of this page.
49 def title 49 def title
50 - @attributes[:title] || "" 50 + if @attributes[:title]
  51 + @attributes[:title].gsub(/-+/, ' ')
  52 + else
  53 + ""
  54 + end
51 end 55 end
52 56
53 # Sets the title of this page. 57 # Sets the title of this page.
app/views/projects/wikis/edit.html.haml
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 = render 'main_links' 3 = render 'main_links'
4 %h3.page-title 4 %h3.page-title
5 Editing - 5 Editing -
6 - %span.light #{@page.title.titleize} 6 + %span.light #{@page.title}
7 %hr 7 %hr
8 = render 'form' 8 = render 'form'
9 9
app/views/projects/wikis/history.html.haml
1 = render 'nav' 1 = render 'nav'
2 %h3.page-title 2 %h3.page-title
3 %span.light History for 3 %span.light History for
4 - = link_to @page.title.titleize, project_wiki_path(@project, @page) 4 + = link_to @page.title, project_wiki_path(@project, @page)
5 5
6 %table.table 6 %table.table
7 %thead 7 %thead
app/views/projects/wikis/pages.html.haml
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 - @wiki_pages.each do |wiki_page| 5 - @wiki_pages.each do |wiki_page|
6 %li 6 %li
7 %h4 7 %h4
8 - = link_to wiki_page.title.titleize, project_wiki_path(@project, wiki_page) 8 + = link_to wiki_page.title, project_wiki_path(@project, wiki_page)
9 %small (#{wiki_page.format}) 9 %small (#{wiki_page.format})
10 .pull-right 10 .pull-right
11 %small Last edited #{time_ago_with_tooltip(wiki_page.commit.created_at)} 11 %small Last edited #{time_ago_with_tooltip(wiki_page.commit.created_at)}
app/views/projects/wikis/show.html.haml
1 = render 'nav' 1 = render 'nav'
2 %h3.page-title 2 %h3.page-title
3 - = @page.title.titleize 3 + = @page.title
4 = render 'main_links' 4 = render 'main_links'
5 - if @page.historical? 5 - if @page.historical?
6 .warning_message 6 .warning_message
features/steps/project/wiki.rb
@@ -83,7 +83,7 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps @@ -83,7 +83,7 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps
83 83
84 Then 'I should see the existing page in the pages list' do 84 Then 'I should see the existing page in the pages list' do
85 page.should have_content current_user.name 85 page.should have_content current_user.name
86 - page.should have_content @page.title.titleize 86 + page.should have_content @page.title
87 end 87 end
88 88
89 def wiki 89 def wiki
spec/models/wiki_page_spec.rb
@@ -155,4 +155,20 @@ describe WikiPage do @@ -155,4 +155,20 @@ describe WikiPage do
155 end 155 end
156 end 156 end
157 157
  158 + describe "#title" do
  159 + before do
  160 + create_page("Title", "content")
  161 + @page = wiki.find_page("Title")
  162 + end
  163 +
  164 + after do
  165 + destroy_page("Title")
  166 + end
  167 +
  168 + it "should be replace a hyphen to a space" do
  169 + @page.title = "Import-existing-repositories-into-GitLab"
  170 + @page.title.should == "Import existing repositories into GitLab"
  171 + end
  172 + end
  173 +
158 end 174 end