Hello,
I know and make use of the task report in Confluence. Extremely useful.
What I'd like to do is to generate the same kind of report, creating a dedicated macro that a user could place in a page, regarding warnings, tips, etc .... that might have been placed in some pages of one or more spaces.
I actually imagine the same kind of search criteria of the task report (by label, by space, etc... "search for all the warning boxes placed in the pages labelled as ... in that space, and show me the body of this macro, the page where it's placed and so on").
I'd like to generate then a user macro called "decision", which can be used by a user to embed a paragraph in, and so classify this paragraph as a decision. It's not difficult to generate this "decision" macro, while I have more difficult (for me) to create the report to generate the summary list.
If there's an easy way to make use of the already existing warnings and tips macros, and summarize them somehow in a page, I could start from it.
I can naturally study dedicated scriptrunner scripts, but if possible I'd like to make use of macros.
Any hints?
Thnks in advance.
CIao, Andrea
Hi all,
As I haven't found any alternative, I've created our own decisionmark macro.
which look like this in page
Then, by Script, I'll search for the macro usage and collect the relevant information.
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.pages.Page
import com.atlassian.confluence.pages.PageManager
import com.atlassian.confluence.spaces.Space
import com.atlassian.confluence.spaces.SpaceManager
import com.atlassian.confluence.pages.Attachment
import com.atlassian.confluence.pages.AttachmentManager
import com.atlassian.confluence.core.DefaultSaveContext
import groovy.xml.MarkupBuilder
import java.math.RoundingMode
import org.jsoup.Jsoup
def spaceManager = ComponentLocator.getComponent(SpaceManager)
def pageManager = ComponentLocator.getComponent(PageManager)
def attachmentManager = ComponentLocator.getComponent(AttachmentManager)
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
//def spacesToCheck=['~BOERIO']
//def spacesChecked=spaceManager.allSpaces.findAll{it-> spacesToCheck.contains(it.key)}
def spacesChecked=spaceManager.allSpaces.findAll{it instanceof Space}
spacesChecked.each(){
spaceChecked->
def pagesChecked=pageManager.getPages(spaceChecked, true).findAll{it instanceof Page}
//def pagesChecked=pageManager.getPages(spaceChecked, true).findAll{it.title == 'Check decision'}
pagesChecked.each(){
pageChecked->
//Get content page for parsing
def body = pageChecked.bodyContent.body
def parsedBody = Jsoup.parse(body)
def decisions = parsedBody.select("ac|structured-macro").findAll{it.attr('ac:name')=="decisionmark"}
//log.warn(parsedBody)
//log.warn(decisions)
decisions.each(){
decision->
def decisionRef=decision.select("ac|rich-text-body").text()
log.warn("Space: ${spaceChecked.name} - Page: ${pageChecked.title} - Decision: ${decisionRef}")
}
}
}
At the moment I'm writing just in log, then I'll write a table in a Confluence page (that's the reason for all the other unused libraries already imported).
It's rough, but does what I need.
Ciao, Andrea
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.