builder.append("<div class='book_line'>");
builder.append("<a href='");
- builder.append(getViewUrl(meta.getLuid(), 0, null));
+ builder.append(getViewUrl(meta.getLuid(), null, null));
builder.append("'");
builder.append(" class='link'>");
if (img != null) {
in = img.newInputStream();
}
+ // TODO: get correct image type
+ mimeType = "image/png";
} else if ("metadata".equals(chapterStr)) {
MetaData meta = meta(luid, whitelist);
JSONObject json = JsonIO.toJson(meta);
String paragraphStr = cover.length < off + 4 ? null : cover[off + 3];
// 1-based (0 = desc)
- int chapter = -1;
+ int chapter = 0;
if (chapterStr != null) {
try {
chapter = Integer.parseInt(chapterStr);
StringBuilder desc = new StringBuilder();
if (chapter <= 0) {
+ desc.append("<h1 class='title'>");
+ desc.append(story.getMeta().getTitle());
+ desc.append("</h1>\n");
desc.append("<div class='desc'>\n");
- desc.append("\t<div class='cover'>\n");
+ desc.append("\t<a href='" + next + "' class='cover'>\n");
desc.append("\t\t<img src='/story/" + luid + "/cover'/>\n");
- desc.append("\t</div>\n");
+ desc.append("\t</a>\n");
desc.append("\t<table class='details'>\n");
Map<String, String> details = BasicLibrary
.getMetaDesc(story.getMeta());
content.append(desc);
String description = new TextOutput(false).convert(chap,
chapter > 0);
- content.append(
- description.isEmpty() ? "No description provided."
- : description);
+ content.append(chap.getParagraphs().size() <= 0
+ ? "No content provided."
+ : description);
content.append("</div>\n");
if (chapter <= 0)
}
}
+ String javascript = "document.getElementById(\"previous\").click(); return false;";
content.append(String.format("" //
- + "<a class='viewer link' href='%s'>"
+ + "<a class='viewer link' oncontextmenu='%s' href='%s'>"
+ "<img class='viewer img' style='%s' src='%s'/>"
+ "</a>", //
+ javascript, //
next, //
zoomStyle, //
getStoryUrl(luid, chapter, paragraph)));
builder.append(String.format("" //
+ "<div class='bar navbar'>\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", //
+ + "\t<a%s id='previous' class='button previous' href='%s'><</a>\n" //
+ + "\t<div class='gotobox itemsbox'>\n" //
+ + "\t\t<div class='button goto'>%d</div>\n" //
+ + "\t\t<div class='items goto'>\n", //
disabledLeft, first, //
disabledLeft, previous, //
+ paragraph > 0 ? paragraph : chapter //
+ ));
+
+ // List of chap/para links
+
+ appendItemA(builder, 3, getViewUrl(luid, 0, null), "Description",
+ paragraph == 0 && chapter == 0);
+ if (paragraph > 0) {
+ for (int i = 1; i <= chap.getParagraphs().size(); i++) {
+ appendItemA(builder, 3, getViewUrl(luid, chapter, i),
+ "Image " + i, paragraph == i);
+ }
+ } else {
+ int i = 1;
+ for (Chapter c : story.getChapters()) {
+ String chapName = "Chapter " + c.getNumber();
+ if (c.getName() != null && !c.getName().isEmpty()) {
+ chapName += ": " + c.getName();
+ }
+
+ appendItemA(builder, 3, getViewUrl(luid, i, null), chapName,
+ chapter == i);
+
+ i++;
+ }
+ }
+
+ builder.append(String.format("" //
+ + "\t\t</div>\n" //
+ + "\t</div>\n" //
+ + "\t<a%s class='button next' href='%s'>></a>\n" //
+ + "\t<a%s class='button last' href='%s'>>></a>\n"//
+ + "</div>\n", //
disabledRight, next, //
disabledRight, last //
));
return "";
}
- private String getViewUrl(String luid, int chap, Integer para) {
+ private String getViewUrl(String luid, Integer chap, Integer para) {
return VIEWER_URL //
.replace("{luid}", luid) //
- .replace("{chap}", Integer.toString(chap)) //
+ .replace("/{chap}", chap == null ? "" : "/" + chap) //
.replace("/{para}",
- para == null ? "" : "/" + Integer.toString(para));
+ (chap == null || para == null) ? "" : "/" + para);
}
private String getStoryUrl(String luid, int chap, Integer para) {
builder.append("</tr>\n");
}
+ private void appendItemA(StringBuilder builder, int depth, String link,
+ String name, boolean selected) {
+ for (int i = 0; i < depth; i++) {
+ builder.append("\t");
+ }
+
+ builder.append("<a href='");
+ builder.append(link);
+ builder.append("' class='item goto");
+ if (selected) {
+ builder.append(" selected");
+ }
+ builder.append("'>");
+ builder.append(name);
+ builder.append("</a>\n");
+ }
+
public static void main(String[] args) throws IOException {
Instance.init();
WebLibraryServer web = new WebLibraryServer(false);