diff --git a/init.rb b/init.rb index f641b5a..485c737 100644 --- a/init.rb +++ b/init.rb @@ -1,6 +1,6 @@ -#Rails.configuration.to_prepare do -# Redmine::Activity.register :glossary_terms -#end +Rails.configuration.to_prepare do + require_dependency "glossary_macros" +end Redmine::Plugin.register :redmine_glossary do name 'Redmine Glossary plugin' @@ -33,17 +33,3 @@ end Redmine::Activity.register :glossary_terms - -Redmine::WikiFormatting::Macros.register do - desc "create macro which links to glossary term." - macro :termno do |obj, args| - puts "@@@@@@@@@@@@ Macros.register macro block: obj=#{obj.inspect} @@@@@@@@@@@@" - term_id = args.first - term = GlossaryTerm.find(term_id) - link_to term.name, project_glossary_term_path(@project, term) - end - macro :term do |obj, args| - term = GlossaryTerm.find_by(name: args.first) - link_to - end -end diff --git a/lib/glossary_macros.rb b/lib/glossary_macros.rb new file mode 100644 index 0000000..9d28753 --- /dev/null +++ b/lib/glossary_macros.rb @@ -0,0 +1,20 @@ +module GlossaryMacros + + Redmine::WikiFormatting::Macros.register do + + desc "create macro which links to glossary term by id." + macro :termno do |obj, args| + term_id = args.first + term = GlossaryTerm.find(term_id) + link_to term.name, project_glossary_term_path(@project, term) + end + + desc "create macro which links to glossary term by name." + macro :term do |obj, args| + term = GlossaryTerm.find_by(name: args.first) + link_to term.name, project_glossary_term_path(@project, term) + end + + end + +end