Description

  • The Page Info macro makes it easy to display information about the page it is used on. This could include information such as page versions, differences in versions, contributors and many other options listed below.

Usage

  • Click Insert > Other Macros.

macro browser
  • Select the Page Info macro from the provided list.

macro browser list
  • Complete the desired fields.

Parameter Description Type Default Required

Information Type

See the Supported Information Types table below

enum

commenters

yes

Page

The name of the page whose information will be displayed, if none is given then the current page is assumed. Option "$self" and "$parent" can be used to refer to the current page and the parent page respectively.

string

current page

no

Date Format

Allows setting the display format for the date and time displayed, when no date is to be displayed this parameter has no effect.

string

MMM dd, yyyy - hh:mm

no

Type

Different options to show information, Can be:

  • Flat ? display a comma separated list (default) or

  • List ? display a bullet list.

enum

flat

yes

Prefix

This parameter insert a prefix before the version number when used. Has no effect with those display types which do not display a version number.

string

none

no

Reverse Order

Reverse the list item when the option is selected with "List" option.

checkbox

unchecked

no

Count

Limit the number of items shown in a list (eg. versions and diffs).

int

none

no

Show Comments

Display the comments that accompany an update.

checkbox

unchecked

no

Show Versions

Display the version numbers.

checkbox

checked

no

Supported Information Types

Information Type Description

Created by

Displays the user who created the page.

Commenters

Displays a comma separated list of the users who have commented on the page.

Create date

Shows the date the page was created.

Current version

Most recent version number of the page.

Diffs

Displays a comma separated list of version number links. These are clickable to view the differences between versions.

Labels

Displays a comma separated list of labels. These are clickable to view other pages that possess the same label.

Modified by

Shows the user who last modified the page.

Modified date

Displays the date the page was last modified.

Modified users

Displays a comma separated list of all the users who have modified the page.

Page id

Shows the Id of the current page.

Participants

Displays a comma separated list of the users who have modified or commented on the page.

Title

Displays the title of the page.

Tiny url

Displays a tiny url link to the specified page.

Versions

Displays a comma separated list of version numbers. These are clickable to view the selected version.

pageInfoPlugin
  • The following screenshot shows the output when "Created by" is selected as the "Information Type". In this case the page has been created by the admin.

example 1

Example

The following two screenshots show how the Page Info macro can be used effectively to populate information. For example the input:

shortExampleOut

The output:

shortExampleIn

Formatting Dates

  • The macro supports standard date formats which allows the user to format the date with various combinations. For example the following screenshot shows how to use "dd-MMM-yyyy" as the date format.

dateFormat1
  • More examples of the Page Info macro are added in a table below.

Page Edit Mode Page Output
Diagram
Diagram

Displaying Versions and Diffs

Here is an example of "Versions" and "Diffs". The versions and differences ("Diffs") are clickable to view a particular version and difference.

diffsOut

View Page Information for a Different Page

Provide the name of the page for which information will be displayed. The following example shows the page creator for page P2. It is also possible to use "$parent" [without double quote] to refer to the parent page of the page that contains the macro.

differentPage

Advanced: Customising Page Info Further

Introduction

To extend the macro users should have basic java or groovy knowledge. In Page Info users can extend the Information Type by overriding the "setCustomVariables" method.

Instructions

The following example adds "Page Reviewer" and "Page Approved By" Information Type in the newly extended macro.

  • Navigate to your script root. Default is <Confluence>/home/scripts. More information about script roots.

  • Create the package com.onresolve.scriptrunner.canned.confluence.macros in your script root.

  • Navigate to the package specified above and inside the macros folder create a new groovy class "CustomPageInformationMacro.groovy" that extends the old class and overrides the setCustomVariables method. A descriptive class name is recommended.

  • Disable the old macro in the Script Macros section in Confluence. Enable the new macro in the same section. The names of the macros will be the same as to not break any macros already used.

  • Populate the class:

package com.onresolve.scriptrunner.canned.confluence.macros

class CustomPageInformationMacro extends PageInformationMacro {

    @Override
    protected Map<String, String> setCustomVariables() {
        //set the custom value
        def customVariables = [:]
        customVariables.put("Page Reviewer", "George Washington")
        customVariables.put("Page Approved By", "Abraham Lincoln")
        customVariables
    }
}
  • Disable the old macro and enable the new macro in the Script Macros section in Confluence (the names of the macros will be the same as to avoid breaking any macros already in use).

script macros section
  • The added information type should be available in the information type list.

custom macro

Have questions? Visit the Atlassian Community to connect, share, and learn with other Atlassian users and experts, including Adaptavist staff.

Ask a question about ScriptRunner for JIRA, Bitbucket Server, or Confluence.

Want to learn more? Check out courses on Adaptavist Learn, an online platform to onboard and train new users for Atlassian solutions.