Commits

Bob Swift committed 00781cd

Add native Confluence 4.x wik-markup macro - CWP-1

  • Participants
  • Parent commits d72d41d
  • Tags 1.1.0

Comments (0)

Files changed (8)

File LICENSE.txt

-Copyright (c) 2012 Bob Swift.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-    * Redistributions of source code must retain the above copyright notice,
-      this list of conditions and the following disclaimer.
-    * Redistributions in binary form must reproduce the above copyright notice,
-      this list of conditions and the following disclaimer in the documentation
-      and/or other materials provided with the distribution.
-    * The names of contributors may not
-      be used to endorse or promote products derived from this software without
-      specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

File license/LICENSE.txt

+Copyright (c) 2012 Bob Swift.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+    * The names of contributors may not
+      be used to endorse or promote products derived from this software without
+      specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <artifactId>wiki-plugin</artifactId>
     <packaging>atlassian-plugin</packaging>
     <name>Wiki Plugin</name>
-    <version>1.0.0</version>
-    <url></url>
-    <description>Wiki markup macro to prevent migration of the macro body's Confluence 3.x wiki style markup on Confluence 4.x.
+    <version>1.1.0</version>
+    <url>http://bobswift.atlassian.net/wiki/display/CWP</url>
+
+    <description>Wiki markup macro allows wiki markup to be retained in the macro body. This means Confluence 3.x wiki style markup can
+    be used after migration to Confluence 4.x.
     </description>
 
     <properties>
-        <atlassian.product.version>3.1</atlassian.product.version>
+        <plugin.name>Bob Swift Software - ${project.name}</plugin.name>
+        <atlassian.product.version>4.0</atlassian.product.version>
+        <amps.version>3.11</amps.version>
         <atlassian.plugin.key>org.swift.confluence.wiki</atlassian.plugin.key>
         <atlassian.plugin.key.directory>org/swift/confluence/wiki</atlassian.plugin.key.directory>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     </properties>
 
     <organization>
-        <name>Bob Swift</name>
-        <url />
+        <name>Bob Swift Software, LLC</name>
+        <url>https://bobswift.atlassian.net/wiki</url>
     </organization>
 
     <developers>
             <name>BSD</name>
             <distribution>http://www.opensource.org/licenses/bsd-license.php</distribution>
             <comments>
-                 Copyright (c) 2012, Bob Swift.  All rights reserved.
+                 Copyright (c) 2012, Bob Swift Software, LLC.  All rights reserved.
             </comments>
-            <url>/LICENSE.txt</url>
+            <url>license/LICENSE.txt</url>
         </license>
     </licenses>
 
                 <filtering>true</filtering>
                 <includes>
                     <include>atlassian-plugin.xml</include>
+                    <include>i18n/${atlassian.plugin.key.directory}/*.properties</include>
                 </includes>
             </resource>
+            <resource>
+                <!-- Add licenses to the jar file -->
+                <directory>.</directory>
+                <includes>
+                    <include>license/*.*</include>
+                </includes>
+                <filtering>false</filtering>
+            </resource>
         </resources>
 
         <plugins>
 
             <plugin>
+                <groupId>com.atlassian.maven.plugins</groupId>
+                <artifactId>maven-confluence-plugin</artifactId>
+                <version>${amps.version}</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <compressResources>false</compressResources>
+                </configuration>
+            </plugin>
+
+            <plugin>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
                     <source>1.6</source>
             <url>http://svn.atlassian.com/svn/public/contrib/repository/maven2</url>
         </pluginRepository>
     </pluginRepositories>
-
-    <distributionManagement>
-        <repository>
-            <id>atlassian-contrib</id>
-            <name>Atlassian repository of contributed code</name>
-            <url>dav:https://maven.atlassian.com/contrib</url>
-        </repository>
-        <snapshotRepository>
-            <id>atlassian-contrib-snapshot</id>
-            <name>Atlassian repository of contributed code snapshots</name>
-            <url>dav:https://maven.atlassian.com/contrib-snapshot</url>
-        </snapshotRepository>
-    </distributionManagement>
-
 </project>

File src/itest/groovy/wiki.gant

+/*
+* Copyright (c) 2012 Bob Swift Software, LLC
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+*     * Redistributions of source code must retain the above copyright notice,
+*       this list of conditions and the following disclaimer.
+*     * Redistributions in binary form must reproduce the above copyright
+*              notice, this list of conditions and the following disclaimer in the
+*            documentation and/or other materials provided with the distribution.
+*     * The names of contributors may not be used to endorse or promote products
+*           derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+* POSSIBILITY OF SUCH DAMAGE.
+*
+* Created on July 29, 2012 by Bob Swift
+*/
+
+@GrabResolver(name='atlassian', root='https://maven.atlassian.com/content/groups/public/')
+@Grab(group='org.swift.tools', module='gint', version='1.5.0')
+import org.swift.tools.*
+
+includeTool << Helper             // helper utilities
+includeTool << GintForConfluence  // gint framework with extensions for Confluence macro testing
+
+gint.initialize(this) // required
+
+def wiki = helper.getBooleanParameterValue('wiki')
+if (wiki) {
+    gint.setSpaceKey(gint.getSpaceKey() + 'WIKI')  // different space for wiki test
+    gint.setSpaceName(gint.getSpaceName() + '-wiki')
+}
+
+def info = gint.getServerInfoWithVerify()  // verify server is available, otherwise end test
+
+def space = gint.getSpaceKey()
+
+gint.addSetUp([
+   gint.getAddSpaceTestcase(),
+])
+
+gint.addTearDown([
+   gint.getRemoveSpaceTestcase(),
+])
+
+def body = "| aaaaa | \n | 11111 |"
+def tableData = [
+    '<table class="confluenceTable"><tbody>',
+    '<tr>',
+    '<td class="confluenceTd"',
+    'aaaaa',
+    '</td>',
+    '</tr>',
+    '<tr>',
+    '<td class="confluenceTd"',
+    '11111',
+    '</td>',
+    '</tr>',
+    '</tbody></table>',
+]
+def tableDataEncoded = []
+tableData.each() { line ->
+    tableDataEncoded << line.replace('<', '&lt;').replace('>', '&gt;');
+}
+helper.logWithFormat('tableDataEnocded', tableDataEncoded)
+
+gint.add('base', [
+    [macro: 'wiki',
+        body: body,
+        data: [ordered: tableData],
+    ],
+    [macro: 'wiki-markup',
+        body: body,
+        data: [ordered: tableDataEncoded],
+    ],
+])
+
+gint.finalizeTest() // final preparations for running tests

File src/main/java/org/swift/confluence/wiki/LegacyWikiMarkupMacro.java

+/*
+ * Copyright (c) 2012 Bob Swift Software, LLC.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *     * Redistributions of source code must retain the above copyright notice,
+ *       this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *              notice, this list of conditions and the following disclaimer in the
+ *            documentation and/or other materials provided with the distribution.
+ *     * The names of contributors may not be used to endorse or promote products
+ *           derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.swift.confluence.wiki;
+
+import java.util.Map;
+
+import com.atlassian.confluence.content.render.xhtml.DefaultConversionContext;
+import com.atlassian.confluence.macro.MacroExecutionException;
+import com.atlassian.renderer.RenderContext;
+import com.atlassian.renderer.WikiStyleRenderer;
+import com.atlassian.renderer.v2.RenderMode;
+import com.atlassian.renderer.v2.macro.BaseMacro;
+import com.atlassian.renderer.v2.macro.MacroException;
+
+public class LegacyWikiMarkupMacro extends BaseMacro {
+
+    protected final WikiMarkupMacro newMacro;
+
+    protected LegacyWikiMarkupMacro(final WikiStyleRenderer wikiStyleRenderer) {
+        newMacro = new WikiMarkupMacro(wikiStyleRenderer);
+    }
+
+    @Override
+    public boolean hasBody() {
+        return true;
+    }
+
+    @Override
+    public boolean isInline() {
+        return true;
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public String execute(@SuppressWarnings("rawtypes") Map params, String body, RenderContext renderContext) throws MacroException {
+        try {
+            return newMacro.execute(params, body, new DefaultConversionContext(renderContext));
+        } catch (MacroExecutionException e) {
+            throw new MacroException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public RenderMode getBodyRenderMode() {
+        return RenderMode.ALL;
+    }
+}

File src/main/java/org/swift/confluence/wiki/WikiMarkupMacro.java

+package org.swift.confluence.wiki;
+
+/*
+ * Copyright (c) 2012 Bob Swift Software, LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *     * Redistributions of source code must retain the above copyright notice,
+ *       this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *              notice, this list of conditions and the following disclaimer in the
+ *            documentation and/or other materials provided with the distribution.
+ *     * The names of contributors may not be used to endorse or promote products
+ *           derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+import java.util.Map;
+
+import com.atlassian.confluence.content.render.xhtml.ConversionContext;
+import com.atlassian.confluence.macro.Macro;
+import com.atlassian.confluence.macro.MacroExecutionException;
+import com.atlassian.renderer.WikiStyleRenderer;
+
+/**
+ * Simple wiki markup that will not be migrated on Confluence 4.x
+ */
+public class WikiMarkupMacro implements Macro {
+
+    WikiStyleRenderer wikiStyleRenderer;
+
+    protected WikiMarkupMacro(final WikiStyleRenderer wikiStyleRenderer) {
+        this.wikiStyleRenderer = wikiStyleRenderer;
+    }
+
+    @Override
+    public String execute(Map<String, String> parameters, String body, ConversionContext conversionContext) throws MacroExecutionException {
+        return wikiStyleRenderer.convertWikiToXHtml(conversionContext.getEntity().toPageContext(), body);
+    }
+
+    @Override
+    public BodyType getBodyType() {
+        return BodyType.PLAIN_TEXT;
+    }
+
+    @Override
+    public OutputType getOutputType() {
+        return OutputType.BLOCK;
+    }
+
+    public void setWikiStyleRenderer(WikiStyleRenderer wikiStyleRenderer) {
+        this.wikiStyleRenderer = wikiStyleRenderer;
+    }
+}

File src/main/resources/atlassian-plugin.xml

-<atlassian-plugin name="${project.name}" key="${atlassian.plugin.key}" plugins-version="2">
+<atlassian-plugin name="${plugin.name}" key="${atlassian.plugin.key}" plugins-version="2">
     <plugin-info>
         <description>${project.description}</description>
         <vendor name="${project.organization.name}" url="${project.organization.url}"/>
         <version>${project.version}</version>
+        <param name="plugin-icon">images/wiki-plugin-16x16.png</param>
+        <param name="plugin-logo">images/wiki-plugin-72x72.png</param>
+        <param name="plugin-banner">images/wiki-plugin-banner.png</param>
     </plugin-info>
 
+    <resource type="download" name="img/" location="org/swift/confluence/wiki/img/"/>
+
+    <xhtml-macro name="wiki-markup" key="wiki-markup" class="${atlassian.plugin.key}.WikiMarkupMacro" state="enabled"
+        documentation-url="https://bobswift.atlassian.net/wiki/display/cwp"
+        icon="/download/resources/${atlassian.plugin.key}/img/wiki-plugin-80x80.png">
+        <description>${project.description}</description>
+        <resource type="i18n" name="i18n" location="i18n/${atlassian.plugin.key}.wiki"/>
+        <category name="content"/>
+        <parameters>
+        </parameters>
+    </xhtml-macro>
+
+    <macro name="wiki-markup" key="wiki-markup-legacy" class="org.swift.confluence.wiki.LegacyWikiMarkupMacro" state="enabled">
+        <description>${project.description}</description>
+    </macro>
+
     <macro name="wiki" key="wiki" class="${atlassian.plugin.key}.WikiMacro" state="enabled">
-        <description>
-            ${project.description}
-            Useful for testing legacy macro support and for those that need to hang onto wiki markup for a bit longer even on Confluence 4.x.
-        </description>
+        <description>Wiki macro that will remain a Confluence 3.x style macro and will not be migrated to Confluence 4.x content.
+        Useful to ease migration pains for complex wiki markup pages and for testing legacy macro support.</description>
         <category name="content"/>
     </macro>
 

File src/main/resources/i18n/org/swift/confluence/wiki/wiki.properties

+# Macro browser
+${atlassian.plugin.key}.wiki-markup.label=Wiki markup without migration
+${atlassian.plugin.key}.wiki-markup.desc=Allow Confluence 3.x wiki markup that will not be migrated to Confluence 4.x format.