Julien Hoarau avatar Julien Hoarau committed a1a5d48

Add recommendations to user's network tab.

Comments (0)

Files changed (3)

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-import key="activeObjects" interface="com.atlassian.activeobjects.external.ActiveObjects"/>
-    <component-import key="crowd-service" interface="com.atlassian.crowd.embedded.api.CrowdService"/>
-    <component-import key="user-accessor" interface="com.atlassian.confluence.user.UserAccessor"/>
-    <component-import key="follow-manager" interface="com.atlassian.confluence.follow.FollowManager"/>
-    <component-import key="webresource-urlprovider" interface="com.atlassian.plugin.webresource.WebResourceUrlProvider"/>
-    <component-import key="settings-manager" interface="com.atlassian.confluence.setup.settings.SettingsManager"/>
-    <component-import key="i18nbean-factory" interface="com.atlassian.confluence.util.i18n.I18NBeanFactory"/>
-    <component-import key="space-permission-manager" interface="com.atlassian.confluence.security.SpacePermissionManager"/>
-    <component-import key="web-resource-manager" interface="com.atlassian.plugin.webresource.WebResourceManager"/>
-    <component-import key="user-details-manager" interface="com.atlassian.confluence.user.UserDetailsManager"/>
-
-    <component key="tx-processor" name="Transactional Annotation Processor"
-               class="com.atlassian.activeobjects.external.TransactionalAnnotationProcessor">
-        <decription>Processes @Transactional annotations.</decription>
-    </component>
-
-    <component key="usernode-daoservice" interface="com.atlassian.confluence.plugins.whotofollow.data.services.IUserNodeDaoService"
-               class="com.atlassian.confluence.plugins.whotofollow.data.services.impl.UserNodeDaoService"/>
-
-    <component key="recommendation-engine" class="com.atlassian.confluence.plugins.whotofollow.RecommendationEngine"/>
-
-    <ao key="ao-module">
-        <entity>com.atlassian.confluence.plugins.whotofollow.data.UserNode</entity>
-    </ao>
-
-    <!-- Macro -->
-    <macro key="recommendations-macro-old" name="recommendations" class="com.atlassian.confluence.plugins.whotofollow.RecommendationsMacro" state="enabled">
-        <category name="content"/>
-    </macro>
-
-    <xhtml-macro  key="recommendations-macro" name="recommendations" class="com.atlassian.confluence.plugins.whotofollow.RecommendationsMacro">
-        <parameters>
-            <parameter name="username" type="string" default="">
-                <option key="showNameInPlaceholder" value="false" />
-                <option key="showValueInPlaceholder" value="true" />
-            </parameter>
-            <parameter name="theme" type="enum">
-                <value name="small"/>
-                <value name="big"/>
-            </parameter>
-        </parameters>
-    </xhtml-macro>
-
-    <web-resource key="recommendations-macro-css-resources" name="Recommendations CSS Resources">
-        <resource type="download" name="recommendations-macro.css" location="/includes/css/recommendations-macro.css"/>
-    </web-resource>
-
-    <web-resource key="recommendations-macro-js-resources" name="Recommendations Javascript Resources">
-        <resource type="download" name="recommendations-macro.js" location="/includes/js/recommendations-macro.js"/>
-        <context>dashboard</context>
-    </web-resource>
-
-    <web-resource name="Injector Resource" key="injector-resource">
-        <resource name="injector.js" type="download" location="includes/js/injector.js"/>
-        <context>dashboard</context>
-    </web-resource>
-
-    <xwork key="recommendations-action" name="Recommendations Action">
-        <package name="recommendations" extends="default" namespace="/plugins/recommendations">
-            <default-interceptor-ref name="defaultStack"/>
-            <action name="get" class="com.atlassian.confluence.plugins.whotofollow.RecommendationsAction" method="doDefault">
-                <result name="success" type="velocity">/templates/recommendations-injected-macro.vm</result>
-            </action>
-        </package>
-    </xwork>
-
-    <!-- REST -->
-    <rest key="rest-service-resources" path="/whotofollow" version="1.0">
-        <description>Provides the REST resources for WhoToFollow plugin.</description>
-    </rest>
-
-</atlassian-plugin>
+<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-import key="activeObjects" interface="com.atlassian.activeobjects.external.ActiveObjects"/>
+    <component-import key="crowd-service" interface="com.atlassian.crowd.embedded.api.CrowdService"/>
+    <component-import key="user-accessor" interface="com.atlassian.confluence.user.UserAccessor"/>
+    <component-import key="follow-manager" interface="com.atlassian.confluence.follow.FollowManager"/>
+    <component-import key="webresource-urlprovider" interface="com.atlassian.plugin.webresource.WebResourceUrlProvider"/>
+    <component-import key="settings-manager" interface="com.atlassian.confluence.setup.settings.SettingsManager"/>
+    <component-import key="i18nbean-factory" interface="com.atlassian.confluence.util.i18n.I18NBeanFactory"/>
+    <component-import key="space-permission-manager" interface="com.atlassian.confluence.security.SpacePermissionManager"/>
+    <component-import key="web-resource-manager" interface="com.atlassian.plugin.webresource.WebResourceManager"/>
+    <component-import key="user-details-manager" interface="com.atlassian.confluence.user.UserDetailsManager"/>
+
+    <component key="tx-processor" name="Transactional Annotation Processor"
+               class="com.atlassian.activeobjects.external.TransactionalAnnotationProcessor">
+        <decription>Processes @Transactional annotations.</decription>
+    </component>
+
+    <component key="usernode-daoservice" interface="com.atlassian.confluence.plugins.whotofollow.data.services.IUserNodeDaoService"
+               class="com.atlassian.confluence.plugins.whotofollow.data.services.impl.UserNodeDaoService"/>
+
+    <component key="recommendation-engine" class="com.atlassian.confluence.plugins.whotofollow.RecommendationEngine"/>
+
+    <ao key="ao-module">
+        <entity>com.atlassian.confluence.plugins.whotofollow.data.UserNode</entity>
+    </ao>
+
+    <!-- Macro -->
+    <macro key="recommendations-macro-old" name="recommendations" class="com.atlassian.confluence.plugins.whotofollow.RecommendationsMacro" state="enabled">
+        <category name="content"/>
+    </macro>
+
+    <xhtml-macro  key="recommendations-macro" name="recommendations" class="com.atlassian.confluence.plugins.whotofollow.RecommendationsMacro">
+        <parameters>
+            <parameter name="username" type="string" default="">
+                <option key="showNameInPlaceholder" value="false" />
+                <option key="showValueInPlaceholder" value="true" />
+            </parameter>
+            <parameter name="theme" type="enum">
+                <value name="small"/>
+                <value name="big"/>
+            </parameter>
+        </parameters>
+    </xhtml-macro>
+
+    <web-resource key="recommendations-macro-css-resources" name="Recommendations CSS Resources">
+        <resource type="download" name="recommendations-macro.css" location="/includes/css/recommendations-macro.css"/>
+    </web-resource>
+
+    <web-resource key="recommendations-macro-js-resources" name="Recommendations Javascript Resources">
+        <resource type="download" name="recommendations-macro.js" location="/includes/js/recommendations-macro.js"/>
+        <context>dashboard</context>
+        <context>atl.userprofile</context>
+    </web-resource>
+
+    <web-resource name="Injector Resource" key="injector-resource">
+        <resource name="injector.js" type="download" location="includes/js/injector.js"/>
+        <context>dashboard</context>
+        <context>atl.userprofile</context>
+    </web-resource>
+
+    <xwork key="recommendations-action" name="Recommendations Action">
+        <package name="recommendations" extends="default" namespace="/plugins/recommendations">
+            <default-interceptor-ref name="defaultStack"/>
+            <action name="get" class="com.atlassian.confluence.plugins.whotofollow.RecommendationsAction" method="doDefault">
+                <result name="success" type="velocity">/templates/recommendations-injected-macro.vm</result>
+            </action>
+        </package>
+    </xwork>
+
+    <!-- REST -->
+    <rest key="rest-service-resources" path="/whotofollow" version="1.0">
+        <description>Provides the REST resources for WhoToFollow plugin.</description>
+    </rest>
+
+</atlassian-plugin>

src/main/resources/includes/js/injector.js

-AJS.toInit(function($) {
-    var contextPath = Confluence.getContextPath();
-
-    var $networkPane = $("#network-pane");
-
-    AJS.safe.get(contextPath + "/plugins/recommendations/get.action", {}, function(data) {
-        $networkPane.prepend(data);
-        Confluence.Binder.userHover();
-
-        $networkPane.trigger("recommendations-ready");
-    });
-});
+AJS.toInit(function($) {
+    var contextPath = Confluence.getContextPath();
+
+    var $networkPane = $("#network-pane");
+    var $pane = $networkPane.length ? $networkPane : $("#follow");
+
+    AJS.safe.get(contextPath + "/plugins/recommendations/get.action", {}, function(data) {
+        $pane.prepend(data);
+        Confluence.Binder.userHover();
+
+        $pane.trigger("recommendations-ready");
+    });
+});

src/main/resources/templates/recommendations-macro.vm

-#* @vtlvariable name="recommendations" type="java.util.List<com.atlassian.crowd.embedded.api.User>" *#
-#requireResource("confluence.web.resources:ajs")
-#requireResource("confluence.macros.profile:network-resources")
-#requireResource("com.atlassian.confluence.plugins.whotofollow:recommendations-macro-css-resources")
-#requireResource("com.atlassian.confluence.plugins.whotofollow:recommendations-macro-js-resources")
-
-#set ($limit = 3)
-
-#if ($theme == "small")
-<div class="recommendations-macro network-macro follow-following follow-dashboard">
-    <h2 class="subheading">Who to follow</h2>
-    <ul class="avatars">
-        #foreach ($recommendation in $recommendations)
-            <li class="#if ($velocityCount > $limit) hidden #end">
-              <div id="recommendation-$recommendation.name" style="display:inline;">
-                #logoBlock("~$recommendation.name")
-              </div>
-            </li>
-        #end
-    </ul>
-</div>
-#else
-<div class="recommendations-macro big">
-    <h2>Who to follow</h2>
-    <ul>
-        #foreach ($recommendation in $recommendations)
-            <li #if ($velocityCount > $limit) class="hidden" #end>
-                <div class="recommendation">
-                    #logoBlock("~$recommendation.name")
-                    <div class="infos">
-                        <h4>$recommendation.displayName</h4>
-                        <span><a class="follow" href="#" data-username="$recommendation.name">Follow</a></span>
-                    </div>
-                </div>
-            </li>
-        #end
-    </ul>
-</div>
-#end
+#* @vtlvariable name="recommendations" type="java.util.List<com.atlassian.crowd.embedded.api.User>" *#
+#requireResource("confluence.web.resources:ajs")
+#requireResource("confluence.macros.profile:network-resources")
+#requireResource("com.atlassian.confluence.plugins.whotofollow:recommendations-macro-css-resources")
+#requireResource("com.atlassian.confluence.plugins.whotofollow:recommendations-macro-js-resources")
+
+#set ($limit = 3)
+
+#if ($theme == "small")
+<div class="recommendations-macro network-macro follow-following follow-full">
+    <h2 class="subheading">Who to follow</h2>
+    <div class="description"></div>
+    <ul class="avatars">
+        #foreach ($recommendation in $recommendations)
+            <li class="#if ($velocityCount > $limit) hidden #end">
+              <div id="recommendation-$recommendation.name" style="display:inline;">
+                #logoBlock("~$recommendation.name")
+              </div>
+            </li>
+        #end
+    </ul>
+</div>
+#else
+<div class="recommendations-macro big">
+    <h2>Who to follow</h2>
+    <ul>
+        #foreach ($recommendation in $recommendations)
+            <li #if ($velocityCount > $limit) class="hidden" #end>
+                <div class="recommendation">
+                    #logoBlock("~$recommendation.name")
+                    <div class="infos">
+                        <h4>$recommendation.displayName</h4>
+                        <span><a class="follow" href="#" data-username="$recommendation.name">Follow</a></span>
+                    </div>
+                </div>
+            </li>
+        #end
+    </ul>
+</div>
+#end
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.