Merge pull request #904 from laurentpsychedelic/feature/DmsfVersionAndLastUpdateMacros

Feature: DMSF file's version and last update date macros
This commit is contained in:
Karel Picman 2018-08-24 08:04:36 +02:00 committed by GitHub
commit b6f0f7c28e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 4 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

@ -87,8 +87,8 @@ Redmine::WikiFormatting::Macros.register do
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