Micha Kops avatar Micha Kops committed 1c7e97d

Context provider for blueprint-template added.

Comments (0)

Files changed (6)

 					<productDataVersion>${confluence.data.version}</productDataVersion>
 					<instructions>
 						<Import-Package>
-							com.atlassian.confluence.plugins.createcontent.extensions,
+							com.atlassian.confluence.plugins.createcontent.extensions;version="0.0.0",
 							*
 						</Import-Package>
 					</instructions>

src/main/java/com/hascode/plugin/confluence/component/CustomContextProvider.java

+package com.hascode.plugin.confluence.component;
+
+import java.util.Date;
+import java.util.Map;
+
+import com.atlassian.plugin.PluginParseException;
+import com.atlassian.plugin.web.ContextProvider;
+
+public class CustomContextProvider implements ContextProvider {
+
+	@Override
+	public void init(final Map<String, String> params)
+			throws PluginParseException {
+	}
+
+	@Override
+	public Map<String, Object> getContextMap(final Map<String, Object> context) {
+		context.put("creationDate", new Date());
+		return context;
+	}
+
+}

src/main/resources/atlassian-plugin.xml

 		template-title-key="hascode.sample-template.title">
 		<resource name="template" type="download"
 			location="com/hascode/plugin/confluence/template/xml/sample-template.xml" />
+		<context-provider
+			class="com.hascode.plugin.confluence.component.CustomContextProvider" />
 	</content-template>
 
 	<web-item key="create-by-sample-template" i18n-name-key="hascode.create-link.title"
 		section="system.create.dialog/content">
-		<description key="
-		hascode.create-link.description" />
+		<description key="hascode.create-link.description" />
 		<resource name="icon" type="download"
-			location="com/hascode/plugin/confluence/image/preview-generic-template.png" />
+			location="/com/hascode/plugin/confluence/image/hascode-macro-logo.png" />
 		<param name="blueprintKey" value="hascode-blueprint" />
 	</web-item>
 
Add a comment to this file

src/main/resources/com/hascode/plugin/confluence/image/hascode-macro-logo.png

Added
New image

src/main/resources/com/hascode/plugin/confluence/template/xml/sample-template.xml

-<p>body of template</p>
+<div class="contentLayout"
+	data-atlassian-layout="{&quot;name&quot;:&quot;pagelayout-two-left&quot;,&quot;columns&quot;:[&quot;aside&quot;,&quot;large&quot;],&quot;header&quot;:true,&quot;footer&quot;:true}">
+	<div class="header">
+		<div class="innerCell">
+			<h1>Template Header</h1>
+			<small>Document created: <at:var at:name="creationDate" /></small>
+		</div>
+	</div>
+	<div class="columnLayout twoColumns">
+		<div class="cell aside">
+			<div class="innerCell">
+				<h2>Subpages</h2>
+				<p><ac:macro ac:name="pagetree" /></p>
+			</div>
+		</div>
+		<div class="cell large">
+			<div class="innerCell">
+				<p><ac:macro ac:name="loremipsum" /></p>
+			</div>
+		</div>
+	</div>
+	<div class="footer">
+		<div class="innerCell">
+			<hr />
+		</div>
+	</div>
+</div>

src/main/resources/confluence-blueprint-example.properties

 #put any key/value pairs here
-hascode.sample-template.title=My Sample Template
+hascode.sample-template.title=Sample Template
 hascode.create-link.title=hasCode Sample Template
 hascode.create-link.description=Link to create a new page using the sample template
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.