diff options
author | Joakim Erdfelt <joakime@apache.org> | 2007-05-22 15:48:23 +0000 |
---|---|---|
committer | Joakim Erdfelt <joakime@apache.org> | 2007-05-22 15:48:23 +0000 |
commit | 18454da4e7ee29279bd3f847c25e8930448c566a (patch) | |
tree | 53496096194694c215fb2c621d6fb3a795c33acf /archiva-web | |
parent | 8e4c990b3b4d4da66bc8d4b818cd2990158547e5 (diff) | |
download | archiva-18454da4e7ee29279bd3f847c25e8930448c566a.tar.gz archiva-18454da4e7ee29279bd3f847c25e8930448c566a.zip |
[MRM-346]: Show Artifact results in error 500.
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@540614 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-web')
-rw-r--r-- | archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java | 52 | ||||
-rw-r--r-- | archiva-web/archiva-webapp/src/main/webapp/css/site.css | 26 |
2 files changed, 72 insertions, 6 deletions
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java index a637fd549..691062b99 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java @@ -39,6 +39,7 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti import java.io.IOException; import java.io.Writer; +import java.text.DecimalFormat; import java.util.Iterator; import java.util.List; @@ -80,9 +81,12 @@ public class DownloadArtifact private boolean mini = false; + private DecimalFormat decimalFormat; + public DownloadArtifact( OgnlValueStack stack, PageContext pageContext ) { super( stack ); + decimalFormat = new DecimalFormat( "#,#00" ); this.req = (HttpServletRequest) pageContext.getRequest(); this.res = (HttpServletResponse) pageContext.getResponse(); try @@ -198,13 +202,29 @@ public class DownloadArtifact // Body sb.append( "<p class=\"body\">" ); + sb.append( "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" ); Iterator it = relatedArtifacts.iterator(); while ( it.hasNext() ) { ArchivaArtifact artifact = (ArchivaArtifact) it.next(); - + sb.append("\n<tr>"); + + sb.append( "<td class=\"icon\">" ); + appendImageLink( sb, prefix, layout, artifact ); + sb.append( "</td>" ); + + sb.append( "<td class=\"type\">" ); appendLink( sb, prefix, layout, artifact ); + sb.append( "</td>" ); + + sb.append( "<td class=\"size\">" ); + appendFilesize( sb, artifact ); + sb.append( "</td>" ); + + sb.append("</tr>"); } + sb.append( "</table>" ); + sb.append( "</p>" ); sb.append( "</div>" ); // close "downloadbox.bd.c" sb.append( "</div>" ); // close "downloadbox.bd" @@ -212,6 +232,27 @@ public class DownloadArtifact sb.append( "<div class=\"ft\"><div class=\"c\"></div></div>" ); sb.append( "</div>" ); // close "download" } + + private void appendImageLink( StringBuffer sb, String prefix, BidirectionalRepositoryLayout layout, ArchivaArtifact artifact ) + { + StringBuffer url = new StringBuffer(); + String path = layout.toPath( artifact ); + String type = artifact.getType(); + + url.append( prefix ); + url.append( "/" ).append( path ); + + String filename = path.substring( path.lastIndexOf( "/" ) + 1 ); + + sb.append( "<a href=\"" ).append( StringEscapeUtils.escapeXml( url.toString() ) ).append( "\"" ); + sb.append( " title=\"" ).append( "Download " ).append( StringEscapeUtils.escapeXml( filename ) ).append( "\"" ); + sb.append( ">" ); + + sb.append( "<img src=\"" ).append( req.getContextPath() ); + sb.append( "/images/download-type-" ).append( type ).append( ".png\" />" ); + + sb.append( "</a>" ); + } private void appendLink( StringBuffer sb, String prefix, BidirectionalRepositoryLayout layout, ArchivaArtifact artifact ) @@ -229,13 +270,14 @@ public class DownloadArtifact sb.append( " title=\"" ).append( "Download " ).append( StringEscapeUtils.escapeXml( filename ) ).append( "\"" ); sb.append( ">" ); - sb.append( "<img src=\"" ).append( req.getContextPath() ); - sb.append( "/images/download-type-" ).append( type ).append( ".png\" />" ); - - // TODO: Include file size / date in output ? sb.append( StringUtils.capitalize( type ) ); sb.append( "</a>" ); } + + private void appendFilesize( StringBuffer sb, ArchivaArtifact artifact ) + { + sb.append( decimalFormat.format( artifact.getModel().getSize() ) ); + } public void setArtifactId( String artifactId ) { diff --git a/archiva-web/archiva-webapp/src/main/webapp/css/site.css b/archiva-web/archiva-webapp/src/main/webapp/css/site.css index 73c65f9db..03f6a4f6f 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/css/site.css +++ b/archiva-web/archiva-webapp/src/main/webapp/css/site.css @@ -107,6 +107,30 @@ text-decoration: none; } +.download p.body { + font-weight: bold; +} + +.download table { + margin-left: 5px; + width: 140px; +} + +.download .icon { + width: 16px; +} + +.download .type { + font-size: 0.9em; + text-align: right; +} + +.download .size { + font-weight: normal; + font-size: 0.8em; + text-align: right; +} + #contentArea { /* margin-right: 15em; */ padding: 1em; @@ -342,4 +366,4 @@ div.admin table.consumers th { div.admin table.consumers td strong { font-size: 0.8em; -}
\ No newline at end of file +} |