Commit 201fa8fc authored by RobJBarr's avatar RobJBarr
Browse files

Changed name of pdf to be query name and removed unnecessary imports

parent 71e9dc37
Pipeline #173420 passed with stages
...@@ -2,18 +2,16 @@ package ic.doc.web; ...@@ -2,18 +2,16 @@ package ic.doc.web;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
public class MarkdownResultPage implements Page { public class MarkdownResultPage implements Page {
private final String query; protected final String query;
private final String answer; protected final String answer;
public MarkdownResultPage(String query, String answer) { public MarkdownResultPage(String query, String answer) {
this.query = query; this.query = query;
...@@ -40,7 +38,7 @@ public class MarkdownResultPage implements Page { ...@@ -40,7 +38,7 @@ public class MarkdownResultPage implements Page {
} }
File getFile() throws IOException { File getFile() throws IOException {
File markdown = new File("result.md"); File markdown = new File((query +".md"));
// Header // Header
FileWriter writer = new FileWriter(markdown); FileWriter writer = new FileWriter(markdown);
writer.write("<h1>" + query + "<h1>"); writer.write("<h1>" + query + "<h1>");
......
...@@ -16,10 +16,8 @@ public class PDFResultPage extends MarkdownResultPage { ...@@ -16,10 +16,8 @@ public class PDFResultPage extends MarkdownResultPage {
File markdown = getFile(); File markdown = getFile();
String file_name = markdown.getName();
String[] parts = file_name.split(".");
resp.setHeader("Content-Disposition", "Inline; filename=" + parts[0] + ".pdf"); resp.setHeader("Content-Disposition", "Inline; filename=" + query + ".pdf");
ProcessBuilder pb = new ProcessBuilder("pandoc", markdown.getAbsolutePath(), "-o", "result.pdf"); ProcessBuilder pb = new ProcessBuilder("pandoc", markdown.getAbsolutePath(), "-o", "result.pdf");
Process p = pb.start(); Process p = pb.start();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment