summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-11-12 14:36:33 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-11-12 14:36:33 +0000
commit8a8f819d273e25fa28fb492da92125fb06d1ab01 (patch)
tree110c62a735f1bddcd3996b25a4f0cab56ddd5553 /app
parenta8419c1425b55b91edf24db044725d099b6065a8 (diff)
downloadredmine-8a8f819d273e25fa28fb492da92125fb06d1ab01.tar.gz
redmine-8a8f819d273e25fa28fb492da92125fb06d1ab01.zip
Added wiki macros support. 2 builtin macros are defined: hello_world (sample macro that displays the arguments) and macro_list (display the list of installed macros).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@897 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/helpers/application_helper.rb25
-rw-r--r--app/views/issues/show.rhtml2
-rw-r--r--app/views/wiki/_content.rhtml2
-rw-r--r--app/views/wiki/export.rhtml2
-rw-r--r--app/views/wiki/export_multiple.rhtml2
5 files changed, 24 insertions, 9 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 3fc333aa9..c03f073c1 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module ApplicationHelper
+ include Redmine::WikiFormatting::Macros::Definitions
def current_role
@current_role ||= User.current.role_for_project(@project)
@@ -130,15 +131,28 @@ module ApplicationHelper
:preview => 'r',
:quick_search => 'f',
:search => '4',
- }.freeze
+ }.freeze unless const_defined?(:ACCESSKEYS)
def accesskey(s)
ACCESSKEYS[s]
end
- # format text according to system settings
- def textilizable(text, options = {})
- return "" if text.blank?
+ # Formats text according to system settings.
+ # 2 ways to call this method:
+ # * with a String: textilizable(text, options)
+ # * with an object and one of its attribute: textilizable(issue, :description, options)
+ def textilizable(*args)
+ options = args.last.is_a?(Hash) ? args.pop : {}
+ case args.size
+ when 1
+ obj = nil
+ text = args.shift || ''
+ when 2
+ obj = args.shift
+ text = obj.send(args.shift)
+ else
+ raise ArgumentError, 'invalid arguments to textilizable'
+ end
# when using an image link, try to use an attachment, if possible
attachments = options[:attachments]
@@ -158,7 +172,8 @@ module ApplicationHelper
end
text = (Setting.text_formatting == 'textile') ?
- Redmine::WikiFormatting.to_html(text) : simple_format(auto_link(h(text)))
+ Redmine::WikiFormatting.to_html(text) { |macro, args| exec_macro(macro, obj, args) } :
+ simple_format(auto_link(h(text)))
# different methods for formatting wiki links
case options[:wiki_links]
diff --git a/app/views/issues/show.rhtml b/app/views/issues/show.rhtml
index dfeccc669..db6fc4df2 100644
--- a/app/views/issues/show.rhtml
+++ b/app/views/issues/show.rhtml
@@ -64,7 +64,7 @@ end %>
<% end %>
<p><strong><%=l(:field_description)%></strong></p>
-<%= textilizable @issue.description, :attachments => @issue.attachments %>
+<%= textilizable @issue, :description, :attachments => @issue.attachments %>
<% if @issue.attachments.any? %>
<%= link_to_attachments @issue.attachments, :delete_url => (authorize_for('issues', 'destroy_attachment') ? {:controller => 'issues', :action => 'destroy_attachment', :id => @issue} : nil) %>
diff --git a/app/views/wiki/_content.rhtml b/app/views/wiki/_content.rhtml
index 0c6f4d648..421d26cbb 100644
--- a/app/views/wiki/_content.rhtml
+++ b/app/views/wiki/_content.rhtml
@@ -1,3 +1,3 @@
<div class="wiki">
- <%= textilizable content.text, :attachments => content.page.attachments %>
+ <%= textilizable content, :text, :attachments => content.page.attachments %>
</div>
diff --git a/app/views/wiki/export.rhtml b/app/views/wiki/export.rhtml
index 561e9b000..1ab5c13e4 100644
--- a/app/views/wiki/export.rhtml
+++ b/app/views/wiki/export.rhtml
@@ -9,6 +9,6 @@ h1, h2, h3, h4 { font-family: Trebuchet MS,Georgia,"Times New Roman",serif; }
</style>
</head>
<body>
-<%= textilizable @content.text, :wiki_links => :local %>
+<%= textilizable @content, :text, :wiki_links => :local %>
</body>
</html>
diff --git a/app/views/wiki/export_multiple.rhtml b/app/views/wiki/export_multiple.rhtml
index c76b08fca..6f6c603ad 100644
--- a/app/views/wiki/export_multiple.rhtml
+++ b/app/views/wiki/export_multiple.rhtml
@@ -20,7 +20,7 @@ h1, h2, h3, h4 { font-family: Trebuchet MS,Georgia,"Times New Roman",serif; }
<% @pages.each do |page| %>
<hr />
<a name="<%= page.title %>" />
-<%= textilizable page.content.text, :wiki_links => :anchor %>
+<%= textilizable page.content ,:text, :wiki_links => :anchor %>
<% end %>
</body>