Commits

Shihab Hamid committed 647d495

adding the speakeasy code

Comments (0)

Files changed (4)

src/main/java/com/atlascamp/mywork/ril/PluginEnabledListener.java

 import org.springframework.beans.factory.DisposableBean;
 
 /**
- * When this plugin is enabled, the listener
+ * When this plugin is installed, the listener
  * fires a notification to all users, letting
  * them know they should try out the features
  * of the plugin.

src/main/resources/atlassian-plugin.xml

     <component-import key="crowdService" interface="com.atlassian.crowd.embedded.api.CrowdService"/>
     <component-import key="notificationService" interface="com.atlassian.mywork.service.NotificationService"/>
 
+    <web-resource key="readItLaterWebResources">
+        <context>atl.general</context>
+
+        <resource type="download" name="ril.js" location="js/ril.js"/>
+        <resource type="download" name="ril.css" location="css/ril.css"/>
+    </web-resource>
+
 </atlassian-plugin>

src/main/resources/css/ril.css

+#navigation .ajs-menu-bar .ajs-button a#readLaterLink span {
+    background-image: url(http://findicons.com/files/icons/2222/gloss_basic/16/document_star.png);
+}

src/main/resources/js/ril.js

+AJS.$(document).ready(function() {
+
+    var $ = AJS.$;
+
+    var pageId = $("meta[name='ajs-page-id']").attr("content");
+    var pageTitle = $("meta[name='ajs-page-title']").attr("content");
+
+    if (pageId)
+    {
+        // we're on a page, so add the read it later button
+        $readLaterButton = $('<li class="ajs-button normal"><a id="readLaterLink" href="#" class="read-later"><span>Read It Later</span></a></li>');
+        $('.content-navigation .ajs-menu-bar').append($readLaterButton);
+
+        $readLaterButton.click(function() {
+
+            var task = {
+                application: "com.example.extension.read-later",
+                entity:      "page",
+                status:      "TODO",
+                title:       "Read '" + pageTitle + "'",
+                globalId:    "read-reminder:" + pageId,
+                item: {
+                    title:   pageTitle,
+                    url:     document.URL,
+                    iconUrl: "http://findicons.com/files/icons/2222/gloss_basic/16/document_star.png"
+                }
+            };
+
+            $.ajax({
+                url:'http://localhost:1990/confluence/rest/mywork/latest/task',
+                type:"POST",
+                data:JSON.stringify(task),
+                contentType:"application/json; charset=utf-8",
+                dataType:"json"
+            });
+        });
+    }
+});
+
+