git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix icon not shown if not connected
[fanfix.git]
/
src
/
be
/
nikiroo
/
fanfix
/
library
/
WebLibraryServer.java
diff --git
a/src/be/nikiroo/fanfix/library/WebLibraryServer.java
b/src/be/nikiroo/fanfix/library/WebLibraryServer.java
index e0096fcc590b94963137d1476d9f57caf7398124..35b8ab5774eea4cfaedbb7ec615b0abc6ec16049 100644
(file)
--- a/
src/be/nikiroo/fanfix/library/WebLibraryServer.java
+++ b/
src/be/nikiroo/fanfix/library/WebLibraryServer.java
@@
-231,6
+231,10
@@
public class WebLibraryServer implements Runnable {
}
if (login.isSuccess()) {
}
if (login.isSuccess()) {
+ if (!login.isWl()) {
+ whitelist.clear();
+ }
+
// refresh token
session.getCookies().set(new Cookie("token",
login.getToken(), "30; path=/"));
// refresh token
session.getCookies().set(new Cookie("token",
login.getToken(), "30; path=/"));
@@
-651,6
+655,7
@@
public class WebLibraryServer implements Runnable {
// /story/luid/chapter/para <-- text/image
// /story/luid/cover <-- image
// /story/luid/metadata <-- json
// /story/luid/chapter/para <-- text/image
// /story/luid/cover <-- image
// /story/luid/metadata <-- json
+ // /story/luid/json <-- json, whole chapter (no images)
private Response getStoryPart(String uri, List<String> whitelist) {
String[] cover = uri.split("/");
int off = 2;
private Response getStoryPart(String uri, List<String> whitelist) {
String[] cover = uri.split("/");
int off = 2;
@@
-667,7
+672,8
@@
public class WebLibraryServer implements Runnable {
// 1-based (0 = desc)
int chapter = 0;
if (chapterStr != null && !"cover".equals(chapterStr)
// 1-based (0 = desc)
int chapter = 0;
if (chapterStr != null && !"cover".equals(chapterStr)
- && !"metadata".equals(chapterStr)) {
+ && !"metadata".equals(chapterStr)
+ && !"json".equals(chapterStr)) {
try {
chapter = Integer.parseInt(chapterStr);
if (chapter < 0) {
try {
chapter = Integer.parseInt(chapterStr);
if (chapter < 0) {
@@
-706,6
+712,11
@@
public class WebLibraryServer implements Runnable {
JSONObject json = JsonIO.toJson(meta);
mimeType = "application/json";
in = new ByteArrayInputStream(json.toString().getBytes());
JSONObject json = JsonIO.toJson(meta);
mimeType = "application/json";
in = new ByteArrayInputStream(json.toString().getBytes());
+ } else if ("json".equals(chapterStr)) {
+ Story story = story(luid, whitelist);
+ JSONObject json = JsonIO.toJson(story);
+ mimeType = "application/json";
+ in = new ByteArrayInputStream(json.toString().getBytes());
} else {
Story story = story(luid, whitelist);
if (story != null) {
} else {
Story story = story(luid, whitelist);
if (story != null) {
@@
-825,6
+836,12
@@
public class WebLibraryServer implements Runnable {
String first, previous, next, last;
String content;
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)),
if (paragraph <= 0) {
first = getViewUrl(luid, 1, null);
previous = getViewUrl(luid, (Math.max(chapter - 1, 1)),
@@
-837,6
+854,11
@@
public class WebLibraryServer implements Runnable {
content = "<div class='viewer text'>\n"
+ new TextOutput(false).convert(chap, true)
+ "</div>\n";
content = "<div class='viewer text'>\n"
+ new TextOutput(false).convert(chap, true)
+ "</div>\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,
} else {
first = getViewUrl(luid, chapter, 1);
previous = getViewUrl(luid, chapter,
@@
-846,6
+868,11
@@
public class WebLibraryServer implements Runnable {
last = getViewUrl(luid, chapter,
chap.getParagraphs().size());
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);
Paragraph para = null;
try {
para = chap.getParagraphs().get(paragraph - 1);
@@
-857,15
+884,20
@@
public class WebLibraryServer implements Runnable {
if (para.getType() == ParagraphType.IMAGE) {
String zoomStyle = "max-width: 100%;";
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 = "";
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);";
} 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("" //
}
}
content = String.format("" //
@@
-883,16
+915,16
@@
public class WebLibraryServer implements Runnable {
builder.append(String.format("" //
+ "<div class='bar navbar'>\n" //
builder.append(String.format("" //
+ "<div class='bar navbar'>\n" //
- + "\t<a class='button first' href='%s'><<</a>\n"//
- + "\t<a class='button previous' href='%s'><</a>\n"//
- + "\t<a class='button next' href='%s'>></a>\n"//
- + "\t<a class='button last' href='%s'>>></a>\n"//
+ + "\t<a
%s
class='button first' href='%s'><<</a>\n"//
+ + "\t<a
%s
class='button previous' href='%s'><</a>\n"//
+ + "\t<a
%s
class='button next' href='%s'>></a>\n"//
+ + "\t<a
%s
class='button last' href='%s'>>></a>\n"//
+ "</div>\n" //
+ "%s", //
+ "</div>\n" //
+ "%s", //
- first, //
- previous, //
- next, //
- last, //
+
disabledLeft,
first, //
+
disabledLeft,
previous, //
+
disabledRight,
next, //
+
disabledRight,
last, //
content //
));
content //
));
@@
-908,12
+940,15
@@
public class WebLibraryServer implements Runnable {
if (paragraph > 0) {
builder.append(String.format("" //
if (paragraph > 0) {
builder.append(String.format("" //
- + "\t<a class='button zoomreal' href='%s'>REAL</a>\n"//
- + "\t<a class='button zoomwidth' href='%s'>WIDTH</a>\n"//
- + "\t<a class='button zoomheight' href='%s'>HEIGHT</a>\n"//
+ + "\t<a
%s
class='button zoomreal' href='%s'>REAL</a>\n"//
+ + "\t<a
%s
class='button zoomwidth' href='%s'>WIDTH</a>\n"//
+ + "\t<a
%s
class='button zoomheight' href='%s'>HEIGHT</a>\n"//
+ "</div>\n", //
+ "</div>\n", //
+ disabledZoomReal,
uri + "?optionName=zoom&optionValue=real", //
uri + "?optionName=zoom&optionValue=real", //
+ disabledZoomWidth,
uri + "?optionName=zoom&optionValue=width", //
uri + "?optionName=zoom&optionValue=width", //
+ disabledZoomHeight,
uri + "?optionName=zoom&optionValue=height" //
));
}
uri + "?optionName=zoom&optionValue=height" //
));
}
@@
-1063,7
+1098,7
@@
public class WebLibraryServer implements Runnable {
if (banner) {
builder.append("<div class='banner'>\n");
if (banner) {
builder.append("<div class='banner'>\n");
- builder.append("\t<img class='ico' src='") //
+ builder.append("\t<img class='ico' src='
/
") //
.append(favicon) //
.append("'/>\n");
builder.append("\t<h1>Fanfix</h1>\n");
.append(favicon) //
.append("'/>\n");
builder.append("\t<h1>Fanfix</h1>\n");
@@
-1089,4
+1124,10
@@
public class WebLibraryServer implements Runnable {
}
builder.append(">").append(name).append("</option>\n");
}
}
builder.append(">").append(name).append("</option>\n");
}
+
+ public static void main(String[] args) throws IOException {
+ Instance.init();
+ WebLibraryServer web = new WebLibraryServer(false);
+ web.run();
+ }
}
}