Dashboard > blojsom 3.0 > ... > Plugins > RSS Enclosure Plugin
  blojsom 3.0 Log In   View a printable version of the current page.  
  RSS Enclosure Plugin
Added by David Czarnecki, last edited by David Czarnecki on Jul 10, 2007  (view change)
Labels: 
(None)

Description

The RSS enclosure plugin allows you to attach a file to your blog entry as an enclosure element that would be picked up by RSS enclosure-aware aggregators. This is useful for podcasting.

This plugin requires use of the Meta plugin.

Installation and Setup

In your /WEB-INF/classes/blojsom-plugins.xml file, add the following:

<bean id="rss-enclosure" class="org.blojsom.plugin.common.RSSEnclosurePlugin" init-method="init" destroy-method="destroy">
        <property name="servletConfig">
            <ref bean="servletConfigFactoryBean"/>
        </property>
        <property name="eventBroadcaster">
            <ref bean="eventBroadcaster"/>
        </property>
        <property name="blojsomProperties">
            <ref bean="defaultProperties"/>
        </property>
    </bean>

You may then add "rss-enclosure" to one of the flavor-based plugin chains. It must occur after the meta plugin if you are using the metadata within an entry to create an enclosure.

Usage and URL Parameters

Usage

1. Upload a file you want to attach to your blog entry. This should be done through the web interface as this plugin looks for the enclosure file in your blog's resources directory.

2. On adding or editing an entry, this plugin will modify the entry page to allow you to select a file from your resources directory as an RSS enclosure. You may also provide explicit values for the enclosure using the form items for those values.

Alternatively, create an entry and use the meta-rss-enclosure on a blank line with the name of the file you just uploaded.

The following is a sample blog entry:

The daily podcast entry title

meta-rss-enclosure=10-18-2004-podcast.mp3

BEHOLD! A new podcast for your listening pleasure!

After the RSS enclosure plugin executes, it will populate the meta-data of that blog entry with an item rss-enclosure. This item contains the proper <enclosure .../> element as given by the RSS 2.0 specification. In the example entry above, this might look like:

<enclosure url="http://your.site.com/blog/resources/default/10-18-2004-podcast.mp3" length="51680279" type="audio/x-mpeg"/>

If the RSS enclosure plugin cannot determine the correct MIME type for the enclosure item, it will use a default type of application/octet-stream.

3. You may extract the enclosure element in your RSS 2.0 template by including the following template code before the closing </item> tag:

$!entry.getMetaData().get("rss-enclosure")

For example, adding this to rss2.vm would look as follows:

...
<item>
    <title>$entry.getEscapedTitle()</title>
    <link>$entry.getEscapedLink()</link>
    ...
    $!entry.getMetaData().get("rss-enclosure")
</item>
...

Alternatively, you may use the #RSSEnclosure($entry) macro to print out the enclosure information in a template. The above example would change to the following:

...
<item>
    <title>$entry.getEscapedTitle()</title>
    <link>$entry.getEscapedLink()</link>
    ...
    #RSSEnclosure($entry)
</item>
...

URL Parameters

There are no URL parameters that affect the operation or output of this plugin.

Metadata Attributes and Types

The following table describes the metadata attributes that are available on the Entry object and their associated type. This information is only populated in an entry's metadata if there is an associated enclosure with the entry.

In your template, you would retrieve the metadata through a call like:

$entry.getMetaData().get("metadata-key")

Metadata key Type Description
rss-enclosure String RSS enclosure element populated with data about the RSS enclosure associated with the particular entry.
rss-enclosure-object org.blojsom.plugin.common.RSSEnclosure Helper class which holds the information about the enclosure. You can call the getUrl(), getLength(), and getType() methods on this object.

Site running on a free Atlassian Confluence Open Source Project License granted to blojsom. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators