Adding a 'configure' page to my Add-On in confluence.

Stephen Swavley June 7, 2014

I have written a Confluence Macro that needs the admin to setup a default value that will be system wide. My macro will then need to pull this default value and use it. At the moment I have simply hard coded it in my Macro. Obviously this is not desirable as I would have to modify the Macro for every system that uses it.

I believe that this should be done using the 'configure' button from the Add-Ons page for my Macro.

I have been looking for some sample code of a Macro that has this in it but can't find any and am at a loss as to how to find out how to do this.

Can anyone give me some tips/hints/ideas where I might find out how to do this?

1 answer

0 votes
David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 8, 2014

Hi Stephen

Take a look at the Markdown for Confluence add-on, particularly the ConfigurationServlet and the soy template md-configure.soy:

ConfigurationServlet:
https://bitbucket.org/dvdsmpsn/markdown-for-confluence/src/6f97807fc7abc919cb325dc3e1a2d0e8b12c884c/src/main/java/me/davidsimpson/confluence/addon/markdown/servlet/ConfigurationServlet.java?at=master

md-configure.soy:
https://bitbucket.org/dvdsmpsn/markdown-for-confluence/src/6f97807fc7abc919cb325dc3e1a2d0e8b12c884c/src/main/resources/soy/md-configure.soy?at=master

atlassian-plugin.xml:
https://bitbucket.org/dvdsmpsn/markdown-for-confluence/src/6f97807fc7abc919cb325dc3e1a2d0e8b12c884c/src/main/resources/atlassian-plugin.xml?at=master#cl-65

In the plugin xml file look at the following (I've stripped out the bits that aren't for the config page):

<?xml version="1.0" encoding="UTF-8"?>

<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
  <plugin-info>
    ...
	...
    <param name="configure.url">/plugins/servlet/markdown-for-confluence/configure</param><-- the link in the UPM -->
  </plugin-info>
  
  ...
  ...

  <!-- the servelet -->
  <servlet name="Configuration Servlet" i18n-name-key="configuration-servlet.name" key="configuration-servlet" class="me.davidsimpson.confluence.addon.markdown.servlet.ConfigurationServlet">
    <description key="configuration-servlet.description">The Configuration Servlet Plugin</description>
    <condition class="com.atlassian.confluence.plugin.descriptor.web.conditions.ConfluenceAdministratorCondition" />
    <url-pattern>/markdown-for-confluence/configure</url-pattern>
  </servlet>

  <!-- soy template for the servlet -->
  <web-resource key="configure-soy">
    <transformation extension="soy">
      <transformer key="soyTransformer"/>
    </transformation>
    <resource type="download" name="md-configure.js" location="soy/md-configure.soy"/>
  </web-resource>

  <!-- link in the left hand navigation of the confluence admin section -->
  <web-item key="markdown-for-confluence.configure" name="Markdown Configure Link" weight="10000" section="system.admin/configuration">
    <description>Link to configure action</description>
    <label key="me.davidsimpson.confluence.addon.markdown-for-confluence.configure.web-item"/>
    <link>/plugins/servlet/markdown-for-confluence/configure</link>
    <condition class="com.atlassian.confluence.plugin.descriptor.web.conditions.ConfluenceAdministratorCondition" />
  </web-item>

  <!-- Some plumbing to help out -->
  <component-import key="loginUriProvider" interface="com.atlassian.sal.api.auth.LoginUriProvider"/>
  <component-import key="pluginSettingsFactory" interface="com.atlassian.sal.api.pluginsettings.PluginSettingsFactory"/>
  <component-import key="soyTemplateRenderer" interface="com.atlassian.soy.renderer.SoyTemplateRenderer"/>
  <component-import key="templateRenderer" interface="com.atlassian.templaterenderer.TemplateRenderer"/>

  ...
  ...
  
</atlassian-plugin>

Traditionally people used velocity for configuration screens, but servlets + Soy means that you can use the same kind of code in Confluence, JIRA and other add-ons, so it's quite nice.


Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events