mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-21 00:00:13 +02:00
fix html header in Solr HTMLResponseWriter
- move 1st body content after </head> tag - add closing <span> tag
This commit is contained in:
parent
a09e70cd68
commit
3d5d366f1c
|
@ -89,8 +89,6 @@ public class HTMLResponseWriter implements QueryResponseWriter {
|
||||||
NamedList<Object> paramsList = request.getOriginalParams().toNamedList();
|
NamedList<Object> paramsList = request.getOriginalParams().toNamedList();
|
||||||
paramsList.remove("wt");
|
paramsList.remove("wt");
|
||||||
String xmlquery = dqp.matcher("/solr/select?" + SolrParams.toSolrParams(paramsList).toString()).replaceAll("%22");
|
String xmlquery = dqp.matcher("/solr/select?" + SolrParams.toSolrParams(paramsList).toString()).replaceAll("%22");
|
||||||
writer.write("<div id=\"api\"><a href=\"" + xmlquery + "\"><img src=\"../env/grafics/api.png\" width=\"60\" height=\"40\" alt=\"API\" /></a>\n");
|
|
||||||
writer.write("<span>This search result can also be retrieved as XML. Click the API icon to see this page as XML.</div>\n");
|
|
||||||
|
|
||||||
DocList response = ((ResultContext) values.get("response")).docs;
|
DocList response = ((ResultContext) values.get("response")).docs;
|
||||||
final int sz = response.size();
|
final int sz = response.size();
|
||||||
|
@ -99,22 +97,27 @@ public class HTMLResponseWriter implements QueryResponseWriter {
|
||||||
DocIterator iterator = response.iterator();
|
DocIterator iterator = response.iterator();
|
||||||
IndexSchema schema = request.getSchema();
|
IndexSchema schema = request.getSchema();
|
||||||
|
|
||||||
if (sz == 1) {
|
|
||||||
int id = iterator.nextDoc();
|
int id = iterator.nextDoc();
|
||||||
Document doc = searcher.doc(id, DEFAULT_FIELD_LIST);
|
Document doc = searcher.doc(id, DEFAULT_FIELD_LIST);
|
||||||
LinkedHashMap<String, String> tdoc = translateDoc(schema, doc);
|
LinkedHashMap<String, String> tdoc = translateDoc(schema, doc);
|
||||||
|
|
||||||
String title = tdoc.get(CollectionSchema.title.getSolrFieldName());
|
String title = tdoc.get(CollectionSchema.title.getSolrFieldName());
|
||||||
|
if (sz == 1) {
|
||||||
writer.write("<title>" + title + "</title>\n</head><body>\n");
|
writer.write("<title>" + title + "</title>\n</head><body>\n");
|
||||||
writeDoc(writer, tdoc, title);
|
|
||||||
} else {
|
} else {
|
||||||
writer.write("<title>Document List</title>\n</head><body>\n");
|
writer.write("<title>Document List</title>\n</head><body>\n");
|
||||||
for (int i = 0; i < sz; i++) {
|
|
||||||
int id = iterator.nextDoc();
|
|
||||||
Document doc = searcher.doc(id, DEFAULT_FIELD_LIST);
|
|
||||||
LinkedHashMap<String, String> tdoc = translateDoc(schema, doc);
|
|
||||||
String title = tdoc.get(CollectionSchema.title.getSolrFieldName());
|
|
||||||
writeDoc(writer, tdoc, title);
|
|
||||||
}
|
}
|
||||||
|
writer.write("<div id=\"api\"><a href=\"" + xmlquery + "\"><img src=\"../env/grafics/api.png\" width=\"60\" height=\"40\" alt=\"API\" /></a>\n");
|
||||||
|
writer.write("<span>This search result can also be retrieved as XML. Click the API icon to see this page as XML.</span></div>\n");
|
||||||
|
|
||||||
|
writeDoc(writer, tdoc, title);
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
id = iterator.nextDoc();
|
||||||
|
doc = searcher.doc(id, DEFAULT_FIELD_LIST);
|
||||||
|
tdoc = translateDoc(schema, doc);
|
||||||
|
title = tdoc.get(CollectionSchema.title.getSolrFieldName());
|
||||||
|
writeDoc(writer, tdoc, title);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
writer.write("<title>No Document Found</title>\n</head><body>\n");
|
writer.write("<title>No Document Found</title>\n</head><body>\n");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user