Commit af2677a7 authored by RobJBarr's avatar RobJBarr
Browse files

Added style file and made html pages read from it

parent 47c9f0e2
Pipeline #172415 failed with stages
in 18 seconds
......@@ -17,65 +17,18 @@ public class HTMLResultPage implements Page {
public void writeTo(HttpServletResponse resp) throws IOException {
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
File style = new File("style.html");
BufferedReader reader = new BufferedReader(new FileReader(style));
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>");
String line = reader.readLine();
while (line != null){
writer.println(line);
line = reader.readLine();
}
writer.println("</head><body><div class=\"container\"><h1>");
if (answer == null || answer.isEmpty()) {
......
......@@ -9,80 +9,19 @@ public class IndexPage implements Page {
public void writeTo(HttpServletResponse resp) throws IOException {
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
File style = new File("style.html");
BufferedReader reader = new BufferedReader(new FileReader(style));
// Header
writer.println(
"<html>\n" + " <head>\n" + " <title>\n" + " Welcome\n" + " </title>\n");
<<<<<<< HEAD
// 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>");
>>>>>>> 3ff5d47141923be40daa258eba11f2769370e385
String line = reader.readLine();
while (line != null){
writer.println(line);
line = reader.readLine();
}
writer.println(
" </head>\n"
......
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