improve default style, improve FileServer
This commit is contained in:
parent
c4e7b5b2a8
commit
c2ed21a2c5
2 changed files with 14 additions and 2 deletions
|
@ -56,6 +56,14 @@ public class FileServer implements IRequestCatcher, RequestHandler.Listener {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String fileContent(Request request, String s) {
|
||||||
|
String r = request.context.file(s);
|
||||||
|
if(!s.endsWith(".html") && !s.endsWith(".htm")) {
|
||||||
|
r = "<pre>" + r.replace("<", "<").replace(">", ">") + "</pre>";
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/style.css")
|
@Path("/style.css")
|
||||||
public void style(Request request, Callback<Response> res, Callback<Throwable> rej) {
|
public void style(Request request, Callback<Response> res, Callback<Throwable> rej) {
|
||||||
|
@ -65,13 +73,13 @@ public class FileServer implements IRequestCatcher, RequestHandler.Listener {
|
||||||
@GET
|
@GET
|
||||||
@Path(".*/")
|
@Path(".*/")
|
||||||
public void onIndex(Request request, Callback<Response> res, Callback<Throwable> rej) {
|
public void onIndex(Request request, Callback<Response> res, Callback<Throwable> rej) {
|
||||||
res.call(new Response(request, request.context.file(data.getString("dir") + request.path.replace("..", "") + "/index.html"), 200, "OK"));
|
res.call(new Response(request, fileContent(request, data.getString("dir") + request.path.replace("..", "") + "/index.html"), 200, "OK"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/.+")
|
@Path("/.+")
|
||||||
public void onFile(Request request, Callback<Response> res, Callback<Throwable> rej) {
|
public void onFile(Request request, Callback<Response> res, Callback<Throwable> rej) {
|
||||||
res.call(new Response(request, request.context.file(data.getString("dir") + request.path.replace("..", "")), 200, "OK"));
|
res.call(new Response(request, fileContent(request, data.getString("dir") + request.path.replace("..", "")), 200, "OK"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -14,6 +14,10 @@ body {
|
||||||
text-align: justify;
|
text-align: justify;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue