remove trailing white-spaces from lib/redmine/wiki_formatting/macros.rb.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6951 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-09-01 02:04:41 +00:00
parent 1556481ab1
commit 09d4503eb5
1 changed files with 15 additions and 15 deletions

View File

@ -1,16 +1,16 @@
# redMine - project management software # Redmine - project management software
# Copyright (C) 2006-2007 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 # as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. # of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@ -23,7 +23,7 @@ module Redmine
method_name = "macro_#{name}" method_name = "macro_#{name}"
send(method_name, obj, args) if respond_to?(method_name) send(method_name, obj, args) if respond_to?(method_name)
end end
def extract_macro_options(args, *keys) def extract_macro_options(args, *keys)
options = {} options = {}
while args.last.to_s.strip =~ %r{^(.+)\=(.+)$} && keys.include?($1.downcase.to_sym) while args.last.to_s.strip =~ %r{^(.+)\=(.+)$} && keys.include?($1.downcase.to_sym)
@ -33,17 +33,17 @@ module Redmine
return [args, options] return [args, options]
end end
end end
@@available_macros = {} @@available_macros = {}
class << self class << self
# Called with a block to define additional macros. # Called with a block to define additional macros.
# Macro blocks accept 2 arguments: # Macro blocks accept 2 arguments:
# * obj: the object that is rendered # * obj: the object that is rendered
# * args: macro arguments # * args: macro arguments
# #
# Plugins can use this method to define new macros: # Plugins can use this method to define new macros:
# #
# Redmine::WikiFormatting::Macros.register do # Redmine::WikiFormatting::Macros.register do
# desc "This is my macro" # desc "This is my macro"
# macro :my_macro do |obj, args| # macro :my_macro do |obj, args|
@ -53,7 +53,7 @@ module Redmine
def register(&block) def register(&block)
class_eval(&block) if block_given? class_eval(&block) if block_given?
end end
private private
# Defines a new macro with the given name and block. # Defines a new macro with the given name and block.
def macro(name, &block) def macro(name, &block)
@ -63,19 +63,19 @@ module Redmine
raise "Can not create a macro without a block!" unless block_given? raise "Can not create a macro without a block!" unless block_given?
Definitions.send :define_method, "macro_#{name}".downcase, &block Definitions.send :define_method, "macro_#{name}".downcase, &block
end end
# Sets description for the next macro to be defined # Sets description for the next macro to be defined
def desc(txt) def desc(txt)
@@desc = txt @@desc = txt
end end
end end
# Builtin macros # Builtin macros
desc "Sample macro." desc "Sample macro."
macro :hello_world do |obj, args| macro :hello_world do |obj, args|
"Hello world! Object: #{obj.class.name}, " + (args.empty? ? "Called with no argument." : "Arguments: #{args.join(', ')}") "Hello world! Object: #{obj.class.name}, " + (args.empty? ? "Called with no argument." : "Arguments: #{args.join(', ')}")
end end
desc "Displays a list of all available macros, including description if available." desc "Displays a list of all available macros, including description if available."
macro :macro_list do macro :macro_list do
out = '' out = ''
@ -85,7 +85,7 @@ module Redmine
end end
content_tag('dl', out) content_tag('dl', out)
end end
desc "Displays a list of child pages. With no argument, it displays the child pages of the current wiki page. Examples:\n\n" + desc "Displays a list of child pages. With no argument, it displays the child pages of the current wiki page. Examples:\n\n" +
" !{{child_pages}} -- can be used from a wiki page only\n" + " !{{child_pages}} -- can be used from a wiki page only\n" +
" !{{child_pages(Foo)}} -- lists all children of page Foo\n" + " !{{child_pages(Foo)}} -- lists all children of page Foo\n" +
@ -104,7 +104,7 @@ module Redmine
pages = ([page] + page.descendants).group_by(&:parent_id) pages = ([page] + page.descendants).group_by(&:parent_id)
render_page_hierarchy(pages, options[:parent] ? page.parent_id : page.id) render_page_hierarchy(pages, options[:parent] ? page.parent_id : page.id)
end end
desc "Include a wiki page. Example:\n\n !{{include(Foo)}}\n\nor to include a page of a specific project wiki:\n\n !{{include(projectname:Foo)}}" desc "Include a wiki page. Example:\n\n !{{include(Foo)}}\n\nor to include a page of a specific project wiki:\n\n !{{include(projectname:Foo)}}"
macro :include do |obj, args| macro :include do |obj, args|
page = Wiki.find_page(args.first.to_s, :project => @project) page = Wiki.find_page(args.first.to_s, :project => @project)