## Mimetype to extension map for detecting file type and show icon ## List of types match the icons in /solr/img/filetypes #set($extMap = {"application/x-7z-compressed": "7z", "application/postscript": "ai", "application/pgp-signature": "asc", "application/octet-stream": "bin", "application/x-bzip2": "bz2", "text/x-c": "c", "application/vnd.ms-htmlhelp": "chm", "application/java-vm": "class", "text/css": "css", "text/csv": "csv", "application/x-debian-package": "deb", "application/msword": "doc", "message/rfc822": "eml", "image/gif": "gif", "application/winhlp": "hlp", "text/html": "html", "application/java-archive": "jar", "text/x-java-source": "java", "image/jpeg": "jpeg", "application/javascript": "js", "application/vnd.oasis.opendocument.chart": "odc", "application/vnd.oasis.opendocument.formula": "odf", "application/vnd.oasis.opendocument.graphics": "odg", "application/vnd.oasis.opendocument.image": "odi", "application/vnd.oasis.opendocument.presentation": "odp", "application/vnd.oasis.opendocument.spreadsheet": "ods", "application/vnd.oasis.opendocument.text": "odt", "application/pdf": "pdf", "application/pgp-encrypted": "pgp", "image/png": "png", "application/vnd.ms-powerpoint": "ppt", "audio/x-pn-realaudio": "ram", "application/x-rar-compressed": "rar", "application/vnd.rn-realmedia": "rm", "application/rtf": "rtf", "application/x-shockwave-flash": "swf", "application/vnd.sun.xml.calc": "sxc", "application/vnd.sun.xml.draw": "sxd", "application/vnd.sun.xml.impress": "sxi", "application/vnd.sun.xml.writer": "sxw", "application/x-tar": "tar", "application/x-tex": "tex", "text/plain": "txt", "text/x-vcard": "vcf", "application/vnd.visio": "vsd", "audio/x-wav": "wav", "audio/x-ms-wma": "wma", "video/x-ms-wmv": "wmv", "application/vnd.ms-excel": "xls", "application/xml": "xml", "application/x-xpinstall": "xpi", "application/zip": "zip"}) #if($doc.getFieldValue('title')) #set($title = $esc.html($doc.getFirstValue('title'))) #else #set($title = "["+$doc.getFieldValue('id')+"]") #end #if($doc.getFieldValue('url')) #set($url = $doc.getFieldValue('url')) #elseif($doc.getFieldValue('resourcename')) #set($url = "file:///$doc.getFieldValue('resourcename')") #else #set($url = "$doc.getFieldValue('id')") #end #set($supportedtypes = "7z;ai;aiff;asc;audio;bin;bz2;c;cfc;cfm;chm;class;conf;cpp;cs;css;csv;deb;divx;doc;dot;eml;enc;file;gif;gz;hlp;htm;html;image;iso;jar;java;jpeg;jpg;js;lua;m;mm;mov;mp3;mpg;odc;odf;odg;odi;odp;ods;odt;ogg;pdf;pgp;php;pl;png;ppt;ps;py;ram;rar;rb;rm;rpm;rtf;sig;sql;swf;sxc;sxd;sxi;sxw;tar;tex;tgz;txt;vcf;video;vsd;wav;wma;wmv;xls;xml;xpi;xvid;zip") #set($ct = $list.get($doc.getFirstValue('content_type').split(";"),0)) #set($filename = $doc.getFieldValue('resourcename')) #set($filetype = false) #set($filetype = $extMap.get($ct)) ##TODO: falling back to file extension is convenient, except when you don't have an icon for that extension ## example "application/vnd.openxmlformats-officedocument.wordprocessingml.document" document ## with a .docx extension. It'd be nice to fall back to an "unknown" or the existing "file" type ## We sort of do this below, but only if the filename has no extension (anything after the last dot). #if(!$filetype)#set($filetype = $filename.substring($filename.lastIndexOf(".")).substring(1))#end ##if(!$filetype)#set($filetype = "file")#end ##if(!$supportedtypes.contains($filetype))#set($filetype = "file")#end
## Small file type icons from http://www.splitbrain.org/projects/file_icons (public domain) $title #if($params.getBool('mlt', false) == false)More Like This#end
Id: #field('id')
#if($doc.getFieldValue('resourcename'))Resource name: $filename #elseif($url)URL: $url #end #if($ct) ($ct)#end
#if($doc.getFieldValue('author'))
Author: #field('author')
#end #if($doc.getFieldValue('last_modified'))
last-modified: #field('last_modified')
#end
#field('content')
#set($mlt = $mltResults.get($docId)) #set($mltOn = $params.getBool('mlt')) #if($mltOn == true)
Similar Items
#end #if ($mltOn && $mlt && $mlt.size() > 0) #elseif($mltOn && $mlt.size() == 0)
No Similar Items Found
#end
#parse('debug.vm')