Merge pull request #6 from iris-edu/master
Added support for text blocks with wiki formatting.
This commit is contained in:
commit
d954144984
2 changed files with 48 additions and 28 deletions
18
init.rb
18
init.rb
|
@ -21,9 +21,21 @@ begin
|
|||
rescue LoadError
|
||||
end
|
||||
|
||||
Dir::foreach(File.join(File.dirname(__FILE__), 'lib')) do |file|
|
||||
next unless /\.rb$/ =~ file
|
||||
require file
|
||||
def init_redmine_wiki_notes
|
||||
Dir::foreach(File.join(File.dirname(__FILE__), 'lib')) do |file|
|
||||
next unless /\.rb$/ =~ file
|
||||
require_dependency file
|
||||
end
|
||||
end
|
||||
|
||||
if Rails::VERSION::MAJOR >= 3
|
||||
ActionDispatch::Callbacks.to_prepare do
|
||||
init_redmine_wiki_notes
|
||||
end
|
||||
else
|
||||
Dispatcher.to_prepare :redmine_wiki_notes do
|
||||
init_redmine_wiki_notes
|
||||
end
|
||||
end
|
||||
|
||||
require 'redcloth3'
|
||||
|
|
|
@ -1,37 +1,45 @@
|
|||
module WikiNotesMacro
|
||||
Redmine::WikiFormatting::Macros.register do
|
||||
desc "Adds a note to the wiki page:\n\n" +
|
||||
" @!{{note(text)}}@\n" +
|
||||
" @!{{tip(text)}}@\n" +
|
||||
" @!{{important(text)}}@\n"
|
||||
" @!{{warning(text)}}@\n"
|
||||
|
||||
macro :note, :parse_args => false do |obj, args|
|
||||
o = '<div class="noteclassic">'
|
||||
o << textilizable(args)
|
||||
o << '</div>'
|
||||
o.html_safe
|
||||
"<pre>\n" +
|
||||
"{{note(text with *wiki formatting*)}}\n" +
|
||||
"{{note\nAlternately, you can put blocks of *wiki-formatted* text here.\n}}\n" +
|
||||
"{{note(Or if you really want)\nYou can do both...\n}}\n" +
|
||||
"</pre>"
|
||||
macro :note, :parse_args => false do |obj, args, text|
|
||||
o = textilizable(args)
|
||||
if text.present?
|
||||
o << textilizable(text, :object => obj, :headings => false)
|
||||
end
|
||||
content_tag('div', o.html_safe, :class => "noteclassic")
|
||||
end
|
||||
|
||||
macro :tip, :parse_args => false do |obj, args|
|
||||
o = '<div class="notetip">'
|
||||
o << textilizable(args)
|
||||
o << '</div>'
|
||||
o.html_safe
|
||||
desc "Variant of @note@."
|
||||
macro :tip, :parse_args => false do |obj, args, text|
|
||||
o = textilizable(args)
|
||||
if text.present?
|
||||
o << textilizable(text, :object => obj, :headings => false)
|
||||
end
|
||||
content_tag('div', o.html_safe, :class => "notetip")
|
||||
end
|
||||
|
||||
macro :important, :parse_args => false do |obj, args|
|
||||
o = '<div class="noteimportant">'
|
||||
o << textilizable(args)
|
||||
o << '</div>'
|
||||
o.html_safe
|
||||
desc "Variant of @note@."
|
||||
macro :important, :parse_args => false do |obj, args, text|
|
||||
o = textilizable(args)
|
||||
if text.present?
|
||||
o << textilizable(text, :object => obj, :headings => false)
|
||||
end
|
||||
content_tag('div', o.html_safe, :class => "noteimportant")
|
||||
end
|
||||
|
||||
macro :warning, :parse_args => false do |obj, args|
|
||||
o = '<div class="notewarning">'
|
||||
o << textilizable(args)
|
||||
o << '</div>'
|
||||
o.html_safe
|
||||
desc "Variant of @note@."
|
||||
macro :warning, :parse_args => false do |obj, args, text|
|
||||
o = textilizable(args)
|
||||
if text.present?
|
||||
o << textilizable(text, :object => obj, :headings => false)
|
||||
end
|
||||
content_tag('div', o.html_safe, :class => "notewarning")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue