Patch #30162 » collapse_block_pdf.patch
| app/helpers/application_helper.rb (working copy) | ||
|---|---|---|
|
@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
|
||
| ... | ... | |
|
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 = ''
|
||
| ... | ... | |
|
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
|
||
| ... | ... | |
|
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
|
||
| lib/redmine/wiki_formatting/macros.rb (working copy) | ||
|---|---|---|
|
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)
|
||
| ... | ... | |
|
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:
|
||
| ... | ... | |
|
@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
|
||
| ... | ... | |
|
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
|
||
- « Previous
- 1
- 2
- Next »