Commit a0101259 authored by Syretta Man's avatar Syretta Man

modified copy command in docker

parent e112489c
Pipeline #113882 passed with stages
in 53 seconds
FROM openjdk:8
COPY ./webapp
RUN apt-get install maven
RUN install -y pandoc
RUN install -y textlive-latex-base
RUN install -y textlive-fonts-recommended
RUN install -y textlive-fonts-extra
RUN mvn package
WORKDIR webapp
CMD ["sh", "target/bin/simplewebapp"]
FROM openjdk:8
COPY ./webapp
COPY src ./webapp
RUN apt-get install maven
RUN install -y pandoc
RUN install -y textlive-latex-base
......
......@@ -25,6 +25,25 @@ public class WebServer {
server.start();
}
private static void writeToMDFile(File file, HTMLResultPage resultPage, String query) throws IOException {
BufferedWriter bw = new BufferedWriter(new FileWriter(file));
String answer = resultPage.getAnswer();
// Content
if (answer == null || answer.isEmpty()) {
bw.write("#Sorry\n");
bw.write("Sorry, we didn't understand _" + query + "_");
} else {
bw.write("#" + query + "\n");
bw.write(answer.replace("\n", "<br>"));
}
bw.write("[Back to Search Page](\"/\")");
bw.close();
}
static class Website extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
......@@ -40,22 +59,7 @@ public class WebServer {
} else if (filetype.equals("markdown")) {
File file = new File("answer.md");
BufferedWriter bw = new BufferedWriter(new FileWriter(file));
String answer = resultPage.getAnswer();
// Content
if (answer == null || answer.isEmpty()) {
bw.write("#Sorry\n");
bw.write("Sorry, we didn't understand _" + query + "_");
} else {
bw.write("#" + query + "\n");
bw.write(answer.replace("\n", "<br>"));
}
bw.write("[Back to Search Page](\"/\")");
bw.close();
writeToMDFile(file, resultPage, query);
resp.setContentType("text/markdown");
resp.setHeader("Content-disposition", "attachment; filename=sample.md");
......@@ -76,30 +80,13 @@ public class WebServer {
} else if (filetype.equals("pdf")) {
File file = new File("answer.md");
BufferedWriter bw = new BufferedWriter(new FileWriter(file));
String answer = resultPage.getAnswer();
// Content
if (answer == null || answer.isEmpty()) {
bw.write("#Sorry\n");
bw.write("Sorry, we didn't understand _" + query + "_");
} else {
bw.write("#" + query + "\n");
bw.write(answer.replace("\n", "<br>"));
}
bw.write("[Back to Search Page](\"/\")");
bw.close();
writeToMDFile(file, resultPage, query);
resp.setContentType("application/pdf");
resp.setHeader("Content-disposition", "attachment; filename=anything.pdf");
String path = file.getAbsolutePath();
ProcessBuilder pb = new ProcessBuilder("bash", "-c", "pandoc -s -o answer.pdf " + path);
// String[] cm = {"pandoc", "-s", "-o", "sample.pdf", "answer.md"};
// pb.command(cm);
Process process = pb.start();
try {
......
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