Hi,
We have +500 pages that are affected by
https://help.refined.com/space/MIGRATETOOLKITCLOUD/5334139038/Preparation+guide and using the old legacy editor in cloud is not a real option.
So - anyone with a good idea / tool to do some change via the databae prior to migration - like remove these parts:
The would prevent the nesting (at least). Such a tool would be gold for many Confluence migrators.
PS: I know of all the dangers regarding this :-)
Hi @Normann P_ Nielsen _Netic_ if you would like some scriptrunner help you can contact the customer success team here
Hi @Normann P_ Nielsen _Netic_
This is a job for Scriptrunner, if you don't already have it, it is one of the addons that I break my rule of not recommending addons by name. They have a builtin script for removing or updating macros.
Take a look at this thread as well for more info:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi - Love scriptrunner - and using it like this:
def macroBody = parsedBody.select('ac|structured-macro').attr('ac:name', 'ui-steps')
give me the inner part, but I need a hadle to the entire macro.
In Short - I want to remove the "ui-steps" macro - BUT keep all inside its rich-text-body
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ok, I am close to giving up - either I am stupid or jsoup is :-/
The page source for my page when fetched like:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'd ask Scriptrunner support for the syntax, @Abi Brown- Kolekti added a link for them.
If I understand correctly you need to remove the contents from the macro, remove the macro then put the contents into a different macro? This is doable with script runner I've done something similar in the past.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ive submittet a ticket to Adaptavist, and stared https://www.mos-eisley.dk/spaces/ATLASSIAN/pages/279478283/Confluence+Data+Center+to+Cloud+Migration+Tips for advising other on stuff :-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Normann P_ Nielsen _Netic_ , your script was useful to us as a base, we had the same usecase of needing to remove macros in multiple pages.
I fixed a couple things in it:
def macroBody = parsedBody.select('ac|structured-macro').attr('ac:name', 'ui-steps')
This was finding all structured-macros, then setting the ac:name attribute to "ui-steps", instead of only finding the one with that attribute.
pageObject.setBodyAsString(parsedBody.toString())
Here you save the parsed body with the changes, but I noticed that JSoup applies some kind of prettifier to it by default when you call toString, that breaks some macro configurations by adding spaces and line breaks.
Here's what the final script we used looks like:
import com.atlassian.confluence.pages.PageManager
import com.atlassian.sal.api.component.ComponentLocator
import org.jsoup.Jsoup
def space = '...'
def pageName = '...'
def pageManager = ComponentLocator.getComponent(PageManager)
def page = pageManager.getPage(space, pageName)
log.warn "Inspecting page ${page.title}"
def body = page.bodyContent.body
def parsedBody = Jsoup.parse(body)
// Remove the unwanted macros, we wanted to remove these three
parsedBody.select('ac|structured-macro[ac:name=getlastmodifiername]').remove()
parsedBody.select('ac|structured-macro[ac:name=getlastdatemodified]').remove()
parsedBody.select('ac|structured-macro[ac:name=getpageversion]').remove()
// Set prettyPrint to false to not break macro configurations with spaces and line breaks
parsedBody.outputSettings().prettyPrint(false)
// log.warn parsedBody.toString()
// Save the page
pageManager.saveNewVersion(page) { pageObject ->
pageObject.setBodyAsString(parsedBody.toString())
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Jose Rojo
I really dont get how a "select" in:
def macroBody = parsedBody.select('ac|structured-macro').attr('ac:name', 'ui-steps')
Can do a "set" on someting :-)
But thanks for looking into the script, I will do some testing of the refactored script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.