From 397c8f30673d3a46edc27b414c846b2d202c0a5b Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Thu, 12 May 2011 09:53:13 +0000 Subject: [PATCH] [MRM-1463] better layout for artifact download box submitted by Lucien Weller o enlarged box to 280px (CSS and images) o display size in KB, MB, GB depending on effective size o added classifier next to type when available git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-1.3.x@1102222 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva/web/tags/DownloadArtifact.java | 29 ++++++++++++++++-- .../src/main/webapp/css/site.css | 6 ++-- .../src/main/webapp/images/download.bl.gif | Bin 179 -> 198 bytes .../src/main/webapp/images/download.ml.gif | Bin 103 -> 116 bytes .../src/main/webapp/images/download.tl.gif | Bin 179 -> 197 bytes 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java index 23dcadd84..4a0cbe24d 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java @@ -59,6 +59,10 @@ public class DownloadArtifact extends Component { private static final String DEFAULT_DOWNLOAD_IMAGE = "download-type-other.png"; + + private static final double KILO_BYTE = 1024.0; + private static final double MEGA_BYTE = 1048576.0; + private static final double GIGA_BYTE = 1073741824.0; /** * @plexus.requirement role-hint="jdo" @@ -100,7 +104,7 @@ public class DownloadArtifact public DownloadArtifact( ValueStack stack, PageContext pageContext ) { super( stack ); - decimalFormat = new DecimalFormat( "#,#00" ); + decimalFormat = new DecimalFormat( "#,##0.00" ); this.req = (HttpServletRequest) pageContext.getRequest(); this.res = (HttpServletResponse) pageContext.getResponse(); try @@ -290,13 +294,34 @@ public class DownloadArtifact { String type = artifact.getType(); String linkText = StringUtils.capitalize( type ); + + if( artifact.getModel().getClassifier() != null && !artifact.getModel().getClassifier().trim().equals( "" ) ) + { + linkText = new StringBuilder(linkText).append(" (").append(artifact.getModel().getClassifier()).append(")").toString(); + } appendLink( sb, prefix, repo, artifact, linkText ); } private void appendFilesize( StringBuffer sb, ArchivaArtifact artifact ) { - sb.append( decimalFormat.format( artifact.getModel().getSize() ) ); + long size = artifact.getModel().getSize(); + if( size > GIGA_BYTE ) + { + sb.append( decimalFormat.format( artifact.getModel().getSize() / GIGA_BYTE ) ).append(" GB"); + } + else if( size > MEGA_BYTE ) + { + sb.append( decimalFormat.format( artifact.getModel().getSize() / MEGA_BYTE ) ).append(" MB"); + } + else if( size > KILO_BYTE ) + { + sb.append( decimalFormat.format( artifact.getModel().getSize() / KILO_BYTE ) ).append(" KB"); + } + else + { + sb.append( decimalFormat.format( artifact.getModel().getSize() ) ).append(" B"); + } } public void setArtifactId( String artifactId ) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css index 996614608..8b24948db 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css @@ -45,7 +45,7 @@ font-weight: bold; margin: 15px auto 0px auto; height: auto; - width: 150px; + width: 280px; min-width: 120px; display: block; } @@ -113,7 +113,7 @@ .download table { margin-left: 2px; - width: 140px; + width: 270px; } .download .icon { @@ -122,7 +122,7 @@ .download .type { font-size: 0.9em; - text-align: center; + text-align: left; } .download .size { diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download.bl.gif b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download.bl.gif index c59ba00625d1d780296edeb67b43a9b2af222fd9..849bd582e19440e23011ad7357547e78b3c7b81e 100644 GIT binary patch delta 141 zcmV;80CNAc0mcCcM@dFFIbk9JkqAP3A^{2j00eUom`SU>IP1;3|6nMNWNDtLcNA&s zzHlthbWI(Et?zvA|1m@WNGuwU$d^LEN;;p=C{S?-G^NIP1;3|6nMN<57@ks;+G7 zW(V=kbZy@p65xFA{~m?l1S}elGsPi5L^_|)jY2tSMz7f8G_ka1zu?+*dJqH%-mrQt c8jlf&17J?C+wb_ie$Vgw|A2vlgL@GGJB;EuO#lD@ diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download.ml.gif b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download.ml.gif index 8fcfa4220ab8f65efa6aaa1142fa6c228d39c216..7f193e405cf2267eb7d32c87caeb544d5f15c432 100644 GIT binary patch delta 93 zcmV-j0HXhAbO=XDMmRZPA_0*I9!??w3IG5CMMRFN%k2-NoV41Dv)){q4u;}Lmgb2f zU&^-b3&-Os*Y=I)Ag%ZQ4~+4G#G>&y86ua=rcddNN~b3%^@`0>tlF-(TL1t%HXtkE delta 80 zcmV-W0I&aaX9!10MmRZPz5tO39znhU3IG5CI7E)A%k2-NoV40|4c@%_4~C5f22-whOfH+x-Dnui uZoA*`t3t4j+wb_i8xhd^|A2u^2LytKhlqy0kZ)JM@dFFIbps4kqAO*z5ogU00dxA$%)PZIP1;3|6nMNWNDr#I4Oq^ z5QQPnbZy^wuJ3&B|G=P7CrKOvv7vIwY&xINndC4?Mz7ecc57oHx!|yPyi*9Q