is a nice example
@@ -44,7 +45,6 @@ public class SolrParamResourceLoader extends ResourceLoader {
templates.put(name.substring(9) + ".vm",params.get(name));
}
}
-
}
public void init(ExtendedProperties extendedProperties) {
diff --git a/contrib/velocity/src/main/java/org/apache/solr/request/SolrVelocityResourceLoader.java b/contrib/velocity/src/main/java/org/apache/solr/request/SolrVelocityResourceLoader.java
new file mode 100644
index 00000000000..b485213adfc
--- /dev/null
+++ b/contrib/velocity/src/main/java/org/apache/solr/request/SolrVelocityResourceLoader.java
@@ -0,0 +1,34 @@
+package org.apache.solr.request;
+
+import org.apache.velocity.runtime.resource.loader.ResourceLoader;
+import org.apache.velocity.runtime.resource.Resource;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.commons.collections.ExtendedProperties;
+import org.apache.solr.core.SolrResourceLoader;
+
+import java.io.InputStream;
+
+// TODO: the name of this class seems ridiculous
+public class SolrVelocityResourceLoader extends ResourceLoader {
+ private SolrResourceLoader loader;
+
+ public SolrVelocityResourceLoader(SolrResourceLoader loader) {
+ super();
+ this.loader = loader;
+ }
+
+ public void init(ExtendedProperties extendedProperties) {
+ }
+
+ public InputStream getResourceStream(String template_name) throws ResourceNotFoundException {
+ return loader.openResource(template_name);
+ }
+
+ public boolean isSourceModified(Resource resource) {
+ return false;
+ }
+
+ public long getLastModified(Resource resource) {
+ return 0;
+ }
+}
diff --git a/contrib/velocity/src/main/java/org/apache/solr/request/VelocityResponseWriter.java b/contrib/velocity/src/main/java/org/apache/solr/request/VelocityResponseWriter.java
index 1b50c744869..ae4d309f022 100644
--- a/contrib/velocity/src/main/java/org/apache/solr/request/VelocityResponseWriter.java
+++ b/contrib/velocity/src/main/java/org/apache/solr/request/VelocityResponseWriter.java
@@ -49,8 +49,10 @@ public class VelocityResponseWriter implements QueryResponseWriter {
baseDir = new File(template_root);
}
engine.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, baseDir.getAbsolutePath());
- engine.setProperty("params.resource.loader.instance",new SolrParamResourceLoader(request));
- engine.setProperty(VelocityEngine.RESOURCE_LOADER, "params,file");
+ engine.setProperty("params.resource.loader.instance", new SolrParamResourceLoader(request));
+ engine.setProperty("solr.resource.loader.instance",
+ new SolrVelocityResourceLoader(request.getCore().getSolrConfig().getResourceLoader()));
+ engine.setProperty(VelocityEngine.RESOURCE_LOADER, "params,file,solr");
return engine;
}
diff --git a/contrib/velocity/src/main/solr/conf/velocity/browse.vm b/contrib/velocity/src/main/solr/conf/velocity/browse.vm
index 7cffe9600d0..9c1b4e11489 100644
--- a/contrib/velocity/src/main/solr/conf/velocity/browse.vm
+++ b/contrib/velocity/src/main/solr/conf/velocity/browse.vm
@@ -44,19 +44,7 @@
-#if (${nlResponse.suggestions.size()} > 0)
-
-
Did you mean?
- #foreach ($suggestion in ${nlResponse.suggestions})
-
${suggestion}#if ($velocityCount < $nlResponse.suggestions.size()),#end
- #end
-
-#end
-#if (${nlResponse.autoSpell} == true)
-There were no results for your original query, so we automatically searched a few spelling
- variants: ${nlResponse.autoSpellQuery}
-
-#end
+
#foreach($id in $doclist.iterator())
#set($doc = $searcher.doc($id,$response.returnFields))