New RSS feed for releases.

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@410401 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
aheritier committed 2006-05-30 22:58:28 +00:00
1 parent b79ad3db5e
commit 7211ccab28
7 files changed
+153 -3

No files matched your search

@@ -0,0 +1,56 @@
package org.apache.maven.plugin.multichanges.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* This class provides a method to convert a date in the changes plugin format
* (yyyy-MM-dd) to a date in RSS format (RFC 822).
*
*/
public class RssDateFormatter {
/**
* The date format used in changes report file (changes.xml used in
* maven-changes-plugin).
*/
private final static SimpleDateFormat changesSDF = new SimpleDateFormat(
"yyyy-MM-dd");
/**
* The date format defined in RFC 822 and used in RSS feeds.
*/
private final static SimpleDateFormat rfc822DF = new SimpleDateFormat(
"EEE, dd MMM yyyy HH:mm:ss Z");
/**
* Log for debug output
*/
private static Log log = LogFactory.getLog(RssDateFormatter.class);
/**
* Converts a date in the changes plugin format (yyyy-MM-dd) to a date in
* RSS format (RFC 822).
*
* @param changesDate
* the date to convert
* @return the date in the RFC 822 format. An empty String if an exception
* occurs.
*/
public static final String convertDate(final String changesDate) {
try {
return rfc822DF.format(changesSDF.parse(changesDate));
} catch (ParseException e) {
if (log.isDebugEnabled())
log
.error("Unable to convert the date [" + changesDate
+ "]", e);
else
log.error("Unable to convert the date [" + changesDate + "] : "
+ e.getMessage());
return "";
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

@@ -2,7 +2,7 @@
<!--
* ========================================================================
*
* Copyright 2004 The Apache Software Foundation.
* Copyright 2004-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,8 +24,12 @@
<properties>
<title>Latest releases</title>
</properties>
<head>
<link rel="alternative" href="releases.rss" type="application/rss+xml" />
</head>
<body>
<section name="Latest releases">
<p>Get the RSS feed of the last releases <a href="releases.rss"><img src="images/rss.png"/></a></p>
<table>
<tr>
<th>Project name</th>
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* ========================================================================
*
* Copyright 2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ========================================================================
-->
<jsl:stylesheet select="$doc" xmlns:jsl="jelly:jsl" xmlns:x="jelly:xml" xmlns:j="jelly:core" xmlns="dummy" trim="false">
<!-- This needs to be instantiated here to be available in the template matches -->
<j:useBean var="rssDateFormatter" class="org.apache.maven.plugin.multichanges.util.RssDateFormatter"/>
<jsl:template match="releases">
<rss version="2.0">
<channel>
<title>${pom.name} releases</title>
<link>${pom.url}</link>
<description>${pom.name} releases</description>
<lastBuildDate>${currentDate}</lastBuildDate>
<language>en-us</language>
<copyright>Copyright ${currentYear} ${pom.organization.name}</copyright>
<x:set var="projects" sort="@date" descending="true" select="project[not(@date = 'Not released') and not(@date = 'No information available')]"/>
<j:forEach var="project" items="${projects}">
<j:set var="baseUrl"><x:expr select="$project/@url"/></j:set>
<j:set var="version"><x:expr select="$project/@version"/></j:set>
<j:set var="date"><x:expr select="$project/@date"/></j:set>
<item>
<title><x:expr select="$project/@name"/> <x:expr select="$project/@version"/> released.</title>
<link>${baseUrl}/announcements/announcement-${version}.txt</link>
<guid>${baseUrl}/announcements/announcement-${version}.txt</guid>
<pubDate>${rssDateFormatter.convertDate(date)}</pubDate>
</item>
</j:forEach>
</channel>
</rss>
</jsl:template>
</jsl:stylesheet>