X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;ds=sidebyside;f=library%2FWebLibraryServerHtml.java;h=69d8671736d7e2e4cf8c2922ca61358803f6bd2f;hb=e992c260c059c53c4aabc980db85efd58f190205;hp=8895fb83a07b0eb6ff7116b3998a7a89a2acfb15;hpb=002972e9de731678035d56304d75a6d9e8233635;p=fanfix.git diff --git a/library/WebLibraryServerHtml.java b/library/WebLibraryServerHtml.java index 8895fb8..69d8671 100644 --- a/library/WebLibraryServerHtml.java +++ b/library/WebLibraryServerHtml.java @@ -22,6 +22,7 @@ import be.nikiroo.fanfix.data.Paragraph.ParagraphType; import be.nikiroo.fanfix.data.Story; import be.nikiroo.fanfix.library.WebLibraryServer.WLoginResult; import be.nikiroo.fanfix.library.web.WebLibraryServerIndex; +import be.nikiroo.fanfix.library.web.templates.WebLibraryServerTemplates; import be.nikiroo.fanfix.reader.TextOutput; import be.nikiroo.utils.IOUtils; import be.nikiroo.utils.NanoHTTPD; @@ -173,13 +174,13 @@ abstract class WebLibraryServerHtml implements Runnable { } Response rep = null; - if (!login.isSuccess() - && WebLibraryUrls.isSupportedUrl(uri, true)) { - rep = loginPage(login, uri); - } + try { + if (!login.isSuccess() + && WebLibraryUrls.isSupportedUrl(uri, true)) { + rep = loginPage(login, uri); + } - if (rep == null) { - try { + if (rep == null) { if (WebLibraryUrls.isSupportedUrl(uri, false)) { if (WebLibraryUrls.INDEX_URL.equals(uri)) { rep = root(session, cookies, login); @@ -253,13 +254,12 @@ abstract class WebLibraryServerHtml implements Runnable { NanoHTTPD.MIME_PLAINTEXT, "Not Found"); } } - } catch (Exception e) { - Instance.getInstance().getTraceHandler().error( - new IOException("Cannot process web request", - e)); - rep = newFixedLengthResponse(Status.INTERNAL_ERROR, - NanoHTTPD.MIME_PLAINTEXT, "An error occured"); } + } catch (Exception e) { + Instance.getInstance().getTraceHandler().error( + new IOException("Cannot process web request", e)); + rep = newFixedLengthResponse(Status.INTERNAL_ERROR, + NanoHTTPD.MIME_PLAINTEXT, "An error occured"); } return rep; @@ -309,31 +309,34 @@ abstract class WebLibraryServerHtml implements Runnable { this.tracer = tracer; } - private Response loginPage(WLoginResult login, String uri) { + private Response loginPage(WLoginResult login, String uri) + throws IOException { StringBuilder builder = new StringBuilder(); - appendPreHtml(builder, true); + builder.append(getTemplateIndexPreBanner(true)); if (login.isBadLogin()) { - builder.append("
You must be logged into the system to see the stories.
"); + builder.append("\t\t\t\n"); + builder.append("\t\t\t\n"); + builder.append("\t\t\t\n"); + builder.append("\t\t\n"); - appendPostHtml(builder); + builder.append(getTemplate("index.post")); return NanoHTTPD.newFixedLengthResponse(Status.FORBIDDEN, NanoHTTPD.MIME_HTML, builder.toString()); @@ -345,7 +348,7 @@ abstract class WebLibraryServerHtml implements Runnable { MetaResultList result = new MetaResultList(metas(login)); StringBuilder builder = new StringBuilder(); - appendPreHtml(builder, true); + builder.append(getTemplateIndexPreBanner(true)); Map