mirror of
https://github.com/Alfresco/alfresco-sdk.git
synced 2025-10-01 14:41:57 +00:00
-- added maven-alfresco-share-module-archetype to build share JAR extensions as in http://mindthegab.com/2010/02/23/howto-build-your-jar-alfresco-share-dashlet-with-maven-in-3-minutes/
-- fixed minor issues in maven-alfresco-share-archetype -- merged other fixes git-svn-id: http://maven-alfresco-archetypes.googlecode.com/svn/trunk@294 04253f4f-3451-0410-a141-5562f1e59037
This commit is contained in:
@@ -11,8 +11,12 @@
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>alfresco-public</id>
|
||||
<url>http://maven.alfresco.com/nexus/content/groups/public/</url>
|
||||
<url>http://maven.alfresco.com/nexus/content/groups/public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>alfresco-public-snapshots</id>
|
||||
<url>http://maven.alfresco.com/nexus/content/groups/public-snapshots</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<!-- Configuration point for the build time properties -->
|
||||
@@ -35,7 +39,17 @@
|
||||
<version>${alfresco.version}</version>
|
||||
<classifier>community</classifier>
|
||||
</dependency>
|
||||
<!-- Share module dependencies
|
||||
| As of Alfresco 3.3 you can add here below Share Dashlets/Pages packaged as Jars (see http://blogs.alfresco.com/wp/kevinr/2010/01/28/alfresco-share-33-extensions-and-springsurf/)
|
||||
| You can build them with Maven using the Maven Share Module Archetype, documentation can be found here: http://wiki.alfresco.com/wiki/Managing_Alfresco_Lifecyle_with_Maven)
|
||||
|
||||
<dependency>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>my-share-module</artifactId>
|
||||
<type>jar</type>
|
||||
<version>0.0.1</version>
|
||||
</dependency>
|
||||
-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -59,7 +73,7 @@
|
||||
classpath:alfresco/extension/application.properties
|
||||
-->
|
||||
<resource>
|
||||
<directory>src/main/properties</directory>
|
||||
<directory>src/main/properties/${env}</directory>
|
||||
<includes>
|
||||
<include>application.properties</include>
|
||||
</includes>
|
||||
|
@@ -6,6 +6,7 @@
|
||||
|
||||
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="ignoreResourceNotFound" value="true" />
|
||||
<property name="ignoreUnresolvablePlaceholders" value="true"/>
|
||||
<property name="locations">
|
||||
<list>
|
||||
<value>classpath:alfresco/web-extension/application.properties</value>
|
||||
|
@@ -1,93 +1,83 @@
|
||||
<alfresco-config>
|
||||
|
||||
|
||||
<config evaluator="string-compare" condition="Server">
|
||||
<server>
|
||||
<!-- Enable and adjust the following settings to allow for external access URLs to the
|
||||
WebScript Framework - to return an externally accessable address for absolute url generation.
|
||||
-->
|
||||
<scheme>${share.server.scheme}</scheme>
|
||||
<hostname>${share.server.name}</hostname>
|
||||
<port>${share.server.port}</port>
|
||||
</server>
|
||||
</config>
|
||||
<config evaluator="string-compare" condition="Server">
|
||||
<server>
|
||||
<!--
|
||||
Enable and adjust the following settings to allow for external
|
||||
access URLs to the WebScript Framework - to return an externally
|
||||
accessable address for absolute url generation.
|
||||
-->
|
||||
<scheme>${share.server.scheme}</scheme>
|
||||
<hostname>${share.server.name}</hostname>
|
||||
<port>${share.server.port}</port>
|
||||
</server>
|
||||
</config>
|
||||
|
||||
|
||||
<!-- Overriding endpoints to reference a remote Alfresco server -->
|
||||
<!-- Overriding endpoints to reference a remote Alfresco server -->
|
||||
|
||||
<config evaluator="string-compare" condition="Remote">
|
||||
<remote>
|
||||
<config evaluator="string-compare" condition="Remote">
|
||||
<remote>
|
||||
<endpoint>
|
||||
<id>alfresco-noauth</id>
|
||||
<name>Alfresco - unauthenticated access</name>
|
||||
<description>Access to Alfresco Repository WebScripts that do not require authentication</description>
|
||||
<connector-id>alfresco</connector-id>
|
||||
<endpoint-url>
|
||||
${alfresco.server.scheme}://${alfresco.server.name}:${alfresco.server.port}/${alfresco.webapp.name}/s
|
||||
</endpoint-url>
|
||||
<identity>none</identity>
|
||||
</endpoint>
|
||||
|
||||
<!-- Endpoints -->
|
||||
<!-- Example of a 'declared' identity endpoint configuration
|
||||
<endpoint>
|
||||
<id>alfresco-system</id>
|
||||
<name>Alfresco - System access</name>
|
||||
<description>System account access to Alfresco</description>
|
||||
<connector-id>alfresco</connector-id>
|
||||
<endpoint-url>http://localhost:8080/alfresco/s</endpoint-url>
|
||||
<identity>declared</identity>
|
||||
<username>admin</username>
|
||||
<password>admin</password>
|
||||
<unsecure>true</unsecure>
|
||||
</endpoint> -->
|
||||
|
||||
<endpoint>
|
||||
<id>alfresco-noauth</id>
|
||||
<name>Alfresco - unauthenticated access</name>
|
||||
<description>Access to Alfresco Repository WebScripts that do not require authentication</description>
|
||||
<connector-id>alfresco</connector-id>
|
||||
<endpoint-url>${alfresco.server.scheme}://${alfresco.server.name}:${alfresco.server.port}/${alfresco.webapp.name}/s</endpoint-url>
|
||||
<identity>none</identity>
|
||||
</endpoint>
|
||||
|
||||
<endpoint>
|
||||
<id>alfresco</id>
|
||||
<name>Alfresco - user access</name>
|
||||
<description>Access to Alfresco Repository WebScripts that require user authentication</description>
|
||||
<connector-id>alfresco</connector-id>
|
||||
<endpoint-url>${alfresco.server.scheme}://${alfresco.server.name}:${alfresco.server.port}/${alfresco.webapp.name}/s</endpoint-url>
|
||||
<identity>user</identity>
|
||||
</endpoint>
|
||||
|
||||
</remote>
|
||||
</config>
|
||||
<endpoint>
|
||||
<id>alfresco</id>
|
||||
<name>Alfresco - user access</name>
|
||||
<description>Access to Alfresco Repository WebScripts that require user authentication</description>
|
||||
<connector-id>alfresco</connector-id>
|
||||
<endpoint-url>
|
||||
${alfresco.server.scheme}://${alfresco.server.name}:${alfresco.server.port}/${alfresco.webapp.name}/s
|
||||
</endpoint-url>
|
||||
<identity>user</identity>
|
||||
</endpoint>
|
||||
</remote>
|
||||
</config>
|
||||
|
||||
|
||||
|
||||
<!-- Overriding endpoints to reference an Alfresco server with external SSO or NTLM enabled -->
|
||||
<!-- NOTE: For NTLM, the NTLM Authentication Filter must also be enabled in share web.xml -->
|
||||
<!-- NOTE: if utilising a load balancer between web-tier and repository cluster, the "sticky -->
|
||||
<!-- sessions" feature of your load balancer must be used -->
|
||||
<!-- Uses SSL client certificate + trusted CAs. Optionally used to authenticate share to an external SSO system such as CAS
|
||||
<config evaluator="string-compare" condition="Remote">
|
||||
<remote>
|
||||
<keystore>
|
||||
<path>alfresco/web-extension/alfresco-system.p12</path>
|
||||
<type>pkcs12</type>
|
||||
<password>alfresco-system</password>
|
||||
</keystore>
|
||||
<!--
|
||||
Overriding endpoints to reference an Alfresco server with external SSO
|
||||
or NTLM enabled
|
||||
-->
|
||||
<!--
|
||||
NOTE: For NTLM, the NTLM Authentication Filter must also be enabled in
|
||||
share web.xml
|
||||
-->
|
||||
<!--
|
||||
NOTE: if utilising a load balancer between web-tier and repository
|
||||
cluster, the "sticky
|
||||
-->
|
||||
<!-- sessions" feature of your load balancer must be used -->
|
||||
<!--
|
||||
Uses SSL client certificate + trusted CAs. Optionally used to
|
||||
authenticate share to an external SSO system such as CAS <config
|
||||
evaluator="string-compare" condition="Remote"> <remote> <keystore>
|
||||
<path>alfresco/web-extension/alfresco-system.p12</path>
|
||||
<type>pkcs12</type> <password>alfresco-system</password> </keystore>
|
||||
|
||||
<connector>
|
||||
<id>alfrescoCookie</id>
|
||||
<name>Alfresco Connector</name>
|
||||
<description>Connects to an Alfresco instance using cookie-based authentication</description>
|
||||
<class>org.alfresco.connector.AlfrescoConnector</class>
|
||||
</connector>
|
||||
<connector> <id>alfrescoCookie</id> <name>Alfresco Connector</name>
|
||||
<description>Connects to an Alfresco instance using cookie-based
|
||||
authentication</description>
|
||||
<class>org.alfresco.connector.AlfrescoConnector</class> </connector>
|
||||
|
||||
<endpoint>
|
||||
<id>alfresco</id>
|
||||
<name>Alfresco - user access</name>
|
||||
<description>Access to Alfresco Repository WebScripts that require user authentication</description>
|
||||
<connector-id>alfrescoCookie</connector-id>
|
||||
<endpoint-url>http://localhost/alfresco/wcs</endpoint-url>
|
||||
<identity>user</identity>
|
||||
<external-auth>true</external-auth>
|
||||
</endpoint>
|
||||
</remote>
|
||||
|
||||
</config>
|
||||
-->
|
||||
<endpoint> <id>alfresco</id> <name>Alfresco - user access</name>
|
||||
<description>Access to Alfresco Repository WebScripts that require
|
||||
user authentication</description>
|
||||
<connector-id>alfrescoCookie</connector-id>
|
||||
<endpoint-url>http://localhost/alfresco/wcs</endpoint-url>
|
||||
<identity>user</identity> <external-auth>true</external-auth>
|
||||
</endpoint> </remote> </config>
|
||||
-->
|
||||
|
||||
|
||||
</alfresco-config>
|
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.alfresco.maven</groupId>
|
||||
<artifactId>maven-alfresco-share-module-archetype</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>maven-archetype</packaging>
|
||||
<name>Maven Archetype to build Alfresco Share JAR modules (dashlets,pages,etc.)</name>
|
||||
<parent>
|
||||
<groupId>com.sourcesense.alfresco</groupId>
|
||||
<artifactId>maven-alfresco-archetypes</artifactId>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<build>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.archetype</groupId>
|
||||
<artifactId>archetype-packaging</artifactId>
|
||||
<version>2.0-alpha-4</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-archetype-plugin</artifactId>
|
||||
<version>2.0-alpha-4</version>
|
||||
<extensions>true</extensions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><archetype-descriptor name="maven-share-module">
|
||||
<fileSets>
|
||||
<fileSet filtered="false" encoding="UTF-8">
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.xml</include>
|
||||
<include>**/*.properties</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<fileSet filtered="false" encoding="UTF-8">
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.js</include>
|
||||
<include>**/*.ftl</include>
|
||||
<include>**/*.css</include>
|
||||
<include>**/*.png</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</archetype-descriptor>
|
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><archetype>
|
||||
<id>maven-share-module</id>
|
||||
<resources>
|
||||
<resource>src/main/resources/alfresco/site-webscripts/org/alfresco/components/dashlets/site-tags.get.config.xml</resource>
|
||||
<resource>src/main/resources/alfresco/site-webscripts/org/alfresco/components/dashlets/site-tags.get.desc.xml</resource>
|
||||
<resource>src/main/resources/alfresco/site-webscripts/org/alfresco/components/dashlets/site-tags.get.head.ftl</resource>
|
||||
<resource>src/main/resources/alfresco/site-webscripts/org/alfresco/components/dashlets/site-tags.get.html.ftl</resource>
|
||||
<resource>src/main/resources/alfresco/site-webscripts/org/alfresco/components/dashlets/site-tags.get.js</resource>
|
||||
<resource>src/main/resources/alfresco/site-webscripts/org/alfresco/components/dashlets/site-tags.get.properties</resource>
|
||||
<resource>src/main/resources/alfresco/site-webscripts/org/alfresco/components/dashlets/site-tags.get_cy.properties</resource>
|
||||
<resource>src/main/resources/META-INF/components/dashlets/images/refresh.png</resource>
|
||||
<resource>src/main/resources/META-INF/components/dashlets/site-tags.css</resource>
|
||||
<resource>src/main/resources/META-INF/components/dashlets/site-tags.js</resource>
|
||||
</resources>
|
||||
</archetype>
|
@@ -0,0 +1,35 @@
|
||||
<?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>${groupId}</groupId>
|
||||
<artifactId>${artifactId}</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>${version}</version>
|
||||
<name>${artifactId} project</name>
|
||||
<url>http://share.alfresco.com</url>
|
||||
<!-- New Alfresco Maven Community Repository instance, pro -->
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>alfresco-public</id>
|
||||
<url>http://maven.alfresco.com/nexus/content/groups/public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>alfresco-public-snapshots</id>
|
||||
<url>http://maven.alfresco.com/nexus/content/groups/public-snapshots</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>daily</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- Spring Surf dependencies are available via proxy via maven.alfresco.com so just add them below -->
|
||||
</dependencies>
|
||||
</project>
|
Binary file not shown.
After Width: | Height: | Size: 604 B |
@@ -0,0 +1 @@
|
||||
(function(){var e=YAHOO.util.Dom,r=YAHOO.util.Event;var k=Alfresco.util.encodeHTML,i=Alfresco.util.combinePaths;var l="org.alfresco.share.dashlet",c=l+".siteTagsFilter";Alfresco.dashlet.SiteTags=function p(s){return Alfresco.dashlet.SiteTags.superclass.constructor.call(this,"Alfresco.dashlet.SiteTags",s)};YAHOO.extend(Alfresco.dashlet.SiteTags,Alfresco.component.Base,{options:{maxItems:50,activeFilter:"all"},tagsContainer:null,containerId:null,onReady:function m(){var w=this;this.tagsContainer=e.get(this.id+"-tags");r.addListener(this.id+"-refresh","click",this.onRefresh,this,true);this.services.preferences=new Alfresco.service.Preferences();this.widgets.all=new YAHOO.widget.Button(this.id+"-all",{type:"checkbox",value:"all",checked:true});this.widgets.all.on("checkedChange",this.onAllCheckedChanged,this.widgets.all,this);this.widgets.filter=new YAHOO.widget.Button(this.id+"-filter",{type:"split",menu:this.id+"-filter-menu",lazyloadmenu:false});this.widgets.filter.on("click",this.onFilterClicked,this,true);var x=this.widgets.filter.getMenu();x.subscribe("click",function(z,y){var A=y[1];if(A){w.widgets.filter.set("label",A.cfg.getProperty("text"));w.onFilterChanged.call(w,y[1])}});if(this.options.activeFilter=="all"){this.widgets.filter.value="documentLibrary";this.setActiveFilter("all")}else{this.widgets.filter.value=this.options.activeFilter;var t=x.getItems(),v,s,u;for(s=0,u=t.length;s<u;s++){v=t[s];if(v.value==this.options.activeFilter){x.clickEvent.fire({type:"click"},v);break}}}},onRefresh:function d(s){if(s){r.preventDefault(s)}this.refreshTags()},refreshTags:function n(){e.setStyle(this.tagsContainer,"display","none");Alfresco.util.Ajax.jsonGet({url:Alfresco.constants.PROXY_URI+"api/tagscopes/site/"+i(this.options.siteId,this.containerId,"tags"),successCallback:{fn:this.onTagsSuccess,scope:this},failureCallback:{fn:this.onTagsFailed,scope:this},scope:this,noReloadOnAuthFailure:true})},onTagsSuccess:function g(x){var E=x.json.tags.slice(0,this.options.maxItems),y=E.length,C=0,w="",v,D;for(v=0,D=E.length;v<D;v++){C+=E[v].count}if(E.length===0){w='<div class="msg">'+this.msg("message.no-tags")+"</div>"}else{var F,s=function t(G){return G.count/(C/y)},A=function z(G){return(0.5+s(G)).toFixed(2)},B=function u(H,G){if(H.name<G.name){return -1}if(H.name>G.name){return 1}return 0};E.sort(B);for(v=0,D=E.length;v<D;v++){F=E[v];w+='<div class="tag"><a href="'+this.getUriTemplate(F)+'" class="theme-color-1" style="font-size: '+A(F)+'em">'+k(F.name)+"</a></div> "}}this.tagsContainer.innerHTML=w;Alfresco.util.Anim.fadeIn(this.tagsContainer)},onTagsFailed:function o(){this.tagsContainer.innerHTML=this.msg("refresh-failed");Alfresco.util.Anim.fadeIn(this.tagsContainer)},getUriTemplate:function j(s){var t=Alfresco.constants.URL_CONTEXT+"page/site/"+this.options.siteId;switch(this.options.activeFilter){case"wiki":t+="/wiki";break;case"blog":t+="/blog-postlist";break;case"documentLibrary":t+="/documentlibrary#filter=tag|"+encodeURIComponent(s.name);break;case"calendar":t+="/calendar";break;case"links":t+="/links";break;case"discussions":t+="/discussions-topiclist";break;default:t+="/search?tag="+encodeURIComponent(s.name)+"&a=false"}return t},updateFilterUI:function b(){switch(this.options.activeFilter){case"all":e.removeClass(this.widgets.filter.get("element"),"yui-checkbox-button-checked");break;default:this.widgets.all.set("checked",false,true);e.addClass(this.widgets.filter.get("element"),"yui-checkbox-button-checked");break}},setActiveFilter:function f(s,t){this.options.activeFilter=s;this.containerId=s!=="all"?s:"";this.updateFilterUI();this.refreshTags();if(t!==true){this.services.preferences.set(c,s)}},onAllCheckedChanged:function h(s,t){this.setActiveFilter("all");t.set("checked",true,true)},onFilterClicked:function a(s){this.setActiveFilter(this.widgets.filter.value)},onFilterChanged:function q(t){var s=t.value;this.widgets.filter.value=s;this.setActiveFilter(s)}})})();
|
@@ -0,0 +1,27 @@
|
||||
.site-tags .tag
|
||||
{
|
||||
display: inline-block;
|
||||
padding: 0.2em;
|
||||
}
|
||||
|
||||
.site-tags .refresh
|
||||
{
|
||||
background-image: url(images/refresh.png);
|
||||
background-repeat: no-repeat;
|
||||
float: right;
|
||||
height: 16px;
|
||||
left: -8px;
|
||||
position: relative;
|
||||
top: -22px;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
.site-tags .refresh a,
|
||||
.site-tags .refresh a:active,
|
||||
.site-tags .refresh a:hover
|
||||
{
|
||||
display: block;
|
||||
height: 16px;
|
||||
text-decoration: none;
|
||||
width: 16px;
|
||||
}
|
@@ -0,0 +1,422 @@
|
||||
/**
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Dashboard Site Tags component.
|
||||
*
|
||||
* @namespace Alfresco
|
||||
* @class Alfresco.dashlet.SiteTags
|
||||
*/
|
||||
(function()
|
||||
{
|
||||
/**
|
||||
* YUI Library aliases
|
||||
*/
|
||||
var Dom = YAHOO.util.Dom,
|
||||
Event = YAHOO.util.Event;
|
||||
|
||||
/**
|
||||
* Alfresco Slingshot aliases
|
||||
*/
|
||||
var $html = Alfresco.util.encodeHTML,
|
||||
$combine = Alfresco.util.combinePaths;
|
||||
|
||||
/**
|
||||
* Preferences
|
||||
*/
|
||||
var PREFERENCES_DASHLET = "org.alfresco.share.dashlet",
|
||||
PREF_SITE_TAGS_FILTER = PREFERENCES_DASHLET + ".siteTagsFilter";
|
||||
|
||||
|
||||
/**
|
||||
* Dashboard SiteTags constructor.
|
||||
*
|
||||
* @param {String} htmlId The HTML id of the parent element
|
||||
* @return {Alfresco.dashlet.SiteTags} The new component instance
|
||||
* @constructor
|
||||
*/
|
||||
Alfresco.dashlet.SiteTags = function SiteTags_constructor(htmlId)
|
||||
{
|
||||
return Alfresco.dashlet.SiteTags.superclass.constructor.call(this, "Alfresco.dashlet.SiteTags", htmlId);
|
||||
};
|
||||
|
||||
/**
|
||||
* Extend from Alfresco.component.Base and add class implementation
|
||||
*/
|
||||
YAHOO.extend(Alfresco.dashlet.SiteTags, Alfresco.component.Base,
|
||||
{
|
||||
/**
|
||||
* Object container for initialization options
|
||||
*
|
||||
* @property options
|
||||
* @type object
|
||||
*/
|
||||
options:
|
||||
{
|
||||
/**
|
||||
* Max items
|
||||
*
|
||||
* @property maxItems
|
||||
* @type integer
|
||||
* @default 50
|
||||
*/
|
||||
maxItems: 50,
|
||||
|
||||
/**
|
||||
* Currently active filter.
|
||||
*
|
||||
* @property activeFilter
|
||||
* @type string
|
||||
* @default "all"
|
||||
*/
|
||||
activeFilter: "all"
|
||||
},
|
||||
|
||||
/**
|
||||
* Tags DOM container.
|
||||
*
|
||||
* @property tagsContainer
|
||||
* @type object
|
||||
*/
|
||||
tagsContainer: null,
|
||||
|
||||
/**
|
||||
* ContainerId for tag scope query
|
||||
*
|
||||
* @property containerId
|
||||
* @type string
|
||||
* @default ""
|
||||
*/
|
||||
containerId: null,
|
||||
|
||||
/**
|
||||
* Fired by YUI when parent element is available for scripting
|
||||
* @method onReady
|
||||
*/
|
||||
onReady: function SiteTags_onReady()
|
||||
{
|
||||
var me = this;
|
||||
|
||||
// The tags container
|
||||
this.tagsContainer = Dom.get(this.id + "-tags");
|
||||
|
||||
// Hook the refresh icon click
|
||||
Event.addListener(this.id + "-refresh", "click", this.onRefresh, this, true);
|
||||
|
||||
// Preferences service
|
||||
this.services.preferences = new Alfresco.service.Preferences();
|
||||
|
||||
// "All" filter
|
||||
this.widgets.all = new YAHOO.widget.Button(this.id + "-all",
|
||||
{
|
||||
type: "checkbox",
|
||||
value: "all",
|
||||
checked: true
|
||||
});
|
||||
this.widgets.all.on("checkedChange", this.onAllCheckedChanged, this.widgets.all, this);
|
||||
|
||||
// Dropdown filter
|
||||
this.widgets.filter = new YAHOO.widget.Button(this.id + "-filter",
|
||||
{
|
||||
type: "split",
|
||||
menu: this.id + "-filter-menu",
|
||||
lazyloadmenu: false
|
||||
});
|
||||
this.widgets.filter.on("click", this.onFilterClicked, this, true);
|
||||
// Clear the lazyLoad flag and fire init event to get menu rendered into the DOM
|
||||
var menu = this.widgets.filter.getMenu();
|
||||
menu.subscribe("click", function (p_sType, p_aArgs)
|
||||
{
|
||||
var menuItem = p_aArgs[1];
|
||||
if (menuItem)
|
||||
{
|
||||
me.widgets.filter.set("label", menuItem.cfg.getProperty("text"));
|
||||
me.onFilterChanged.call(me, p_aArgs[1]);
|
||||
}
|
||||
});
|
||||
|
||||
if (this.options.activeFilter == "all")
|
||||
{
|
||||
this.widgets.filter.value = "documentLibrary";
|
||||
this.setActiveFilter("all");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.widgets.filter.value = this.options.activeFilter;
|
||||
|
||||
// Loop through and find the menuItem corresponding to the default filter
|
||||
var menuItems = menu.getItems(),
|
||||
menuItem,
|
||||
i, ii;
|
||||
|
||||
for (i = 0, ii = menuItems.length; i < ii; i++)
|
||||
{
|
||||
menuItem = menuItems[i];
|
||||
if (menuItem.value == this.options.activeFilter)
|
||||
{
|
||||
menu.clickEvent.fire(
|
||||
{
|
||||
type: "click"
|
||||
}, menuItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Event handler for refresh click
|
||||
* @method onRefresh
|
||||
* @param e {object} Event
|
||||
*/
|
||||
onRefresh: function SiteTags_onRefresh(e)
|
||||
{
|
||||
if (e)
|
||||
{
|
||||
// Stop browser's default click behaviour for the link
|
||||
Event.preventDefault(e);
|
||||
}
|
||||
this.refreshTags();
|
||||
},
|
||||
|
||||
/**
|
||||
* Refresh tags
|
||||
* @method refreshTags
|
||||
*/
|
||||
refreshTags: function SiteTags_refreshTags()
|
||||
{
|
||||
// Hide the existing content
|
||||
Dom.setStyle(this.tagsContainer, "display", "none");
|
||||
|
||||
// Make an AJAX request to the Tag Service REST API
|
||||
Alfresco.util.Ajax.jsonGet(
|
||||
{
|
||||
url: Alfresco.constants.PROXY_URI + "api/tagscopes/site/" + $combine(this.options.siteId, this.containerId, "tags"),
|
||||
successCallback:
|
||||
{
|
||||
fn: this.onTagsSuccess,
|
||||
scope: this
|
||||
},
|
||||
failureCallback:
|
||||
{
|
||||
fn: this.onTagsFailed,
|
||||
scope: this
|
||||
},
|
||||
scope: this,
|
||||
noReloadOnAuthFailure: true
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Tags retrieved successfully
|
||||
* @method onTagsSuccess
|
||||
* @param p_response {object} Response object from request
|
||||
*/
|
||||
onTagsSuccess: function SiteTags_onTagsSuccess(p_response)
|
||||
{
|
||||
// Retrieve the tags list from the JSON response and trim accordingly
|
||||
var tags = p_response.json.tags.slice(0, this.options.maxItems),
|
||||
numTags = tags.length,
|
||||
totalTags = 0,
|
||||
html = "",
|
||||
i, ii;
|
||||
|
||||
// Work out total number of tags for scaling
|
||||
for (i = 0, ii = tags.length; i < ii; i++)
|
||||
{
|
||||
totalTags += tags[i].count;
|
||||
}
|
||||
|
||||
// Tags to show?
|
||||
if (tags.length === 0)
|
||||
{
|
||||
html = '<div class="msg">' + this.msg("message.no-tags") + '</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Define inline scaling functions
|
||||
var tag,
|
||||
fnTagWeighting = function tagWeighting(thisTag)
|
||||
{
|
||||
return thisTag.count / (totalTags / numTags);
|
||||
},
|
||||
fnTagFontSize = function tagFontSize(thisTag)
|
||||
{
|
||||
return (0.5 + fnTagWeighting(thisTag)).toFixed(2);
|
||||
},
|
||||
fnSortByTagAlphabetical = function sortByTagAlphabetical(tag1, tag2)
|
||||
{
|
||||
if (tag1.name < tag2.name)
|
||||
return -1;
|
||||
|
||||
if (tag1.name > tag2.name)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
// Sort tags alphabetically - standard for tag clouds
|
||||
tags.sort(fnSortByTagAlphabetical);
|
||||
|
||||
// Generate HTML mark-up for each tag
|
||||
for (i = 0, ii = tags.length; i < ii; i++)
|
||||
{
|
||||
tag = tags[i];
|
||||
html += '<div class="tag"><a href="' + this.getUriTemplate(tag) + '" class="theme-color-1" style="font-size: ' + fnTagFontSize(tag) + 'em">' + $html(tag.name) + '</a></div> ';
|
||||
}
|
||||
}
|
||||
this.tagsContainer.innerHTML = html;
|
||||
|
||||
// Fade the new content in
|
||||
Alfresco.util.Anim.fadeIn(this.tagsContainer);
|
||||
},
|
||||
|
||||
/**
|
||||
* Tags request failed
|
||||
* @method onTagsFailed
|
||||
*/
|
||||
onTagsFailed: function SiteTags_onTagsFailed()
|
||||
{
|
||||
this.tagsContainer.innerHTML = this.msg("refresh-failed");
|
||||
Alfresco.util.Anim.fadeIn(this.tagsContainer);
|
||||
},
|
||||
|
||||
/**
|
||||
* Generate Uri template based on current active filter
|
||||
* @method getUriTemplate
|
||||
* @param tag {object} Tag object literal
|
||||
*/
|
||||
getUriTemplate: function SiteTags_getUriTemplate(tag)
|
||||
{
|
||||
var uri = Alfresco.constants.URL_CONTEXT + 'page/site/' + this.options.siteId;
|
||||
switch (this.options.activeFilter)
|
||||
{
|
||||
case "wiki":
|
||||
uri += '/wiki';
|
||||
break;
|
||||
|
||||
case "blog":
|
||||
uri += '/blog-postlist';
|
||||
break;
|
||||
|
||||
case "documentLibrary":
|
||||
uri += '/documentlibrary#filter=tag|' + encodeURIComponent(tag.name);
|
||||
break;
|
||||
|
||||
case "calendar":
|
||||
uri += '/calendar';
|
||||
break;
|
||||
|
||||
case "links":
|
||||
uri += '/links';
|
||||
break;
|
||||
|
||||
case "discussions":
|
||||
uri += '/discussions-topiclist';
|
||||
break;
|
||||
|
||||
default:
|
||||
uri += '/search?tag=' + encodeURIComponent(tag.name) + '&a=false';
|
||||
}
|
||||
return uri;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the active filter highlight in the UI
|
||||
* @method updateFilterUI
|
||||
*/
|
||||
updateFilterUI: function SiteTags_updateFilterUI()
|
||||
{
|
||||
switch (this.options.activeFilter)
|
||||
{
|
||||
case "all":
|
||||
Dom.removeClass(this.widgets.filter.get("element"), "yui-checkbox-button-checked");
|
||||
break;
|
||||
|
||||
default:
|
||||
this.widgets.all.set("checked", false, true);
|
||||
Dom.addClass(this.widgets.filter.get("element"), "yui-checkbox-button-checked");
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Saves active filter to user preferences
|
||||
* @method saveActiveFilter
|
||||
* @param filter {string} New filter to set
|
||||
* @param noPersist {boolean} [Optional] If set, preferences are not updated
|
||||
*/
|
||||
setActiveFilter: function SiteTags_saveActiveFilter(filter, noPersist)
|
||||
{
|
||||
this.options.activeFilter = filter;
|
||||
this.containerId = filter !== "all" ? filter : "";
|
||||
this.updateFilterUI();
|
||||
this.refreshTags();
|
||||
if (noPersist !== true)
|
||||
{
|
||||
this.services.preferences.set(PREF_SITE_TAGS_FILTER, filter);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* YUI WIDGET EVENT HANDLERS
|
||||
* Handlers for standard events fired from YUI widgets, e.g. "click"
|
||||
*/
|
||||
|
||||
/**
|
||||
* All tasks
|
||||
* @method onAllCheckedChanged
|
||||
* @param p_oEvent {object} Button event
|
||||
* @param p_obj {object} Button
|
||||
*/
|
||||
onAllCheckedChanged: function Sitetags_onAllCheckedChanged(p_oEvent, p_obj)
|
||||
{
|
||||
this.setActiveFilter("all");
|
||||
p_obj.set("checked", true, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Filter button clicked event handler
|
||||
* @method onFilterClicked
|
||||
* @param p_oEvent {object} Dom event
|
||||
*/
|
||||
onFilterClicked: function SiteTags_onFilterClicked(p_oEvent)
|
||||
{
|
||||
this.setActiveFilter(this.widgets.filter.value);
|
||||
},
|
||||
|
||||
/**
|
||||
* Filter drop-down changed event handler
|
||||
* @method onFilterChanged
|
||||
* @param p_oMenuItem {object} Selected menu item
|
||||
*/
|
||||
onFilterChanged: function SiteTags_onFilterChanged(p_oMenuItem)
|
||||
{
|
||||
var filter = p_oMenuItem.value;
|
||||
this.widgets.filter.value = filter;
|
||||
this.setActiveFilter(filter);
|
||||
}
|
||||
});
|
||||
})();
|
@@ -0,0 +1,3 @@
|
||||
<site-tags>
|
||||
<maxitems>50</maxitems>
|
||||
</site-tags>
|
@@ -0,0 +1,6 @@
|
||||
<webscript>
|
||||
<shortname>Tag Cloud</shortname>
|
||||
<description>Displays a cloud of all the tags defined in this site</description>
|
||||
<family>site-dashlet</family>
|
||||
<url>/components/dashlets/site-tags</url>
|
||||
</webscript>
|
@@ -0,0 +1,4 @@
|
||||
<#include "../component.head.inc">
|
||||
<!-- Tag cloud -->
|
||||
<@link rel="stylesheet" type="text/css" href="${page.url.context}/res/components/dashlets/site-tags.css" />
|
||||
<@script type="text/javascript" src="${page.url.context}/res/components/dashlets/site-tags.js"></@script>
|
@@ -0,0 +1,31 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
new Alfresco.dashlet.SiteTags("${args.htmlid}").setOptions(
|
||||
{
|
||||
siteId: "${page.url.templateArgs.site!""}",
|
||||
maxItems: ${(maxItems?string!"50")},
|
||||
activeFilter: "${preferences.siteTagsFilter!"all"}"
|
||||
}).setMessages(
|
||||
${messages}
|
||||
);
|
||||
new Alfresco.widget.DashletResizer("${args.htmlid}", "${instance.object.id}");
|
||||
//]]></script>
|
||||
<div class="dashlet site-tags">
|
||||
<div class="title">${msg("header")}</div>
|
||||
<div class="refresh"><a id="${args.htmlid}-refresh" href="#"> </a></div>
|
||||
<div class="toolbar flat-button">
|
||||
<input id="${args.htmlid}-all" type="checkbox" name="all" value="${msg("filter.all")}" checked="checked" />
|
||||
<input id="${args.htmlid}-filter" type="button" name="filter" value="${msg("filter.documentLibrary")}" />
|
||||
<select id="${args.htmlid}-filter-menu">
|
||||
<option value="wiki">${msg("filter.wiki")}</option>
|
||||
<option value="blog">${msg("filter.blog")}</option>
|
||||
<option value="documentLibrary">${msg("filter.documentLibrary")}</option>
|
||||
<option value="calendar">${msg("filter.calendar")}</option>
|
||||
<option value="links">${msg("filter.links")}</option>
|
||||
<option value="discussions">${msg("filter.discussions")}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="body" <#if args.height??>style="height: ${args.height}px;"</#if>>
|
||||
<div id="${args.htmlid}-tags"></div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,32 @@
|
||||
const PREFERENCES_ROOT = "org.alfresco.share.dashlet";
|
||||
|
||||
function main()
|
||||
{
|
||||
var s = new XML(config.script);
|
||||
model.maxItems = parseInt(s.maxitems, 10);
|
||||
|
||||
var result, preferences = {};
|
||||
|
||||
// Request the current user's preferences
|
||||
var result = remote.call("/api/people/" + stringUtils.urlEncode(user.name) + "/preferences?pf=" + PREFERENCES_ROOT);
|
||||
if (result.status == 200 && result != "{}")
|
||||
{
|
||||
var prefs = eval('(' + result + ')');
|
||||
try
|
||||
{
|
||||
// Populate the preferences object literal for easy look-up later
|
||||
preferences = eval('(prefs.' + PREFERENCES_ROOT + ')');
|
||||
if (typeof preferences != "object")
|
||||
{
|
||||
preferences = {};
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
model.preferences = preferences;
|
||||
}
|
||||
|
||||
main();
|
@@ -0,0 +1,11 @@
|
||||
header=Site Tags
|
||||
message.no-tags=No tags found
|
||||
message.error=Error: Could not retrieve tags list.
|
||||
|
||||
filter.all=All
|
||||
filter.wiki=Wiki
|
||||
filter.blog=Blog
|
||||
filter.documentLibrary=Document Library
|
||||
filter.calendar=Calendar
|
||||
filter.links=Links
|
||||
filter.discussions=Discussions
|
@@ -0,0 +1,2 @@
|
||||
header.siteTags=Tagiau Safle
|
||||
header.noTags=Dim tagiau wedi canfod
|
@@ -22,6 +22,7 @@
|
||||
<module>maven-alfresco-amp-archetype</module>
|
||||
<module>maven-alfresco-extension-archetype</module>
|
||||
<module>maven-alfresco-share-archetype</module>
|
||||
<module>maven-alfresco-share-module-archetype/</module>
|
||||
</modules>
|
||||
<build>
|
||||
<extensions>
|
||||
|
1
pom.xml
1
pom.xml
@@ -229,6 +229,7 @@ community contexts.
|
||||
<url>http://maven.alfresco.com/nexus/content/repositories/releases</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<name>alfresco snapshots repository</name>
|
||||
<id>alfresco-snapshots</id>
|
||||
<url>http://maven.alfresco.com/nexus/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
|
Reference in New Issue
Block a user