From 4bd7d202930dd0ba9129c7bd6af7dd83bc294c24 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Wed, 13 May 2020 00:07:12 +0200 Subject: [PATCH] ui --- .../fanfix/library/WebLibraryServer.java | 160 +++++++++--------- .../fanfix/library/web/clear-32x32.png | Bin 0 -> 1848 bytes src/be/nikiroo/fanfix/library/web/clear.png | Bin 0 -> 1698 bytes src/be/nikiroo/fanfix/library/web/style.css | 21 ++- 4 files changed, 98 insertions(+), 83 deletions(-) create mode 100644 src/be/nikiroo/fanfix/library/web/clear-32x32.png create mode 100644 src/be/nikiroo/fanfix/library/web/clear.png diff --git a/src/be/nikiroo/fanfix/library/WebLibraryServer.java b/src/be/nikiroo/fanfix/library/WebLibraryServer.java index 4abd438b..7c5cf425 100644 --- a/src/be/nikiroo/fanfix/library/WebLibraryServer.java +++ b/src/be/nikiroo/fanfix/library/WebLibraryServer.java @@ -93,8 +93,8 @@ public class WebLibraryServer implements Runnable { subkeys.add(""); for (String subkey : subkeys) { - if (CookieUtils.validateCookie( - wookie + subkey + opts, rehashed)) { + if (CookieUtils.validateCookie(wookie + subkey + + opts, rehashed)) { this.wookie = wookie; this.token = token; this.success = true; @@ -148,8 +148,7 @@ public class WebLibraryServer implements Runnable { Integer port = Instance.getInstance().getConfig() .getInteger(Config.SERVER_PORT); if (port == null) { - throw new IOException( - "Cannot start web server: port not specified"); + throw new IOException("Cannot start web server: port not specified"); } int cacheMb = Instance.getInstance().getConfig() @@ -173,8 +172,8 @@ public class WebLibraryServer implements Runnable { if (!keystorePath.isEmpty()) { File keystoreFile = new File(keystorePath); try { - KeyStore keystore = KeyStore - .getInstance(KeyStore.getDefaultType()); + KeyStore keystore = KeyStore.getInstance(KeyStore + .getDefaultType()); InputStream keystoreStream = new FileInputStream( keystoreFile); try { @@ -226,8 +225,8 @@ public class WebLibraryServer implements Runnable { params.get("login"), whitelist); } else { String token = cookies.get("token"); - login = login(who, token, Instance.getInstance().getConfig() - .getList(Config.SERVER_ALLOWED_SUBKEYS)); + login = login(who, token, Instance.getInstance() + .getConfig().getList(Config.SERVER_ALLOWED_SUBKEYS)); } if (login.isSuccess()) { @@ -236,8 +235,9 @@ public class WebLibraryServer implements Runnable { } // refresh token - session.getCookies().set(new Cookie("token", - login.getToken(), "30; path=/")); + session.getCookies() + .set(new Cookie("token", login.getToken(), + "30; path=/")); // set options String optionName = params.get("optionName"); @@ -247,8 +247,9 @@ public class WebLibraryServer implements Runnable { session.getCookies().delete(optionName); cookies.remove(optionName); } else { - session.getCookies().set(new Cookie(optionName, - optionValue, "; path=/")); + session.getCookies().set( + new Cookie(optionName, optionValue, + "; path=/")); cookies.put(optionName, optionValue); } } @@ -258,7 +259,7 @@ public class WebLibraryServer implements Runnable { if (!login.isSuccess() && (uri.equals("/") // || uri.startsWith(STORY_URL_BASE) // || uri.startsWith(VIEWER_URL_BASE) // - || uri.startsWith(LIST_URL))) { + || uri.startsWith(LIST_URL))) { rep = loginPage(login, uri); } @@ -302,9 +303,10 @@ public class WebLibraryServer implements Runnable { NanoHTTPD.MIME_PLAINTEXT, "Not Found"); } } catch (Exception e) { - Instance.getInstance().getTraceHandler().error( - new IOException("Cannot process web request", - e)); + Instance.getInstance() + .getTraceHandler() + .error(new IOException( + "Cannot process web request", e)); rep = newFixedLengthResponse(Status.INTERNAL_ERROR, NanoHTTPD.MIME_PLAINTEXT, "An error occured"); } @@ -413,8 +415,8 @@ public class WebLibraryServer implements Runnable { wl = false; } - rw = Instance.getInstance().getConfig().getBoolean(Config.SERVER_RW, - rw); + rw = Instance.getInstance().getConfig() + .getBoolean(Config.SERVER_RW, rw); if (!subkey.isEmpty()) { List allowed = Instance.getInstance().getConfig() .getList(Config.SERVER_ALLOWED_SUBKEYS); @@ -448,10 +450,9 @@ public class WebLibraryServer implements Runnable { uri = "/"; } - builder.append( - "