Skip to content

Instantly share code, notes, and snippets.

@mhayes
Created August 30, 2010 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhayes/558245 to your computer and use it in GitHub Desktop.
Save mhayes/558245 to your computer and use it in GitHub Desktop.
component output="no" {
public function fileAnchorTag(
required relativePath,
displayName,
fileType) {
// determine file details
var fileInfo = GetFileInfo(ExpandPath(relativePath));
// set default params
param name="arguments.fileType", default="";
param name="arguments.displayName", default="#fileInfo.name#";
// fetch file size
var fileSizeInKb = Round(fileInfo.size * 0.0009765625);
// generate link
var linkTag = "<a href='#arguments.relativePath#'>#displayName#</a>";
var infoText = "#fileSizeInKb# kb";
if(arguments.fileType neq "") {
infoText = "#arguments.fileType# #infoText#";
}
return "#linkTag# <em>(#infoText#)</em>";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment