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 2007/01/01 22:34:48 UTC

svn commit: r491635 - in /velocity/site: ./ velocity-news-extension/ velocity-news-extension/config/ velocity-news-extension/src/ velocity-news-extension/src/main/ velocity-news-extension/src/main/java/ velocity-news-extension/src/main/java/org/ veloci...

Author: henning
Date: Mon Jan  1 13:34:47 2007
New Revision: 491635

URL: http://svn.apache.org/viewvc?view=rev&rev=491635
Log:
Split the News plugin into a plugin and an extension module which also
provides the Doxia Macro for generating the "Recent News" block on the
main page.



Added:
    velocity/site/velocity-news-extension/   (with props)
    velocity/site/velocity-news-extension/config/
    velocity/site/velocity-news-extension/config/apache-header.txt   (with props)
    velocity/site/velocity-news-extension/config/checkstyle.xml   (with props)
    velocity/site/velocity-news-extension/pom.xml   (with props)
    velocity/site/velocity-news-extension/src/
    velocity/site/velocity-news-extension/src/main/
    velocity/site/velocity-news-extension/src/main/java/
    velocity/site/velocity-news-extension/src/main/java/org/
    velocity/site/velocity-news-extension/src/main/java/org/apache/
    velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/
    velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/
    velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/DefaultNewsContainer.java   (with props)
    velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsBlockGenerator.java   (with props)
    velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsContainer.java   (with props)
    velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsReport.java   (with props)
    velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/VelocityNewsException.java   (with props)
    velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/macro/
    velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/macro/VelocityNewsMacro.java   (with props)
    velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/utils/
    velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/utils/VelocityNewsUtils.java   (with props)
    velocity/site/velocity-news-extension/src/main/mdo/
    velocity/site/velocity-news-extension/src/main/mdo/news.mdo
    velocity/site/velocity-news-extension/src/main/resources/
    velocity/site/velocity-news-extension/src/main/resources/velocity-news-report.properties   (with props)
    velocity/site/velocity-news-extension/src/site/
    velocity/site/velocity-news-extension/src/site/apt/
    velocity/site/velocity-news-extension/src/site/apt/index.apt
    velocity/site/velocity-news-extension/src/site/resources/
    velocity/site/velocity-news-extension/src/site/resources/images/
    velocity/site/velocity-news-extension/src/site/resources/images/pbv90x30.png   (with props)
    velocity/site/velocity-news-extension/src/site/resources/images/velocity_project_wide.png   (with props)
    velocity/site/velocity-news-extension/src/site/site.xml   (with props)
    velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/AbstractVelocityNewsPlugin.java
      - copied, changed from r491447, velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/AbstractVelocityNewsReport.java
    velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/VelocityNewsPlugin.java   (with props)
Removed:
    velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/AbstractVelocityNewsReport.java
    velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsReport.java
    velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsReportUtils.java
    velocity/site/velocity-news-plugin/src/main/mdo/
Modified:
    velocity/site/pom.xml
    velocity/site/velocity-news-plugin/pom.xml
    velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsPageGenerator.java
    velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/VelocityNewsReport.java

Modified: velocity/site/pom.xml
URL: http://svn.apache.org/viewvc/velocity/site/pom.xml?view=diff&rev=491635&r1=491634&r2=491635
==============================================================================
--- velocity/site/pom.xml (original)
+++ velocity/site/pom.xml Mon Jan  1 13:34:47 2007
@@ -42,6 +42,7 @@
     <module>apache-velocity-site-skin</module>
     <module>doxia-velocity-renderer</module>
     <module>velocity-news-plugin</module>
+    <module>velocity-news-extension</module>
   </modules>
 
   <build>

Propchange: velocity/site/velocity-news-extension/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jan  1 13:34:47 2007
@@ -0,0 +1,4 @@
+.classpath
+.settings
+.project
+target

Added: velocity/site/velocity-news-extension/config/apache-header.txt
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-extension/config/apache-header.txt?view=auto&rev=491635
==============================================================================
--- velocity/site/velocity-news-extension/config/apache-header.txt (added)
+++ velocity/site/velocity-news-extension/config/apache-header.txt Mon Jan  1 13:34:47 2007
@@ -0,0 +1,21 @@
+^package .*\;$
+^\s*$
+^/\*\s*$
+^ \* Licensed to the Apache Software Foundation \(ASF\) under one\s*$
+^ \* or more contributor license agreements.  See the NOTICE file\s*$
+^ \* distributed with this work for additional information\s*$
+^ \* regarding copyright ownership.  The ASF licenses this file\s*$
+^ \* to you under the Apache License, Version 2.0 \(the\s*$
+^ \* "License"\)\; you may not use this file except in compliance\s*$
+^ \* with the License.  You may obtain a copy of the License at\s*$
+^ \*\s*$
+^ \*   http://www\.apache\.org/licenses/LICENSE-2\.0\s*$
+^ \*\s*$
+^ \* Unless required by applicable law or agreed to in writing,\s*$
+^ \* software distributed under the License is distributed on an\s*$
+^ \* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\s*$
+^ \* KIND, either express or implied.  See the License for the\s*$
+^ \* specific language governing permissions and limitations\s*$
+^ \* under the License.\s*$
+^ \*/\s*$
+^\s*$

Propchange: velocity/site/velocity-news-extension/config/apache-header.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: velocity/site/velocity-news-extension/config/checkstyle.xml
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-extension/config/checkstyle.xml?view=auto&rev=491635
==============================================================================
--- velocity/site/velocity-news-extension/config/checkstyle.xml (added)
+++ velocity/site/velocity-news-extension/config/checkstyle.xml Mon Jan  1 13:34:47 2007
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2001-2005 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.
+-->
+
+<!DOCTYPE module PUBLIC
+    "-//Puppy Crawl//DTD Check Configuration 1.1//EN"
+    "http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
+
+<!--
+
+  Checkstyle configuration that checks the sun coding conventions from:
+
+    - the Java Language Specification at
+      http://java.sun.com/docs/books/jls/second_edition/html/index.html
+
+    - the Sun Code Conventions at http://java.sun.com/docs/codeconv/
+
+    - the Javadoc guidelines at
+      http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
+
+    - the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html
+
+    - some best practices
+
+  Checkstyle is very configurable. Be sure to read the documentation at
+  http://checkstyle.sf.net (or in your downloaded distribution).
+
+  Most Checks are configurable, be sure to consult the documentation.
+
+  To completely disable a check, just comment it out or delete it from the file.
+
+  Finally, it is worth reading the documentation.
+
+-->
+
+<module name="Checker">
+
+    <!-- Checks that a package.html file exists for each package.     -->
+    <!-- See http://checkstyle.sf.net/config_javadoc.html#PackageHtml -->
+    <module name="PackageHtml"/>
+
+    <!-- Checks whether files end with a new line.                        -->
+    <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
+    <module name="NewlineAtEndOfFile"/>
+
+    <!-- Checks that property files contain the same keys.         -->
+    <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
+    <module name="Translation"/>
+
+    <module name="TreeWalker">
+
+        <property name="cacheFile" value="${checkstyle.cache.file}"/>
+
+        <!-- ************************************************************** -->
+        <!-- Checks that are different from the sun coding conventions ones -->
+        <!-- ************************************************************** -->
+        <property name="tabWidth" value="4"/>
+        <module name="LeftCurly">
+          <property name="option" value="nl"/>
+        </module>
+        <module name="RightCurly">
+          <property name="option" value="alone"/>
+        </module>
+        <module name="LineLength">
+          <property name="ignorePattern" value="@version"/>
+          <property name="max" value="132"/>
+        </module>
+        <module name="MemberName">
+          <property name="format" value="^[a-z]+_*[a-zA-Z0-9]*$"/>
+        </module>
+        <module name="StaticVariableName">
+          <property name="format" value="^[a-z]+_*[a-zA-Z0-9]*$"/>
+        </module>
+        <module name="ConstantName">
+          <property name="format" value="^(([A-Z][A-Z0-9]*(_[A-Z0-9]+)*)|log)$"/>
+        </module>
+        <module name="ParameterName">
+          <property name="format" value="^[a-z]+_*[a-zA-Z0-9]*$"/>
+        </module>
+
+        <!-- ************************************************************** -->
+        <!-- Default Sun coding conventions checks                          -->
+        <!-- ************************************************************** -->
+
+        <!-- Checks for Javadoc comments.                     -->
+        <!-- See http://checkstyle.sf.net/config_javadoc.html -->
+        <module name="JavadocMethod">
+          <property name="excludeScope" value="private"/>
+        </module>
+        <module name="JavadocType"/>
+        <module name="JavadocVariable"/>
+
+
+        <!-- Checks for Naming Conventions.                  -->
+        <!-- See http://checkstyle.sf.net/config_naming.html -->
+        <module name="LocalFinalVariableName"/>
+        <module name="LocalVariableName"/>
+        <module name="MethodName"/>
+        <module name="PackageName"/>
+        <module name="TypeName"/>
+
+
+        <!-- Checks for Headers                              -->
+        <!-- See http://checkstyle.sf.net/config_header.html -->
+        <module name="RegexpHeader">
+            <!-- The follow property value demonstrates the ability     -->
+            <!-- to have access to ANT properties. In this case it uses -->
+            <!-- the ${basedir} property to allow Checkstyle to be run  -->
+            <!-- from any directory within a project.                   -->
+            <property name="headerFile" value="${checkstyle.header.file}"/>
+        </module>
+
+        <!-- Following interprets the header file as regular expressions. -->
+        <!-- <module name="RegexpHeader"/>                                -->
+
+
+        <!-- Checks for imports                              -->
+        <!-- See http://checkstyle.sf.net/config_import.html -->
+        <module name="AvoidStarImport"/>
+        <module name="IllegalImport"/> <!-- defaults to sun.* packages -->
+        <module name="RedundantImport"/>
+        <module name="UnusedImports"/>
+
+
+        <!-- Checks for Size Violations.                    -->
+        <!-- See http://checkstyle.sf.net/config_sizes.html -->
+        <module name="FileLength"/>
+        <module name="MethodLength"/>
+        <module name="ParameterNumber"/>
+
+
+        <!-- Checks for whitespace                               -->
+        <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+        <module name="EmptyForIteratorPad"/>
+        <module name="NoWhitespaceAfter"/>
+        <module name="NoWhitespaceBefore"/>
+        <module name="OperatorWrap"/>
+        <module name="ParenPad"/>
+        <module name="TabCharacter"/>
+        <module name="WhitespaceAfter"/>
+        <module name="WhitespaceAround"/>
+
+
+        <!-- Modifier Checks                                    -->
+        <!-- See http://checkstyle.sf.net/config_modifiers.html -->
+        <module name="ModifierOrder"/>
+        <module name="RedundantModifier"/>
+
+        <module name="EmptyBlock"/>
+        <module name="NeedBraces"/>
+
+        <!-- Checks for common coding problems               -->
+        <!-- See http://checkstyle.sf.net/config_coding.html -->
+        <module name="DoubleCheckedLocking"/>    <!-- MY FAVOURITE -->
+        <module name="EmptyStatement"/>
+        <module name="EqualsHashCode"/>
+        <module name="FallThrough"/>
+        <module name="HiddenField">
+          <property name="ignoreConstructorParameter" value="true"/>
+          <property name="ignoreSetter" value="true"/>
+        </module>
+        <module name="IllegalInstantiation"/>
+        <module name="InnerAssignment"/>
+        <module name="MagicNumber"/>
+        <module name="MissingSwitchDefault"/>
+<!--        <module name="OneMethodPrivateField" /> -->
+        <module name="RedundantThrows"/>
+        <module name="SimplifyBooleanExpression"/>
+        <module name="SimplifyBooleanReturn"/>
+
+        <!-- Checks for class design                         -->
+        <!-- See http://checkstyle.sf.net/config_design.html -->
+        <module name="FinalClass"/>
+        <module name="HideUtilityClassConstructor"/>
+        <module name="VisibilityModifier">
+        <module name="MissingSwitchDefault"/>
+          <property name="protectedAllowed" value="true"/>
+        </module>
+
+
+        <!-- Miscellaneous other checks.                   -->
+        <!-- See http://checkstyle.sf.net/config_misc.html -->
+        <module name="ArrayTypeStyle"/>
+<!--         <module name="FinalParameters"/> -->
+        <module name="GenericIllegalRegexp">
+            <property name="format" value="\s+$"/>
+            <property name="message" value="Line has trailing spaces."/>
+        </module>
+        <module name="UpperEll"/>
+
+    </module>
+
+</module>

Propchange: velocity/site/velocity-news-extension/config/checkstyle.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/site/velocity-news-extension/config/checkstyle.xml
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision

Added: velocity/site/velocity-news-extension/pom.xml
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-extension/pom.xml?view=auto&rev=491635
==============================================================================
--- velocity/site/velocity-news-extension/pom.xml (added)
+++ velocity/site/velocity-news-extension/pom.xml Mon Jan  1 13:34:47 2007
@@ -0,0 +1,151 @@
+<?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-extension</artifactId>
+  <name>Velocity News Extension</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-extension/</url>
+  <inceptionYear>2006</inceptionYear>
+  <scm>
+    <connection>scm:svn:http://svn.apache.org/repos/asf/velocity/site/velocity-news-extension/</connection>
+    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/velocity/site/velocity-news-extension/</developerConnection>
+    <url>http://svn.apache.org/viewvc/velocity/site/velocity-news-extension/</url>
+  </scm>
+  <build>
+    <plugins>
+      <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>
+      <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>
+    </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.codehaus.plexus</groupId>
+      <artifactId>plexus-container-default</artifactId>
+      <version>1.0-alpha-8</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.doxia</groupId>
+      <artifactId>doxia-sink-api</artifactId>
+      <version>1.0-alpha-8</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.doxia</groupId>
+      <artifactId>doxia-core</artifactId>
+      <version>1.0-alpha-8</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-extension</url>
+    </site>
+  </distributionManagement>
+</project>

Propchange: velocity/site/velocity-news-extension/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/site/velocity-news-extension/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision

Added: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/DefaultNewsContainer.java
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/DefaultNewsContainer.java?view=auto&rev=491635
==============================================================================
--- velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/DefaultNewsContainer.java (added)
+++ velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/DefaultNewsContainer.java Mon Jan  1 13:34:47 2007
@@ -0,0 +1,107 @@
+package org.apache.velocity.news;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.maven.doxia.parser.Parser;
+import org.apache.velocity.maven.plugin.news.model.NewsModel;
+import org.apache.velocity.maven.plugin.news.model.io.xpp3.NewsXpp3Reader;
+import org.codehaus.plexus.logging.LogEnabled;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+/**
+ * This is the container that keeps the news model for us.
+ * @plexus.component role="org.apache.velocity.news.NewsContainer"
+ */
+public class DefaultNewsContainer
+        implements NewsContainer,LogEnabled {
+
+    private NewsModel newsModel = null;
+
+    private Parser aptParser;
+
+    private Logger logger = null;
+
+    private String newsPageName = null;
+
+    /**
+     * Plexus lifecycle.
+     */
+    public void enableLogging(final Logger logger) {
+        this.logger = logger;
+    }
+
+    public void load(final File newsFile) throws VelocityNewsException {
+
+        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 VelocityNewsException("While parsing news file: ", xppe);
+            } catch (IOException ioe) {
+                throw new VelocityNewsException("While reading news file: ", ioe);
+            } finally {
+                if (fis != null) {
+                    try {
+                        fis.close();
+                    } catch (IOException ioe) {
+                        logger.error("While closing news stream: ", ioe);
+                    }
+                }
+                if (isr != null) {
+                    try {
+                        isr.close();
+                    } catch (IOException ioe) {
+                        logger.error("While closing news reader: ", ioe);
+                    }
+                }
+            }
+        }
+
+        setNewsModel(newsModel);
+    }
+
+    public NewsModel getNewsModel() {
+        return this.newsModel;
+    }
+
+    protected void setNewsModel(final NewsModel newsModel) {
+        this.newsModel = newsModel;
+    }
+
+    //
+    // This is a kludge. Because Plexus can not resolve cyclic dependencies
+    // and we need the parser inside a macro, we pass it in from the plugin.
+    // Don't do this at home, kids!.
+    //
+
+    public Parser getAptParser() {
+        return this.aptParser;
+    }
+
+    public void setAptParser(Parser aptParser) {
+        this.aptParser = aptParser;
+    }
+
+    public String getNewsPageName() {
+        return this.newsPageName;
+    }
+
+    public void setNewsPageName(String newsPageName) {
+        this.newsPageName = newsPageName;
+    }
+
+
+}
+
+

Propchange: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/DefaultNewsContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/DefaultNewsContainer.java
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision

Added: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsBlockGenerator.java
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsBlockGenerator.java?view=auto&rev=491635
==============================================================================
--- velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsBlockGenerator.java (added)
+++ velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsBlockGenerator.java Mon Jan  1 13:34:47 2007
@@ -0,0 +1,67 @@
+package org.apache.velocity.news;
+
+import java.io.StringReader;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.doxia.parser.ParseException;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.velocity.maven.plugin.news.model.Item;
+import org.apache.velocity.news.utils.VelocityNewsUtils;
+
+/**
+ * Render the news teasers for the Macro.
+ *
+ * @author  <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
+ * @version  $Revision$
+ *
+ */
+public class NewsBlockGenerator {
+
+    private final NewsReport newsReport;
+
+    private final Sink sink;
+
+    private final Locale locale;
+
+    private final DateFormat localeDateFormat;
+
+    public NewsBlockGenerator(final NewsReport newsReport, final Locale locale) {
+        this.newsReport = newsReport;
+        this.locale = locale;
+        this.sink = newsReport.getSink();
+
+        localeDateFormat = new SimpleDateFormat(newsReport.getBundle(this.locale).getString("report.news.page.dateFormat"));
+    }
+
+    public void displayItem(final Item item) throws VelocityNewsException {
+
+        sink.section2();
+        sink.sectionTitle2();
+
+        if (item.getDate() != null) {
+            sink.text(localeDateFormat.format(VelocityNewsUtils.parseItemDate(item.getDate())) + " - ");
+        }
+
+        sink.text(item.getHeadline());
+        sink.sectionTitle2_();
+
+        addAptParagraph(item.getText(), item.getId());
+        sink.section2_();
+    }
+
+    private void addAptParagraph(final String text, final String itemId) throws VelocityNewsException {
+
+        // The first sentence is our teaser...
+        String [] textFields = StringUtils.splitByWholeSeparator(text, ". ");
+        String aptText = " " + textFields[0] + ". [{{{" + newsReport.getNewsPageName() + ".html#" + itemId + "}Read more...}}]";
+        try {
+            // Leading space makes sure this gets interpreted as text.
+            newsReport.getAptParser().parse(new StringReader(aptText), sink);
+        } catch (ParseException pe) {
+            throw new VelocityNewsException("While parsing Apt: ", pe);
+        }
+    }
+}
\ No newline at end of file

Propchange: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsBlockGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsBlockGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision

Added: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsContainer.java
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsContainer.java?view=auto&rev=491635
==============================================================================
--- velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsContainer.java (added)
+++ velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsContainer.java Mon Jan  1 13:34:47 2007
@@ -0,0 +1,28 @@
+package org.apache.velocity.news;
+
+import java.io.File;
+
+import org.apache.maven.doxia.parser.Parser;
+import org.apache.velocity.maven.plugin.news.model.NewsModel;
+
+/**
+ * Plexus role description.
+ *
+ */
+public interface NewsContainer {
+
+    String ROLE = NewsContainer.class.getName();
+
+    void load(final File newsFile) throws VelocityNewsException;
+
+    NewsModel getNewsModel();
+
+    void setAptParser(Parser parser);
+
+    Parser getAptParser();
+
+    void setNewsPageName(String newsPageName);
+
+    String getNewsPageName();
+}
+

Propchange: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsContainer.java
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision

Added: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsReport.java
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsReport.java?view=auto&rev=491635
==============================================================================
--- velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsReport.java (added)
+++ velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsReport.java Mon Jan  1 13:34:47 2007
@@ -0,0 +1,26 @@
+package org.apache.velocity.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);
+
+    String getNewsPageName();
+}

Propchange: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsReport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/NewsReport.java
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision

Added: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/VelocityNewsException.java
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/VelocityNewsException.java?view=auto&rev=491635
==============================================================================
--- velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/VelocityNewsException.java (added)
+++ velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/VelocityNewsException.java Mon Jan  1 13:34:47 2007
@@ -0,0 +1,21 @@
+package org.apache.velocity.news;
+
+/**
+ * Generic Exception for the news extension.
+ */
+
+public class VelocityNewsException
+    extends Exception
+{
+    private static final long serialVersionUID = 1L;
+
+    public VelocityNewsException(final String message)
+    {
+        super(message);
+    }
+
+    public VelocityNewsException(final String message, final Throwable cause)
+    {
+        super(message, cause);
+    }
+}

Propchange: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/VelocityNewsException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/VelocityNewsException.java
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision

Added: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/macro/VelocityNewsMacro.java
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/macro/VelocityNewsMacro.java?view=auto&rev=491635
==============================================================================
--- velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/macro/VelocityNewsMacro.java (added)
+++ velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/macro/VelocityNewsMacro.java Mon Jan  1 13:34:47 2007
@@ -0,0 +1,87 @@
+package org.apache.velocity.news.macro;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.apache.maven.doxia.macro.AbstractMacro;
+import org.apache.maven.doxia.macro.MacroExecutionException;
+import org.apache.maven.doxia.macro.MacroRequest;
+import org.apache.maven.doxia.parser.Parser;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.velocity.maven.plugin.news.model.Item;
+import org.apache.velocity.maven.plugin.news.model.NewsModel;
+import org.apache.velocity.news.NewsBlockGenerator;
+import org.apache.velocity.news.NewsContainer;
+import org.apache.velocity.news.NewsReport;
+import org.apache.velocity.news.VelocityNewsException;
+import org.apache.velocity.news.utils.VelocityNewsUtils;
+
+
+/**
+ * apt usage: %{news}
+ * @plexus.component role="org.apache.maven.doxia.macro.Macro"
+ * role-hint="news"
+ */
+public class VelocityNewsMacro
+        extends AbstractMacro {
+
+    /**
+     * The news container.
+     *
+     * @plexus.requirement role="org.apache.velocity.news.NewsContainer"
+     */
+    private NewsContainer newsContainer;
+
+    public void execute(final Sink sink, final MacroRequest request) throws MacroExecutionException {
+
+        try {
+
+            NewsModel newsModel = newsContainer.getNewsModel();
+
+            if (newsModel != null) {
+                int count = Integer.parseInt(getParameter(request, "count", "5"));
+
+                generateNewsBlock(sink, newsModel, count);
+            }
+        } catch (VelocityNewsException vne) {
+            throw new MacroExecutionException("While executing news macro: ", vne);
+        }
+    }
+
+    protected String getParameter(final MacroRequest request, final String field, final String defaultValue) {
+        String value = (String) request.getParameter(field);
+        return value != null ? value : defaultValue;
+    }
+
+    protected void generateNewsBlock(final Sink sink, final NewsModel newsModel, final int maxCount) throws VelocityNewsException {
+
+        NewsBlockGenerator newsBlockGenerator = new NewsBlockGenerator(new NewsReport() {
+                public Sink getSink() {
+                    return sink;
+                }
+
+                public Parser getAptParser() {
+                    return newsContainer.getAptParser();
+                }
+
+                public ResourceBundle getBundle(final Locale locale) {
+                    return ResourceBundle.getBundle("velocity-news-report", locale);
+                }
+
+                public String getNewsPageName() {
+                    return newsContainer.getNewsPageName();
+                }
+            }, Locale.ENGLISH);
+
+        List items = VelocityNewsUtils.sortItemsByReverseDate(newsModel.getItem());
+        int count = 0;
+
+        for(Iterator it = items.iterator(); it.hasNext() && count < maxCount; count++ ) {
+            Item newsItem = (Item) it.next();
+
+            newsBlockGenerator.displayItem(newsItem);
+        }
+    }
+}

Propchange: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/macro/VelocityNewsMacro.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/macro/VelocityNewsMacro.java
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision

Added: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/utils/VelocityNewsUtils.java
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/utils/VelocityNewsUtils.java?view=auto&rev=491635
==============================================================================
--- velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/utils/VelocityNewsUtils.java (added)
+++ velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/utils/VelocityNewsUtils.java Mon Jan  1 13:34:47 2007
@@ -0,0 +1,76 @@
+package org.apache.velocity.news.utils;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.velocity.maven.plugin.news.model.Item;
+import org.apache.velocity.news.VelocityNewsException;
+
+/**
+ * Some Utility Code.
+ *
+ * @author  <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
+ * @version  $Revision$
+ */
+
+public abstract class VelocityNewsUtils {
+
+    private static final DateFormat itemDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+
+    private VelocityNewsUtils() {
+    }
+
+    public static final  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 = null;
+                    Date d2 = null;
+                    try {
+                        d1 = VelocityNewsUtils.parseItemDate(i1.getDate());
+                        d2 = VelocityNewsUtils.parseItemDate(i2.getDate());
+                    } catch (VelocityNewsException mee) {
+                        throw new ClassCastException("While parsing date:" + mee.getMessage());
+                    }
+
+                    if (d1 == null) {
+                        return  (d2 == null) ? 0 : -1;
+                    }
+
+                    if (d2 == null) {
+                        return 1;
+                    }
+
+                    return - (d1.compareTo(d2));
+                }
+            });
+        return result;
+    }
+
+    public static final Date parseItemDate(final String dateString) throws VelocityNewsException {
+        Date date = null;
+        try {
+            date = itemDateFormat.parse(dateString);
+        } catch (ParseException pe) {
+            throw new VelocityNewsException(dateString + " is not a valid yyyy-MM-dd date!");
+        }
+        return date;
+    }
+}

Propchange: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/utils/VelocityNewsUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/site/velocity-news-extension/src/main/java/org/apache/velocity/news/utils/VelocityNewsUtils.java
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision

Added: velocity/site/velocity-news-extension/src/main/mdo/news.mdo
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-extension/src/main/mdo/news.mdo?view=auto&rev=491635
==============================================================================
--- velocity/site/velocity-news-extension/src/main/mdo/news.mdo (added)
+++ velocity/site/velocity-news-extension/src/main/mdo/news.mdo Mon Jan  1 13:34:47 2007
@@ -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>&lt;news&gt;</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-extension/src/main/resources/velocity-news-report.properties
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-extension/src/main/resources/velocity-news-report.properties?view=auto&rev=491635
==============================================================================
--- velocity/site/velocity-news-extension/src/main/resources/velocity-news-report.properties (added)
+++ velocity/site/velocity-news-extension/src/main/resources/velocity-news-report.properties Mon Jan  1 13:34:47 2007
@@ -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-extension/src/main/resources/velocity-news-report.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/site/velocity-news-extension/src/main/resources/velocity-news-report.properties
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision

Added: velocity/site/velocity-news-extension/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-extension/src/site/apt/index.apt?view=auto&rev=491635
==============================================================================
--- velocity/site/velocity-news-extension/src/site/apt/index.apt (added)
+++ velocity/site/velocity-news-extension/src/site/apt/index.apt Mon Jan  1 13:34:47 2007
@@ -0,0 +1,6 @@
+ --------
+Velocity News Plugin
+ --------
+
+Velocity News Plugin
+

Added: velocity/site/velocity-news-extension/src/site/resources/images/pbv90x30.png
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-extension/src/site/resources/images/pbv90x30.png?view=auto&rev=491635
==============================================================================
Binary file - no diff available.

Propchange: velocity/site/velocity-news-extension/src/site/resources/images/pbv90x30.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: velocity/site/velocity-news-extension/src/site/resources/images/velocity_project_wide.png
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-extension/src/site/resources/images/velocity_project_wide.png?view=auto&rev=491635
==============================================================================
Binary file - no diff available.

Propchange: velocity/site/velocity-news-extension/src/site/resources/images/velocity_project_wide.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: velocity/site/velocity-news-extension/src/site/site.xml
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-extension/src/site/site.xml?view=auto&rev=491635
==============================================================================
--- velocity/site/velocity-news-extension/src/site/site.xml (added)
+++ velocity/site/velocity-news-extension/src/site/site.xml Mon Jan  1 13:34:47 2007
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="Velocity News Plugin">
+  <publishDate position="bottom" format="yyyy-MM-dd HH:mm:ss"/>
+  <bannerLeft>
+    <name>Velocity News Plugin</name>
+    <src>/images/velocity_project_wide.png</src>
+    <href>http:/velocity.apache.org/</href>
+  </bannerLeft>
+
+  <poweredBy>
+    <logo name="Apache Velocity" 
+          href="http://velocity.apache.org"
+          img="/images/pbv90x30.png" />
+  </poweredBy>
+
+  <body>
+    <breadcrumbs>
+      <item name="Apache" href="http://www.apache.org"/>
+      <item name="Velocity" href="http://velocity.apache.org/"/>
+    </breadcrumbs>
+
+    <menu name="General">
+      <item name="Overview" href="index.html"/>
+    </menu> 
+
+    ${reports}
+  </body>
+</project>
+ 
+

Propchange: velocity/site/velocity-news-extension/src/site/site.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/site/velocity-news-extension/src/site/site.xml
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision

Modified: velocity/site/velocity-news-plugin/pom.xml
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-plugin/pom.xml?view=diff&rev=491635&r1=491634&r2=491635
==============================================================================
--- velocity/site/velocity-news-plugin/pom.xml (original)
+++ velocity/site/velocity-news-plugin/pom.xml Mon Jan  1 13:34:47 2007
@@ -22,38 +22,6 @@
   <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>
@@ -92,6 +60,11 @@
       <groupId>org.apache.maven.reporting</groupId>
       <artifactId>maven-reporting-impl</artifactId>
       <version>2.0.4</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.velocity</groupId>
+      <artifactId>velocity-news-extension</artifactId>
+      <version>0.0.1</version>
     </dependency>
   </dependencies>
   <reporting>

Copied: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/AbstractVelocityNewsPlugin.java (from r491447, 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/AbstractVelocityNewsPlugin.java?view=diff&rev=491635&p1=velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/AbstractVelocityNewsReport.java&r1=491447&p2=velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/AbstractVelocityNewsPlugin.java&r2=491635
==============================================================================
--- velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/AbstractVelocityNewsReport.java (original)
+++ velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/AbstractVelocityNewsPlugin.java Mon Jan  1 13:34:47 2007
@@ -1,13 +1,10 @@
 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;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.velocity.news.NewsContainer;
 
 /**
  * Generate news items for the site.
@@ -16,31 +13,7 @@
  * @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;
+public abstract class AbstractVelocityNewsPlugin extends AbstractMojo {
 
     /**
      * Directory containing the site files.
@@ -51,11 +24,11 @@
     private File siteDirectory;
 
     /**
-     * Configuration of the name of the news file to read.
+     * The news container.
      *
-     * @parameter expression="${newsfile}" default-value="news"
+     * @component
      */
-    protected String newsfile;
+    private NewsContainer newsContainer;
 
     /**
      * Apt Parser for running the news items.
@@ -65,67 +38,25 @@
     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)
+     * Configuration of the name of the news file to read.
+     *
+     * @parameter expression="${newsfile}" default-value="news"
      */
-    public String getName(final Locale locale) {
-        return getBundle(locale).getString("report.news.name");
-    }
+    protected String newsFileName;
 
-    /**
-     * @see org.apache.maven.reporting.AbstractMavenReport#canGenerateReport()
-     */
-    public boolean canGenerateReport()
-    {
-        return true; // For now.
+    public Parser getAptParser() {
+        return aptParser;
     }
 
     protected File getSiteDirectory() {
         return siteDirectory;
     }
 
-    public ResourceBundle getBundle(final Locale locale) {
-        return ResourceBundle.getBundle( "velocity-news-report", locale, VelocityNewsReport.class.getClassLoader() );
+    protected NewsContainer getNewsContainer() {
+        return newsContainer;
     }
 
-    public Parser getAptParser() {
-        return aptParser;
+    protected String getNewsFileName() {
+        return newsFileName;
     }
 }

Modified: 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=diff&rev=491635&r1=491634&r2=491635
==============================================================================
--- velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsPageGenerator.java (original)
+++ velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/NewsPageGenerator.java Mon Jan  1 13:34:47 2007
@@ -8,8 +8,10 @@
 
 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;
+import org.apache.velocity.news.NewsReport;
+import org.apache.velocity.news.VelocityNewsException;
+import org.apache.velocity.news.utils.VelocityNewsUtils;
 
 
 /**
@@ -61,18 +63,20 @@
 
     }
 
-    void displayItem(final Item item) throws MojoExecutionException {
+    public void displayItem(final Item item) throws VelocityNewsException {
 
         sink.section2();
 
         sink.sectionTitle2();
+        sink.anchor(item.getId());
         sink.text(item.getHeadline());
+        sink.anchor_();
         sink.sectionTitle2_();
 
         if (item.getDate() != null) {
             sink.paragraph();
             sink.bold();
-            sink.text(localeDateFormat.format(NewsReportUtils.parseItemDate(item.getDate())));
+            sink.text(localeDateFormat.format(VelocityNewsUtils.parseItemDate(item.getDate())));
             sink.bold_();
             sink.paragraph_();
         }
@@ -102,12 +106,13 @@
         sink.section2_();
     }
 
-    private void addAptParagraph(final String text) throws MojoExecutionException {
+    private void addAptParagraph(final String text) throws VelocityNewsException {
+        // Add leading space for interpretation as text.
+        String aptText = " " + text;
         try {
-            // Leading space makes sure this gets interpreted as text.
-            newsReport.getAptParser().parse(new StringReader(" " + text), sink);
+            newsReport.getAptParser().parse(new StringReader(aptText), sink);
         } catch (ParseException pe) {
-            throw new MojoExecutionException("While parsing Apt: ", pe);
+            throw new VelocityNewsException("While parsing Apt: ", pe);
         }
     }
 

Added: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/VelocityNewsPlugin.java
URL: http://svn.apache.org/viewvc/velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/VelocityNewsPlugin.java?view=auto&rev=491635
==============================================================================
--- velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/VelocityNewsPlugin.java (added)
+++ velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/VelocityNewsPlugin.java Mon Jan  1 13:34:47 2007
@@ -0,0 +1,44 @@
+package org.apache.velocity.maven.plugin.news;
+
+import java.io.File;
+
+import org.apache.velocity.maven.plugin.news.model.NewsModel;
+import org.apache.velocity.news.VelocityNewsException;
+
+/**
+ * Generate news items for the site.
+ *
+ * @author  <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
+ * @version  $Revision$
+ *
+ * @goal  pre-site
+ * @phase  pre-site
+ */
+public class VelocityNewsPlugin
+        extends AbstractVelocityNewsPlugin {
+
+    public void execute()
+    {
+        try {
+
+            NewsModel newsModel = getNewsContainer().getNewsModel();
+
+            if (newsModel == null) {
+                getNewsContainer().load(new File(getSiteDirectory(), "/" + getNewsFileName()  + ".xml"));
+            }
+
+            // This is a kludge to avoid a Plexus lockup. Plexus can not resolve cyclic
+            // dependencies and we need the Apt parser inside a macro which in turn is
+            // needed inside the Apt parser.
+            getNewsContainer().setAptParser(getAptParser());
+
+            //
+            // Page name can be configured inside the plugin.
+            //
+            getNewsContainer().setNewsPageName(getNewsFileName());
+
+        } catch (VelocityNewsException vne) {
+            getLog().error("While loading news information: ", vne);
+        }
+    }
+}

Propchange: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/VelocityNewsPlugin.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/VelocityNewsPlugin.java
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision

Modified: 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=diff&rev=491635&r1=491634&r2=491635
==============================================================================
--- velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/VelocityNewsReport.java (original)
+++ velocity/site/velocity-news-plugin/src/main/java/org/apache/velocity/maven/plugin/news/VelocityNewsReport.java Mon Jan  1 13:34:47 2007
@@ -1,27 +1,20 @@
 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.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
+import java.util.ResourceBundle;
 
-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;
+import org.apache.velocity.news.NewsReport;
+import org.apache.velocity.news.VelocityNewsException;
+import org.apache.velocity.news.utils.VelocityNewsUtils;
 
 /**
- * Generate news items for the site.
+ * Report news items for the site.
  *
  * @author  <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
  * @version  $Revision$
@@ -30,32 +23,51 @@
  */
 public class VelocityNewsReport extends AbstractVelocityNewsReport implements MavenReport, NewsReport {
 
-    protected void executeReport(final Locale locale) throws MavenReportException {
+    public ResourceBundle getBundle(final Locale locale) {
+        return ResourceBundle.getBundle( "velocity-news-report", locale, VelocityNewsReport.class.getClassLoader() );
+    }
+
+    /**
+     * @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");
+    }
+
+    public String getNewsPageName() {
+        return getNewsContainer().getNewsPageName();
+    }
+
+   protected void executeReport(final Locale locale) throws MavenReportException {
 
-        getLog().debug("Coming up on Velocity news report!");
         try {
 
-            NewsModel newsModel = getNewsModel();
+            NewsModel newsModel = getNewsContainer().getNewsModel();
 
             if (newsModel != null) {
                 generateNewsPage(newsModel, locale);
-
             }
 
-
-        } catch (MojoExecutionException mee) {
-            throw new MavenReportException("While generating report: ", mee);
+        } catch (VelocityNewsException vne) {
+            throw new MavenReportException("While generating report: ", vne);
         }
     }
 
-    private void generateNewsPage(final NewsModel newsModel, final Locale locale) throws MojoExecutionException {
+    private void generateNewsPage(final NewsModel newsModel, final Locale locale) throws VelocityNewsException {
 
         NewsPageGenerator newsPageGenerator = new NewsPageGenerator(this, locale);
 
         newsPageGenerator.openPage();
         newsPageGenerator.displayHeader();
 
-        List items = sortItemsByReverseDate(newsModel.getItem());
+        List items = VelocityNewsUtils.sortItemsByReverseDate(newsModel.getItem());
 
         for(Iterator it = items.iterator(); it.hasNext(); ) {
             Item newsItem = (Item) it.next();
@@ -63,84 +75,5 @@
         }
 
         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 = null;
-                    Date d2 = null;
-                    try {
-                        d1 = NewsReportUtils.parseItemDate(i1.getDate());
-                        d2 = NewsReportUtils.parseItemDate(i2.getDate());
-                    } catch (MojoExecutionException mee) {
-                        throw new ClassCastException("While parsing date:" + mee.getMessage());
-                    }
-
-                    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;
     }
 }