Skip to content

Convert Server/DataCenter Confluence pages in storage format to their forge Cloud App equivalent

License

Notifications You must be signed in to change notification settings

codeclou/advanced-codeblocks-cloud-migration-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Advanced Codeblocks for Confluence

🚀 Cloud Migration Helper

This migration helper transforms a Server/DataCenter Confluence page in Storage Format to Cloud Confluence Storage Format. It will convert the Advanced Codeblocks for Confluence macros to their Cloud forge app equivalent.

For example a Data Center Confluence page containing the Advanced Codeblocks Single Macro will look like this:

<p>some text</p>
<ac:structured-macro ac:name="advanced-single-codeblock-macro" ac:schema-version="1" ac:macro-id="0a76fb27-ee70-41a4-bead-063a0908804d">
  <ac:parameter ac:name="enableddl">true</ac:parameter>
  <ac:parameter ac:name="theme">light-mono</ac:parameter>
  <ac:parameter ac:name="lang">Bash</ac:parameter>
  <ac:parameter ac:name="globaltitle">test</ac:parameter>
  <ac:plain-text-body><![CDATA[echo "foo"]]></ac:plain-text-body>
</ac:structured-macro>

The Cloud App equivalent will look like this:

<p>some text</p>
<ac:adf-extension>
  <ac:adf-node type="extension">
    <ac:adf-attribute key="extension-type">com.atlassian.ecosystem</ac:adf-attribute>
    <ac:adf-attribute key="extension-key">9a81c16f-31e6-4be7-be6e-dfc872fe4155/35d2082a-431b-46b7-90da-75a526882f2f/static/advancedsinglecodeblockmacro</ac:adf-attribute>
    <ac:adf-attribute key="parameters">
      <ac:adf-parameter key="local-id">0658e817-aaf6-7e1d-8000-36a917095fd3</ac:adf-parameter>
      <ac:adf-parameter key="extension-id">ari:cloud:ecosystem::extension/9a81c16f-31e6-4be7-be6e-dfc872fe4155/35d2082a-431b-46b7-90da-75a526882f2f/static/advancedsinglecodeblockmacro</ac:adf-parameter>
      <ac:adf-parameter key="extension-title">Advanced Codeblocks Single</ac:adf-parameter>
      <ac:adf-parameter key="guest-params">
        <ac:adf-parameter key="globaltitle">test</ac:adf-parameter>
        <ac:adf-parameter key="code">echo "foo"</ac:adf-parameter>
        <ac:adf-parameter key="enableddl">
          <ac:adf-parameter-value>true</ac:adf-parameter-value>
        </ac:adf-parameter>
        <ac:adf-parameter key="theme">light-mono</ac:adf-parameter>
        <ac:adf-parameter key="lang">Bash</ac:adf-parameter>
      </ac:adf-parameter>
    </ac:adf-attribute>
    <ac:adf-attribute key="text">Advanced Codeblocks Single</ac:adf-attribute>
    <ac:adf-attribute key="layout">default</ac:adf-attribute>
    <ac:adf-attribute key="local-id">0658e817-aaf6-7d86-8000-4dd60f28b018</ac:adf-attribute>
  </ac:adf-node>
  <ac:adf-fallback>
    <!-- shortened ... -->
  </ac:adf-fallback>
</ac:adf-extension>

 


 

Installation

git clone https://github.com/codeclou/advanced-codeblocks-cloud-migration-helper.git
cd advanced-codeblocks-cloud-migration-helper
python3 -m pip install -r requirements.txt

 


 

Disclaimer

‼️ Please check the output storage file for errors before submitting it into your Confluence page. codeclou GmbH is not responsible for damages to your Confluence installation and/or content. Please test the output on a test instance first. This tool is provided as an example on how to transform your storage format from server to cloud. It might need further adaption to your specific needs.

 


 

Run transformer

The extension key must be extracted from the cloud page, see the documentation for details.

# single macro
python3 index.py -ek 9a81c16f-31e6-4be7-be6e-dfc872fe4155/35d2082a-431b-46b7-90da-75a526882f2f \
                 -if ./lib/input/ac-single-test1.input.storage \
                 -of ./lib/output/ac-single-test1.output.storage

# multi macro
python3 index.py -ek 9a81c16f-31e6-4be7-be6e-dfc872fe4155/35d2082a-431b-46b7-90da-75a526882f2f \
                 -if ./lib/input/ac-multi-test1.input.storage \
                 -of ./lib/output/ac-multi-test1.output.storage

# multi remote macro
python3 index.py -ek 9a81c16f-31e6-4be7-be6e-dfc872fe4155/35d2082a-431b-46b7-90da-75a526882f2f \
                 -if ./lib/input/ac-remote-test1.input.storage \
                 -of ./lib/output/ac-remote-test1.output.storage

Will produce an output like this:

======================================
 ADVANCED CODEBLOCKS MIGRATION HELPER
======================================

extension key part: 9a81c16f-31e6-4be7-be6e-dfc872fe4155/35d2082a-431b-46b7-90da-75a526882f2f

START > reading storage format file from: ./lib/input/ac-single-test1.input.storage

>> advanced-single-codeblock-macro
    macro param lang        : Bash
    macro param enableddl   : true
    macro param globaltitle : test
    macro param theme       : light-mono
    macro body (shortened)  : echo "foo"
    macro attr local id     : 0658e829-ab6b-7f11-8000-c612fa7cbd38
    macro param local id    : 0658e829-ab6b-7fa8-8000-1b5180ffb326

DONE > written transformed storage format to: ./lib/output/ac-single-test1.output.storage

The local ids will be auto generated using uuid v7. The classic server/DC macro-id is not used in Cloud and will be discarded.

 


 

Run tests

you might need to add pytest to $PATH first, then:

pytest

 

License

MIT © codeclou GmbH

About

Convert Server/DataCenter Confluence pages in storage format to their forge Cloud App equivalent

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages