SOLR-3735: Relocate the example mime-to-extension mapping, and upgrade Velocity Engine to 1.7

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1426716 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2012-12-29 08:41:53 +00:00
parent f88d2ee6a7
commit fcc4d6f01a
6 changed files with 89 additions and 67 deletions

View File

@ -22,7 +22,27 @@ $Id$
================== 5.0.0 ==================
(No changes)
Versions of Major Components
---------------------
Apache Tika 1.2
Carrot2 3.5.0
Velocity 1.7 and Velocity Tools 2.0
Apache UIMA 2.3.1
Apache ZooKeeper 3.4.5
Upgrading from Solr 4.x
----------------------
TBD...
Detailed Change List
----------------------
Other Changes
----------------------
* SOLR-3735: Relocate the example mime-to-extension mapping, and
upgrade Velocity Engine to 1.7 (ehatcher)
================== 4.1.0 ==================

View File

@ -21,7 +21,7 @@
<dependencies>
<dependency org="commons-beanutils" name="commons-beanutils" rev="1.7.0" transitive="false"/>
<dependency org="commons-collections" name="commons-collections" rev="3.2.1" transitive="false"/>
<dependency org="org.apache.velocity" name="velocity" rev="1.6.4" transitive="false"/>
<dependency org="org.apache.velocity" name="velocity" rev="1.7" transitive="false"/>
<dependency org="org.apache.velocity" name="velocity-tools" rev="2.0" transitive="false"/>
<exclude org="*" ext="*" matcher="regexp" type="${ivy.exclude.types}"/>
</dependencies>

View File

@ -30,8 +30,6 @@ import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.tools.generic.*;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
public class VelocityResponseWriter implements QueryResponseWriter {
@ -84,64 +82,6 @@ public class VelocityResponseWriter implements QueryResponseWriter {
context.put("engine", engine); // for $engine.resourceExists(...)
// Mimetype to extension map for detecting file type and show icon
// List of types match the icons in /solr/img/filetypes
Map<String, String> mimeToExt = new HashMap<String, String>() {{
put("application/x-7z-compressed", "7z");
put("application/postscript", "ai");
put("application/pgp-signature", "asc");
put("application/octet-stream", "bin");
put("application/x-bzip2", "bz2");
put("text/x-c", "c");
put("application/vnd.ms-htmlhelp", "chm");
put("application/java-vm", "class");
put("text/css", "css");
put("text/csv", "csv");
put("application/x-debian-package", "deb");
put("application/msword", "doc");
put("message/rfc822", "eml");
put("image/gif", "gif");
put("application/winhlp", "hlp");
put("text/html", "html");
put("application/java-archive", "jar");
put("text/x-java-source", "java");
put("image/jpeg", "jpeg");
put("application/javascript", "js");
put("application/vnd.oasis.opendocument.chart", "odc");
put("application/vnd.oasis.opendocument.formula", "odf");
put("application/vnd.oasis.opendocument.graphics", "odg");
put("application/vnd.oasis.opendocument.image", "odi");
put("application/vnd.oasis.opendocument.presentation", "odp");
put("application/vnd.oasis.opendocument.spreadsheet", "ods");
put("application/vnd.oasis.opendocument.text", "odt");
put("application/pdf", "pdf");
put("application/pgp-encrypted", "pgp");
put("image/png", "png");
put("application/vnd.ms-powerpoint", "ppt");
put("audio/x-pn-realaudio", "ram");
put("application/x-rar-compressed", "rar");
put("application/vnd.rn-realmedia", "rm");
put("application/rtf", "rtf");
put("application/x-shockwave-flash", "swf");
put("application/vnd.sun.xml.calc", "sxc");
put("application/vnd.sun.xml.draw", "sxd");
put("application/vnd.sun.xml.impress", "sxi");
put("application/vnd.sun.xml.writer", "sxw");
put("application/x-tar", "tar");
put("application/x-tex", "tex");
put("text/plain", "txt");
put("text/x-vcard", "vcf");
put("application/vnd.visio", "vsd");
put("audio/x-wav", "wav");
put("audio/x-ms-wma", "wma");
put("video/x-ms-wmv", "wmv");
put("application/vnd.ms-excel", "xls");
put("application/xml", "xml");
put("application/x-xpinstall", "xpi");
put("application/zip", "zip");
}};
context.put("mimeToExt", mimeToExt);
String layout_template = request.getParams().get("v.layout");
String json_wrapper = request.getParams().get("v.json");
boolean wrap_response = (layout_template != null) || (json_wrapper != null);

View File

@ -1,3 +1,59 @@
## 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
@ -13,10 +69,16 @@
#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 = $mimeToExt.get($ct))
#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
##if(!$filetype)#set($filetype = "file")#end
##if(!$supportedtypes.contains($filetype))#set($filetype = "file")#end
<div class="result-title">
## Small file type icons from http://www.splitbrain.org/projects/file_icons (public domain)
<img src="#{url_root}/img/filetypes/${filetype}.png" align="center">
@ -29,7 +91,7 @@
#if($ct) ($ct)#end
</div>
#if($doc.getFieldValue('author'))<div>Author: #field('author')</div>#end
#if($doc.getFieldValue('last_modified'))<div>Last-modified: #field('last_modified')</div>#end
#if($doc.getFieldValue('last_modified'))<div>last-modified: #field('last_modified')</div>#end
<div class="result-body">#field('content')</div>
<div class="mlt">
#set($mlt = $mltResults.get($docId))

View File

@ -1 +0,0 @@
fcc58693dd8fc83d714fba149789be37cc19b66d

View File

@ -0,0 +1 @@
2ceb567b8f3f21118ecdec129fe1271dbc09aa7a