You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by he...@apache.org on 2006/12/31 18:12:19 UTC
svn commit: r491447 - in /velocity/site/velocity-news-plugin: ./ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/velocity/ src/main/java/org/apache/velocity/maven/
src/main/java/org/apache/velocity/ma...
Author: henning
Date: Sun Dec 31 09:12:17 2006
New Revision: 491447
URL: http://svn.apache.org/viewvc?view=rev&rev=491447
Log:
Maven 2 Plugin to generate news page in the site.
Added:
velocity/site/velocity-news-plugin/ (with props)
velocity/site/velocity-news-plugin/pom.xml (with props)
velocity/site/velocity-news-plugin/src/
velocity/site/velocity-news-plugin/src/main/
velocity/site/velocity-news-plugin/src/main/java/
velocity/site/velocity-news-plugin/src/main/java/org/
velocity/site/velocity-news-plugin/src/main/java/org/apache/
velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/
velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/
velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/
velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/
velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/AbstractVelocityNewsReport.java (with props)
velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsPageGenerator.java (with props)
velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsReport.java (with props)
velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsReportUtils.java (with props)
velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/VelocityNewsReport.java (with props)
velocity/site/velocity-news-plugin/src/main/mdo/
velocity/site/velocity-news-plugin/src/main/mdo/news.mdo
velocity/site/velocity-news-plugin/src/main/resources/
velocity/site/velocity-news-plugin/src/main/resources/velocity-news-report.properties (with props)
Propchange: velocity/site/velocity-news-plugin/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Dec 31 09:12:17 2006
@@ -0,0 +1,4 @@
+.classpath
+.settings
+.project
+target
Added: velocity/site/velocity-news-plugin/pom.xml
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-plugin/pom.xml?view=auto&rev=491447
==============================================================================
--- velocity/site/velocity-news-plugin/pom.xml (added)
+++ velocity/site/velocity-news-plugin/pom.xml Sun Dec 31 09:12:17 2006
@@ -0,0 +1,152 @@
+<?xml version="1.0" encoding="UTF-8"?><project>
+ <parent>
+ <artifactId>apache-velocity-site-parent</artifactId>
+ <groupId>org.apache.velocity</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity-news-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+ <name>Velocity News Plugin</name>
+ <version>0.0.1</version>
+ <description>This plugin generates a news page and rss feed from news items. It also allows timed display of these items and
+ integration into other pages through doxia macros.</description>
+ <url>http://people.apache.org/~henning/velocity-news-plugin/</url>
+ <inceptionYear>2006</inceptionYear>
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/velocity/site/velocity-news-plugin/</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/velocity/site/velocity-news-plugin/</developerConnection>
+ <url>http://svn.apache.org/viewvc/velocity/site/velocity-news-plugin/</url>
+ </scm>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.modello</groupId>
+ <artifactId>modello-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>descriptor</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>xpp3-writer</goal>
+ <goal>java</goal>
+ <goal>xpp3-reader</goal>
+ <goal>xsd</goal>
+ </goals>
+ <configuration>
+ <model>src/main/mdo/news.mdo</model>
+ <version>1.0.0</version>
+ </configuration>
+ </execution>
+ <execution>
+ <id>descriptor-site</id>
+ <phase>pre-site</phase>
+ <goals>
+ <goal>xdoc</goal>
+ <goal>xsd</goal>
+ </goals>
+ <configuration>
+ <model>src/main/mdo/news.mdo</model>
+ <version>1.0.0</version>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-maven-plugin</artifactId>
+ <version>1.2</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.reporting</groupId>
+ <artifactId>maven-reporting-impl</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ </dependencies>
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>dependencies</report>
+ <report>license</report>
+ <report>summary</report>
+ <report>scm</report>
+ <report>project-team</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <configLocation>config/checkstyle.xml</configLocation>
+ <headerLocation>config/apache-header.txt</headerLocation>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>taglist-maven-plugin</artifactId>
+ <configuration>
+ <tag>TODO</tag>
+ <tag>FIXME</tag>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jxr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <links>
+ <link>http://java.sun.com/j2ee/1.4/docs/api</link>
+ <link>http://jakarta.apache.org/commons/collections/apidocs-COLLECTIONS_3_0/</link>
+ <link>http://jakarta.apache.org/velocity/api/</link>
+ </links>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-changelog-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+ <distributionManagement>
+ <site>
+ <id>velocity.apache.org</id>
+ <url>scpexe://people.apache.org/home/henning/public_html/velocity-news-plugin</url>
+ </site>
+ </distributionManagement>
+</project>
Propchange: velocity/site/velocity-news-plugin/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: velocity/site/velocity-news-plugin/pom.xml
------------------------------------------------------------------------------
svn:keywords = Id Author Date Revision
Added: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/AbstractVelocityNewsReport.java
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/AbstractVelocityNewsReport.java?view=auto&rev=491447
==============================================================================
--- velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/AbstractVelocityNewsReport.java (added)
+++ velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/AbstractVelocityNewsReport.java Sun Dec 31 09:12:17 2006
@@ -0,0 +1,131 @@
+package org.apache.velocity.maven.plugin.news;
+
+import java.io.File;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.apache.maven.doxia.parser.Parser;
+import org.apache.maven.doxia.siterenderer.Renderer;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.reporting.AbstractMavenReport;
+
+/**
+ * Generate news items for the site.
+ *
+ * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
+ * @version $Revision$
+ *
+ */
+public abstract class AbstractVelocityNewsReport extends AbstractMavenReport {
+
+ /**
+ * @component
+ * @required
+ * @readonly
+ */
+ protected Renderer siteRenderer;
+
+ /**
+ * The Maven Project Object
+ *
+ * @parameter default-value="${project}"
+ * @required
+ * @readonly
+ */
+ private MavenProject project;
+
+ /**
+ * Specifies the directory where the report will be generated
+ *
+ * @parameter default-value="${project.reporting.outputDirectory}"
+ * @required
+ */
+ protected File outputDirectory;
+
+ /**
+ * Directory containing the site files.
+ *
+ * @parameter expression="${basedir}/src/site"
+ * @required
+ */
+ private File siteDirectory;
+
+ /**
+ * Configuration of the name of the news file to read.
+ *
+ * @parameter expression="${newsfile}" default-value="news"
+ */
+ protected String newsfile;
+
+ /**
+ * Apt Parser for running the news items.
+ *
+ * @component role-hint="apt"
+ */
+ private Parser aptParser;
+
+ /**
+ * @see org.apache.maven.reporting.AbstractMavenReport#getOutputDirectory()
+ */
+ protected String getOutputDirectory()
+ {
+ return outputDirectory.getAbsolutePath();
+ }
+
+ /**
+ * @see org.apache.maven.reporting.AbstractMavenReport#getProject()
+ */
+ protected MavenProject getProject()
+ {
+ return project;
+ }
+
+ /**
+ * @see org.apache.maven.reporting.AbstractMavenReport#getSiteRenderer()
+ */
+ protected Renderer getSiteRenderer()
+ {
+ return siteRenderer;
+ }
+
+ /**
+ * @see org.apache.maven.reporting.MavenReport#getOutputName()
+ */
+ public String getOutputName() {
+ return "news";
+ }
+
+ /**
+ * @see org.apache.maven.reporting.MavenReport#getDescription(java.util.Locale)
+ */
+ public String getDescription(final Locale locale) {
+ return getBundle(locale).getString("report.news.description");
+ }
+
+ /**
+ * @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale)
+ */
+ public String getName(final Locale locale) {
+ return getBundle(locale).getString("report.news.name");
+ }
+
+ /**
+ * @see org.apache.maven.reporting.AbstractMavenReport#canGenerateReport()
+ */
+ public boolean canGenerateReport()
+ {
+ return true; // For now.
+ }
+
+ protected File getSiteDirectory() {
+ return siteDirectory;
+ }
+
+ public ResourceBundle getBundle(final Locale locale) {
+ return ResourceBundle.getBundle( "velocity-news-report", locale, VelocityNewsReport.class.getClassLoader() );
+ }
+
+ public Parser getAptParser() {
+ return aptParser;
+ }
+}
Propchange: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/AbstractVelocityNewsReport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/AbstractVelocityNewsReport.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Revision
Added: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsPageGenerator.java
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsPageGenerator.java?view=auto&rev=491447
==============================================================================
--- velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsPageGenerator.java (added)
+++ velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsPageGenerator.java Sun Dec 31 09:12:17 2006
@@ -0,0 +1,122 @@
+package org.apache.velocity.maven.plugin.news;
+
+import java.io.StringReader;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Iterator;
+import java.util.Locale;
+
+import org.apache.maven.doxia.parser.ParseException;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.velocity.maven.plugin.news.model.Item;
+
+
+/**
+ * Render the actual news page.
+ *
+ * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
+ * @version $Revision$
+ *
+ */
+public class NewsPageGenerator {
+
+ private final NewsReport newsReport;
+
+ private final Sink sink;
+
+ private final Locale locale;
+
+ private final DateFormat localeDateFormat;
+
+ public NewsPageGenerator(final NewsReport newsReport, final Locale locale) {
+ this.newsReport = newsReport;
+ this.locale = locale;
+ this.sink = newsReport.getSink();
+
+ localeDateFormat = new SimpleDateFormat(newsReport.getBundle(locale).getString("report.news.page.dateFormat"));
+ }
+
+ public void openPage() {
+ sink.head();
+ sink.title();
+ sink.text(getLocaleTitle());
+ sink.title_();
+ sink.head_();
+
+ sink.body();
+ }
+
+ public void closePage() {
+ sink.body_();
+ sink.flush();
+ }
+
+ public void displayHeader() {
+ sink.section1();
+ sink.sectionTitle1();
+ sink.text(getLocaleTitle());
+ sink.sectionTitle1_();
+ sink.section1_();
+
+ }
+
+ void displayItem(final Item item) throws MojoExecutionException {
+
+ sink.section2();
+
+ sink.sectionTitle2();
+ sink.text(item.getHeadline());
+ sink.sectionTitle2_();
+
+ if (item.getDate() != null) {
+ sink.paragraph();
+ sink.bold();
+ sink.text(localeDateFormat.format(NewsReportUtils.parseItemDate(item.getDate())));
+ sink.bold_();
+ sink.paragraph_();
+ }
+
+ addAptParagraph(item.getText());
+
+
+ if (item.getCategories() != null) {
+ sink.paragraph();
+
+ sink.text(getLocaleCategories());
+
+ for (Iterator it = item.getCategories().iterator(); it.hasNext(); ) {
+ String category = (String) it.next();
+
+ sink.italic();
+ sink.text(category);
+ sink.italic_();
+
+ if (it.hasNext()) {
+ sink.text(", ");
+ }
+ }
+ sink.paragraph_();
+ }
+
+ sink.section2_();
+ }
+
+ private void addAptParagraph(final String text) throws MojoExecutionException {
+ try {
+ // Leading space makes sure this gets interpreted as text.
+ newsReport.getAptParser().parse(new StringReader(" " + text), sink);
+ } catch (ParseException pe) {
+ throw new MojoExecutionException("While parsing Apt: ", pe);
+ }
+ }
+
+ private String getLocaleTitle() {
+ return newsReport.getBundle(locale).getString("report.news.page.title");
+ }
+
+ private String getLocaleCategories() {
+ return newsReport.getBundle(locale).getString("report.news.page.categories") + " ";
+ }
+
+}
Propchange: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsPageGenerator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsPageGenerator.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Revision
Added: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsReport.java
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsReport.java?view=auto&rev=491447
==============================================================================
--- velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsReport.java (added)
+++ velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsReport.java Sun Dec 31 09:12:17 2006
@@ -0,0 +1,24 @@
+package org.apache.velocity.maven.plugin.news;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.apache.maven.doxia.parser.Parser;
+import org.apache.maven.doxia.sink.Sink;
+
+/**
+ * The News Reporter API.
+ *
+ * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
+ * @version $Revision$
+ *
+ */
+
+public interface NewsReport {
+
+ Sink getSink();
+
+ Parser getAptParser();
+
+ ResourceBundle getBundle(final Locale locale);
+}
Propchange: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsReport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsReport.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Revision
Added: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsReportUtils.java
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsReportUtils.java?view=auto&rev=491447
==============================================================================
--- velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsReportUtils.java (added)
+++ velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsReportUtils.java Sun Dec 31 09:12:17 2006
@@ -0,0 +1,37 @@
+package org.apache.velocity.maven.plugin.news;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * Utility code.
+ *
+ * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
+ * @version $Revision$
+ *
+ */
+
+public abstract class NewsReportUtils {
+
+ private static final DateFormat itemDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+
+ private NewsReportUtils() {
+ }
+
+ public static final Date parseItemDate(final String dateString) throws MojoExecutionException {
+ Date date = null;
+ try {
+ date = itemDateFormat.parse(dateString);
+ } catch (ParseException pe) {
+ throw new MojoExecutionException(dateString + " is not a valid yyyy-MM-dd date!");
+ }
+ return date;
+ }
+}
+
+
+
Propchange: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsReportUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsReportUtils.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Revision
Added: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/VelocityNewsReport.java
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/VelocityNewsReport.java?view=auto&rev=491447
==============================================================================
--- velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/VelocityNewsReport.java (added)
+++ velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/VelocityNewsReport.java Sun Dec 31 09:12:17 2006
@@ -0,0 +1,139 @@
+package org.apache.velocity.maven.plugin.news;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.reporting.MavenReport;
+import org.apache.maven.reporting.MavenReportException;
+import org.apache.velocity.maven.plugin.news.model.Item;
+import org.apache.velocity.maven.plugin.news.model.NewsModel;
+import org.apache.velocity.maven.plugin.news.model.io.xpp3.NewsXpp3Reader;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+/**
+ * Generate news items for the site.
+ *
+ * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
+ * @version $Revision$
+ *
+ * @goal news
+ */
+public class VelocityNewsReport extends AbstractVelocityNewsReport implements MavenReport, NewsReport {
+
+ protected void executeReport(final Locale locale) throws MavenReportException {
+
+ getLog().debug("Coming up on Velocity news report!");
+ try {
+
+ NewsModel newsModel = getNewsModel();
+
+ if (newsModel != null) {
+ generateNewsPage(newsModel, locale);
+
+ }
+
+
+ } catch (MojoExecutionException mee) {
+ throw new MavenReportException("While generating report: ", mee);
+ }
+ }
+
+ private void generateNewsPage(final NewsModel newsModel, final Locale locale) throws MojoExecutionException {
+
+ NewsPageGenerator newsPageGenerator = new NewsPageGenerator(this, locale);
+
+ newsPageGenerator.openPage();
+ newsPageGenerator.displayHeader();
+
+ List items = sortItemsByReverseDate(newsModel.getItem());
+
+ for(Iterator it = items.iterator(); it.hasNext(); ) {
+ Item newsItem = (Item) it.next();
+ newsPageGenerator.displayItem(newsItem);
+ }
+
+ newsPageGenerator.closePage();
+ }
+
+ private List sortItemsByReverseDate(final List items) {
+ List result = new ArrayList(items);
+ Collections.sort(result, new Comparator() {
+ public int compare (final Object o1, final Object o2) {
+ Item i1 = (Item) o1;
+ Item i2 = (Item) o2;
+
+ if (i1 == null) {
+ return (i2 == null) ? 0 : -1;
+ }
+
+ if (i2 == null) {
+ return 1;
+ }
+
+ Date d1 = i1.getDate();
+ Date d2 = i2.getDate();
+
+ if (d1 == null) {
+ return (d2 == null) ? 0 : -1;
+ }
+
+ if (d2 == null) {
+ return 1;
+ }
+
+ return - (d1.compareTo(d2));
+ }
+ });
+ return result;
+ }
+
+ private NewsModel getNewsModel() throws MojoExecutionException {
+
+ NewsModel newsModel = null;
+
+ File newsFile = new File(getSiteDirectory(), "/news.xml");
+
+ if (newsFile.exists() && newsFile.canRead()) {
+
+ FileInputStream fis = null;
+ InputStreamReader isr = null;
+
+ try {
+ fis = new FileInputStream(newsFile);
+ isr = new InputStreamReader(fis);
+
+ newsModel = new NewsXpp3Reader().read(isr);
+ } catch (XmlPullParserException xppe) {
+ throw new MojoExecutionException("While parsing news file: ", xppe);
+ } catch (IOException ioe) {
+ throw new MojoExecutionException("While reading news file: ", ioe);
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException ioe) {
+ getLog().error("While closing news stream: ", ioe);
+ }
+ }
+ if (isr != null) {
+ try {
+ isr.close();
+ } catch (IOException ioe) {
+ getLog().error("While closing news reader: ", ioe);
+ }
+ }
+ }
+ }
+
+ return newsModel;
+ }
+}
Propchange: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/VelocityNewsReport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/VelocityNewsReport.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Revision
Added: velocity/site/velocity-news-plugin/src/main/mdo/news.mdo
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-plugin/src/main/mdo/news.mdo?view=auto&rev=491447
==============================================================================
--- velocity/site/velocity-news-plugin/src/main/mdo/news.mdo (added)
+++ velocity/site/velocity-news-plugin/src/main/mdo/news.mdo Sun Dec 31 09:12:17 2006
@@ -0,0 +1,97 @@
+<model>
+ <id>news</id>
+ <name>News</name>
+ <description><![CDATA[
+ <p>This is a reference for the news items used in the Velocity News Plugin.</p>
+ <p>An XSD is available at:</p>
+ <ul>
+ <li><a href="http://maven.apache.org/decoration-1.0.0.xsd">http://maven.apache.org/decoration-1.0.0.xsd</a> for Maven 2.0.</li>
+ </ul>
+ ]]></description>
+ <defaults>
+ <default>
+ <key>package</key>
+ <value>org.apache.velocity.maven.plugin.news.model</value>
+ </default>
+ </defaults>
+ <classes>
+ <class rootElement="true" xml.tagName="news">
+ <name>NewsModel</name>
+ <description><![CDATA[
+ The <code><news></code> element is the root of the news items.
+ The following table lists all of the possible child elements.
+ ]]></description>
+ <version>1.0.0</version>
+ <fields>
+ <field xml.listStyle="flat">
+ <name>item</name>
+ <description><![CDATA[
+ A news item.
+ ]]></description>
+ <version>1.0.0</version>
+ <association>
+ <type>Item</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ <identifier>true</identifier>
+ </field>
+ </fields>
+ </class>
+ <class>
+ <name>Item</name>
+ <description><![CDATA[
+ A single news item
+ ]]></description>
+ <version>1.0.0</version>
+ <fields>
+ <field xml.attribute="true">
+ <name>id</name>
+ <version>1.0.0</version>
+ <description><![CDATA[
+ Id of this entry.
+ ]]></description>
+ <type>String</type>
+ <identifier>true</identifier>
+ <required>true</required>
+ </field>
+ <field>
+ <name>date</name>
+ <version>1.0.0</version>
+ <description><![CDATA[
+ Posting date of this entry.
+ ]]></description>
+ <type>String</type>
+ <identifier>true</identifier>
+ </field>
+ <field>
+ <name>headline</name>
+ <version>1.0.0</version>
+ <description><![CDATA[
+ Headline of this entry.
+ ]]></description>
+ <type>String</type>
+ <identifier>true</identifier>
+ <required>true</required>
+ </field>
+ <field>
+ <name>text</name>
+ <version>1.0.0</version>
+ <description><![CDATA[
+ Content of this item in xdoc format.
+ ]]></description>
+ <type>String</type>
+ <identifier>true</identifier>
+ <required>true</required>
+ </field>
+ <field xml.listStyle="wrapped">
+ <name>categories</name>
+ <version>1.0.0</version>
+ <association>
+ <type>String</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ </field>
+ </fields>
+ </class>
+ </classes>
+</model>
Added: velocity/site/velocity-news-plugin/src/main/resources/velocity-news-report.properties
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-plugin/src/main/resources/velocity-news-report.properties?view=auto&rev=491447
==============================================================================
--- velocity/site/velocity-news-plugin/src/main/resources/velocity-news-report.properties (added)
+++ velocity/site/velocity-news-plugin/src/main/resources/velocity-news-report.properties Sun Dec 31 09:12:17 2006
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
+report.news.name= News
+report.news.description= Reports newsworthy items from the project.
+
+# Stuff on the main news page
+report.news.page.title= Project news
+report.news.page.dateFormat= EEEE, d MMMM yyyy
+report.news.page.categories= Categories:
Propchange: velocity/site/velocity-news-plugin/src/main/resources/velocity-news-report.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: velocity/site/velocity-news-plugin/src/main/resources/velocity-news-report.properties
------------------------------------------------------------------------------
svn:keywords = Id Author Date Revision