Don Brown avatar Don Brown committed 0462b55

Initial import

Comments (0)

Files changed (6)

+target
+.*.iml
+.*.ipr
+.*.iws
+.*~
+To avoid future confusion, we recommend that you include a license with your plugin.
+This file is simply a reminder.
+
+For a template license you can have a look at: http://www.opensource.org/licenses/
+
+Atlassian releases most of its modules under a BSD license: http://www.opensource.org/licenses/bsd-license.php
+You have successfully created a plugin using the Confluence plugin archetype!
+
+Here are the SDK commands you'll use immediately:
+
+* atlas-run   -- installs this plugin into Confluence and starts it on http://localhost:1990/confluence
+* atlas-debug -- same as atlas-run, but allows a debugger to attach at port 5005
+* atlas-cli   -- after atlas-run or atlas-debug, opens a Maven command line window:
+                 - 'pi' reinstalls the plugin into the running Confluence instance
+* atlas-help  -- prints description for all commands in the SDK
+
+Full documentation is always available at:
+
+http://confluence.atlassian.com/display/DEVNET/Developing+your+Plugin+using+the+Atlassian+Plugin+SDK
+<?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.labs</groupId>
+    <artifactId>confluence-quicktemplates-plugin</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <organization>
+        <name>Example Company</name>
+        <url>http://www.example.com/</url>
+    </organization>
+
+    <name>confluence-quicktemplates-plugin</name>
+    <description>
+        Supports inserting content from recently created pages and blog posts.
+        Only works for wiki text, not the RTE.
+    </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.plugin</groupId>
+            <artifactId>func-test</artifactId>
+            <version>2.3-beta1</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>3.3-m7</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <productVersion>${confluence.version}</productVersion>
+                    <productDataVersion>${confluence.data.version}</productDataVersion>
+                    <compressResources>false</compressResources>
+                    <pluginArtifacts>
+                        <pluginArtifact>
+                            <groupId>com.atlassian.labs</groupId>
+                            <artifactId>speakeasy-plugin</artifactId>
+                            <version>0.3.1</version>
+                        </pluginArtifact>
+                    </pluginArtifacts>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <properties>
+        <confluence.version>3.4</confluence.version>
+        <confluence.data.version>3.1</confluence.data.version>
+    </properties>
+
+</project>

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>
+
+    <scoped-web-resource key="quicktemplates">
+        <resource type="download" name="quicktemplates.js" location="js/quicktemplates.js" />
+        <context>page</context>
+        <context>blogpost</context>
+    </scoped-web-resource>
+</atlassian-plugin>

src/main/resources/js/quicktemplates.js

+
+(function($) {
+
+    var pageRowTemplate = '<tr><td><a href="javascript:void(0)" class="quick-template-item">{title}</a></td></tr>';
+
+    function supports_html5_storage() {
+      try {
+        return 'localStorage' in window && window['localStorage'] !== null;
+      } catch (e) {
+        return false;
+      }
+    }
+
+
+    $(document).ready(function() {
+        if (supports_html5_storage()) {
+            var $form = $('#createpageform');
+            var $title = $('#content-title');
+            var $body = $('#markupTextarea');
+            if ($form.length > 0) {
+                var addedPages = (localStorage.addedPages ? JSON.parse(localStorage.addedPages) : []);
+                $('#editor-tabs').append('<li class="notab editor-setting" id="quick-template-load"><a href="javascript:void(0)">Load from quick template</a></li>');
+                $('#quick-template-load').click(function(e) {
+                    var rows = "";
+                    $.each(addedPages, function() {
+                        rows += AJS.template(pageRowTemplate).fill({title: this.title});
+                    });
+                    var dialog = new AJS.Dialog({width:500, height:400});
+                    dialog.addHeader("Insert recent pages");
+                    dialog.addPanel("Recent Pages",
+                            '<table class="aui">' +
+                            '<tr>' +
+                            '  <th>Title</th>' +
+                            '</tr>' +
+                            rows +
+                            '</table>',
+                            "panel-body");
+                    dialog.addButton("Cancel", function (dialog) {
+                        dialog.hide();
+                    });
+                    $('.quick-template-item').click(function(e) {
+                        var desiredTitle = $(e.target).text();
+                        $.each(addedPages, function() {
+                            if (this.title == desiredTitle) {
+                                $title.val(this.title);
+                                $body.val(this.body);
+                                dialog.hide();
+                            }
+                        });
+                    });
+                    dialog.show();
+                });
+
+                $form.submit(function(e) {
+                    var title = $('#content-title').val();
+                    var body = $('#markupTextarea', $form).val();
+
+
+                    console.log("adding title:" + title + " body:" + body);
+                    addedPages.push({
+                        title : title,
+                        body : body
+                    });
+                    if (addedPages.length > 10) {
+                        addedPages.shift();
+                    }
+                    localStorage.addedPages = JSON.stringify(addedPages);
+                });
+            }
+        }
+
+        AJS.whenIType('shift+i').execute(function() {
+            var addedPages = (localStorage.addedPages ? JSON.parse(localStorage.addedPages) : []);
+            jQuery.each(addedPages, function() {
+                console.log("title:" + this.title);
+                console.log("body:" + this.body);
+            })
+        });
+        AJS.whenIType('shift+x').execute(function() {
+            localStorage.clear();
+            console.log("data cleared");
+        });
+
+    });
+})(jQuery);
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.