Uploaded image for project: 'Confluence'
  1. Confluence
  2. CONFLUENCE-124

Improve the way the user parameters of confluence macros are imported.

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Minor
    • 9.20.0
    • 9.19.1
    • Syntax - XHTML, XML
    • None
    • Unit
    • Unknown

    Description

      Currently, when importing a macro that has a user reference as a parameter, it is ultimately imported as follows:

      // Confluence 
      <ac:structured-macro ac:name="macroWithUserParams" ac:schema-version="1">
        <ac:parameter ac:name="userParam1">
          <ri:user ri:userkey="0123456789abcdefedcba98765432100" />
        </ac:parameter>
        <ac:parameter ac:name="userParam2">
          <ri:user ri:userkey="23123132erwerwer343242wfdsfwerew" />
          <ri:user ri:userkey="54352121354352312354353413125544" />
        </ac:parameter>
      </ac:structured-macro>
      // XWiki
      {{macroWithUserParams .user="54352121354352312354353413125544" userParam1="" userParam2="" /}}
      

      There are several problems with this approach:

      1. If there is a parameter with multiple users, only the last value will be taken into consideration.
      2. If there are multiple user parameters, they will be merged into a single ".user" parameter and the last userkey/username will be taken into consideration.
      3. The parameter value is not resolved.

      What I'm proposing is to mark the parameters that have user references as values with a prefix like "user--", similar to the attachment parameters ("att--"). This will happen in the XHTML component. With this change, we will have the following output.

      // Confluence
      <ac:structured-macro ac:name="macroWithUserParams" ac:schema-version="1">
        <ac:parameter ac:name="userParam1">
          <ri:user ri:userkey="0123456789abcdefedcba98765432100" />
        </ac:parameter>
        <ac:parameter ac:name="userParam2">
          <ri:user ri:userkey="23123132erwerwer343242wfdsfwerew" />
          <ri:user ri:userkey="54352121354352312354353413125544" />
        </ac:parameter>
      </ac:structured-macro>
      
      // Events
      beginDocument
      onMacroStandalone [macroWithUserParams] [user--userParam1=0123456789abcdefedcba98765432100|user--userParam2=23123132erwerwer343242wfdsfwerew,54352121354352312354353413125544]
      endDocument
      

      The next step is to modify the default macro converter to look for the parameters that have the previously mentioned prefix and resolve their parameters. With this change, we should have the following output.

      // Confluence
      <ac:structured-macro ac:name="macroWithUserParams" ac:schema-version="1">
        <ac:parameter ac:name="userParam1">
          <ri:user ri:userkey="0123456789abcdefedcba98765432100" />
        </ac:parameter>
        <ac:parameter ac:name="userParam2">
          <ri:user ri:userkey="23123132erwerwer343242wfdsfwerew" />
          <ri:user ri:userkey="54352121354352312354353413125544" />
        </ac:parameter>
      </ac:structured-macro>
      
      // XWiki 
      {{macroWithUserParams userParam1="XWiki.User1" userParam2="XWiki.User2,XWiki.User3" /}}
      

      Attachments

        Activity

          People

            tcaras Teodor Caras
            tcaras Teodor Caras
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: