This widget displays the names of recently registered users. Through
one of its properties, you can specify the number of users that should
be listed.
NOTE: this plugin / widget is designed to be example code and ONLY works if you're using a MySQL database.
The example code here illustrates how to:
Expose custom widget properties.
Retrieve user information from the Clearspace database.
Display data using a FreeMarker template.
build.xml -- Ant build file.
plugin.xml -- Plugin descriptor required by Clearspace.
resources/userstats.ftl -- FreeMarker template for displaying user data.
src/com.jivesoftware.clearspace.plugin.widget.UserStatsWidget.java -- Main widget class.
src/com.jivesoftware.community.impl.UserStatsManager.java
-- Class with logic for connecting to the database and retrieving user
information.
src/com.jivesoftware.community.impl.UserDTO.java -- Class representing user information in the widget.
The Ant build.xml file at the root of the plugin includes a
build.plugins target you can use to compile the code and package it
into a JAR file. There's also a deploy.plugins target that copies the
JAR into the <jiveHome>/plugins directory that accompanies your
Clearspace distribution.
Be sure to read the notes below about dependencies. The JAR files you'll need are included as part of Clearspace.
Build and deploy the code.
Open Clearspace
and begin customizing a space overview. To do this, navigate to a space
for which you are a space administrator (note: you can't customize the
root space).
Drag the User Statistics widget onto the layout, edit its properties, then publish the layout to see the statistics.
In addition to requiring Java 1.5, this code requires a few of the
libraries you'll find in the WEB-INF/lib directory of your Clearspace
installation, listed below.
clearspace-<version>.jar
freemarker.jar
If you'd rather deploy the plugin manually, you can do that in one of two ways:
Just copy the plugin JAR file into the
<jiveHome>/plugins directory. Your running Clearspace instance
will deploy it automatically.
Open the admin console and navigate to System > Settings > Plugins, then browse for your plugin JAR file.
The attached file contains the jar file or you can get all of the source files from svn.
After installing I tried customizing a community page and pulled the User Statistics widget on to it.
Got error
Failed to render this widget. An unexpected error has occured.
What did I do wrong?
Hi Jack..
As a matter of interest, I got the same message:
Failed to render this widget. An unexpected error has occured.
I am running CS 2.0.3 and downloaded the userstats-cs2.zip
I extracted the jar file and uploaded it via the admin portal.
I then went into my homepage and dragged the User Statistics widget into my page - thats it..
Any thoughts Dawn?
Cheers
Nathan
Apologies for the errors everyone. I've updated the plugin for 2.0.4 and it will be uploaded within the next day or so (it's in the queue).
hi everyone,
The user stats plugin has been updated for Clearspace 2.0 and Clearspace 2.5.
Rick: note that the plugin now lives in three SVN directories:
https://svn.jivesoftware.com/svn/dev/repos/jive/clearspace/userstats/
https://svn.jivesoftware.com/svn/dev/repos/jive/clearspace_2_0/userstats/
https://svn.jivesoftware.com/svn/dev/repos/jive/clearspace_2_5/userstats/
Cheers,
AJ
Good Examples. Thanks
I found a minor bug in the link from the Example Profile Action or the Example Profile Tab, if you are viewing the profile of someone other than yourself. The link for user 2001 is "example-profile.jspa?userID=2,001", so I guess the ID must be the formatted string version and not a numeric. I have not looked at the code yet, but I will when time allows.
Okay, I looked at plugin.xml. It outputs the URL using this in an FTL tag:
@s.url value="/example-profile.jspa?userID=${targetUser.ID}"
Why does the ID, which should be numeric, have a comma, like it is localized or formatted? I can;t find a reference to targetUser anywhere. Where does it come from?
Installing the jar file into a test clearspace install with the embedded database kills the server for me, requiring a restart. There is nothing obvious in the logs other then error messages about not being able to find the userstats.ftl (a global template is setup).
Also, from this page:
"widget displays the names of recently registered users."
And from the plugin description in the admin console:
"Displays currently logged in user info (number of users, and last n usernames)"
They can't both be right.