cancel
Showing results for 
Search instead for 
Did you mean: 

Rss

xerox
Champ in-the-making
Champ in-the-making
How can I make a rssfeed op a page in alfresco?
Is this possible?
10 REPLIES 10

xerox
Champ in-the-making
Champ in-the-making
I've just saw the rsstemplate.
Whate can you do with this? How does you use it?

kevinr
Star Contributor
Star Contributor
The RSS Template is a Freemarker template.

The output from the template can can be streamed without the Alfresco GUI using the Template Servlet

You must ensure that this template and the space where it resides and applies to is readable by Guest (Invite the Guest user) as you will need anonymous Guest access to allow RSS readers to use the template URL without going through the Alfresco login page.

So, to build a Template Servlet URL that exposes the result of the RSS template, you need to do a little setup work. Firstly, you need to edit the 'RSS_2.0_recent_docs.ftl' file and change the name of the hostname to the external name of your Alfresco server:
<#assign hostname="http://localhost:8080/alfresco">
to something like:
<#assign hostname="http://myserverurl:8080/alfresco">
As RSS clients will need to be able to see your Alfresco server! Smiley Happy

Secondly, you need to build the URL for the Template Servlet to execute. As the Wiki page above explains, this URL is built of 2 NodeRef elements. The first NodeRef is the reference to the template we want to execute (e.g. the RSS 2.0 template) and the second NodeRef is the reference to the space you want to execute the template against.

So you need to find the NodeRef for the template file (copy it from from the files Details page 'Alfresco Node Reference' link) and the NodeRef for the space you want to be your RSS feed source (also copy it from the Details page).

Once you have the NodeRefs, you can build the URL to the content servlet, so it will be something like this:
http://yourserver:8080/alfresco/template/workspace/SpacesStore/5e242b42-b028-11da-9d9b-85c44443370e/...

We are nearly done, however for an RSS client to understand the feed, we need to tell the Template Servlet to return the result as an XML mimetype, and also we need Guest access on the URL so the RSS client won't be presented with the Alfresco login page. So the final URL will look something like this:
http://yourserver:8080/alfresco/template/workspace/SpacesStore/5e242b42-b028-11da-9d9b-85c44443370e/...

You can paste this URL into an RSS feeder such as Thunderbird and it will work great.

So the URL is long and complicated yes - but in the future we will provide an RSS button on a space that does all this work for you! Smiley Happy But for now it shows the power of combining the templating functionality with Guest access and a little bit of cunning.

Hope this helps,

Kevin

xerox
Champ in-the-making
Champ in-the-making
Thanx…

lesteinb
Champ in-the-making
Champ in-the-making
Can the template be used for creating RSS feeds for podcasting?

What does the mimetype=text need to be changed to?

How can you add this to the template?

<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">

Thanks?

lesteinb
Champ in-the-making
Champ in-the-making
Nevermind. I figured it out. I modified RSS_2.0_recent_docs.ftl (see below)

:lol:

The mimetype remains text because it is really just creating an XML file that points to quicktime files. The trick is to replace the link with

  <enclosure url="${hostname}${child.url}" />




<?xml version="1.0"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">

   <channel>
      <ttl>Michigan Technological University (MTU)</ttl>
      <title>MTU on iTunes U</title>
      <copyright>Copyright © 2005 Alfresco Software, Inc. All rights reserved.</copyright>
      <#assign hostname="http://localhost:8080/alfresco">
      <#assign spaceref="${hostname}/navigate/browse/${space.nodeRef.storeRef.protocol}/${space.nodeRef.storeRef.identifier}/${space.nodeRef.id}">
      <#assign datetimeformat="EEE, dd MMM yyyy HH:mm:ss zzz">
      <link>${spaceref}</link>

<itunes:subtitle>Online Learning News and Resources</itunes:subtitle>
<itunes:author>Leroy Steinbacher</itunes:author>

      <description>Recent Lectures in '${space.name}'</description>
      <language>en-us</language>
      <lastBuildDate>${date?string(datetimeformat)}</lastBuildDate>
      <pubDate>${date?string(datetimeformat)}</pubDate>
      <ttl>120</ttl>
      <generator>Alfresco 1.2</generator>
      <image>
         <title>${space.name}</title>
         <width>32</width>
         <height>32</height>
         <link>${spaceref}</link>
         <url>${hostname}${space.icon32}</url>
      </image>
      <#assign weekms=1000*60*60*24*7>
      <#list space.childrenByXPath[".//*[subtypeOf('cm:content')]"] as child>
      <#if (dateCompare(child.properties["cm:modified"], date, weekms) == 1) || (dateCompare(child.properties["cm:created"], date, weekms) == 1)>


<itunesSmiley Surprisedwner>

<itunes:name>Leroy Steinbacher</itunes:name>

<itunes:email>lesteinb@mtu.edu</itunes:email>

</itunesSmiley Surprisedwner>

<itunes:image href="http://www.techonline.mtu.edu/images/online.jpg" />

<itunes:category text="Education">

<itunes:category text="Online Learning"/>

</itunes:category>

<itunes:category text="News"/>
      <item>
         <title>${child.properties.name}</title>
         <enclosure url="${hostname}${child.url}" />
         <description>
            ${"<a href='${hostname}${child.url}'>"?xml}${child.properties.name}${"</a>"?xml}
            <#if child.properties["cm:description"]?exists && child.properties["cm:description"] != "">
               ${child.properties["cm:description"]}
            </#if>
         </description>
         <pubDate>${child.properties["cm:modified"]?string(datetimeformat)}</pubDate>
         <guid isPermaLink="false">${hostname}${child.url}</guid>
      </item>
      </#if>
      </#list>
   
   </channel>
</rss>

kevinr
Star Contributor
Star Contributor
Nevermind. I figured it out. I modified RSS_2.0_recent_docs.ftl (see below)

That's cool, yes it should be possible to generate RSS template for any kind of feed, it's only XML after all Smiley Happy

For 1.4 we have added RSS feed support in the UI, there is now an extra panel on the Space Details page which allows you to select an RSS template for a space, it will generate the feed URL for you and add an RSS icon to the browse screen for that space. There is also a new folder in the Data Dictionary area specifically for storing RSS templates, so you can add yours and any others you create to that folder and they will be accessable for any space RSS feed.

Thanks,

Kevin

anhernandez
Champ in-the-making
Champ in-the-making
Alright so i got my link to the content and RSS template.

http://localhost:8080/alfresco/template/workspace/SpacesStore/7213f5c2-33a6-11db-a219-4d41e731d8be/w...

I get an error when trying to access my repository.  Here is the error.

org.alfresco.error.AlfrescoRuntimeException: Error during template servlet processing: IO Error during processing of the template 'workspace://SpacesStore/6ebe62af-33a6-11db-a219-4d41e731d8be'. Please contact your system adminstrator.
   org.alfresco.web.app.servlet.TemplateContentServlet.doGet(TemplateContentServlet.java:209)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

I have no cluse why i get this error or even how to fix it.  Any help would be appreciated.

note: the localhost:8080 is set this way because i am doing testing on my local machine.

kevinr
Star Contributor
Star Contributor
Have you made sure the Guest user is invited to view both the target space and the template itself? Also check the noderefs are correct.

You'll be pleased to know that in 1.4, RSS feed support (with the URLs generated for you) has been added to the web-client UI.

Thanks,

Kevin

anhernandez
Champ in-the-making
Champ in-the-making
I gave the guest user consumer rights to the template and the target space.  Double checked the noderefs and still can't access the rss feed without adding the template to the dashboard of the target space.

It works that way.  So, for know I will merely apply the dashboard.

Thanks for the help.