Commit 3ff5d471 authored by Joshua Priestley's avatar Joshua Priestley
Browse files

Added basic styling

parent d3066303
Pipeline #172218 passed with stages
in 18 seconds
......@@ -6,36 +6,93 @@ import java.io.PrintWriter;
public class HTMLResultPage implements Page {
private final String query;
private final String answer;
private final String query;
private final String answer;
public HTMLResultPage(String query, String answer) {
this.query = query;
this.answer = answer;
public HTMLResultPage(String query, String answer) {
this.query = query;
this.answer = answer;
}
public void writeTo(HttpServletResponse resp) throws IOException {
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
writer.println(
"<html>\n" + " <head>\n" + " <title>\n" + " Welcome\n" + " </title>\n");
writer.println(
"<style>body {\n"
+ " font-family: Helvetica, sans-serif;\n"
+ " }\n"
+ "\n"
+ " .container {\n"
+ " width: 500px;\n"
+ " height: 350px;\n"
+ " background-color: rgb(238, 238, 238);\n"
+ " position: fixed;\n"
+ " border: 2px solid rgb(190, 190, 190);\n"
+ " top: 50%;\n"
+ " left: 50%;\n"
+ " transform: translate(-50%, -90%);\n"
+ " border-radius: 20px;\n"
+ " padding:40px;\n"
+ " }\n"
+ " \n"
+ " h1 {\n"
+ " font-family: Helvetica, sans-serif;\n"
+ " margin-top: 30px;\n"
+ " }\n"
+ " hr {\n"
+ " border: 3px solid rgb(190, 190, 190);\n"
+ " border-radius: 5px;\n"
+ " }\n"
+ " \n"
+ " input[type=text], select {\n"
+ " width: 100%;\n"
+ " padding: 12px 20px;\n"
+ " margin: 8px 0;\n"
+ " display: inline-block;\n"
+ " border: 1px solid #ccc;\n"
+ " border-radius: 4px;\n"
+ " box-sizing: border-box;\n"
+ "}\n"
+ "\n"
+ "input[type=submit], button {\n"
+ " width: 100%;\n"
+ " background-color: #4CAF50;\n"
+ " color: white;\n"
+ " padding: 14px 20px;\n"
+ " margin: 8px 0;\n"
+ " border: none;\n"
+ " border-radius: 4px;\n"
+ " cursor: pointer;\n"
+ " }\n"
+ "\n"
+ " input[type=submit]:hover {\n"
+ " background-color: #45a049;\n"
+ " }\n"
+ "\n"
+ " form {\n"
+ " margin-top: 30px;\n"
+ " }</style>");
writer.println("</head><body><div class=\"container\"><h1>");
if (answer == null || answer.isEmpty()) {
writer.println("Query Not Found");
} else {
writer.println(query.toUpperCase());
}
public void writeTo(HttpServletResponse resp) throws IOException {
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
// Header
writer.println("<html>");
writer.println("<head><title>" + query + "</title></head>");
writer.println("<body>");
// Content
if (answer == null || answer.isEmpty()) {
writer.println("<h1>Sorry</h1>");
writer.print("<p>Sorry, we didn't understand <em>" + query + "</em></p>");
} else {
writer.println("<h1>" + query + "</h1>");
writer.println("<p>" + answer.replace("\n", "<br>") + "</p>");
}
writer.println("<p><a href=\"/\">Back to Search Page</a></p>");
// Footer
writer.println("</body>");
writer.println("</html>");
writer.println("</h1><hr>");
if (answer == null || answer.isEmpty()) {
writer.print("<p>Sorry, we didn't understand <em>" + query + "</em></p>");
} else {
writer.println("<p>" + answer.replace("\n", "<br>") + "</p>");
}
writer.println("<a href=\"/\"><button>Back to Search Page</button></a>");
writer.println("</div></body></html>");
}
}
......@@ -6,30 +6,96 @@ import java.io.PrintWriter;
public class IndexPage implements Page {
public void writeTo(HttpServletResponse resp) throws IOException {
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
public void writeTo(HttpServletResponse resp) throws IOException {
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
// Header
writer.println("<html>");
writer.println("<head><title>Welcome</title></head>");
writer.println("<body>");
// Header
writer.println(
"<html>\n" + " <head>\n" + " <title>\n" + " Welcome\n" + " </title>\n");
// Content
writer.println(
"<h1>Welcome!!</h1>" +
"<p>Enter your query in the box below: " +
"<form>" +
"<input type=\"text\" name=\"q\" />" +
"<input type=\"radio\" id=\"md\" name=\"markdown\" value=\"md\">" +
"<label for=\"markdown\">Download as Markdown file?</label><br>" +
"<br><br><input type=\"submit\">" +
"</form>" +
"</p>");
writer.println(
"<style>body {\n"
+ " font-family: Helvetica, sans-serif;\n"
+ " }\n"
+ "\n"
+ " .container {\n"
+ " width: 500px;\n"
+ " height: 350px;\n"
+ " background-color: rgb(238, 238, 238);\n"
+ " position: fixed;\n"
+ " border: 2px solid rgb(190, 190, 190);\n"
+ " top: 50%;\n"
+ " left: 50%;\n"
+ " transform: translate(-50%, -90%);\n"
+ " border-radius: 20px;\n"
+ " padding:40px;\n"
+ " }\n"
+ " \n"
+ " h1 {\n"
+ " font-family: Helvetica, sans-serif;\n"
+ " margin-top: 30px;\n"
+ " }\n"
+ " hr {\n"
+ " border: 3px solid rgb(190, 190, 190);\n"
+ " border-radius: 5px;\n"
+ " }\n"
+ " \n"
+ " input[type=text], select {\n"
+ " width: 100%;\n"
+ " padding: 12px 20px;\n"
+ " margin: 8px 0;\n"
+ " display: inline-block;\n"
+ " border: 1px solid #ccc;\n"
+ " border-radius: 4px;\n"
+ " box-sizing: border-box;\n"
+ "}\n"
+ "\n"
+ "input[type=submit] {\n"
+ " width: 100%;\n"
+ " background-color: #4CAF50;\n"
+ " color: white;\n"
+ " padding: 14px 20px;\n"
+ " margin: 8px 0;\n"
+ " border: none;\n"
+ " border-radius: 4px;\n"
+ " cursor: pointer;\n"
+ " }\n"
+ "\n"
+ " input[type=submit]:hover {\n"
+ " background-color: #45a049;\n"
+ " }\n"
+ "\n"
+ " form {\n"
+ " margin-top: 30px;\n"
+ " }</style>");
// Footer
writer.println("</body>");
writer.println("</html>");
}
writer.println(
" </head>\n"
+ " <body>\n"
+ " <div class=\"container\">\n"
+ " <h1>\n"
+ " Search\n"
+ " </h1>\n"
+ " <hr>\n"
+ " <form>\n"
+ " <label>Enter your query in the box below.</label>\n"
+ " <input type=\"text\" name=\"q\" />\n"
+ " <label for=\"dl\">Choose a download type:</label>\n"
+ "\n"
+ " <select name=\"markdown\" id=\"dl\">\n"
+ " <option>No Download (Default)</option>\n"
+ " <option id=\"md\" name=\"markdown\" value=\"md\">Markdown File</option>\n"
+ " <option value=\"pdf\">PDF File</option>\n"
+ " </select>\n"
+ " <input type=\"submit\">\n"
+ " </form>\n"
+ " </div>\n"
+ " </body>\n"
+ "</html>");
// Footer
writer.println("</body>");
writer.println("</html>");
}
}
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