blob: 6ffb04c01dc7e26d54ecd1991769fcb5bc88a343 [file] [log] [blame]
#**
* 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
<div class="result-title">
## Icon
## Small file type icons from http://www.splitbrain.org/projects/file_icons (public domain)
<img src="#{url_root}/img/filetypes/${filetype}.png" align="center">
## Title, hyperlinked
<a href="${url}" target="_blank">
<b>$title</b></a>
## Link for MLT / More Like This / Find Similar
<span class="mlt">
#if($params.getBool('mlt', false) == false)
<a href="#lensNoQ&q=id:%22$docId%22&mlt=true">
More Like This</a>
#end
</span>
</div>
## Row 2?: ID / URL
<div>
Id: #field('id')
</div>
## Resource Name
<div>
#if($doc.getFieldValue('resourcename'))
Resource name: $filename
#elseif($url)
URL: $url
#end
#if($ct)
($ct)
#end
</div>
## Author
#if($doc.getFieldValue('author'))
<div>
Author: #field('author')
</div>
#end
## Last_Modified Date
#if($doc.getFieldValue('last_modified'))
<div>
last-modified:
#field('last_modified')
</div>
#end
## Main content of doc
<div class="result-body">
#field('content')
</div>
## Display Similar Documents / MLT = More Like This
<div class="mlt">
#set($mlt = $mltResults.get($docId))
#set($mltOn = $params.getBool('mlt'))
#if($mltOn == true)
<div class="field-name">
Similar Items
</div>
#end
## If has MLT enabled An Entries to show
#if ($mltOn && $mlt && $mlt.size() > 0)
<ul>
#foreach($mltHit in $mlt)
#set($mltId = $mltHit.getFieldValue('id'))
<li>
<div>
<a href="#url_for_home?q=id:$mltId">
$mltId</a>
</div>
<div>
<span class="field-name">
Title:
</span>
$mltHit.getFieldValue('title')
</div>
<div>
<span class="field-name">
Author:
</span>
$mltHit.getFieldValue('author')
<span class="field-name">
Description:
</span>
$mltHit.getFieldValue('description')
</div>
</li>
#end ## end for each mltHit in $mlt
</ul>
## Else MLT Enabled but no mlt results for this query
#elseif($mltOn && $mlt.size() == 0)
<div>No Similar Items Found</div>
#end
</div> ## div class=mlt
#parse('debug.vm')