Added macros to reference a file's version and last update date:

Example:
        {{dmsfversion(123)}} -> "2.5" -> return version of file with id "123"
        {{dmsflastupdate(123)}} -> "2018-08-24 08:46" -> returns the file's last update date (formatted according to redmine settings)
This commit is contained in:
Laurent FABRE 2018-08-24 10:09:39 +09:00
parent 3bbf9f26da
commit c22b88802e
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