Confluence--BluePrint

本文档详细介绍了如何创建一个Atlassian Confluence的蓝图插件,包括设置项目、添加编辑插件、创建模板、配置XML文件、添加JavaScript支持等多个步骤,并提供了如何为用户提供多种模板选择及初始化页面的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

write confluence BluePrint plugin
1.创建工程:atlas-create-confluence-plugin;
2.添加编辑插件: > Add-ons >Confluence Source Editor
3.创建template: (Create a template for your project):
mkdir src/main/resources/templates >templates.xml(jsp/html)
4.通过修改 atlassian-plugin.xml 添加模板:

<!-- Template for Blueprint -->
    <content-template key="simplebp-template" template-title-key="my.blueprint.title">
        <resource name="template" type="download" location="/templates/mytemplate.xml" />
    </content-template>

<!-- Blueprint -->
    <blueprint key="my-blueprint" content-template-key="simplebp-template" index-key="my-index" />
    <!-- Add to the Create Menu -->
    <web-item key="create-by-sample-template" i18n-name-key="my.create-link.title" section="system.create.dialog/content">
        <description key="my.create-link.description" />
        <resource name="icon" type="download" location="/images/myblueprint.png" />
        <param name="blueprintKey" value="my-blueprint" />
     </web-item>

*Each blueprint three component modules:
content-template:Describes the templates available with your plugin.
blueprint :Identifies the blueprint.
web-item :Adds the option for your blueprint to the Create dialog.*

5.为使用API 需要add a new dependency (confluence-create-content-plugin artifact.)to the pom.xml file;

<dependency>
   <groupId>com.atlassian.confluence.plugins</groupId>
   <artifactId>confluence-create-content-plugin</artifactId>
   <version>${create.content.version}</version>
   <scope>provided</scope>
</dependency>

<create.content.version>4.0.9</create.content.version>

6.添加相关JS:Add a Soy template and support it with Javascript;

namespace MyPlugin.Blueprints.Simple}
/**
*  A form that accepts a person's name
*/
{template .page1Form}
    <form action="#" method="post" class="aui">
      <fieldset>
        <div class="field-group">
            <label for="vname">{getText('my.blueprint.form.label.title.vName')}</label>
            <input id="vname" class="text" type="text" name="vName">
        </div>
      </fieldset>
    </form>
{/template}

simplebp.js:

Confluence.Blueprint.setWizard('com.example.plugins.tutorial.confluence.simplebp.simplebp:create-by-sample-template', 
function(wizard) {
 wizard.on('submit.page1Id', function(e, state) {   
         var vName = state.pageData.vName;
         if (!vName){
             alert('Please provide a name value.');
             return false;
         }
     });
});

7.更新atlassian-plugin.xml file:

<!-- add our web resources -->
<web-resource key="simplebp-resources" name="simplebp Web Resources">
    <dependency>com.atlassian.auiplugin:ajs</dependency>
    <dependency>com.atlassian.confluence.plugins.confluence-create-content-plugin:resources</dependency>

<transformation extension="soy">
        <transformer key="soyTransformer">
            <functions>com.atlassian.confluence.plugins.soy:soy-core-functions
            </functions>
        </transformer>
    </transformation>



    <resource type="download" name="simplebp.css" location="/css/simplebp.css" />
    <resource type="download" name="simplebp.js" location="/js/simplebp.js" />
    <resource type="download" name="simplebp.soy.js" location="/soy/simplebp.soy" />
    <resource type="download" name="images/" location="/images" />

    <context>simplebp</context>
     <context>atl.general</context>
    <context>atl.admin</context>
</web-resource>

8.为bluePrint添加介绍与描述:

<blueprint key="myplugin-blueprint"
           index-key="myplugin-index">
  ...
  <dialog-wizard key="myplugin-wizard">
    <dialog-page id="page1Id"
                 template-key="MyPlugin.Blueprints.Simple.page1Form"
                 title-key="my.blueprint.wizard.page1.title"
                 description-header-key="my.blueprint.wizard.page1.desc.header"
                 description-content-key="my.blueprint.wizard.page1.desc.content"
                 last="true" />
  </dialog-wizard>
</blueprint>

By attention: 注意simplebp.properties file相关变量的声明;
9.提供多个template选择时:
(1)Create a templates/mytemplate2.xml file.
(2)Add a content-template module for the second template file

<!-- Second Template for Blueprint -->
<content-template key="simplebp-template2" template-title-key="my.blueprint.title2">
    <resource name="template" type="download" location="/templates/mytemplate2.xml" />
</content-template>
<!-- Blueprint -->
<blueprint key="my-blueprint" index-key="my-index" >
    <content-template ref="simplebp-template" />
    <content-template ref="simplebp-template2" />
    <dialog-wizard key="simplebp-wizard">
        <dialog-page id="page1Id" template-key="MyPlugin.Blueprints.Simple.page1Form" 
            title-key="my.blueprint.wizard.page1.title" 
            description-header-key="my.blueprint.wizard.page1.desc.header"
            description-content-key="my.blueprint.wizard.page1.desc.content"
            last="true"/>
    </dialog-wizard>
</blueprint>

( 3) Update the Javascript to handle two templates:

   {template .page1Form}
    <form action="#" method="post" class="aui">
        <fieldset>
         <div class="field-group">
               <label for="myname">{getText('my.blueprint.form.label.templatekey')}</label>
                <input id="myname" class="text" type="text" name="myName">
            </div>
            <div class="field-group">
                <label for="template-key">{getText('myplugin.blueprint.form.label.templatekey')}</label>
                <select id="template-key" class="select" name="contentTemplateKey">
                    <option value="simplebp-template">{getText('my.blueprint.title')}</option>
                    <option value="simplebp-template2">{getText('my.blueprint.title2')}</option>
                </select>
            </div>
        </fieldset>
    </form>
{/template}

10.Add a “let’s get started” page:
By Attention:要把这部分置于前面;

/**
 * Let's-get-started page for the Create dialog.
 */
{template .letsGetStarted}
    <h2>{getText('my.blueprint.letsgetstarted.title')}</h2>
    <p>{getText('my.blueprint.letsgetstarted.content')}</p>
{/template}

blueprint中添加:
how-to-use-template=”MyPlugin.Blueprints.Simple.letsGetStarted”

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值