##// END OF EJS Templates
remove trailing white-spaces from app/models/wiki.rb....
Toshi MARUYAMA -
r6717:1fda93a02fad
parent child
Show More
@@ -1,16 +1,16
1 1 # Redmine - project management software
2 # Copyright (C) 2006-2009 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 #
8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 #
13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -19,29 +19,29 class Wiki < ActiveRecord::Base
19 19 belongs_to :project
20 20 has_many :pages, :class_name => 'WikiPage', :dependent => :destroy, :order => 'title'
21 21 has_many :redirects, :class_name => 'WikiRedirect', :dependent => :delete_all
22
22
23 23 acts_as_watchable
24
24
25 25 validates_presence_of :start_page
26 26 validates_format_of :start_page, :with => /^[^,\.\/\?\;\|\:]*$/
27
27
28 28 def visible?(user=User.current)
29 29 !user.nil? && user.allowed_to?(:view_wiki_pages, project)
30 30 end
31
31
32 32 # Returns the wiki page that acts as the sidebar content
33 33 # or nil if no such page exists
34 34 def sidebar
35 35 @sidebar ||= find_page('Sidebar', :with_redirect => false)
36 36 end
37
37
38 38 # find the page with the given title
39 39 # if page doesn't exist, return a new page
40 40 def find_or_new_page(title)
41 41 title = start_page if title.blank?
42 42 find_page(title) || WikiPage.new(:wiki => self, :title => Wiki.titleize(title))
43 43 end
44
44
45 45 # find the page with the given title
46 46 def find_page(title, options = {})
47 47 @page_found_with_redirect = false
@@ -58,7 +58,7 class Wiki < ActiveRecord::Base
58 58 end
59 59 page
60 60 end
61
61
62 62 # Returns true if the last page was found with a redirect
63 63 def page_found_with_redirect?
64 64 @page_found_with_redirect
@@ -82,7 +82,7 class Wiki < ActiveRecord::Base
82 82 end
83 83 end
84 84 end
85
85
86 86 # turn a string into a valid page title
87 87 def self.titleize(title)
88 88 # replace spaces with _ and remove unwanted caracters
@@ -90,5 +90,5 class Wiki < ActiveRecord::Base
90 90 # upcase the first letter
91 91 title = (title.slice(0..0).upcase + (title.slice(1..-1) || '')) if title
92 92 title
93 end
93 end
94 94 end
General Comments 0
You need to be logged in to leave comments. Login now