Highly configurable RSS feeds for web content and Struts action hooks

RSS (Really Simple Syndication) is a family of web feed formats used to publish frequently updated works—such as blog entries, news headlines, audio, and video—in a standardized format. A web feed (or news feed) is a data format used for providing users with frequently updated content. Content distributors syndicate a web feed, thereby allowing users to subscribe to it.

Liferay portal first provides secure RSS feeds (see Ray’s blogs post). All secure RSS feeds transparently support BASIC Authentication. Liferay portlet supports RSS feed type: ATOM 1.0, RSS 1.0 and RSS 2.0.
Liferay portal provides RSS feed for its content types like blogs entries, web content articles (by feeds), message boards threads, wiki pages, and so on.

Message Boards threads (using Struts Action): 

/c/message_boards/rss?p_l_id=10447&mbCategoryId=10157

Blogs entries (using Struts PortletAction): 

/web/guest/test/-/blogs/rss

Wiki pages (using Struts Action): 

/c/wiki/rss?p_l_id=10447&companyId=10132&nodeId=11635&title=FrontPage&type=rss&version=2.0

Asset Publisher (using Struts PortletAction): 

/web/guest/test/-/asset_publisher/7Pnm/rss?p_p_cacheability=cacheLevelPage

Web content feeds (use case I - using Struts PortletAction):

/web/guest/home/-/journal/rss/11301?doAsGroupId=10157&refererPlid=10447&_15_groupId=10157

Especially the portal provides RSS feeds for web content in following URLs:

Use case II (using Action): for a list of articles, including different versions

/c/journal/get_articles?groupId=@value@[&templateId=@value@][&structureId=@value@][&orderBy=@value@][&orderByType=@value@][&orderByCol=@value@][&type=@value@][&displayDateGT=@value@][&displayDateLT=@value@][&delta=@value@]

Use case III (using Action): for a given article by article ID

/c/journal/get_article?groupId=@value@&articleId=@value@

Above features are very useful in many use cases. Here let’s consider different requirements:

  • Use Case A: Web content RSS feeds should be presented in authentication public path, like /c/web_content/rss
  • Use Case B: Web content RSS feeds should be able to feed articles by different article types like press-release, feature, and types combination like press-release and feature
  • Use Case C: Web content RSS feeds should be able to feed articles by authors
  • Use Case D: Web content RSS feeds should be ordered by either modified date or display date; and only show the latest version.

This article will first address an implementation for above use cases (A, B, C, D) in Liferay 6; then it will show how to leverage Struts action hooks to implement above use cases in Liferay 6.1.  

Making RSS feeds of web content highly configurable

In order to make RSS feeds configurable, add following properties.

## Custom RSS feeds

## default type and version: ATOM 1.0, RSS 1.0, RSS 2.0
custom.rss.default.type=atom
custom.rss.default.version=10

## custom RSS feeds display
## display style: abstract, full-content, content, title
custom.rss.display.style=content

## set default content field
## if custom.rss.display.style is set to content
custom.rss.default.content.field=CONTENT

## set maximum characters
custom.rss.display.length=350

## set default content type
custom.rss.default.content.type=press-release

## set default maximum value
custom.rss.default.delta.max=50

## enable or disable to display author
custom.rss.display.author.enabled=false

## Custom RSS feeds links URL
## enable or disable RSS links URL
## custom.rss.link.preview.enabled is in use if
## custom.rss.link.enabled is set to true.
## custom friendly URL like /${content.type}/${id}/${title} will be in use when
## custom.rss.link.preview.enabled is set to false and
## custom.rss.link.friendly.url.enabled is set to true
custom.rss.link.enabled=true
custom.rss.link.preview.enabled=false
custom.rss.link.friendly.url.enabled=true

## Custom RSS feeds title prefix
custom.rss.title.prefix=The Network
custom.rss.title.author.prefix=Contributed Articles by

## Custom RSS feeds via author
## possible values: press-release, feature
custom.rss.author.content.type=feature

New features in Liferay 6

Leveraging auth public path: /c/journal/get_articles, customize GetArticlesAction extending Action

Testing results:

Press releases

Features

Press releases and features

Features by author

Using Struts action hooks in Liferay 6.1 

In brief, there are several kinds of hooks: portal properties, language properties, custom JSP, indexer post processors, service wrappers, servlet filters and servlets mapping, and struts actions in Liferay 6.1.

Struts action hook provides capabilities to override existing struts action and / or add new struts actions from plugins. With struts action hook, you can either add new struts actions to the portal core from plugins, or override any existing action within the portal core from plugins.

Above use cases (A, B, C and D, using auth public path /c/web_content/rss) could be implemented through portal properties and struts actions in following steps.

First, edit the liferay-hook.xml and add following fragment.

<hook>
   <portal-properties>portal.properties</portal-properties>
   <struts-action>
      <struts-action-path>/web_content/rss</struts-action-path>
      <struts-action-impl>com.liferay.knowledgebase.hook.action.RSSAction</struts-action-impl>
   </struts-action>
</hook>

As shown in the above code, it specified at least three kinds of hooks: portal properties hooks and struts action hooks.

Secondly, add following line in the portal.properties.

auth.public.paths=/web_content/rss

The property auth.public.paths specifies public paths that don’t require authentication.

Last but not least, implement same logic in the com.liferay.knowledgebase.hook.action.RSSAction, which extends BaseStrutsAction implementing StrutsAction.

Abstracted from the book: Liferay Systems Development - Liferay Cookbook (coming out soon).

Summary

As you can see, new features (implementing use cases A, B, C, D) make RSS feeds of web content highly configurable - related ticket LPS-16041.  In Liferay 6 or previous versions, these features were implemented as a fix patch, while same features were implemented in the plugin via portal properties hook plus struts actions hook.

Are these features useful?

Any suggestions or comments?

Blogues
I Need Help!!
I'm trying to do some like a "Communities Clone".. I want to now how to add Control Panel at Portal section a new tab called "Project"
So, the Portal section on Liferay Control Panel will look like:
-Users
-Organizations
-Communities
-"Projects"
-....
-etc.
Hi Melvin, thanks.

The Control Panel is highly configurable. But for your requirements, you can develop a new plugin and add same navigation as that of Control Panel.

Hope that it helps,
The portlet of the control panel is enterprise_admin, isn't it???
So on it portlet I'm looking for the tab of communities, but I can't see it.
Thanks!
Hi Melvin, you may check communities admin portlet - like communities_admin.
communities_admin portlet exists?
Hi Melvin, gave you data for different version. You can find My Communities portlet and JSP at /communities in 6.0 or previous versions.

Hope that this helps.
I am new in liferay. Company logo does not display with brochure theme. When I switch back to the classic theme it displays. I have changed it from Control Panel (dockbar) -> Portal -> Portal Settings (left menu) -> Display Settings (right menu). Can anyone help me in this issue?
Hi Fais, you may refer to the book: Liferay User Interface Development at http://www.amazon.com/Liferay-User-Interface-Development-Yuan/dp/1849512620

Hope that it helps.
Hi Jonas, may I ask where should i put the RSS properties at ? Is it at portal-ext.properties? I placed it in the file but it doesn't seem to be working
Hi Mucheng, thanks.

You do need the fix patch for this feature. Which version are you using? CE 6.0.6? or EE 6.0?
Hi Jonas,

Thank you for replying. I'm using CE 6.0.6
I notice from your article that the latest version of the web content should only be displayed (Use case D) . My feed displays all the previous approved versions, which I need to exclude . I'm using Liferay v6. Please can you advise where I configure this? Thanks Vicky
Hi Vicky, you can check real example:

http://newsroom.cisco.com/c/journal/get_articles?cmd=rss&groupId=10157&limit=20&contentType=release

limit=10|20|...

Is it what you look for?

Thanks

Jonas
My RSS feed from forum is broken,
https://www.appex.com/en/web/boite-a-idees/home/-/message_boards/rss?p_l_id=4123­4&_19_mbCategoryId=41224&

p_l_id has no value causing 404 error.