Skip to content

Commit 31c2bd2

Browse files
committed
Initial site blog dashlet code
git-svn-id: https://share-extras.googlecode.com/svn/trunk/Site Blog Dashlet@22 a3f5c567-fd0f-3a89-9b71-a290c5a5f590
1 parent be02455 commit 31c2bd2

File tree

14 files changed

+768
-0
lines changed

14 files changed

+768
-0
lines changed

.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Site Blog Dashlet</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
</buildSpec>
9+
<natures>
10+
</natures>
11+
</projectDescription>

MAINTAINERS.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Will Abson
2+
3+
Userid: wabson

README.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Site Blog dashlet for Alfresco Share
2+
====================================
3+
4+
Author: Will Abson
5+
6+
This add-on project for Alfresco Share defines a simple dashlet to display
7+
the last ten blog posts from the site.
8+
9+
Installation
10+
------------
11+
12+
The dashlet has been developed to install on top of an existing Alfresco
13+
3.3 installation.
14+
15+
An Ant build script is provided to build a JAR file containing the
16+
custom files, which can then be installed into the 'tomcat/shared/lib' folder
17+
of your Alfresco installation.
18+
19+
To build the JAR file, run the following command from the base project
20+
directory.
21+
22+
ant clean dist-jar
23+
24+
The command should build a JAR file named site-blog-dashlet.jar
25+
in the 'dist' directory within your project.
26+
27+
To deploy the dashlet files into a local Tomcat instance for testing, you can
28+
use the hotcopy-tomcat-jar task. You will need to set the tomcat.home
29+
property in Ant.
30+
31+
ant -Dtomcat.home=C:/Alfresco/tomcat clean hotcopy-tomcat-jar
32+
33+
Once you have run this you will need to restart Tomcat so that the classpath
34+
resources in the JAR file are picked up.
35+
36+
Using the dashlet
37+
-----------------
38+
39+
Log in to Alfresco Share and navigate to a site dashboard. Click the
40+
Customize Dashboard button to edit the contents of the dashboard and drag
41+
the dashlet into one of the columns from the list of dashlets.

build.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
zip.name=site-blog-dashlet.zip
2+
jar.name=site-blog-dashlet.jar
3+
build.res.dir.name=share

build.xml

Lines changed: 317 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,317 @@
1+
<!--
2+
3+
***********************************
4+
Share Extensions build script
5+
***********************************
6+
7+
Author: Will Abson
8+
9+
Provides a set of targets for building extensions to Alfresco Share in ZIP, ACP and JAR archive
10+
formats. Since Alfresco 3.3, JAR is the recommended package structure for all simple extensions.
11+
For more complex extensions that add additional Java libraries or Spring configuration, ACP
12+
should be used.
13+
14+
The following file structure is required in your project directory
15+
16+
/build.xml - This file
17+
/config - All web-tier configuration files, e.g. web scripts and Surf configuration
18+
/source/web - All static resource files, e.g. CSS, JS
19+
20+
For building AMP files, the files module.proerties and file-mapping.properties are also required
21+
in the project root directory.
22+
23+
During the build process, temporary 'build' and 'dist' directories will be created in the base
24+
project directory. These may be removed at any time using the 'clean' target.
25+
26+
-->
27+
<project basedir="." default="dist-jar" name="Share Example Dashlets">
28+
29+
<!-- Allow override properties -->
30+
<property file="build.properties" />
31+
<property file="${user.home}/build.properties" />
32+
33+
<!-- Property default values. May be overridden using above files or via command-line args -->
34+
<property name="jar.name" value="share-extension.jar" />
35+
<property name="zip.name" value="share-extension.zip" />
36+
<property name="amp.name" value="share-extension.amp" />
37+
<property name="config.includes" value="**/*.*" />
38+
<property name="config.excludes" value="" />
39+
<property name="build.res.includes" value="**/*.*" />
40+
<property name="build.res.excludes" value="" />
41+
<property name="build.res.dir.name" value="ROOT/share-extension" />
42+
<property name="post.verbose" value="false" />
43+
<property name="webapp.alfresco.path" value="/alfresco" />
44+
<property name="webapp.share.path" value="/share" />
45+
<!-- Properties to access the Tomcat Manager application -->
46+
<property name="tomcat.url" value="http://localhost:8080" />
47+
<property name="webapp.manager.url" value="${tomcat.url}/manager" />
48+
<property name="webapp.manager.username" value="admin" />
49+
<property name="webapp.manager.password" value="" />
50+
51+
<!-- Additional property values. Generally should not be overridden -->
52+
<property name="config.dir" value="${basedir}/config" />
53+
<property name="res.dir" value="${basedir}/source/web" />
54+
<property name="build.dir" value="${basedir}/build" />
55+
<property name="build.jar.dir" value="${build.dir}/jar" />
56+
<property name="build.zip.dir" value="${build.dir}/war" />
57+
<property name="build.amp.dir" value="${build.dir}/amp" />
58+
<property name="dist.dir" value="${basedir}/dist" />
59+
<property name="amp.file.properties" value="module.properties" />
60+
<property name="amp.file.mappings" value="file-mapping.properties" />
61+
62+
<!-- Define optional tasks -->
63+
<!--
64+
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask" />
65+
<taskdef name="post" classname="net.sf.antcontrib.net.PostTask" />
66+
-->
67+
68+
<!-- Alias targets -->
69+
<target name="build-zip" depends="build-zip-tomcat" />
70+
<target name="dist-zip" depends="dist-zip-tomcat" />
71+
72+
73+
<path id="yuicompressor.classpath">
74+
<fileset dir="lib">
75+
<include name="yuicompressor-2.4.2.jar"/>
76+
<include name="yui-compressor-ant-task-0.5.jar"/>
77+
</fileset>
78+
</path>
79+
80+
<taskdef name="yuicompress" classname="net.noha.tools.ant.yuicompressor.tasks.YuiCompressorTask">
81+
<classpath>
82+
<path refid="yuicompressor.classpath"/>
83+
</classpath>
84+
</taskdef>
85+
86+
<!-- Clean out the build and distribution directories -->
87+
<target name="clean" description="Clean out all build directories">
88+
<delete dir="${build.dir}" />
89+
<delete dir="${dist.dir}" />
90+
</target>
91+
92+
<!-- Create required prerequisite directory structure -->
93+
<target name="prepare" description="Create initial build structures">
94+
<mkdir dir="${build.dir}" />
95+
<mkdir dir="${dist.dir}" />
96+
</target>
97+
98+
<!--
99+
Assemble the configuration and resource files in a JAR file structure. This mechanism
100+
was introduced in Alfresco 3.3 and allows Share extensions containing web scripts, Surf
101+
configuration and static assets to be added to the servlet container as shared libraries.
102+
103+
For more complex extensions that add additional Java libraries or Spring configuration, ACP
104+
should be used.
105+
106+
This target excludes the files custom-slingshot-application-context.xml, share-config-custom.xml
107+
and similar files as only one of these should be present on the classpath.
108+
-->
109+
<target name="build-jar" description="Assemble configuration and resource files in a JAR file structure">
110+
<mkdir dir="${build.jar.dir}" />
111+
<copy todir="${build.jar.dir}" includeEmptyDirs="false">
112+
<fileset dir="${config.dir}" includes="${config.includes}" excludes="${config.excludes}" >
113+
<exclude name="alfresco/web-extension/custom-slingshot-application-context.xml" />
114+
<exclude name="alfresco/web-extension/share-config-custom.xml" />
115+
<exclude name="${config.excludes}" />
116+
</fileset>
117+
</copy>
118+
<mkdir dir="${build.jar.dir}/META-INF" />
119+
<copy todir="${build.jar.dir}/META-INF" includeEmptyDirs="false">
120+
<fileset dir="${res.dir}" includes="${build.res.includes}" excludes="${build.res.excludes}" />
121+
</copy>
122+
<!-- Minify JS -->
123+
<yuicompress fromdir="${res.dir}" todir="${build.jar.dir}/META-INF" >
124+
<include name="**/*.js" />
125+
</yuicompress>
126+
</target>
127+
128+
<!-- Build the JAR file -->
129+
<target name="dist-jar" depends="clean, prepare, build-jar"
130+
description="Build a JAR file containing configuration and resource files">
131+
<jar destfile="${dist.dir}/${jar.name}">
132+
<fileset dir="${build.jar.dir}" />
133+
</jar>
134+
</target>
135+
136+
<!--
137+
Assemble the configuration and resource files in a file structure suitable for deploying
138+
into an existing Tomcat installation, with the following directories.
139+
140+
/shared/classes/alfresco/extension all repository config files
141+
/shared/classes/alfresco/web-extension all web-tier config files
142+
/webapps/ROOT/share-extension all web resources
143+
144+
The target will only copy resources in the alfresco/extension and alfresco/web-extension
145+
directories from config.dir. It can also optionally map the contents of alfresco/site-data
146+
and alfresco/site-webscripts to alfresco/web-extension/site-data and
147+
alfresco/web-extension/site-webscripts if you set build.zip.config.translate=true.
148+
149+
By default web resources are placed in the 'share-extension' directory in the ROOT webapp. You
150+
can specify a different directory by overriding the build.res.dir.name property value. If you set
151+
this to 'share', files will be copied into the share webapp.
152+
153+
The share-extension directory is not an official location for storing web resources
154+
required by extensions but works as an interim measure for versions of Alfresco prior to
155+
version 3.3, provided that the ROOT webapp is enabled in your Tomcat instance.
156+
157+
In version 3.3 and above the JAR file mechanism is recommended as an alternative.
158+
-->
159+
<target name="build-zip-tomcat" depends="build-zip-prepare,build-zip-shared,build-zip-shared-translate"
160+
description="Assemble the configuration and resource files for a Tomcat deployment structure">
161+
<!-- Copy web assets -->
162+
<copy todir="${build.zip.dir}/webapps/${build.res.dir.name}">
163+
<fileset dir="${res.dir}" includes="${build.res.includes}" excludes="${build.res.excludes}" />
164+
</copy>
165+
<!-- Minifies JS -->
166+
<yuicompress fromdir="${res.dir}" todir="${build.zip.dir}/webapps/${build.res.dir.name}" >
167+
<include name="**/*.js" />
168+
</yuicompress>
169+
</target>
170+
171+
<target name="build-zip-prepare">
172+
<mkdir dir="${build.zip.dir}/shared/classes" />
173+
<mkdir dir="${build.zip.dir}/webapps/${build.res.dir.name}" />
174+
</target>
175+
176+
<target name="build-zip-shared">
177+
<copy todir="${build.zip.dir}/shared/classes">
178+
<fileset dir="${config.dir}" includes="${config.includes}" excludes="${config.excludes}">
179+
<or>
180+
<filename name="alfresco/web-extension/**"/>
181+
<filename name="alfresco/extension/**"/>
182+
</or>
183+
</fileset>
184+
</copy>
185+
</target>
186+
187+
<target name="build-zip-shared-translate" if="build.zip.config.translate">
188+
<copy todir="${build.zip.dir}/shared/classes">
189+
<globmapper from="alfresco/site-*" to="alfresco/web-extension/site-*" handledirsep="true" />
190+
<fileset dir="${config.dir}" includes="${config.includes}" excludes="${config.excludes}">
191+
<filename name="alfresco/site-*/**"/>
192+
</fileset>
193+
</copy>
194+
</target>
195+
196+
<!-- Build the Tomcat ZIP file -->
197+
<target name="dist-zip-tomcat" depends="clean, prepare, build-zip-tomcat"
198+
description="Build a ZIP file containing the customisations that can be deployed in an existing Tomcat installation">
199+
<zip destfile="${dist.dir}/${zip.name}">
200+
<fileset dir="${build.zip.dir}" />
201+
</zip>
202+
</target>
203+
204+
<!--
205+
Assemble the configuration and resource files in an AMP file structure. The files
206+
module.properties and file-mapping.properties must be present in the root of the
207+
project.
208+
209+
This creates a structure which can be deployed into an exising share.war file using the
210+
Alfresco Module Management Tool (MMT). See http://wiki.alfresco.com/wiki/AMP_Files.
211+
212+
This mechanism is compatible with all versions of Alfresco Share and can therefore be
213+
used as an alternative to the JAR extension mechanism introduced in version 3.3.
214+
215+
Note that this mechanism will place files directly into the webapp structure when the
216+
AMP is deployed, rather than the extension mechanisms used by the JAR and ZIP files that
217+
ensure files are placed outside the webapp for safety during upgrades, etc.
218+
219+
In this case this should be acceptable since the MMT modifies the WAR file itself
220+
rather than just the exploded files, and AMPs can always be re-applied if needed.
221+
222+
In version 3.3 and above the JAR file mechanism is recommended as an alternative for all
223+
non-complex extensions.
224+
-->
225+
<target name="build-amp" description="Assemble the configuration and resource files in an AMP file structure">
226+
227+
<!-- Copy properties files -->
228+
<copy todir="${build.amp.dir}" file="${amp.file.properties}" failonerror="true" />
229+
<copy todir="${build.amp.dir}" file="${amp.file.mappings}" failonerror="true" />
230+
231+
<!-- Copy config files -->
232+
<mkdir dir="${build.amp.dir}/config" />
233+
<copy todir="${build.amp.dir}/config">
234+
<fileset dir="${config.dir}" includes="${config.includes}" excludes="${config.excludes}" />
235+
</copy>
236+
237+
<!-- Copy resource files -->
238+
<mkdir dir="${build.amp.dir}/web" />
239+
<copy todir="${build.amp.dir}/web">
240+
<fileset dir="${res.dir}" includes="${build.res.includes}" excludes="${build.res.excludes}" />
241+
</copy>
242+
243+
<!-- Minify JS -->
244+
<yuicompress fromdir="${res.dir}" todir="${build.amp.dir}/web" >
245+
<include name="**/*.js" />
246+
</yuicompress>
247+
</target>
248+
249+
<!-- Build the AMP file -->
250+
<target name="dist-amp" depends="clean, prepare, build-amp" description="Build an AMP file containing all customisations">
251+
<zip destfile="${dist.dir}/${amp.name}">
252+
<fileset dir="${build.amp.dir}" />
253+
</zip>
254+
</target>
255+
256+
<target name="hotcopy-tomcat-zip" depends="build-zip-tomcat" description="Hot copy files into the Tomcat shared/classes folder">
257+
<copy todir="${tomcat.home}" includeEmptyDirs="false">
258+
<fileset dir="${build.zip.dir}" />
259+
</copy>
260+
</target>
261+
262+
<target name="hotcopy-tomcat-jar" depends="dist-jar" description="Hot copy JAR into the Tomcat shared/classes folder">
263+
<mkdir dir="${tomcat.home}/shared/lib" />
264+
<copy todir="${tomcat.home}/shared/lib">
265+
<fileset file="${dist.dir}/${jar.name}" />
266+
</copy>
267+
</target>
268+
269+
<!--
270+
Uncomment to enable web script reloading from Ant. These tasks use the HTTP Post task from
271+
http://ant-contrib.sourceforge.net/.
272+
273+
To use these tasks you will need to add ant-contrib.jar to your Ant libs, uncomment the task
274+
definitions at the start of this file and override the org/alfresco/index.post.js web script
275+
descriptor to set the authentication to 'none' (since the post task cannot handle HTTP
276+
authentication).
277+
-->
278+
<!--
279+
<target name="reload-webscripts-repo" depends="" description="Reload repository-tier webscripts">
280+
<post to="${tomcat.url}${webapp.alfresco.path}/service/index" failonerror="true" verbose="${post.verbose}">
281+
<prop name="reset" value="on" />
282+
</post>
283+
</target>
284+
285+
<target name="reload-webscripts-webtier" depends="" description="Reload web-tier webscripts">
286+
<post to="${tomcat.url}${webapp.share.path}/service/index" failonerror="true" verbose="${post.verbose}">
287+
<prop name="reset" value="on" />
288+
</post>
289+
</target>
290+
-->
291+
292+
<!--
293+
Uncomment to enable web application reloading from Ant. These tasks use the optional Tomcat
294+
ant tasks from catalina-ant.jar distributed with Tomcat.
295+
296+
To use these tasks you will need to add catalina-ant.jar to your Ant libs and uncomment the
297+
task definitions at the start of this file.
298+
-->
299+
<!--
300+
<target name="reload-webapp-alfresco" description="Reload alfresco web application" depends="">
301+
<reload
302+
url="${webapp.manager.url}"
303+
username="${webapp.manager.username}"
304+
password="${webapp.manager.password}"
305+
path="${webapp.alfresco.path}"/>
306+
</target>
307+
308+
<target name="reload-webapp-share" description="Reload share web application" depends="">
309+
<reload
310+
url="${webapp.manager.url}"
311+
username="${webapp.manager.username}"
312+
password="${webapp.manager.password}"
313+
path="${webapp.share.path}"/>
314+
</target>
315+
-->
316+
317+
</project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<webscript>
2+
<shortname>Site Blog</shortname>
3+
<description>Component used to show latest blog posts in the site</description>
4+
<family>site-dashlet</family>
5+
<url>/components/dashlets/site-blog</url>
6+
</webscript>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<#include "../component.head.inc">
2+
<!-- Site Blog -->
3+
<@link rel="stylesheet" type="text/css" href="${page.url.context}/res/components/dashlets/site-blog.css" />

0 commit comments

Comments
 (0)