Sidehistorik
Looking for Jira Data Center to Cloud Migration Tips?
| Indholdsfortegnelse |
|---|
Breaking news (September 2025) - Data Center Ascend (Closure)
| Tip |
|---|
Site Concept
Migrating a Confluence to a "Site" - do notice a Site is in Atlassian terms a trusted scoped place, where not everything has access control.
...
| Kodeblok |
|---|
#if ($renderContext.outputType == "preview")
<div role="note" aria-labelledby="message-warning-title" class="aui-message aui-message-warning">
<p id="message-warning-title" aria-hidden="true" class="title">
<strong hidden="">Warning: </strong>
<strong>Removed afer migration</strong>
</p
<p>This macro is no longer available. Please delete it.</p>
</div>
#else
<script>
[50, 300, 700].forEach(t => setTimeout(() => AP.resize('0px', '0px'), t));
</script>
#end |
In Cloud, its invisions invisible in View mode, but when editing a page, its shows like this:
The complete macro for import: dummy-macro.json
The founder did this code for us, to replace an old macro showling a Google Calender:
...
Corrections according to https://community.atlassian.com/forums/Confluence-questions/Macro-removal-in-many-pages/qaq-p/2981874?utm_source=atlcomm&utm_medium=email&utm_campaign=mentions_reply&utm_content=topic#U3024976
| Kodeblok |
|---|
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())
}
|
...
All Home pages are added 2 pages with the Storage Format code from 2 other pages (Id=480590905 and 480590813) (
| Status | ||||||
|---|---|---|---|---|---|---|
|
| Kodeblok | ||||||
|---|---|---|---|---|---|---|
| ||||||
#!/bin/bash
# set -x
# Query strings
SQL="SELECT s.homepage || '#' || s.SPACEKEY FROM CONTENT_LABEL cl LEFT JOIN LABEL l ON (l.LABELID = cl.LABELID) LEFT JOIN CONTENT c ON (c.CONTENTID = cl.CONTENTID) LEFT JOIN SPACES s ON (s.SPACEID = c.SPACEID) WHERE l.NAMESPACE = 'team' AND l.NAME = 'customer';"
# Declare and instantiate the space* arrays
declare -a spaceHomepage="`echo $SQL | psql -t -h localhost -U confluenceuser -d confluence`"
# Iterate through each Space
for sID in ${spaceHomepage[@]}
do
#Split $sID
HOMEPAGEID=$(echo $sID | cut -d "#" -f 1)
SPACEKEY=$(echo $sID | cut -d "#" -f 2)
# Customer Details
rm page1.json
curl -u username:password -X GET https://server.domain.com/rest/api/content/480590905?expand=body.storage > page1.json
rm customer-details.xml
cat page1.json | jq .body.storage.value > customer-details.xml
CUSTOMERDETAILS=$(cat customer-details.xml)
# Customer Information
rm page2.json
curl -u username:password -X GET https://server.domain.com/rest/api/content/480590813?expand=body.storage > page2.json
rm customer-information.xml
cat page2.json | jq .body.storage.value > customer-information.xml
CUSTOMERINFORMATION=$(cat customer-information.xml)
#Add Customer Information page
echo "Adding Customer Information page for space ${SPACEKEY} - ${HOMEPAGEID}"
echo "{\"type\":\"page\",\"space\":{\"key\":\"${SPACEKEY}\"},\"ancestors\":[{\"id\":${HOMEPAGEID}}],\"body\":{\"storage\":{\"value\":${CUSTOMERINFORMATION},\"representation\":\"storage\"}},\"title\":\"Customer Information\"}" > data.json
curl -u username:password -X POST -H 'Content-Type: application/json' --data @data.json https://server.domain.com/rest/api/content/
#Add Customer Details page
echo "Adding Customer Details page for space ${SPACEKEY} - ${HOMEPAGEID}"
echo "{\"type\":\"page\",\"space\":{\"key\":\"${SPACEKEY}\"},\"ancestors\":[{\"id\":${HOMEPAGEID}}],\"body\":{\"storage\":{\"value\":${CUSTOMERDETAILS},\"representation\":\"storage\"}},\"title\":\"Customer Details\"}" > data.json
curl -u username:password -X POST -H 'Content-Type: application/json' --data @data.json https://server.domain.com/rest/api/content/
done |
...
Each Home pages are updated with the Storage Format code from another page (Id=480590449) (
| Status | ||||||
|---|---|---|---|---|---|---|
|
| Kodeblok | ||||||
|---|---|---|---|---|---|---|
| ||||||
#!/bin/bash
# set -x
# Query strings
SQL="SELECT s.homepage || '#' || s.SPACEKEY FROM CONTENT_LABEL cl LEFT JOIN LABEL l ON (l.LABELID = cl.LABELID) LEFT JOIN CONTENT c ON (c.CONTENTID = cl.CONTENTID) LEFT JOIN SPACES s ON (s.SPACEID = c.SPACEID) WHERE l.NAMESPACE = 'team' AND l.NAME = 'customer';"
# Declare and instantiate the space* arrays
declare -a spaceHomepage="`echo $SQL | psql -t -h localhost -U confluenceuser -d confluence`"
# Iterate through each Space
for sID in ${spaceHomepage[@]}
do
#Split $sID
HOMEPAGEID=$(echo $sID | cut -d "#" -f 1)
SPACEKEY=$(echo $sID | cut -d "#" -f 2)
# Page Id of the page we want copy copy Storage Format from
FRONTSOUCE="480590449"
# Get newFront
rm page1.json
curl -u username:password -X GET https://server.domain.com/rest/api/content/${FRONTSOUCE}?expand=body.storage > page1.json
cat page1.json | jq .body.storage.value > front.xml
FRONT=$(cat front.xml)
# Get existing version
rm page2.json
curl -u username:password -X GET https://server.domain.com/rest/api/content/${HOMEPAGEID}?expand=version > page2.json
TITLE=$(cat page2.json | jq .title)
VERSION=$(cat page2.json | jq .version.number)
VERSION=$(($VERSION+1))
#Replace front page
echo "Replace front for space ${SPACEKEY} - ${HOMEPAGEID}"
echo "{\"id\":\"${HOMEPAGEID}\",\"type\":\"page\",\"space\":{\"key\":\"${SPACEKEY}\"},\"version\":{\"number\":$VERSION},\"body\":{\"storage\":{\"value\":${FRONT},\"representation\":\"storage\"}},\"title\":$TITLE}}" > data.json
curl -u username:password -X PUT -H 'Content-Type: application/json' --data @data.json https://server.domain.com/rest/api/content/$HOMEPAGEID
done |
...
