Commits

sarahcm committed 38527f4

Initial commit

Comments (0)

Files changed (6)

+*.iml
+*.ipr
+*.iws
+target/
+Copyright (c) 2011, Atlassian Pty Ltd
+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.
+   * Neither the name of the Atlassian Pty Ltd nor the names of its
+     contributors may 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 HOLDER 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.
+This is the source code for the autoconvert-dev-docs tutorial: https://developer.atlassian.com/display/CONFDEV/Plugin+Tutorial+-+Extending+Autoconvert
+It changes the link text on developer.atlassian.com pages to the Page name.
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>com.atlassian.tutorial.confluence</groupId>
+  <artifactId>confluence-autoconvert-dev-docs</artifactId>
+  <packaging>atlassian-plugin</packaging>
+  <name>Autoconvert for developer.atlassian.com</name>
+  <version>1.0-SNAPSHOT</version>
+  <description>This is the com.atlassian.tutorial.confluence:confluence-autoconvert-dev-docs plugin for Atlassian Confluence.</description>
+  <organization>
+    <name>Atlassian</name>
+    <url>http://www.atlassian.com/</url>
+  </organization>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>com.atlassian.maven.plugins</groupId>
+        <artifactId>maven-confluence-plugin</artifactId>
+        <version>3.7</version>
+        <extensions>true</extensions>
+        <configuration>
+          <productVersion>${confluence.version}</productVersion>
+          <productDataVersion>${confluence.data.version}</productDataVersion>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.6</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>com.atlassian.confluence</groupId>
+      <artifactId>confluence</artifactId>
+      <version>${confluence.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>com.atlassian.confluence.plugin</groupId>
+      <artifactId>func-test</artifactId>
+      <version>2.3</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>net.sourceforge.jwebunit</groupId>
+      <artifactId>jwebunit-htmlunit-plugin</artifactId>
+      <version>2.2</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>net.sourceforge.nekohtml</groupId>
+      <artifactId>nekohtml</artifactId>
+      <version>1.9.12</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-all</artifactId>
+      <version>1.8.5</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <properties>
+    <amps.version>3.7</amps.version>
+    <confluence.version>4.3</confluence.version>
+    <confluence.data.version>4.3</confluence.data.version>
+	</properties>
+</project>
+

src/main/resources/atlassian-plugin.xml

+<?xml version="1.0" encoding="UTF-8"?>
+
+<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
+    <plugin-info>
+        <description>${project.description}</description>
+        <version>${project.version}</version>
+        <vendor name="${project.organization.name}" url="${project.organization.url}"/>
+    </plugin-info>
+    <web-resource key="autoconvert-dev-docs" name="Autoconvert developer.atlassian.com example handler">
+        <description>Changes link text for URLs pasted from https://developer.atlassian.com.</description>
+        <resource type="download" name="autoconvert-dev-docs.js" location="js/autoconvert-dev-docs.js"/>
+
+        <!-- This will ensure the resource is loaded after autoconvert, and only if autoconvert is enabled. -->
+        <dependency>com.atlassian.confluence.plugins.confluence-paste:autoconvert-core</dependency>
+
+        <!-- Assuming the dependency above is met, this context means that whenever the editor is loaded, so is your autoconvert handler. -->
+        <context>editor</context>
+    </web-resource>
+</atlassian-plugin>

src/main/resources/js/autoconvert-dev-docs.js

+(function(){
+
+AJS.toInit(function($){
+	var pasteHandler = function(uri, node, done){
+        var directoryParts = uri.directory.split('/'),
+            pageName;
+		if (uri.host == "developer.atlassian.com" &&
+                directoryParts.length == 4 && directoryParts[0] == "" &&
+                directoryParts[1] == "display" &&
+                uri.anchor == "" &&
+                node.text() == uri.source) {
+
+            pageName = decodeURIComponent(directoryParts[3]).replace(/\+/g, " ");
+
+            node.text(pageName);
+            done(node);
+		} else {
+            done();
+        }
+    };
+
+	tinymce.plugins.Autoconvert.autoConvert.addHandler(pasteHandler);
+});
+
+})();