X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=supported%2FText.java;h=45b761a1f2e0fba52b91aff057a303086a40e134;hb=bb7d9ea97cc614a04dd45f342a4caeeb7dcb23fe;hp=232eab6ec4f7736b6b470011f51d09548fe733e8;hpb=5f3671e17febc5b7f6abbfc62c66c4045d47ec8d;p=fanfix.git diff --git a/supported/Text.java b/supported/Text.java index 232eab6..45b761a 100644 --- a/supported/Text.java +++ b/supported/Text.java @@ -15,9 +15,7 @@ import org.jsoup.nodes.Document; import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.bundles.Config; -import be.nikiroo.fanfix.data.Chapter; import be.nikiroo.fanfix.data.MetaData; -import be.nikiroo.fanfix.data.Paragraph; import be.nikiroo.utils.Image; import be.nikiroo.utils.ImageUtils; import be.nikiroo.utils.Progress; @@ -87,14 +85,11 @@ class Text extends BasicSupport { meta.setAuthor(getAuthor()); meta.setDate(bsHelper.formatDate(getDate())); meta.setTags(new ArrayList()); - meta.setSource(getType().getSourceName()); meta.setUrl(getSourceFile().toURI().toURL().toString()); - meta.setPublisher(""); meta.setUuid(getSourceFile().toString()); meta.setLuid(""); meta.setLang(getLang()); // default is EN meta.setSubject(getSourceFile().getParentFile().getName()); - meta.setType(getType().toString()); meta.setImageDocument(false); meta.setCover(getCover(getSourceFile())); @@ -105,10 +100,12 @@ class Text extends BasicSupport { @SuppressWarnings("resource") // cannot close, or we loose getInput()! Scanner scan = new Scanner(getInput(), "UTF-8"); scan.useDelimiter("\\n"); - scan.next(); // Title - scan.next(); // Author (Date) - String chapter0 = scan.next(); // empty or Chapter 0 - while (chapter0.isEmpty()) { + if (scan.hasNext()) + scan.next(); // Title + if (scan.hasNext()) + scan.next(); // Author (Date) + String chapter0 = ""; + while (scan.hasNext() && chapter0.isEmpty()) { chapter0 = scan.next(); } @@ -131,15 +128,20 @@ class Text extends BasicSupport { @SuppressWarnings("resource") // cannot close, or we loose getInput()! Scanner scan = new Scanner(getInput(), "UTF-8"); scan.useDelimiter("\\n"); - return scan.next(); + if (scan.hasNext()) + return scan.next(); + return ""; } private String getAuthor() { @SuppressWarnings("resource") // cannot close, or we loose getInput()! Scanner scan = new Scanner(getInput(), "UTF-8"); scan.useDelimiter("\\n"); - scan.next(); - String authorDate = scan.next(); + if (scan.hasNext()) + scan.next(); + String authorDate = ""; + if (scan.hasNext()) + authorDate = scan.next(); String author = authorDate; int pos = authorDate.indexOf('('); @@ -154,8 +156,11 @@ class Text extends BasicSupport { @SuppressWarnings("resource") // cannot close, or we loose getInput()! Scanner scan = new Scanner(getInput(), "UTF-8"); scan.useDelimiter("\\n"); - scan.next(); - String authorDate = scan.next(); + if (scan.hasNext()) + scan.next(); + String authorDate = ""; + if (scan.hasNext()) + authorDate = scan.next(); String date = ""; int pos = authorDate.indexOf('('); @@ -172,20 +177,7 @@ class Text extends BasicSupport { @Override protected String getDesc() throws IOException { - String content = getChapterContent(null, 0, null).trim(); - if (!content.isEmpty()) { - Chapter desc = bsPara.makeChapter(this, null, 0, "Description", - content, isHtml(), null); - StringBuilder builder = new StringBuilder(); - for (Paragraph para : desc) { - if (builder.length() > 0) { - builder.append("\n"); - } - builder.append(para.getContent()); - } - } - - return content; + return getChapterContent(null, 0, null).trim(); } protected Image getCover(File sourceFile) { @@ -245,9 +237,12 @@ class Text extends BasicSupport { @SuppressWarnings("resource") // cannot close, or we loose getInput()! Scanner scan = new Scanner(getInput(), "UTF-8"); scan.useDelimiter("\\n"); - scan.next(); // title - scan.next(); // author - scan.next(); // date or empty + if (scan.hasNext()) + scan.next(); // title + if (scan.hasNext()) + scan.next(); // author + if (scan.hasNext()) + scan.next(); // date or empty Boolean inChap = null; String line = ""; while (scan.hasNext()) {