2 * Render a complex document in the results list
5 ## Load Mime-Type List and Mapping
6 #parse('mime_type_lists.vm')
8 ## * supportedMimeTypes, AKA supportedtypes
9 ## * mimeExtensionsMap, AKA extMap
12 #if($doc.getFieldValue('title'))
13 #set($title = $esc.html($doc.getFirstValue('title')))
15 #set($title = "["+$doc.getFieldValue('id')+"]")
19 #if($doc.getFieldValue('url'))
20 #set($url = $doc.getFieldValue('url'))
21 #elseif($doc.getFieldValue('resourcename'))
22 #set($url = "file:///$doc.getFieldValue('resourcename')")
24 #set($url = "$doc.getFieldValue('id')")
28 #set($ct = $list.get($doc.getFirstValue('content_type').split(";"),0))
29 #set($filename = $doc.getFieldValue('resourcename'))
30 #set($filetype = false)
31 #set($filetype = $mimeExtensionsMap.get($ct))
33 ## TODO: falling back to file extension is convenient,
34 ## except when you don't have an icon for that extension
35 ## example "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
36 ## document with a .docx extension.
37 ## It'd be nice to fall back to an "unknown" or the existing "file" type
38 ## We sort of do this below, but only if the filename has no extension
39 ## (anything after the last dot).
42 #set($filetype = $filename.substring($filename.lastIndexOf(".")).substring(1))
46 ## #set($filetype = "file")
48 ## #if(!$supportedMimeTypes.contains($filetype))
49 ## #set($filetype = "file")
52 ## Row 1: Icon and Title and mlt link
53 <div class="result-title">
55 ## Small file type icons from http://www.splitbrain.org/projects/file_icons (public domain)
56 <img src="#{url_root}/img/filetypes/${filetype}.png" align="center">
59 <a href="${url}" target="_blank">
62 ## Link for MLT / More Like This / Find Similar
64 #if($params.getBool('mlt', false) == false)
65 <a href="#lensNoQ&q=id:%22$docId%22&mlt=true">
79 #if($doc.getFieldValue('resourcename'))
80 Resource name: $filename
90 #if($doc.getFieldValue('author'))
92 Author: #field('author')
97 #if($doc.getFieldValue('last_modified'))
100 #field('last_modified')
104 ## Main content of doc
105 <div class="result-body">
109 ## Display Similar Documents / MLT = More Like This
111 #set($mlt = $mltResults.get($docId))
112 #set($mltOn = $params.getBool('mlt'))
114 <div class="field-name">
118 ## If has MLT enabled An Entries to show
119 #if ($mltOn && $mlt && $mlt.size() > 0)
121 #foreach($mltHit in $mlt)
122 #set($mltId = $mltHit.getFieldValue('id'))
125 <a href="#url_for_home?q=id:$mltId">
129 <span class="field-name">
132 $mltHit.getFieldValue('title')
135 <span class="field-name">
138 $mltHit.getFieldValue('author')
139 <span class="field-name">
142 $mltHit.getFieldValue('description')
145 #end ## end for each mltHit in $mlt
147 ## Else MLT Enabled but no mlt results for this query
148 #elseif($mltOn && $mlt.size() == 0)
149 <div>No Similar Items Found</div>
151 </div> ## div class=mlt