Patch #30162 » collapse_block_pdf.patch
| app/helpers/application_helper.rb (working copy) | ||
|---|---|---|
| 697 | 697 |
@current_section = 0 if options[:edit_section_links] |
| 698 | 698 | |
| 699 | 699 |
parse_sections(text, project, obj, attr, only_path, options) |
| 700 |
text = parse_non_pre_blocks(text, obj, macros) do |text| |
|
| 700 |
text = parse_non_pre_blocks(text, obj, macros, options) do |text|
|
|
| 701 | 701 |
[:parse_inline_attachments, :parse_hires_images, :parse_wiki_links, :parse_redmine_links].each do |method_name| |
| 702 | 702 |
send method_name, text, project, obj, attr, only_path, options |
| 703 | 703 |
end |
| ... | ... | |
| 711 | 711 |
text.html_safe |
| 712 | 712 |
end |
| 713 | 713 | |
| 714 |
def parse_non_pre_blocks(text, obj, macros) |
|
| 714 |
def parse_non_pre_blocks(text, obj, macros, options={})
|
|
| 715 | 715 |
s = StringScanner.new(text) |
| 716 | 716 |
tags = [] |
| 717 | 717 |
parsed = '' |
| ... | ... | |
| 720 | 720 |
text, full_tag, closing, tag = s[1], s[2], s[3], s[4] |
| 721 | 721 |
if tags.empty? |
| 722 | 722 |
yield text |
| 723 |
inject_macros(text, obj, macros) if macros.any? |
|
| 723 |
inject_macros(text, obj, macros, true, options) if macros.any?
|
|
| 724 | 724 |
else |
| 725 |
inject_macros(text, obj, macros, false) if macros.any? |
|
| 725 |
inject_macros(text, obj, macros, false, options) if macros.any?
|
|
| 726 | 726 |
end |
| 727 | 727 |
parsed << text |
| 728 | 728 |
if tag |
| ... | ... | |
| 1164 | 1164 |
end |
| 1165 | 1165 | |
| 1166 | 1166 |
# Executes and replaces macros in text |
| 1167 |
def inject_macros(text, obj, macros, execute=true) |
|
| 1167 |
def inject_macros(text, obj, macros, execute=true, options={})
|
|
| 1168 | 1168 |
text.gsub!(MACRO_SUB_RE) do |
| 1169 | 1169 |
all, index = $1, $2.to_i |
| 1170 | 1170 |
orig = macros.delete(index) |
| 1171 | 1171 |
if execute && orig && orig =~ MACROS_RE |
| 1172 | 1172 |
esc, all, macro, args, block = $2, $3, $4.downcase, $6.to_s, $7.try(:strip) |
| 1173 | 1173 |
if esc.nil? |
| 1174 |
h(exec_macro(macro, obj, args, block) || all) |
|
| 1174 |
h(exec_macro(macro, obj, args, block, options) || all)
|
|
| 1175 | 1175 |
else |
| 1176 | 1176 |
h(all) |
| 1177 | 1177 |
end |
| lib/redmine/wiki_formatting/macros.rb (working copy) | ||
|---|---|---|
| 24 | 24 |
Redmine::WikiFormatting::Macros.available_macros.key?(name.to_sym) |
| 25 | 25 |
end |
| 26 | 26 | |
| 27 |
def exec_macro(name, obj, args, text) |
|
| 27 |
def exec_macro(name, obj, args, text, options={})
|
|
| 28 | 28 |
macro_options = Redmine::WikiFormatting::Macros.available_macros[name.to_sym] |
| 29 | 29 |
return unless macro_options |
| 30 | 30 | |
| 31 |
if options[:inline_attachments] == false |
|
| 32 |
Redmine::WikiFormatting::Macros.inline_attachments = false |
|
| 33 |
else |
|
| 34 |
Redmine::WikiFormatting::Macros.inline_attachments = true |
|
| 35 |
end |
|
| 36 | ||
| 31 | 37 |
method_name = "macro_#{name}"
|
| 32 | 38 |
unless macro_options[:parse_args] == false |
| 33 | 39 |
args = args.split(',').map(&:strip)
|
| ... | ... | |
| 57 | 63 |
end |
| 58 | 64 | |
| 59 | 65 |
@@available_macros = {}
|
| 66 |
@@inline_attachments = true |
|
| 60 | 67 |
mattr_accessor :available_macros |
| 68 |
mattr_accessor :inline_attachments |
|
| 61 | 69 | |
| 62 | 70 |
class << self |
| 63 | 71 |
# Plugins can use this method to define new macros: |
| ... | ... | |
| 209 | 217 |
@included_wiki_pages ||= [] |
| 210 | 218 |
raise 'Circular inclusion detected' if @included_wiki_pages.include?(page.id) |
| 211 | 219 |
@included_wiki_pages << page.id |
| 212 |
out = textilizable(page.content, :text, :attachments => page.attachments, :headings => false) |
|
| 220 |
out = textilizable(page.content, :text, :attachments => page.attachments, :headings => false, :inline_attachments => @@inline_attachments)
|
|
| 213 | 221 |
@included_wiki_pages.pop |
| 214 | 222 |
out |
| 215 | 223 |
end |
| ... | ... | |
| 225 | 233 |
out = ''.html_safe |
| 226 | 234 |
out << link_to_function(show_label, js, :id => "#{html_id}-show", :class => 'collapsible collapsed')
|
| 227 | 235 |
out << link_to_function(hide_label, js, :id => "#{html_id}-hide", :class => 'collapsible', :style => 'display:none;')
|
| 228 |
out << content_tag('div', textilizable(text, :object => obj, :headings => false), :id => html_id, :class => 'collapsed-text', :style => 'display:none;')
|
|
| 236 |
out << content_tag('div', textilizable(text, :object => obj, :headings => false, :inline_attachments => @@inline_attachments), :id => html_id, :class => 'collapsed-text', :style => 'display:none;')
|
|
| 229 | 237 |
out |
| 230 | 238 |
end |
| 231 | 239 | |
- « Previous
- 1
- 2
- Next »