User Macro to add version and date to all links inside

Vladimir Vakhlov August 1, 2020

Greetings!

Context: my final goal is to have a big tree of company documentation (100+ documents divided onto several categories + subcategories +subsubcategories). I am using combination of horizontal and vertical menus for it.

I've created a user macro, which renders selected page as a hyperlink and adds version + last modification date below the link (code posted below).

However I feel that supporting it in a blanket-like final page editing space will be very hard, since browser doesn't even see text in macro placeholder (so, I wouldn't be able to find a necessary link/page quickly and have to scroll down to it by my own).

Is this hard to convert it into user macro with a body, which parses all links inserted in it and adds version + modification date?

Thanks.

## Macro title: LINK
## Macro has a body: No
## Body processing: No Macro Body
## Output: Selected output option
##
## Developed by: Vladimir + Stackoverflow
## Date created: 23 Apr 2020
## Created by: Vladimir

## @param Page:title=Page|option-showTitleInPlaceholder=true|type=confluence-content|desc=Target page
#if ($paramPage.contains(':'))
#set ( $strArray = [] )
#foreach($str in $paramPage.split(':'))
#set($dummy = $strArray.add($str)) ## Assign returnval to avoid printing 'true'.
#end
#set($spacekey = $strArray.get(0).trim())
#set($pagetitle = $strArray.get(1).trim())
#else
#set($spacekey = $content.getSpaceKey()) ## Current spacekey
#set($pagetitle = $paramPage.trim())
#end
#set ($urlPath = $pageManager.getPage($spacekey, $pagetitle).getUrlPath())
#set ( $requestedPage = $pageManager.getPage($spacekey, $pagetitle) )

<ac:link>
<ri:page ri:content-title="$pagetitle" ri:space-key="$spacekey"/>
<ac:plain-text-link-body><![CDATA[$pagetitle]]></ac:plain-text-link-body>
</ac:link>
<br/>
<p style="font-size:11px; margin-top: -3px;">v. $requestedPage.version ($action.dateFormatter.formatDateTime($requestedPage.lastModificationDate))</p>

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events