From ff8af0ea2e4ab23f75dd4e4933e28fb0a5c4e04b Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Sun, 21 Aug 2011 02:00:35 +0000 Subject: [PATCH] remove trailing white-spaces from app/models/wiki_page.rb. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6511 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/wiki_page.rb | 54 ++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 99a88cf9c..f937b8d67 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -5,12 +5,12 @@ # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -36,27 +36,27 @@ class WikiPage < ActiveRecord::Base :project_key => "#{Wiki.table_name}.project_id" attr_accessor :redirect_existing_links - + validates_presence_of :title validates_format_of :title, :with => /^[^,\.\/\?\;\|\s]*$/ validates_uniqueness_of :title, :scope => :wiki_id, :case_sensitive => false validates_associated :content - + # eager load information about last updates, without loading text named_scope :with_updated_on, { :select => "#{WikiPage.table_name}.*, #{WikiContent.table_name}.updated_on", :joins => "LEFT JOIN #{WikiContent.table_name} ON #{WikiContent.table_name}.page_id = #{WikiPage.table_name}.id" } - + # Wiki pages that are protected by default DEFAULT_PROTECTED_PAGES = %w(sidebar) - + def after_initialize if new_record? && DEFAULT_PROTECTED_PAGES.include?(title.to_s.downcase) self.protected = true end end - + def visible?(user=User.current) !user.nil? && user.allowed_to?(:view_wiki_pages, project) end @@ -68,7 +68,7 @@ class WikiPage < ActiveRecord::Base end def before_save - self.title = Wiki.titleize(title) + self.title = Wiki.titleize(title) # Manage redirects if the title has changed if !@previous_title.blank? && (@previous_title != title) && !new_record? # Update redirects that point to the old title @@ -83,51 +83,51 @@ class WikiPage < ActiveRecord::Base @previous_title = nil end end - + def before_destroy # Remove redirects to this page wiki.redirects.find_all_by_redirects_to(title).each(&:destroy) end - + def pretty_title WikiPage.pretty_title(title) end - + def content_for_version(version=nil) result = content.versions.find_by_version(version.to_i) if version result ||= content result end - + def diff(version_to=nil, version_from=nil) version_to = version_to ? version_to.to_i : self.content.version version_from = version_from ? version_from.to_i : version_to - 1 version_to, version_from = version_from, version_to unless version_from < version_to - + content_to = content.versions.find_by_version(version_to) content_from = content.versions.find_by_version(version_from) - + (content_to && content_from) ? WikiDiff.new(content_to, content_from) : nil end - + def annotate(version=nil) version = version ? version.to_i : self.content.version c = content.versions.find_by_version(version) c ? WikiAnnotate.new(c) : nil end - + def self.pretty_title(str) (str && str.is_a?(String)) ? str.tr('_', ' ') : str end - + def project wiki.project end - + def text content.text if content end - + def updated_on unless @updated_on if time = read_attribute(:updated_on) @@ -139,20 +139,20 @@ class WikiPage < ActiveRecord::Base end @updated_on end - + # Returns true if usr is allowed to edit the page, otherwise false def editable_by?(usr) !protected? || usr.allowed_to?(:protect_wiki_pages, wiki.project) end - + def attachments_deletable?(usr=User.current) editable_by?(usr) && super(usr) end - + def parent_title @parent_title || (self.parent && self.parent.pretty_title) end - + def parent_title=(t) @parent_title = t parent_page = t.blank? ? nil : self.wiki.find_page(t) @@ -160,7 +160,7 @@ class WikiPage < ActiveRecord::Base end protected - + def validate errors.add(:parent_title, :invalid) if !@parent_title.blank? && parent.nil? errors.add(:parent_title, :circular_dependency) if parent && (parent == self || parent.ancestors.include?(self)) @@ -170,7 +170,7 @@ end class WikiDiff < Redmine::Helpers::Diff attr_reader :content_to, :content_from - + def initialize(content_to, content_from) @content_to = content_to @content_from = content_from @@ -180,7 +180,7 @@ end class WikiAnnotate attr_reader :lines, :content - + def initialize(content) @content = content current = content @@ -212,7 +212,7 @@ class WikiAnnotate break unless @lines.detect { |line| line[0].nil? } current = current.previous end - @lines.each { |line| + @lines.each { |line| line[0] ||= current.version # if the last known version is > 1 (eg. history was cleared), we don't know the author line[1] ||= current.author if current.version == 1