[phase-16]add term macro, and macro define moved from init.rb to new file
This commit is contained in:
parent
a8ad7e36f4
commit
32a3149ca9
20
init.rb
20
init.rb
@ -1,6 +1,6 @@
|
|||||||
#Rails.configuration.to_prepare do
|
Rails.configuration.to_prepare do
|
||||||
# Redmine::Activity.register :glossary_terms
|
require_dependency "glossary_macros"
|
||||||
#end
|
end
|
||||||
|
|
||||||
Redmine::Plugin.register :redmine_glossary do
|
Redmine::Plugin.register :redmine_glossary do
|
||||||
name 'Redmine Glossary plugin'
|
name 'Redmine Glossary plugin'
|
||||||
@ -33,17 +33,3 @@ end
|
|||||||
|
|
||||||
|
|
||||||
Redmine::Activity.register :glossary_terms
|
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
|
|
||||||
|
20
lib/glossary_macros.rb
Normal file
20
lib/glossary_macros.rb
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user