Commits

Micha Kops committed b0b3826 Draft

Initial import.

Comments (0)

Files changed (5)

+.project
+.settings
+.classpath
+target
+# Confluence Template Bundle Plugin Samples #
+
+A quick example how to create a template bundle plugin for Confluence using the Atlassian Plugin SDK.
+
+Please feel free to take a look at [my blog] for the full tutorial.
+
+---
+
+**Micha Kops / hasCode.com**
+
+   [my blog]:http://www.hascode.com/2010/07/how-to-create-a-template-bundle-plugin-in-confluence/
+<?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.hascode.confluence.plugin</groupId>
+	<artifactId>template-bundle-sample</artifactId>
+	<version>0.1.0</version>
+
+	<organization>
+		<name>Example Company</name>
+		<url>http://www.example.com/</url>
+	</organization>
+
+	<name>template-bundle-sample</name>
+	<description>This is the com.hascode.confluence.plugin:template-bundle-sample plugin for Atlassian Confluence.</description>
+	<packaging>atlassian-plugin</packaging>
+
+	<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.plugins</groupId>
+			<artifactId>templates-framework</artifactId>
+			<version>0.12</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>
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>com.atlassian.maven.plugins</groupId>
+				<artifactId>maven-confluence-plugin</artifactId>
+				<version>${amps.version}</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>
+
+	<properties>
+		<confluence.version>4.1.6</confluence.version>
+		<confluence.data.version>3.5</confluence.data.version>
+		<amps.version>3.11</amps.version>
+	</properties>
+
+</project>

src/main/java/com/hascode/confluence/plugin/template/MyTemplatePackage.java

+package com.hascode.confluence.plugin.template;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.atlassian.confluence.pages.templates.PageTemplate;
+import com.atlassian.confluence.plugin.templates.export.TemplatePackage;
+import com.atlassian.confluence.plugin.templates.export.TemplatePackageException;
+
+public class MyTemplatePackage implements TemplatePackage {
+
+	@Override
+	public List<PageTemplate> getAvailableTemplates()
+			throws TemplatePackageException {
+		List<PageTemplate> templates = new ArrayList<PageTemplate>();
+		PageTemplate t = new PageTemplate();
+		t.setName("Some sample template");
+		t.setContent("This is a test");
+		t.setDescription("This sample template prints some sample text");
+		t.setLabels("test");
+		templates.add(t);
+
+		return templates;
+	}
+
+	@Override
+	public String getPackageName() {
+		return "A nice template package bundle";
+	}
+
+}

src/main/resources/atlassian-plugin.xml

+<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>
+
+	<component name="Templates: Default Package" key="templates"
+		public="true"
+		class="com.hascode.confluence.plugin.template.MyTemplatePackage">
+		<interface>com.atlassian.confluence.plugin.templates.export.TemplatePackage
+		</interface>
+	</component>
+</atlassian-plugin>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.