Now available: Alfresco Fivestar Ratings add-on for Alfresco Share

A couple of weeks ago I posted a survey asking if anyone saw any value in a five star ratings widget for Alfresco Share. Honestly, it would have only taken one or two positive responses–even if no one needed one, there’s value in it for example’s sake. It turns out about 20 readers of this blog voted positively, so I went ahead and knocked it out.

This Alfresco Share customization makes it possible for any document in the repository to become “rateable”. When a document is rateable, the Alfresco Share user interface will show a clickable five star ratings widget. The stars light up to indicate the average rating for that document. Users simply click one of the stars to post their own rating. When clicked, the widget refreshes itself with the updated average.

Here is a short screencast that demonstrates the customization. You’ll want to make it full screen.

To implement this, I took the Someco Ratings Service from the Alfresco Developer Guide, moved it to the Metaversant namespace, and changed the names of my Spring beans and JavaScript root variable. Even though my initial target Alfresco version is 3.3, I didn’t want the code to conflict with Alfresco’s new back-end-only ratings service in 3.4 which uses some of the same names that were in the book. I also changed the JSON that the ratings web scripts use to be closer to what exists in 3.4. That way, when I do make a version that works with 3.4, it could potentially work with either my ratings back-end or Alfresco’s.

I then went to work on the UI side, integrating the widget into Share’s document details page, document library (both Share and repository views), search results page, and document-related dashlets. To go from what was in the book to a working integration I revamped the client-side ratings JavaScript from a set of functions to an actual object. Then, I started injecting my own methods into Alfresco’s client-side object prototypes to drop my widget in where appropriate.

Alfresco is still working to make customizations like this more modular and easier to plug in alongside their code and code from the community. Until then, be aware that if your Alfresco implementation already has customizations that override some of the same web scripts and client-side components this module does, there may be some manual integration needed. If you have an out-of-the-box installation (or a set of customizations that won’t conflict with this one) you can deploy the AMP to the Alfresco WAR and the Share customizations to the Share WAR and you’ll be set.

The Alfresco Fivestar Ratings project lives at Google Code. Feel free to check out the source, try it out, and use it on your projects. If you find a bug, log it, then fix it!

19 comments

  1. jpotts says:

    I have just updated the Google Code project with a version that works on 3.4 Enterprise and 3.4d Community.

    Jeff

  2. jpotts says:

    This isn’t supported in the code as-is, but it could be enhanced to work. There are two things you have to do: First, you have to make sure that the repo web scripts that return discussion/blog data also return rating stats. That’s why our code overrides some web scripts on the repo tier–so that when the document library, for example, calls the repo to get the list of items to show in a folder, it gets back the ratings data.

    Next, you’d need the ratings widget to show up in the UI for discussion/blog posts. At least in 3.3, Discussion didn’t use the form service. Not sure about blogs. If they did use the form service, you should theoretically be able to extend the form config for the discussion or blog object and drop in the rating field just like we’re doing with cm:content in the code provided. You would also have to update the discussion/blog head to add the reference to the client-side JS file.

    If they still don’t use the form service, you’d go find the html view for the related web script and drop in some markup that will create the ratings div in the right spot. And, as mentioned, update the web script’s get.head.ftl to add the client-side JS reference.

    From a data standpoint, the rateable aspect should have no problem being applied to discussions, blogs, or wikis. I believe the service adds the rateable aspect if it doesn’t exist, so you don’t have to worry about writing a behavior or a rule to make discussions/blogs rateable–you just post the rating and it should work.

    Using this approach, you could make every piece of content in Share rateable. If you try it and it works, please send me the code. That would be a nice contribution. If one of my teammates or I get a chance we might try this as well, but I doubt we’ll get to it within the next week or so.

  3. alove says:

    Jeff, this sounds very promising.

    Not having done any development of this nature in Alfresco I’ll take a deep breath and dive in! I will definitely contribute back should I have any success.

    Many thanks for your response.

  4. Alex says:

    Thanks for this cool extension, Jeff.

    Is anyone implementing fivestar rating also for blog, discussion and wiki?

  5. jpotts says:

    alove (see thread) was talking about doing it. None of us at Metaversant are working on it at the moment. Care to knock it out?

  6. Alex says:

    I think blog posts, discussions and wiki pages are more e2.0 compliant than document sharing 🙂 So, rating is very important for them.
    It is very likely that this feature (and “top rated content too” dashlet) will help to spread the use of all the tools in case of adoption of alfresco share as an E2.0 platform…

  7. Nirvan says:

    Hi ,

    I have installed the latest amp module in my share and I can see its effect while creating a document. Comment feature is enabled in Google Code Five Start Rating but Rating Feature is not at all Visible after Enabling all the Aspects and stuff.

    Plz guide.

  8. Nirvan says:

    Hi jpotts,

    Thanks for your reply.

    I have used that for Alfresco 3.4.d.

    That issue has already been raised.

    here I am not finding any link for Uploading a Screenshot.

    Plz Guide.

    -Nirvan

  9. jpotts says:

    Nirvan,

    I am looking at the issues log in the Google Code project for alfresco-fivestar-ratings and I don’t see a new issue from you.

    When you click “New Issue” you should see a link that says “Attach a file”. Use that to provide a screenshot of the problem.

    Thanks!

    Jeff

  10. Nirvan says:

    Hi jpotts,

    I havent raised that issues. Some body has raised that issue.

    I am still not able to see that rating functionality in my alfresco share.

    Thanks!

    -Nirvan

  11. Sam says:

    Hi,

    I just want to know if the latest version works with alfresco 4.0 ? if not, will you develop this addon for this alfresco 4.0 ?

    Thanks for your answer.

    Sam

  12. jpotts says:

    It more than likely does not work with Alfresco 4 in its current state. There are a lot of new extensibility features in Alfresco 4, especially in the document library. So, yes, I am planning on refactoring the add-on to work with Alfresco 4. I’m hoping the lines of code are significantly reduced by leveraging the extension points.

    Jeff

  13. Hi Jeff,

    One of our customers is after a rating service similar to this addon. They are on version 4.1. Is is supported on this version. Also, has Alfresco done any more with their rating service to include it in the UI (Other than liking content).

    Regards

    Brian

  14. jpotts says:

    Brian,

    I haven’t tested it with 4.1. It is possible it works, but what I’d really like to do is port it to the newer extension mechanisms that started to be made available in 4.1 and continue to evolve in 4.2. Or, if you have the time and skills to do it, that would be a welcome contribution to the code.

    There haven’t been any changes on the Share side with regard to liking/rating.

    Jeff

Comments are closed.