Metadata Plugin 2

Name Metadata Plugin 2
Vendor Andy Armstrong
Authors Andy Armstrong, Kelsey Grant
Homepage http://confluence.atlassian.com/display/CONFEXT/Metadata+Plugin
Issue Management http://developer.atlassian.com/jira/browse/META
Categories Content Macros
Version 2.1.0
Availability Confluence v2.7 to v2.9-m2-r2
State Stable
License Freeware / Open Source (BSD)
Price Free
Release Docs http://confluence.atlassian.com/display/CONFEXT/Metadata+Plugin
Java API Docs n/a
Download Source http://svn.atlassian.com/svn/public/contrib/confluence/metadata-plugin/tags/2.1
Download JAR metadata-2.1.0.jar
Version 2 of the Metadata Plugin provides full metadata support for spaces, users, blog posts and attachments, as well as adding support for hierarchical spaces.

Description/Features

Version 2 is a major rewrite of the Metadata Plugin that extends the functionality in a number of directions. The highlights are as follows:

Space metadata

This release adds the same metadata functionality to spaces that the previous version provided for pages. There are a lot of useful reports that you can now generate automatically from your Wiki.

e.g. a report of all the spaces, all the spaces tagged with a specific label

The main improvement over the built-in Confluence support for showing spaces is that these reports can include columns with different metadata from the space. Some examples include the space's status, its owner, its purpose etc.

Hierarchical spaces

Version 2 of the plugin also provides the ability to define space hierarchies by utilizing space metadata. By default, Confluence provides a flat list of spaces, but as your wiki grows this becomes harder and harder to manage. For example, note that the Atlassian wiki has a large number of spaces, many of which could be grouped together. There are eight general Atlassian spaces, two for Bamboo, six for Confluence etc.

This plugin allows you to create new parent spaces (say one called "Confluence") and to parent other spaces into it. You simply attach a single piece of space metadata to the home page of the space indicating the key of its parent space. Note that this metadata is used to visually group spaces, but does not affect the existing Confluence permissioning scheme.

For example, to specify that the current space is a child of the dev space, you would add this to the home page:

{parent-space}dev{parent-space}

This hierarchy metadata is now available to all the other metadata macros. For example, a new space-breadcrumb macro is provided to render a new hierarchical breadcrumb for your pages from this information. In the following screenshot, you are looking at a page in the Development space, which is under the "New Product" space, which itself is under the "Root Space".

The new breadcrumb can optionally drop the 'Dashboard' link so that the home page is itself a space. This can allow Confluence to lose its administrative feel, and hence be used as a website for people who don't need to know that they are accessing a wiki.

See "Setting up hierarchical spaces" for details.

Metadata reports for users, blog posts and attachments

In addition to all the new functionality around spaces, version 2 also provides useful functionality for generating reports for users, blog posts and attachments.

For users, Metadata can either be posted to a user's profile or to their personal space, and then reports generated. For example, every user in a company could be requested to attach personal metadata such as work phone, cell phone, location etc. A company directory can then be generated that includes all of this information.

See the users-report macro for details.

Similarly, there are two new reports available for blog posts and attachments. See the blog-posts-report and attachments-report macros.

Alternative report styles

The Metadata Plugin has been generalized to allow alternate report styles to be provided. As with other Confluence macros, the style parameter is used to control the rendering. THe possible values are:

table The old-style tabular report.
list A bare-bones list representation, useful for a concise list of content.
ol A bulleted list representation.
ul An ordered list representation.

Here's an example of the four different styles when showing a blog posts report:

Support for dates

In order to fully benefit from all of the new metadata, the plugin has been extended to add full support for dates. Internally metadata used to be stored as strings, but the code base has been generalized to allow for arbitrary data types. This means that metadata collections can be sorted by date, and that date fields can use a custom renderer so that the user's date and time format preferences are obeyed.

Currently dates can only come from internal metadata such as a blog's post date, the last modified date of a page etc. The plan is to add support for user-supplied date metadata shortly.

Additional internal metadata

The following internal metadata can now be accessed from reports:

Attachment A link to the matching attachment.
Author The author of this piece of content.
Blog Post A link to the matching blog.
Comment The comment attached to an attachment.
Comments A link to the comments for a blog, along with a count.
Creator The creator of this piece of content.
Date The date that this content was last modified.
Download A link to download the attachment.
Email The email address for the owner of a space or personal profile.
Excerpt The excerpt from the page or blog.
File Size The size of an attachment.
File Type The attachment's file type.
Last Changed By The user that last changed this content.
Last Time Changed The time that this content was last changed.
Page A link to the matching page.
Parent A link to the parent of this page.
Posted The date that this piece of content was posted.
Poster A link to the user that posted this piece of content.
Size The size of the matching attachment.
Space A link to the space that this content belongs too.
Time The time that this content was last modified.
Time Created The time that this content was created.
Title The title of this piece of content.
Type The type of the attachment.
User The user that created this piece of content.
Version The version number of this piece of content.

Issues addressed

This release addresses a few of the issues reported against version 1:

Issue Summary Votes
META-44 Unable to install the Plugin with Confluence 2.3 7
META-24 Ability to do a report over profiles 0
META-13 Add the ability to poll Last Modified Date and User to reporting macros 3

In addition, the following general Confluence issues are addressed (some only partially):

Issue Summary Votes
CONF-5385 Provide {blog-posts} option to show concise list of titles 5
CONF-1095 Nested Spaces 59
CONF-2460 Home Page 8
CONF-4429 Breadcrumbs don't need to show space name and home page name when 'View Space Goes to Browse Space' is not set 9
CONF-5795 Breadcrumbs shouldn't hyperlink the current page 5

Usage

Metadata macros

The plugin provides the following new macros:

space-metadata Adds one piece of metadata to the space.
space-metadata-list Adds a list of metadata values to the space.
space-metadata-from Shows a metadata value from a space.
spaces-report Shows a tabular report of metadata from matching spaces.
space-hierarchy Shows a tree representation of the space hiearchy from the current space.
space-breadcrumbs Shows a tabular report of metadata from matching spaces.
users-report Shows a tabular report of metadata from matching user profiles and/or spaces.
attachments-report Shows a tabular report of metadata from matching attachments.
blog-posts-report Shows a tabular report of metadata from matching blog posts.

space-metadata macro

This lets you attach a single piece of metadata to a space (see the original metadata macro for the equivalent functionality for pages).

For example:

{space-metadata:location}Bedford, MA{space-metadata}

would render simply as:

Bedford, MA

but would also attach "location" as a piece of metadata to the page. Note that as with the other metadata macros, the metadata is stored as unrendered Wiki markup. The reporting macros then render the markup into the page they are used on. This usually works very well because links, emoticons etc can be used.

If you don't want the metadata to show on the page you can use the "hidden" parameter.

{space-metadata:location|hidden=true}Bedford, MA{space-metadata}

space-metadata-list macro

This macro allows the user to attach multiple pieces of metadata to a space with one macro. The main purpose of this is to make it allow a user to add metadata more concisely and to make the Wiki markup easier to read.

The following usage:

{space-metadata-list}
|| Location | Bedford, MA |
|| Extension | x1234 |
|| Cell Phone | 617 123-4567 |
{space-metadata-list}

adds three pieces of metadata to the space, as well as rendering the following output:

Location Bedford, MA
Extension x1234
Cell Phone 617 123-4567

An optional orientation=horizontal parameter changes the rendering to be horizontal. It will then render as follows:

Location Extension Cell Phone
Bedford, MA x1234 617 123-4567

space-metadata-from macro

This is a simple macro that can pull one piece of metadata from a space.

This space's owner is {space-metadata-from:Owner}

will just display as:

This space's owner is Andy Armstrong.

spaces-report macro

As with the standard metadata-report, this macro allows you to generate a report detailing the metadata attached to the matching spaces. There are a large number of internal metadata types that can be used, plus custom metadata can be attached using the space-metadata and space-metadata-list macros.

Here's a sample

{spaces-report:Space,Owner,Purpose,Last Changed By,Last Time Changed|sort=Last Time Changed desc}

which produces this result:

space-hierarchy macro

This is a very simple macro that shows the hierarchy beneath the current space.

For example:

h2. Spaces
{space-hierarchy}

shows this:

In addition, you can show the hierarchy beneath a different space using the space argument:

{space-hierarchy:space=dev}

space-breadcrumbs macro

This is a very simple macro that will add breadcrumbs to a page. In particular, it analyzes the space hierarchy information so that it includes all of the parent spaces up to the root space.

You can control the display of the breadcrumb using an optional second parameter. It can take any of the following three values:

dashboard Includes the standard 'Dashboard' link at the start of the breadcrumb
home Shows the 'Home' link in addition to the link to the space itself
dashboard+home Includes both 'Dashboard' and 'Home' links in the breadcrumb

By default, neither the 'Dashboard' link nor the 'Home' link are shown. Note that you should be careful before removing the 'Dashboard' link to make sure that all of the required functionality is available elsewhere in your site. I would suggest including the 'Dashboard' link initially until you are ready to give it up. Probably the best place to put it is in your root space, either on the home page or on an "Administration" subpage.

_Note: I plan to provide an example page that replicates all of the dashboard functionality.

users-report macro

As with the other report macros, you can generate a report of all the users, showing any metadata attached to the user. For users with personal spaces, the metadata is fetched from the space, while for regular users the metadata is fetched from their profile.

Here's a sample

{users-report:User,Location,Email,Extension,Cell Phone}

which produces this result:

blog-posts-report macro

As with the other report macros, you can generate a report of all the blog posts in a particular space. Here's some sample usages, which illustrate some of the different report styles.

h4. Table
{blog-posts-report:Title,Date,Time,Author,Comments,Time Created|sort=Time Created desc|maxResults=5}

h4. Plain list
{blog-posts-report:Title|sort=Time Created desc|maxResults=5|style=list}

h4. Unordered list
{blog-posts-report:Title|sort=Time Created desc|maxResults=5|style=ul}

h4. Ordered list
{blog-posts-report:Title|sort=Time Created desc|maxResults=5|style=ol}

and here is the resulting page:

attachments-report macro

As with the other report macros, you can generate a report of all the attachments on a single page. Here's an example usage:

{attachments-report:Attachment,Title,File Type,Size,Version,Download,Creator,Date,Time|sort=Time desc}

and here's how it looks on my home page:

Setting up hierarchical spaces

There are four steps to setting up Confluence for hierarchical spaces:

  1. Create a root space
  2. Create a 'Users' space
  3. Add parent metadata to every other space
  4. Update the breadcrumb

Create a root space

The first thing to do is to decide upon a root space. Most non-hierarchical Wiki installations would not currently have a root space, so in that case you should create one. It should probably have the same name as the Wiki itself, because it will be shown as the root of the breadcrumb. e.g. Progress Software's wiki now has a space called "Progress Wiki". Remember the space key designated for this space as that will be needed in subsequent steps.

I also recommend setting the root space to be the site home page for your site. You can set this in the Administration page, under Configuration/General Configuration.

Create a 'Users' space

In addition to having a root space, it seems to be useful to also have a users space. This is conceptually the parent space of every personal space, and helps to provide another level of structure. Note that this step is optional.

If you want a user space, you should put the following metadata into the home page (note that 'root' should be replaced with your root space's key):

{parent-space}root{parent-space}
{users-space}

You might also want to put a user report directly onto this page, assuming that you don't have many users. Something like this:

{users-report:User,Location,Email,Extension,Cell Phone}

Eventually this will provide a pageable report of all the users, but currently it shows every single user, so be careful!

Add parent metadata to every other space

Now you should go through all of your existing spaces and attach the parent space information to every page. For each space, find the space key of the parent, and then change the home page of the space to include:

{parent-space}PARENT_SPACE_KEY{parent-space}

Updating the breadcrumb

Unfortunately the plugin cannot directly change the site breadcrumb. Instead a new macro called space-breadcrumbs has been provided, and it has to be manually installed into your main site velocity template. Edit the Main Layout (found in the Administration page, under Look and Feel/Layouts) and replace the reference to:

<span class="topBarDiv"> #breadcrumbs() </span>

with:

#if ($spaceKey != '')
  $helper.renderConfluenceMacro("{space-breadcrumbs:$spaceKey:$title|dashboard}")
#else
  <span class="topBarDiv"> #breadcrumbs() </span>
#end
Some older version of Confluence call the variable $spacekey instead of $spaceKey, so the two references in the code above should be updated.

You can configure the display of the breadcrumb by specifying parameters to the space-breadcrumbs macro.

Version History

  • 2.0.0 - Initial release
  • 2.0.1 - Adds support for dates, blog posts and attachments and new renderers
  • 2.1.0 - Compatibility with Confluence 2.7. Note I have not back-tested this for compatibility, so it probably works a long way earlier than the indicated version.

Future Improvements

I hope to have the following functionality added in time for my Confluence entry:

  • Provide support for paging through large result sets
  • Ability to change the titles of columns (META-39)
  • Ability to use boolean logic when matching spaces, users and blog posts in reports

Slightly longer term I'm thinking about:

  • Allow the space hierarchy metadata to be edited as properties, rather than entered into Wiki pages

Screenshots

Screenshots
(view as slideshow)
       
  Users space illustrating a user-report macro   Simple page showing a hierarchy of spaces as a tree   Page showing hierarchical spaces in the breadcrumb  
 
       
  A blog report showing in a number of styles   A sample attachments report   A sample spaces report  
 

Labels

 
  1. May 11, 2007

    Guy Fraser says:

    Sweet! If you could make the spacebreadcrumbs macro default to the current spac...

    Sweet!

    If you could make the space-breadcrumbs macro default to the current space it could be used in sites themed with Adaptavist Theme Builder by simply replacing the builder-breadcrumbs macro in the Navigation panel

    Guy

  2. May 14, 2007

    Stuart Gilberd says:

    I'm getting a lot of: "Unable to show "metadatamatches" java.lang.NullPointerExc...

    I'm getting a lot of:

    "Unable to show "metadata-matches"
    java.lang.NullPointerException"

     Messages in my old content (copied from our confluence 2.2.7 with metadata 1.6 to our new test system running confluence 2.5.1) - all the other macros seem to be working fine.  Is there any thing I need to change to get metadata-matches working?

    1. May 14, 2007

      Andy Armstrong says:

      Hi Stuart, My testing missed this problem, but I can indeed reproduce the NullP...

      Hi Stuart,

      My testing missed this problem, but I can indeed reproduce the NullPointerException on my machine. I'll work on a fix for tomorrow if possible.

      Sorry for the inconvenience,

      • Andy
      1. May 14, 2007

        Stuart Gilberd says:

        Thanks so much Andy, I appreciate it. I'll look out for the new version tomorrow...

        Thanks so much Andy, I appreciate it.

        I'll look out for the new version tomorrow.

        1. May 14, 2007

          Stuart Gilberd says:

          And by tomorrow I mean when you get the time Sorry misread your post. :)

          And by tomorrow I mean when you get the time Sorry misread your post.

          1. May 14, 2007

            Andy Armstrong says:

            Well, that was easy. I've uploaded a fixed version now. The repository should up...

            Well, that was easy. I've uploaded a fixed version now. The repository should update within an hour.

            Let me know how it goes.

            • Andy
            1. May 15, 2007

              Stuart Gilberd says:

              that did the trick thanks Andy

              that did the trick - thanks Andy

  3. May 20, 2007

    Stuart Gilberd says:

    The pages attribute seems to have changed I'm getting a lot of these: Unknown pa...

    The pages attribute seems to have changed I'm getting a lot of these:

    Unknown pages code '@descendants'"

    Should I log this as a bug? 

    1. May 20, 2007

      Stuart Gilberd says:

      It looks like a change of spelling: @descendants has become @descendents

      It looks like a change of spelling: @descendants has become @descendents

      1. May 20, 2007

        Stuart Gilberd says:

        I see there is already a Jira ticket in for this: META52

        I see there is already a Jira ticket in for this: META-52

        1. May 29, 2007

          Andy Armstrong says:

          For those who aren't watching META52, this was fixed with version 2.0.3 a week o...

          For those who aren't watching META-52, this was fixed with version 2.0.3 a week or so ago.

  4. May 29, 2007

    Ray Johnson says:

    I'd like to get a spacesreport of all spaces that match a paticular team label.&...

    I'd like to get a spaces-report of all spaces that match a paticular team label.  Is that possible with this plugin?

    1. May 29, 2007

      Andy Armstrong says:

      Hi Ray, Yes, this works as you would expect. You just have to use the special t...

      Hi Ray,

      Yes, this works as you would expect. You just have to use the special team label syntax of team:TEAM_LABEL.

      e.g. I just used this to list all of the engineering spaces:

      {spaces-report:Status,Space,Date,Last Changed By|label=team:engineering}
      

      Let me know if you have any problems with this.

      Cheers,

      • Andy
      1. Sep 19, 2007

        Martijn Danse says:

        Is it also possible to somehow only report global spaces and leave out any perso...

        Is it also possible to somehow only report global spaces and leave out any personal spaces.

        Thanks,

        Martijn

        1. Sep 20, 2007

          David Dembo says:

          According to this comment

          According to this comment, you can reference metadata with the Reporting Plugin using the Data Supplier. I'm not sure if this could reference space metadata, but if you desperately need this functionality you might want to experiment...

          e.g. use a {space-reporter} macro to grab all spaces, then use a {boolean-filter} to filter out personal spaces (see the Space Supplier), and then use the data supplier to populate columns in the report table with space metadata.

          1. Mar 08

            Bill Bennett says:

            Has anyone confirmed that one can include Space Metadata in a report created wit...

            Has anyone confirmed that one can include Space Metadata in a report created with the Reporting Plugin?

            I am trying to organize my spaces by Location, Team, Project ID, Type, and Status. I have successfully attached this space metadata and can use the space-reporter to show a table of this information for all spaces.

            But I am going to have large amounts of spaces so I need to get a little more complex with it and filter the results down. I need to have a report, for example, that will show all of the Chicago and San Francisco spaces for Jim's team that have an "Active" status. On that report I'd like to list space meta data like Project ID's and Types.

            Am I barking up the right tree in general? Is some combo of MetaData 2 and Reporting Plugin's the way to go? Should I be looking into Scaffolding?

            1. Mar 08

              David Peterson says:

              I would be somewhat surprised if reporting supported using space metadata I beli...

              I would be somewhat surprised if reporting supported using space metadata - I believe it currently expects metadata to only be present in pages and news items.

              With regards to Scaffolding, you can only really use that on pages, so it won't work too well at the space level either.

              I have a feeling that getting it working on space metadata will be a simpler task, but isn't currently implemented. If it's something you'd like to see in a future version, the best thing is to create a feature request so it will be on the radar for the next release.

  5. Jun 04, 2007

    James Mortimer says:

    still gives the title from pageX, but no longer gives the excerpt for pageX.

    {metadata-from:Title|pageX}{metadata-from:Excerpt|pageX}
    still gives the title from pageX, but no longer gives the excerpt for pageX.

    1. Jun 07, 2007

      Damon Rand says:

      Hi, We too lose our excerpts when we upgrade to the metadata2 plugin.. We are ...

      Hi,
      We too lose our excerpts when we upgrade to the metadata2 plugin.. We are running Confluence 2.4.2 right now.

      Damon.

  6. Jun 14, 2007

    Ross Sharrott says:

    Is anyone having trouble with addition and sorting of decimals?&nbsp; I have a m...

    Is anyone having trouble with addition and sorting of decimals?  I have a metadata report that pulls sales results from individual salesmen's pages.

    The problem is that the addition sometimes returns really long decimals even though the inputs only go out to 4 digits.

    Also, sorting on whole numbers seems fine, but decimals sometimes sort out of order.

    Example:
    Input: 4.416
    Input: 3.45
    Input: 2.16
    Input: 2.45
    Total: 17.875999999999998

    I opened a Jira bug: meta-55
    Anyone else encountered this problem?

  7. Jun 18, 2007

    Kerry Geiger says:

    I'm trying to use the spacemetadatafrom macro on my dashboard by using the helpe...

    I'm trying to use the space-metadata-from macro on my dashboard by using the helper:  $helper.renderConfluenceMacro("

    Unknown macro: {space-metadata-from}
    ")

     and I'm getting a java.lang.NullPointerException error. Is there a way to do this?

    It would change my life.

    1. Jun 18, 2007

      Andy Armstrong says:

      The problem is that when you render a macro like that, it doesn't have the page ...

      The problem is that when you render a macro like that, it doesn't have the page context, so it can't determine the space for itself. Try doing:

      #helper.renderConfluenceMacro("space-metadata-from:$spaceKey")
      

      I haven't tried this, but it should work.

      • Andy
      1. Jun 19, 2007

        Kerry Geiger says:

        Thanks Andy. I found the the following renders correctly on the dashboard, it s...

        Thanks Andy.

        I found the the following renders correctly on the dashboard, it seems like order of parameters was important:

        $helper.renderConfluenceMacro("{metadata-from:spacekey:Page Name|metadata}")

        When I used space-metadata-from I got an error.

        Thank you for your help and your plugin rocks!

        • Kerry
  8. Jun 25, 2007

    Jacqueline Leslie says:

    Hi,...

    Hi,

    I am trying to create a template based on the metadata-list such as:

     
    {metadata-list}
    ||Term | Enter the term|
    ||Acronymn | Enter the Acronymn|
    ||Description | Enter a Description|
    ||Source | Enter the Source |
    {metadata-list}
    

    But I get this:

     
    {warning:title=Unable to show "metadata-list"}Attempted to set metadata value  for null ContentEntityObject{warning}
    

    I am using 2.5.4. 

    Any ideas why this is occuring?

    Thanks, Jackie.

  9. Jul 05, 2007

    David Aldrich says:

    Hi, we have a problem with the spacehierarchy macro.&nbsp;Our Server Base URL is...

    Hi,

    we have a problem with the space-hierarchy macro. Our Server Base URL is:

    https://aaa.bb.cc.dd/confluence

    But the URLs created by the space-hierarchy macro strip '/confluence' from the URL. For example:

    https://aaa.bb.cc.dd/confluence/display/RsdInv

    becomes

    https://aaa.bb.cc.dd/display/RsdInv

    So the links fail. Is this a bug in the macro or are we using it incorrectly?

    David

    1. Jul 10, 2007

      chris m says:

      Hi, we have exactly the same problem. chris

      Hi,
      we have exactly the same problem.
      chris