You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2005/05/31 02:01:19 UTC
svn commit: r179174 - /maven/components/trunk/maven-core
/maven/components/trunk/maven-reporting/maven-reporting-api
/maven/components/trunk/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting
/maven/components/trunk/maven-reports/maven-project-info-reports-plugin
/maven/components/trunk/maven-reports/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo
Author: brett
Date: Mon May 30 17:01:18 2005
New Revision: 179174
URL: http://svn.apache.org/viewcvs?rev=179174&view=rev
Log:
PR: MNG-411
Submitted By: Vincent Siveton
Reviewed By: Brett Porter
clean up the mailing list report
Modified:
maven/components/trunk/maven-core/pom.xml
maven/components/trunk/maven-reporting/maven-reporting-api/pom.xml
maven/components/trunk/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/AbstractMavenReportRenderer.java
maven/components/trunk/maven-reports/maven-project-info-reports-plugin/pom.xml
maven/components/trunk/maven-reports/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java
Modified: maven/components/trunk/maven-core/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/pom.xml?rev=179174&r1=179173&r2=179174&view=diff
==============================================================================
(empty)
Modified: maven/components/trunk/maven-reporting/maven-reporting-api/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-reporting/maven-reporting-api/pom.xml?rev=179174&r1=179173&r2=179174&view=diff
==============================================================================
--- maven/components/trunk/maven-reporting/maven-reporting-api/pom.xml (original)
+++ maven/components/trunk/maven-reporting/maven-reporting-api/pom.xml Mon May 30 17:01:18 2005
@@ -6,6 +6,12 @@
<version>2.0-SNAPSHOT</version>
</parent>
<artifactId>maven-reporting-api</artifactId>
+ <contributors>
+ <contributor>
+ <name>Vincent Siveton</name>
+ <email>vincent.siveton@gmail.com</email>
+ </contributor>
+ </contributors>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
@@ -21,6 +27,16 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-validator</groupId>
+ <artifactId>commons-validator</artifactId>
+ <version>1.1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>oro</groupId>
+ <artifactId>oro</artifactId>
+ <version>2.0.7</version>
</dependency>
</dependencies>
</project>
Modified: maven/components/trunk/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/AbstractMavenReportRenderer.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/AbstractMavenReportRenderer.java?rev=179174&r1=179173&r2=179174&view=diff
==============================================================================
--- maven/components/trunk/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/AbstractMavenReportRenderer.java (original)
+++ maven/components/trunk/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/AbstractMavenReportRenderer.java Mon May 30 17:01:18 2005
@@ -16,11 +16,14 @@
* limitations under the License.
*/
+import org.apache.commons.validator.EmailValidator;
+import org.apache.commons.validator.UrlValidator;
import org.codehaus.doxia.sink.Sink;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id: AbstractMavenReportRenderer.java 163373 2005-02-22 03:37:00Z brett $
* @todo Later it may be appropriate to create something like a VelocityMavenReportRenderer that could take a velocity template and pipe that through Doxia rather than coding them up like this.
*/
@@ -185,6 +188,53 @@
sink.tableCell_();
}
+ /**
+ * Create a cell with a potential link.
+ *
+ * @param text the text
+ * @param href the href
+ */
+ protected void tableCellWithLink( String text, String href )
+ {
+ sink.tableCell();
+
+ if ( text != null )
+ {
+ if ( href != null )
+ {
+ String[] schemes = {"http", "https"};
+ UrlValidator urlValidator = new UrlValidator( schemes );
+
+ if ( EmailValidator.getInstance().isValid( href ) )
+ {
+ link( "mailto:" + href, text );
+ }
+ else if ( href.toLowerCase().startsWith( "mailto:" ) )
+ {
+ link( href, text );
+ }
+ else if ( urlValidator.isValid( href ) )
+ {
+ link( href, text );
+ }
+ else
+ {
+ sink.text( text );
+ }
+ }
+ else
+ {
+ sink.text( text );
+ }
+ }
+ else
+ {
+ sink.nonBreakingSpace();
+ }
+
+ sink.tableCell_();
+ }
+
protected void tableRow( String[] content )
{
sink.tableRow();
@@ -197,6 +247,31 @@
sink.tableRow_();
}
+ /**
+ * Create a new row : each cell could have a link.
+ * <br>
+ * The arrays should have the same size.
+ *
+ * @param texts an array of text
+ * @param hrefs an array of href
+ */
+ protected void tableRowWithLink( String[] texts, String[] hrefs )
+ {
+ if ( hrefs.length != texts.length )
+ {
+ throw new IllegalArgumentException( "The arrays should have the same size" );
+ }
+
+ sink.tableRow();
+
+ for ( int i = 0; i < texts.length; i++ )
+ {
+ tableCellWithLink( texts[i], hrefs[i] );
+ }
+
+ sink.tableRow_();
+ }
+
protected void tableHeader( String[] content )
{
sink.tableRow();
@@ -209,10 +284,6 @@
sink.tableRow_();
}
- public abstract String getTitle();
-
- protected abstract void renderBody();
-
protected void tableCaption( String caption )
{
sink.tableCaption();
@@ -228,4 +299,17 @@
sink.paragraph_();
}
+
+ protected void link( String href, String name )
+ {
+ sink.link( href );
+
+ sink.text( name );
+
+ sink.link_();
+ }
+
+ public abstract String getTitle();
+
+ protected abstract void renderBody();
}
Modified: maven/components/trunk/maven-reports/maven-project-info-reports-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-reports/maven-project-info-reports-plugin/pom.xml?rev=179174&r1=179173&r2=179174&view=diff
==============================================================================
--- maven/components/trunk/maven-reports/maven-project-info-reports-plugin/pom.xml (original)
+++ maven/components/trunk/maven-reports/maven-project-info-reports-plugin/pom.xml Mon May 30 17:01:18 2005
@@ -10,4 +10,10 @@
<packaging>maven-plugin</packaging>
<name>Maven Project Info Reports Plugin</name>
<inceptionYear>2005</inceptionYear>
+ <contributors>
+ <contributor>
+ <name>Vincent Siveton</name>
+ <email>vincent.siveton@gmail.com</email>
+ </contributor>
+ </contributors>
</project>
Modified: maven/components/trunk/maven-reports/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-reports/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java?rev=179174&r1=179173&r2=179174&view=diff
==============================================================================
--- maven/components/trunk/maven-reports/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java (original)
+++ maven/components/trunk/maven-reports/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java Mon May 30 17:01:18 2005
@@ -19,20 +19,23 @@
import org.apache.maven.model.MailingList;
import org.apache.maven.model.Model;
import org.apache.maven.project.MavenProject;
-import org.apache.maven.reporting.AbstractMavenReportRenderer;
import org.apache.maven.reporting.AbstractMavenReport;
+import org.apache.maven.reporting.AbstractMavenReportRenderer;
import org.apache.maven.reporting.MavenReportException;
import org.codehaus.doxia.sink.Sink;
import org.codehaus.doxia.site.renderer.SiteRenderer;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import java.util.Locale;
/**
- * @goal mailing-list
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id: MailingListsReport.java,v 1.4 2005/02/23 00:08:03 brett Exp $
+ * @goal mailing-list
*/
public class MailingListsReport
extends AbstractMavenReport
@@ -117,7 +120,7 @@
r.render();
}
- catch( IOException e )
+ catch ( IOException e )
{
throw new MavenReportException( "Can't write the report " + getOutputName(), e );
}
@@ -165,20 +168,159 @@
startTable();
- tableHeader( new String[]{"Name", "Subscribe", "Unsubscribe", "Archive"} );
+ // To beautify the display
+ boolean otherArchives = false;
+ for ( Iterator i = model.getMailingLists().iterator(); i.hasNext(); )
+ {
+ MailingList m = (MailingList) i.next();
+ if ( ( ( m.getOtherArchives() != null ) ) && ( m.getOtherArchives().size() > 0 ) )
+ {
+ otherArchives = true;
+ }
+ }
+
+ if ( otherArchives )
+ {
+ tableHeader( new String[]{"Name", "Subscribe", "Unsubscribe", "Archive", "Other Archives"} );
+ }
+ else
+ {
+ tableHeader( new String[]{"Name", "Subscribe", "Unsubscribe", "Archive"} );
+ }
for ( Iterator i = model.getMailingLists().iterator(); i.hasNext(); )
{
MailingList m = (MailingList) i.next();
- // TODO: render otherArchives?
- tableRow( new String[]{m.getName(), m.getSubscribe(), m.getUnsubscribe(), m.getArchive()} );
+ // Verify that subsribe and unsubsribe lists are valid?
+ // Same for archive?
+ if ( ( ( m.getOtherArchives() != null ) ) && ( m.getOtherArchives().size() > 0 ) )
+ {
+ List textRow = new ArrayList();
+ List hrefRow = new ArrayList();
+
+ textRow.add( m.getName() );
+ hrefRow.add( null );
+
+ textRow.add( "Subscribe" );
+ hrefRow.add( m.getSubscribe() );
+
+ textRow.add( "Unsubscribe" );
+ hrefRow.add( m.getUnsubscribe() );
+
+ textRow.add( getArchiveServer( m.getArchive() ) );
+ hrefRow.add( m.getArchive() );
+
+ // For the first line
+ Iterator it = m.getOtherArchives().iterator();
+ String otherArchive = (String) it.next();
+
+ textRow.add( getArchiveServer( otherArchive ) );
+ hrefRow.add( otherArchive );
+ tableRowWithLink( (String[]) textRow.toArray( new String[0] ),
+ (String[]) hrefRow.toArray( new String[0] ) );
+
+ // Other lines...
+ while ( it.hasNext() )
+ {
+ otherArchive = (String) it.next();
+
+ // Reinit the list to beautify the display
+ textRow = new ArrayList();
+ hrefRow = new ArrayList();
+
+ textRow.add( "" );
+ hrefRow.add( null );
+
+ textRow.add( "" );
+ hrefRow.add( null );
+
+ textRow.add( "" );
+ hrefRow.add( null );
+
+ textRow.add( "" );
+ hrefRow.add( null );
+
+ textRow.add( getArchiveServer( otherArchive ) );
+ hrefRow.add( otherArchive );
+
+ tableRowWithLink( (String[]) textRow.toArray( new String[0] ),
+ (String[]) hrefRow.toArray( new String[0] ) );
+ }
+ }
+ else
+ {
+ if ( otherArchives )
+ {
+ List textRow = new ArrayList();
+ List hrefRow = new ArrayList();
+
+ textRow.add( m.getName() );
+ hrefRow.add( null );
+
+ textRow.add( "Subscribe" );
+ hrefRow.add( m.getSubscribe() );
+
+ textRow.add( "Unsubscribe" );
+ hrefRow.add( m.getUnsubscribe() );
+
+ textRow.add( getArchiveServer( m.getArchive() ) );
+ hrefRow.add( m.getArchive() );
+
+ textRow.add( "" );
+ hrefRow.add( null );
+
+ tableRowWithLink( (String[]) textRow.toArray( new String[0] ),
+ (String[]) hrefRow.toArray( new String[0] ) );
+ }
+ else
+ {
+ List textRow = new ArrayList();
+ List hrefRow = new ArrayList();
+
+ textRow.add( m.getName() );
+ hrefRow.add( null );
+
+ textRow.add( "Subscribe" );
+ hrefRow.add( m.getSubscribe() );
+
+ textRow.add( "Unsubscribe" );
+ hrefRow.add( m.getUnsubscribe() );
+
+ textRow.add( getArchiveServer( m.getArchive() ) );
+ hrefRow.add( m.getArchive() );
+
+ tableRowWithLink( (String[]) textRow.toArray( new String[0] ),
+ (String[]) hrefRow.toArray( new String[0] ) );
+ }
+ }
}
endTable();
}
endSection();
}
+ }
+
+ /**
+ * Convenience method to return the name of a web-based mailing list archive server.
+ * <br>
+ * For instance, if the archive uri is <code>http://www.mail-archive.com/dev@maven.apache.org</code>,
+ * this method return <code>www.mail-archive.com</code>
+ *
+ * @param uri
+ * @return the server name of a web-based mailing list archive server
+ */
+ private static String getArchiveServer( String uri )
+ {
+ if ( uri == null )
+ {
+ return "???UNKWOWN???";
+ }
+
+ int at = uri.indexOf( "//" );
+ int from = uri.indexOf( "/", at >= 0 ? ( uri.lastIndexOf( "/", at - 1 ) >= 0 ? 0 : at + 2 ) : 0 );
+ return uri.substring( at + 2, from );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org