maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From denn...@apache.org
Subject svn commit: r494236 - in /maven/doxia/trunk: doxia-core/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/default-site.vm
Date Mon, 08 Jan 2007 23:14:43 GMT
Author: dennisl
Date: Mon Jan  8 15:14:41 2007
New Revision: 494236

URL: http://svn.apache.org/viewvc?view=rev&rev=494236
Log:
[DOXIA-87] Add support for class="externalLink" on links in the same way that Maven 1 did

Modified:
    maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java
    maven/doxia/trunk/doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/default-site.vm

Modified: maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java?view=diff&rev=494236&r1=494235&r2=494236
==============================================================================
--- maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java
(original)
+++ maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java
Mon Jan  8 15:14:41 2007
@@ -645,7 +645,14 @@
     {
         if ( !headFlag )
         {
-            write( "<a href=\"" + HtmlTools.escapeHTML( name ) + "\">" );
+            if ( isExternalLink( name ) )
+            {
+                write( "<a href=\"" + HtmlTools.escapeHTML( name ) + "\" class=\"externalLink\">"
);
+            }
+            else
+            {
+                write( "<a href=\"" + HtmlTools.escapeHTML( name ) + "\">" );
+            }
         }
     }
 
@@ -653,8 +660,21 @@
     {
         if ( !headFlag )
         {
-            write( "<a href=\"" + HtmlTools.escapeHTML( name ) + "\" target=\"" + target
+ "\">" );
+            if ( isExternalLink( name ) )
+            {
+                write( "<a href=\"" + HtmlTools.escapeHTML( name ) + "\" class=\"externalLink\"
target=\"" + target +
+                    "\">" );
+            }
+            else
+            {
+                write( "<a href=\"" + HtmlTools.escapeHTML( name ) + "\" target=\"" +
target + "\">" );
+            }
         }
+    }
+
+    private static boolean isExternalLink( String href )
+    {
+        return href.toLowerCase().startsWith( "http" ) || href.toLowerCase().startsWith(
"https" );
     }
 
     public void link_()

Modified: maven/doxia/trunk/doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/default-site.vm
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/default-site.vm?view=diff&rev=494236&r1=494235&r2=494236
==============================================================================
--- maven/doxia/trunk/doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/default-site.vm
(original)
+++ maven/doxia/trunk/doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/default-site.vm
Mon Jan  8 15:14:41 2007
@@ -1,5 +1,13 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
+#macro ( link $href $name )
+  #if ( ( $href.toLowerCase().startsWith("http") || $href.toLowerCase().startsWith("https")
) )
+    <a href="$href" class="externalLink">$name</a>
+  #else
+    <a href="$href">$name</a>
+  #end
+#end
+
 #macro ( banner $banner $id )
   #if ( $banner )
     #if( $banner.href )
@@ -38,7 +46,7 @@
     #set ( $counter = $counter + 1 )
     #set ( $currentItemHref = $PathTool.calculateLink( $item.href, $relativePath ) )
     #set ( $currentItemHref = $currentItemHref.replaceAll( "\\", "/" ) )
-    <a href="$currentItemHref">$item.name</a>
+    #link( $currentItemHref $item.name )
     #if ( $links.size() > $counter )
       |
     #end
@@ -55,7 +63,7 @@
     #if ( $currentItemHref == $alignedFileName || $currentItemHref == "" )
       $item.name
     #else
-      <a href="$currentItemHref">$item.name</a>
+      #link( $currentItemHref $item.name )
     #end
     #if ( $breadcrumbs.size() > $counter )
       &gt;
@@ -111,7 +119,7 @@
     #if ( $alignedFileName == $currentItemHref )
       <strong>$item.name</strong>
     #else
-      <a href="$currentItemHref">$item.name</a>
+      #link( $currentItemHref $item.name )
     #end
   #if ( $item && $item.items && $item.items.size() > 0 )
     #if ( $collapse == "expanded" )



Mime
View raw message