[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
This commit is contained in:
Maria Odea B. Ching 2011-05-12 09:53:13 +00:00
parent 41f1416002
commit 397c8f3067
5 changed files with 30 additions and 5 deletions

View 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 )

View File

@ -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 {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 B

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 197 B