#** * Render a complex document in the results list *# ## Load Mime-Type List and Mapping #parse('mime_type_lists.vm') ## Sets: ## * supportedMimeTypes, AKA supportedtypes ## * mimeExtensionsMap, AKA extMap ## Title #if($doc.getFieldValue('title')) #set($title = $esc.html($doc.getFirstValue('title'))) #else #set($title = "["+$doc.getFieldValue('id')+"]") #end ## URL #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 ## Sort out Mime-Type #set($ct = $list.get($doc.getFirstValue('content_type').split(";"),0)) #set($filename = $doc.getFieldValue('resourcename')) #set($filetype = false) #set($filetype = $mimeExtensionsMap.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(!$supportedMimeTypes.contains($filetype)) ## #set($filetype = "file") ## #end ## Row 1: Icon and Title and mlt link
## Icon ## Small file type icons from http://www.splitbrain.org/projects/file_icons (public domain) ## Title, hyperlinked $title ## Link for MLT / More Like This / Find Similar #if($params.getBool('mlt', false) == false) More Like This #end
## Row 2?: ID / URL
Id: #field('id')
## Resource Name
#if($doc.getFieldValue('resourcename')) Resource name: $filename #elseif($url) URL: $url #end #if($ct) ($ct) #end
## Author #if($doc.getFieldValue('author'))
Author: #field('author')
#end ## Last_Modified Date #if($doc.getFieldValue('last_modified'))
last-modified: #field('last_modified')
#end ## Main content of doc
#field('content')
## Display Similar Documents / MLT = More Like This
#set($mlt = $mltResults.get($docId)) #set($mltOn = $params.getBool('mlt')) #if($mltOn == true)
Similar Items
#end ## If has MLT enabled An Entries to show #if ($mltOn && $mlt && $mlt.size() > 0) ## Else MLT Enabled but no mlt results for this query #elseif($mltOn && $mlt.size() == 0)
No Similar Items Found
#end
## div class=mlt #parse('debug.vm')