X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FWebLibraryServer.java;h=35b8ab5774eea4cfaedbb7ec615b0abc6ec16049;hb=37d1f0766561becb99d5fd9a9cba25f208844da5;hp=3e2c90605de78b2956290b4b36b56bb8a6a42688;hpb=04ae006fdc06b9cbad52f9851ffcb5ad58068318;p=nikiroo-utils.git
diff --git a/src/be/nikiroo/fanfix/library/WebLibraryServer.java b/src/be/nikiroo/fanfix/library/WebLibraryServer.java
index 3e2c906..35b8ab5 100644
--- a/src/be/nikiroo/fanfix/library/WebLibraryServer.java
+++ b/src/be/nikiroo/fanfix/library/WebLibraryServer.java
@@ -672,7 +672,8 @@ public class WebLibraryServer implements Runnable {
// 1-based (0 = desc)
int chapter = 0;
if (chapterStr != null && !"cover".equals(chapterStr)
- && !"metadata".equals(chapterStr) && !"json".equals(chapterStr)) {
+ && !"metadata".equals(chapterStr)
+ && !"json".equals(chapterStr)) {
try {
chapter = Integer.parseInt(chapterStr);
if (chapter < 0) {
@@ -711,7 +712,7 @@ public class WebLibraryServer implements Runnable {
JSONObject json = JsonIO.toJson(meta);
mimeType = "application/json";
in = new ByteArrayInputStream(json.toString().getBytes());
- } else if ("json".equals(chapterStr)) {
+ } else if ("json".equals(chapterStr)) {
Story story = story(luid, whitelist);
JSONObject json = JsonIO.toJson(story);
mimeType = "application/json";
@@ -835,6 +836,12 @@ public class WebLibraryServer implements Runnable {
String first, previous, next, last;
String content;
+ String disabledLeft = "";
+ String disabledRight = "";
+ String disabledZoomReal = "";
+ String disabledZoomWidth = "";
+ String disabledZoomHeight = "";
+
if (paragraph <= 0) {
first = getViewUrl(luid, 1, null);
previous = getViewUrl(luid, (Math.max(chapter - 1, 1)),
@@ -847,6 +854,11 @@ public class WebLibraryServer implements Runnable {
content = "
\n"
+ new TextOutput(false).convert(chap, true)
+ "
\n";
+
+ if (chapter <= 1)
+ disabledLeft = " disabled='disbaled'";
+ if (chapter >= story.getChapters().size())
+ disabledRight = " disabled='disbaled'";
} else {
first = getViewUrl(luid, chapter, 1);
previous = getViewUrl(luid, chapter,
@@ -856,6 +868,11 @@ public class WebLibraryServer implements Runnable {
last = getViewUrl(luid, chapter,
chap.getParagraphs().size());
+ if (paragraph <= 1)
+ disabledLeft = " disabled='disbaled'";
+ if (paragraph >= chap.getParagraphs().size())
+ disabledRight = " disabled='disbaled'";
+
Paragraph para = null;
try {
para = chap.getParagraphs().get(paragraph - 1);
@@ -867,15 +884,20 @@ public class WebLibraryServer implements Runnable {
if (para.getType() == ParagraphType.IMAGE) {
String zoomStyle = "max-width: 100%;";
+ disabledZoomWidth = " disabled='disabled'";
String zoomOption = cookies.get("zoom");
if (zoomOption != null && !zoomOption.isEmpty()) {
if (zoomOption.equals("real")) {
zoomStyle = "";
+ disabledZoomWidth = "";
+ disabledZoomReal = " disabled='disabled'";
} else if (zoomOption.equals("width")) {
zoomStyle = "max-width: 100%;";
} else if (zoomOption.equals("height")) {
// see height of navbar + optionbar
zoomStyle = "max-height: calc(100% - 128px);";
+ disabledZoomWidth = "";
+ disabledZoomHeight = " disabled='disabled'";
}
}
content = String.format("" //
@@ -893,16 +915,16 @@ public class WebLibraryServer implements Runnable {
builder.append(String.format("" //
+ "\n" //
- + "\t
<<\n"//
- + "\t
<\n"//
- + "\t
>\n"//
- + "\t
>>\n"//
+ + "\t
<<\n"//
+ + "\t
<\n"//
+ + "\t
>\n"//
+ + "\t
>>\n"//
+ "
\n" //
+ "%s", //
- first, //
- previous, //
- next, //
- last, //
+ disabledLeft, first, //
+ disabledLeft, previous, //
+ disabledRight, next, //
+ disabledRight, last, //
content //
));
@@ -918,12 +940,15 @@ public class WebLibraryServer implements Runnable {
if (paragraph > 0) {
builder.append(String.format("" //
- + "\tREAL\n"//
- + "\tWIDTH\n"//
- + "\tHEIGHT\n"//
+ + "\tREAL\n"//
+ + "\tWIDTH\n"//
+ + "\tHEIGHT\n"//
+ "\n", //
+ disabledZoomReal,
uri + "?optionName=zoom&optionValue=real", //
+ disabledZoomWidth,
uri + "?optionName=zoom&optionValue=width", //
+ disabledZoomHeight,
uri + "?optionName=zoom&optionValue=height" //
));
}
@@ -1073,7 +1098,7 @@ public class WebLibraryServer implements Runnable {
if (banner) {
builder.append("\n");
- builder.append("\t
\n");
builder.append("\t
Fanfix
\n");
@@ -1099,4 +1124,10 @@ public class WebLibraryServer implements Runnable {
}
builder.append(">").append(name).append("\n");
}
+
+ public static void main(String[] args) throws IOException {
+ Instance.init();
+ WebLibraryServer web = new WebLibraryServer(false);
+ web.run();
+ }
}