Commits

David Simpson committed bc08f29

initial commit

Comments (0)

Files changed (14)

+*Awesome Plugin*
+
+Awesome plugin shows you how to use internationalisation in your JavaScript for an Atlassian product add-on.
+
+* It uses JavaScript to append "is awesome!" to the end of every user's name in Confluence.
+* It is fully internationalised in the following languages
+  - English
+  - American English
+  - French
+  - German
+  - Spanish
+<?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>me.davidsimpson.confluence.plugins</groupId>
+    <artifactId>awesome-plugin</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <organization>
+        <name>Example Company</name>
+        <url>http://www.example.com/</url>
+    </organization>
+
+    <name>Awesome Plugin</name>
+    <description>Appends " is awesome!" to the end of each user link.</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</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.10.4</amps.version>
+    </properties>
+
+</project>

src/.DS_Store

Binary file added.

src/main/.DS_Store

Binary file added.

src/main/java/.DS_Store

Binary file added.

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>
+  <resource type="i18n" name="propertyfile" location="awesome"/>
+  <web-resource key="awesome-js" name="awesome-js">
+    <resource name="awesome.js" type="download" location="awesome.js"/>
+    <!-- include this everywhere -->
+    <context>main</context>
+    <context>dashboard</context>
+    <context>admin</context>
+  </web-resource>
+</atlassian-plugin>

src/main/resources/awesome.js

+
+function makeUsersAwesome(text) {
+    AJS.$('a.confluence-userlink').each(function () {
+        // Append *text* to every user link
+        AJS.$(this).text(AJS.$(this).text() + ' ' + text); 
+    });
+    var $userMenuLink = AJS.$('#user-menu-link span span:first');
+    $userMenuLink.text($userMenuLink.text() + ' ' + text);
+}
+
+AJS.toInit(function () {
+
+    AJS.log(' +++ awesome-js +++ ');
+
+    AJS.I18n.get('me.davidsimpson.confluence.plugins.awesome-plugin',
+        function(){ // success
+            makeUsersAwesome(AJS.I18n.keys['awesome-plugin.user.is.awesome']);
+         },
+        function(){ // error
+            makeUsersAwesome(' is awesome'); // fallback to default text
+        }
+    ); // Read the i18n from engagement.properties
+});

src/main/resources/awesome.properties

+# British English
+awesome-plugin.user.is.awesome = is spiffing!

src/main/resources/awesome_de.properties

+# German
+awesome-plugin.user.is.awesome = ist gro\u00dfartig!

src/main/resources/awesome_en_US.properties

+# American English
+awesome-plugin.user.is.awesome = is awesome!

src/main/resources/awesome_es.properties

+# Spanish
+awesome-plugin.user.is.awesome =David es impresionante

src/main/resources/awesome_fr.properties

+# French
+awesome-plugin.user.is.awesome = est g\u00e9nial!

src/test/.DS_Store

Binary file added.

src/test/java/.DS_Store

Binary file added.