Index: app/helpers/application_helper.rb =================================================================== --- app/helpers/application_helper.rb (revision 17718) +++ app/helpers/application_helper.rb (working copy) @@ -697,7 +697,7 @@ @current_section = 0 if options[:edit_section_links] parse_sections(text, project, obj, attr, only_path, options) - text = parse_non_pre_blocks(text, obj, macros) do |text| + text = parse_non_pre_blocks(text, obj, macros, options) do |text| [:parse_inline_attachments, :parse_hires_images, :parse_wiki_links, :parse_redmine_links].each do |method_name| send method_name, text, project, obj, attr, only_path, options end @@ -711,7 +711,7 @@ text.html_safe end - def parse_non_pre_blocks(text, obj, macros) + def parse_non_pre_blocks(text, obj, macros, options={}) s = StringScanner.new(text) tags = [] parsed = '' @@ -720,9 +720,9 @@ text, full_tag, closing, tag = s[1], s[2], s[3], s[4] if tags.empty? yield text - inject_macros(text, obj, macros) if macros.any? + inject_macros(text, obj, macros, true, options) if macros.any? else - inject_macros(text, obj, macros, false) if macros.any? + inject_macros(text, obj, macros, false, options) if macros.any? end parsed << text if tag @@ -1164,14 +1164,14 @@ end # Executes and replaces macros in text - def inject_macros(text, obj, macros, execute=true) + def inject_macros(text, obj, macros, execute=true, options={}) text.gsub!(MACRO_SUB_RE) do all, index = $1, $2.to_i orig = macros.delete(index) if execute && orig && orig =~ MACROS_RE esc, all, macro, args, block = $2, $3, $4.downcase, $6.to_s, $7.try(:strip) if esc.nil? - h(exec_macro(macro, obj, args, block) || all) + h(exec_macro(macro, obj, args, block, options) || all) else h(all) end Index: lib/redmine/wiki_formatting/macros.rb =================================================================== --- lib/redmine/wiki_formatting/macros.rb (revision 17718) +++ lib/redmine/wiki_formatting/macros.rb (working copy) @@ -24,10 +24,16 @@ Redmine::WikiFormatting::Macros.available_macros.key?(name.to_sym) end - def exec_macro(name, obj, args, text) + def exec_macro(name, obj, args, text, options={}) macro_options = Redmine::WikiFormatting::Macros.available_macros[name.to_sym] return unless macro_options + if options[:inline_attachments] == false + Redmine::WikiFormatting::Macros.inline_attachments = false + else + Redmine::WikiFormatting::Macros.inline_attachments = true + end + method_name = "macro_#{name}" unless macro_options[:parse_args] == false args = args.split(',').map(&:strip) @@ -57,7 +63,9 @@ end @@available_macros = {} + @@inline_attachments = true mattr_accessor :available_macros + mattr_accessor :inline_attachments class << self # Plugins can use this method to define new macros: @@ -209,7 +217,7 @@ @included_wiki_pages ||= [] raise 'Circular inclusion detected' if @included_wiki_pages.include?(page.id) @included_wiki_pages << page.id - out = textilizable(page.content, :text, :attachments => page.attachments, :headings => false) + out = textilizable(page.content, :text, :attachments => page.attachments, :headings => false, :inline_attachments => @@inline_attachments) @included_wiki_pages.pop out end @@ -225,7 +233,7 @@ out = ''.html_safe out << link_to_function(show_label, js, :id => "#{html_id}-show", :class => 'collapsible collapsed') out << link_to_function(hide_label, js, :id => "#{html_id}-hide", :class => 'collapsible', :style => 'display:none;') - out << content_tag('div', textilizable(text, :object => obj, :headings => false), :id => html_id, :class => 'collapsed-text', :style => 'display:none;') + out << content_tag('div', textilizable(text, :object => obj, :headings => false, :inline_attachments => @@inline_attachments), :id => html_id, :class => 'collapsed-text', :style => 'display:none;') out end