Listing Contents with Specific Text or Macros

There may be times when it is useful to look for pages that uses a specific macro that the user wants to amend.

This recipe generates a list of contents that contains a specific text or macro.

Result

 

 

Recipe

Apps

Reporting for Confluence Server & Data Center

Apps

Reporting for Confluence Server & Data Center

Level

Easy

Estimated time

10 minutes

Macros

Content Reporter, Report Column, Report Info, Report Table, Text Filter

Suppliers

Body Supplier, Collection Supplier, Content Supplier, Text Supplier

Storage format

You can copy and paste this code into the Confluence Source Editor:

<p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="edaa8414-e427-4956-9004-a08781e545b4" ac:name="report-table" ac:schema-version="1"> <ac:rich-text-body> <p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="9d18386d-c24b-445e-9a20-9c7fd3c3f33e" ac:name="content-reporter" ac:schema-version="1"> <ac:parameter ac:name="space"> <ri:space ri:space-key="@all" /> </ac:parameter> <ac:rich-text-body> <ac:structured-macro ac:macro-id="8000b8b3-52e5-4534-a44b-c1c0676b54e8" ac:name="text-filter" ac:schema-version="1"> <ac:parameter ac:name="include">.*macroname.*</ac:parameter> <ac:parameter ac:name="required">true</ac:parameter> <ac:parameter ac:name="">content:body &gt; body:text</ac:parameter> </ac:structured-macro> </ac:rich-text-body> </ac:structured-macro> <p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="3e113909-7cc1-41f6-a4c4-c2e061f89627" ac:name="report-column" ac:schema-version="1"> <ac:parameter ac:name="title">Content</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="bddb85f2-1d9d-4d3d-9744-a8be052c67cb" ac:name="report-info" ac:schema-version="1"> <ac:parameter ac:name="">content:title</ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro> <p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="4acf9106-81ea-41d9-9d1f-702b669a24dd" ac:name="report-column" ac:schema-version="1"> <ac:parameter ac:name="title">Number of Matches</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="f3ce84f3-d040-417d-9c8f-4c203a6d9ef0" ac:name="report-info" ac:schema-version="1"> <ac:parameter ac:name="">content:body &gt; body:text &gt; text:find macroname &gt; collection:size</ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro> <p class="auto-cursor-target"> <br /> </p> </ac:rich-text-body> </ac:structured-macro> <p class="auto-cursor-target"> <br /> </p>

 

Macro structure

You can recreate the example in the editor view:

 

 

Steps

Line

Description

Line

Description

1

The report will be formatted as a table with Report Table

2

Content Reporter is used retrieve all contents in Confluence, with space parameter set to '@all'.

3

The contents retrieved from Content Reporter is filtered for the desired text or macro. This is done with Text Filter, setting supplier key to 'Content Supplier Supplier Keychains Body Supplier'. The first part 'Content Supplier' retrieves the body of each content from the Content Reporter. This is then chained using '>' sign to Body Supplier, which supplies the storage text for the bodies. Required parameter is set to true to filter out blank texts, and include parameter is set to '.*macroname.*', i.e. the name of the macro.'

4

Two columns is created Report Column, with title set accordingly.

5

Title of each content is displayed via Report Info, setting supplier key to 'Content Supplier'.

6

The number of matches with 'macroname' for each content is displayed with Report Info, setting supplier key to 'Content Supplier Supplier Keychains Body Supplier Supplier Keychains Text Supplier Supplier Keychains Collection Supplier'. The first part 'Content Supplier' retrieves the body of each content from the Content Reporter. This is then chained using '>' sign to Body Supplier, which supplies the storage text for the bodies. This is in turned chained to 'Text Supplier' which retrieves the collection of matches for 'macroname'. Finally this collection is chained to 'Collection Supplier' to get the number of items in the list.

 

Line-by-Line Explanation

  • N/A