Skip to content
Permalink
Browse files

Updated Solr snapshots writer for a cleaner html head

  • Loading branch information...
luccioman committed Oct 13, 2018
1 parent f366f43 commit 50b6edfcf56feb6aa930bfb287e4862b0b59c82d
Showing with 18 additions and 4 deletions.
  1. +18 −4 source/net/yacy/cora/federate/solr/responsewriter/SnapshotImagesReponseWriter.java
@@ -5,8 +5,6 @@
import java.util.HashSet;
import java.util.Set;

import net.yacy.search.schema.CollectionSchema;

import org.apache.lucene.document.Document;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
@@ -18,6 +16,8 @@
import org.apache.solr.search.DocList;
import org.apache.solr.search.SolrIndexSearcher;

import net.yacy.search.schema.CollectionSchema;

/**
* this writer is supposed to be used to generate iframes. It generates links for the /api/snapshot.jpg servlet.
*/
@@ -48,15 +48,29 @@ public String getContentType(SolrQueryRequest arg0, SolrQueryResponse arg1) {
@Override
public void init(@SuppressWarnings("rawtypes") NamedList n) {
}

/**
* Append the response HTML head to the writer.
* @param writer an open output writer. Must not be null.
* @throws IOException when a write error occurred
*/
private void writeHtmlHead(final Writer writer) throws IOException {
writer.write("<!DOCTYPE html>\n");
writer.write("<html lang=\"en\">");
writer.write("<head>\n");
writer.write("<meta charset=\"UTF-8\">");
writer.write("<title>Documents snapshots</title>\n");
writer.write("</head>\n");
}

@Override
public void write(final Writer writer, final SolrQueryRequest request, final SolrQueryResponse rsp) throws IOException {
NamedList<?> values = rsp.getValues();
assert values.get("responseHeader") != null;
assert values.get("response") != null;

writer.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
writer.write("<head></head><body>\n");
writeHtmlHead(writer);
writer.write("<body>\n");
final SolrParams originalParams = request.getOriginalParams();

final int width = originalParams.getInt("width", DEFAULT_WIDTH);

0 comments on commit 50b6edf

Please sign in to comment.
You can’t perform that action at this time.