From: Niki Roo
Date: Sun, 17 May 2020 20:02:52 +0000 (+0200)
Subject: update from master
X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=e992c260c059c53c4aabc980db85efd58f190205;p=nikiroo-utils.git
update from master
---
diff --git a/data/MetaData.java b/data/MetaData.java
index bcebf75..2e34ef9 100644
--- a/data/MetaData.java
+++ b/data/MetaData.java
@@ -9,6 +9,12 @@ import be.nikiroo.utils.StringUtils;
/**
* The meta data associated to a {@link Story} object.
+ *
+ * Note that some earlier version of the program did not save the resume as an
+ * external file; for those stories, the resume is not fetched until the story
+ * is.
+ *
+ * The cover is never fetched until the story is.
*
* @author niki
*/
@@ -120,6 +126,10 @@ public class MetaData implements Cloneable, Comparable, Serializable {
* The story resume (a.k.a. description).
*
* This can be NULL if we don't have a resume for this {@link Story}.
+ *
+ * Note that some earlier version of the program did not save the resume as
+ * an external file; for those stories, the resume is not fetched until the
+ * story is.
*
* @return the resume
*/
@@ -129,6 +139,10 @@ public class MetaData implements Cloneable, Comparable, Serializable {
/**
* The story resume (a.k.a. description).
+ *
+ * Note that some earlier version of the program did not save the resume as
+ * an external file; for those stories, the resume is not fetched until the
+ * story is.
*
* @param resume
* the resume to set
@@ -139,6 +153,8 @@ public class MetaData implements Cloneable, Comparable, Serializable {
/**
* The cover image of the story if any (can be NULL).
+ *
+ * The cover is not fetched until the story is.
*
* @return the cover
*/
@@ -148,6 +164,8 @@ public class MetaData implements Cloneable, Comparable, Serializable {
/**
* The cover image of the story if any (can be NULL).
+ *
+ * The cover is not fetched until the story is.
*
* @param cover
* the cover to set
diff --git a/library/BasicLibrary.java b/library/BasicLibrary.java
index 8b72f19..f77d0ed 100644
--- a/library/BasicLibrary.java
+++ b/library/BasicLibrary.java
@@ -475,6 +475,8 @@ abstract public class BasicLibrary {
/**
* Retrieve a specific {@link Story}.
+ *
+ * Note that it will update both the cover and the resume in meta.
*
* @param luid
* the Library UID of the story
@@ -513,6 +515,8 @@ abstract public class BasicLibrary {
/**
* Retrieve a specific {@link Story}.
+ *
+ * Note that it will update both the cover and the resume in meta.
*
* @param luid
* the LUID of the story
diff --git a/library/LocalLibrary.java b/library/LocalLibrary.java
index f655d4d..25f2ec9 100644
--- a/library/LocalLibrary.java
+++ b/library/LocalLibrary.java
@@ -625,6 +625,18 @@ public class LocalLibrary extends BasicLibrary {
files.add(coverFile);
}
+ String summaryExt = ".summary";
+ File summaryFile = new File(path + summaryExt);
+ if (!summaryFile.exists()) {
+ summaryFile = new File(
+ path.substring(0, path.length() - fileExt.length())
+ + summaryExt);
+ }
+
+ if (summaryFile.exists()) {
+ files.add(summaryFile);
+ }
+
return files;
}
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("
Bad login or password
");
+ builder.append(
+ "\t\t
Bad login or password
");
} else if (login.isBadCookie()) {
- builder.append("
Your session timed out
");
+ builder.append(
+ "\t\t
Your session timed out
");
}
if (WebLibraryUrls.LOGOUT_URL.equals(uri)) {
uri = WebLibraryUrls.INDEX_URL;
}
+ builder.append("\t\t\n");
+ "\t\t\t
You must be logged into the system to see the stories.