I share here a small AutoHotkey script to provide a nice Confluence version information with a link to it.
Problem description
We use a Document History subpage to document the versioning of a Confluence document i.e. based on a multiple pages. We would like document the document version with a nice link to the date information.
Implementation
Implementation relies on the Confluence API.
See gist.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Confluence_GetVerLink(url:="") { ; @fun_Confluence_GetVerLink@ | |
; Get Link information from current page Url | |
; sHtml := Confluence_GetVerLink(url:="") | |
If (url="") | |
url := Browser_GetUrl() | |
If (url="") | |
return | |
; Get current pageId | |
pageId := Confluence_GetPageId(url) | |
rootUrl := Confluence_GetRootUrl() | |
pageInfo := Confluence_GetPageInfo(pageId,rootUrl) | |
; If Confluence Document History page, get parentId | |
If RegExMatch(pageInfo["title"],"i)^(Document|Work Product) History") { | |
pageId := pageInfo["parentId"] | |
pageInfo := Confluence_GetPageInfo(pageId,rootUrl) | |
} | |
;MsgBox % Jxon_Dump(pageInfo) ; DBG | |
version := pageInfo["version"] | |
sText := version["createdAt"] . " (v." . version["number"] . ")" | |
sLink := rootUrl . "/pages/viewpage.action?pageId=" . pageId . "&pageVersion=" . version["number"] | |
sHtml := "<a href=""" . sLink . """>" . sText . "</a>" | |
return sHtml | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#If Confluence_IsWinActive() | |
::,ver:: ; Page version info | |
sHtml := Confluence_GetVerLink(url:="") | |
Clip_PasteHtml(sHtml) | |
return |
It is also included in the PowerTool Confluence Library, function Confluence_GetVerLink.
Usage
Simple type ,ver and it will automagically expand into something like:
If the page name starts with "Document History" or "Workproduct History" it will look for the version information of the parent page.