]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1463] better layout for artifact download box
authorMaria Odea B. Ching <oching@apache.org>
Thu, 12 May 2011 09:53:13 +0000 (09:53 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Thu, 12 May 2011 09:53:13 +0000 (09:53 +0000)
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-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download.bl.gif
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download.ml.gif
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download.tl.gif

index 23dcadd847317cb50142186fc3827b21d37f920f..4a0cbe24d46f29b4aaac7660a176f5ccdb9fe2a3 100644 (file)
@@ -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 )
index 99661460890ba5b59f7037c1e9728aba19c5ab83..8b24948db08d9dbef6010deda2eb80c88985f074 100644 (file)
@@ -45,7 +45,7 @@
        font-weight: bold;
        margin: 15px auto 0px auto;
        height: auto;
-       width: 150px;
+       width: 280px;
        min-width: 120px;
        display: block;
 }
 
 .download table {
   margin-left: 2px;
-  width: 140px;
+  width: 270px;
 }
 
 .download .icon {
 
 .download .type {
   font-size: 0.9em;
-  text-align: center;
+  text-align: left;
 }
 
 .download .size {
index c59ba00625d1d780296edeb67b43a9b2af222fd9..849bd582e19440e23011ad7357547e78b3c7b81e 100644 (file)
Binary files a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download.bl.gif and b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download.bl.gif differ
index 8fcfa4220ab8f65efa6aaa1142fa6c228d39c216..7f193e405cf2267eb7d32c87caeb544d5f15c432 100644 (file)
Binary files a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download.ml.gif and b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download.ml.gif differ
index b4a8e97d3fc499efeb8ad674860a3b264854a6ee..06ace5d45a6641f41176122349afb971cbd0e5a4 100644 (file)
Binary files a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download.tl.gif and b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download.tl.gif differ