web lib: getStory
[fanfix.git] / src / be / nikiroo / fanfix / library / WebLibraryServer.java
index a59fa3456d3d294b7614db718eaacadadb2d4415..3e2c90605de78b2956290b4b36b56bb8a6a42688 100644 (file)
@@ -655,6 +655,7 @@ public class WebLibraryServer implements Runnable {
        // /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;
@@ -671,7 +672,7 @@ public class WebLibraryServer implements Runnable {
                // 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) {
@@ -710,6 +711,11 @@ public class WebLibraryServer implements Runnable {
                                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) {