Merge branch 'devel-1.6.2' of github.com:danmunn/redmine_dmsf into devel-1.6.2

This commit is contained in:
Karel Pičman 2018-09-04 13:28:42 +02:00
commit 535a4cc4fe
2 changed files with 39 additions and 5 deletions

View File

@ -128,7 +128,13 @@ Link to a document with id 17 with link text "File": `{{dmsf(17, File)}}`
Link to the details of a document with id 17: `{{dmsfd(17)}}`
Link to the description of a document with id 17: `{{dmsfdesc(17)}}`
Link to the details of a document with id 17 with link text "Details": `{{dmsfd(17, Details)}}`
Text of the description of a document with id 17: `{{dmsfdesc(17)}}`
Text referring to the version of a document with id 17: `{{dmsfversion(17)}}`
Text referring to the last update date of a document with id 17: `{{dmsflastupdate(17)}}`
Link to the preview of 5 lines from a document with id 17: `{{dmsft(17, 5)}}`

View File

@ -81,14 +81,14 @@ Redmine::WikiFormatting::Macros.register do
raise ArgumentError if args.length < 1 # Requires file id
file = DmsfFile.visible.find args[0].strip
if User.current && User.current.allowed_to?(:view_dmsf_files, file.project)
return link_to file.title, dmsf_file_path(:id => file)
return link_to(h(args[1] ? args[1] : file.title), dmsf_file_path(:id => file))
else
raise l(:notice_not_authorized)
end
end
# dmsfdesc - link to the document's description
desc "Wiki link to DMSF document description:\n\n" +
# dmsfdesc - text referring to the document's description
desc "Text referring to DMSF document description:\n\n" +
"{{dmsfdesc(document_id)}}\n\n" +
"_document_id_ can be found in the document's details."
macro :dmsfdesc do |obj, args|
@ -101,6 +101,34 @@ Redmine::WikiFormatting::Macros.register do
end
end
# dmsfversion - text referring to the document's version
desc "Text referring to DMSF document version:\n\n" +
"{{dmsfversion(document_id)}}\n\n" +
"_document_id_ can be found in the document's details."
macro :dmsfversion do |obj, args|
raise ArgumentError if args.length < 1 # Requires file id
file = DmsfFile.visible.find args[0].strip
if User.current && User.current.allowed_to?(:view_dmsf_files, file.project)
return textilizable(file.version)
else
raise l(:notice_not_authorized)
end
end
# dmsflastupdate - text referring to the document's last update date
desc "Text referring to DMSF document last update date:\n\n" +
"{{dmsflastupdate(document_id)}}\n\n" +
"_document_id_ can be found in the document's details."
macro :dmsflastupdate do |obj, args|
raise ArgumentError if args.length < 1 # Requires file id
file = DmsfFile.visible.find args[0].strip
if User.current && User.current.allowed_to?(:view_dmsf_files, file.project)
return textilizable(format_time(file.last_revision.updated_at))
else
raise l(:notice_not_authorized)
end
end
# dmsft - link to the document's content preview
desc "Wiki link to DMSF document's content preview:\n\n" +
"{{dmsft(file_id)}}\n\n" +
@ -203,4 +231,4 @@ Redmine::WikiFormatting::Macros.register do
end
end
end
end