wabson

Enhancing your Repository Web Scripts

Blog Post created by wabson Employee on Jun 1, 2011
I reorganised the front page of Share Extras the other week to organise the growing list of add-ons by type, which should hopefully make it easier to find specific extensions.



Today I added a new type on the front page, Pages, in order to categorise the latest add on - Content Expiration.







The new add-on is interesting for a couple of reasons. Firstly it contains a number of different types of extensions, which (like all the other add-ons on the site) are all bundled in a single JAR file.





  • A custom model that defines a new Validity aspect


  • A repository web script to return a list of all 'expired' content items


  • A custom dashlet to allow a user to quickly see his or her expired items


  • A full page definition to display a more detailed report for a user (or for all users)





It's also interesting because the add-on started out as a single basic web script, which together with the custom model, we put together for the first version of the Alfresco Partner Site. If you take a look at the repository web script still has a HTML template attached to it, which provided the original user interface.



The basic steps we went through to adapt it for the Share UI could equally be applied to any basic repository web script. I wanted to share our approach as not only can it be used to bring your legacy web scripts up-to-date, but it's also a perfect way of prototyping your extensions. First start off with a basic repository script, then build up a richer web-tier layer on top.





  1. Define your basic repository script, by defining a JavaScript controller and a HTML template to present the data


  2. Once you're happy with your data, add a JSON template to the script to provide a machine-readable representation


  3. Now define a basic Share dashlet, pulling in data from the repository script as JSON


  4. If you're tight on space in the dashlet, you can always link to the HTML version of the repository web script for the full report


  5. Finally add a full-page version of your dashlet as a custom user or site page, and provide a link to this from the dashlet





I'll follow up with a more detailed walk-through of this process, but in the meantime I'm interested to know if you have used a similar methodology in your own projects.



You can download version 0.1 of the Content Expiration add-on from the Downloads page.

Outcomes