Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/lui-solr
[lui-solr.git] / zookeeper / solr / collection1 / conf / velocity / richtext_doc.vm
1 #**
2  *  Render a complex document in the results list
3  *#
4
5 ## Load Mime-Type List and Mapping
6 #parse('mime_type_lists.vm')
7 ## Sets:
8 ## * supportedMimeTypes, AKA supportedtypes
9 ## * mimeExtensionsMap, AKA extMap
10
11 ## Title
12 #if($doc.getFieldValue('title'))
13   #set($title = $esc.html($doc.getFirstValue('title')))
14 #else
15   #set($title = "["+$doc.getFieldValue('id')+"]")
16 #end
17
18 ## URL
19 #if($doc.getFieldValue('url'))
20   #set($url = $doc.getFieldValue('url'))
21 #elseif($doc.getFieldValue('resourcename'))
22   #set($url = "file:///$doc.getFieldValue('resourcename')")
23 #else
24   #set($url = "$doc.getFieldValue('id')")
25 #end
26
27 ## Sort out Mime-Type
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))
32
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).
40
41 #if(!$filetype)
42   #set($filetype = $filename.substring($filename.lastIndexOf(".")).substring(1))
43 #end
44
45 ## #if(!$filetype)
46 ##   #set($filetype = "file")
47 ## #end
48 ## #if(!$supportedMimeTypes.contains($filetype))
49 ##   #set($filetype = "file")
50 ## #end
51
52 ## Row 1: Icon and Title and mlt link
53 <div class="result-title">
54   ## Icon
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">
57
58   ## Title, hyperlinked
59   <a href="${url}" target="_blank">
60     <b>$title</b></a>
61
62   ## Link for MLT / More Like This / Find Similar
63   <span class="mlt">
64     #if($params.getBool('mlt', false) == false)
65       <a href="#lensNoQ&q=id:%22$docId%22&mlt=true">
66         More Like This</a>
67     #end
68   </span>
69
70 </div>
71
72 ## Row 2?: ID / URL
73 <div>
74   Id: #field('id')
75 </div>
76
77 ## Resource Name
78 <div>
79   #if($doc.getFieldValue('resourcename'))
80     Resource name: $filename 
81   #elseif($url)
82     URL: $url
83   #end
84   #if($ct)
85     ($ct)
86   #end
87 </div>
88
89 ## Author
90 #if($doc.getFieldValue('author'))
91   <div>
92     Author: #field('author')
93   </div>
94 #end
95
96 ## Last_Modified Date
97 #if($doc.getFieldValue('last_modified'))
98   <div>
99     last-modified:
100     #field('last_modified')
101   </div>
102 #end
103
104 ## Main content of doc
105 <div class="result-body">
106   #field('content')
107 </div>
108
109 ## Display Similar Documents / MLT = More Like This
110 <div class="mlt">
111   #set($mlt = $mltResults.get($docId))
112   #set($mltOn = $params.getBool('mlt'))
113   #if($mltOn == true)
114     <div class="field-name">
115       Similar Items
116     </div>
117   #end
118   ## If has MLT enabled An Entries to show
119   #if ($mltOn && $mlt && $mlt.size() > 0)
120     <ul>
121       #foreach($mltHit in $mlt)
122         #set($mltId = $mltHit.getFieldValue('id'))
123         <li>
124           <div>
125             <a href="#url_for_home?q=id:$mltId">
126               $mltId</a>
127           </div>
128           <div>
129             <span class="field-name">
130               Title:
131             </span>
132             $mltHit.getFieldValue('title')
133           </div>
134           <div>
135             <span class="field-name">
136               Author:
137             </span>
138             $mltHit.getFieldValue('author')
139             <span class="field-name">
140               Description:
141             </span>
142             $mltHit.getFieldValue('description')
143           </div>
144         </li>
145       #end    ## end for each mltHit in $mlt
146     </ul>
147   ## Else MLT Enabled but no mlt results for this query
148   #elseif($mltOn && $mlt.size() == 0)
149     <div>No Similar Items Found</div>
150   #end
151 </div>  ## div class=mlt
152
153 #parse('debug.vm')