X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FText.java;h=1e5977a493660bac7b6551ba7f09d506696c8074;hb=13fdb89adc017452a7a72f552b933f8e7b869413;hp=f6803cd09d6358880290cdf8e2c487caf5794e16;hpb=4ec79417fe5bd4344ac12b39ac8c98db8f9276f6;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/supported/Text.java b/src/be/nikiroo/fanfix/supported/Text.java index f6803cd..1e5977a 100644 --- a/src/be/nikiroo/fanfix/supported/Text.java +++ b/src/be/nikiroo/fanfix/supported/Text.java @@ -18,7 +18,8 @@ import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.bundles.Config; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.utils.Image; -import be.nikiroo.utils.MarkableFileInputStream; +import be.nikiroo.utils.ImageUtils; +import be.nikiroo.utils.streams.MarkableFileInputStream; import be.nikiroo.utils.Progress; /** @@ -66,16 +67,11 @@ class Text extends BasicSupport { return false; } - @Override - public String getSourceName() { - return "text"; - } - @Override protected Document loadDocument(URL source) throws IOException { try { sourceFile = new File(source.toURI()); - in = new MarkableFileInputStream(new FileInputStream(sourceFile)); + in = new MarkableFileInputStream(sourceFile); } catch (URISyntaxException e) { throw new IOException("Cannot load the text document: " + source); } @@ -91,7 +87,7 @@ class Text extends BasicSupport { meta.setAuthor(getAuthor()); meta.setDate(getDate()); meta.setTags(new ArrayList()); - meta.setSource(getSourceName()); + meta.setSource(getType().getSourceName()); meta.setUrl(getSourceFile().toURI().toURL().toString()); meta.setPublisher(""); meta.setUuid(getSourceFile().toString()); @@ -188,8 +184,20 @@ class Text extends BasicSupport { } } - return BasicSupportImages.getImage(this, sourceFile.getParentFile(), - path); + Image cover = BasicSupportImages.getImage(this, + sourceFile.getParentFile(), path); + if (cover != null) { + try { + File tmp = Instance.getTempFiles().createTempFile( + "test_cover_image"); + ImageUtils.getInstance().saveAsImage(cover, tmp, "png"); + tmp.delete(); + } catch (IOException e) { + cover = null; + } + } + + return cover; } @Override @@ -323,9 +331,8 @@ class Text extends BasicSupport { */ static private String detectChapter(String line, int number) { line = line.toUpperCase(); - for (String lang : Instance.getConfig().getString(Config.CHAPTER) - .split(",")) { - String chapter = Instance.getConfig().getStringX(Config.CHAPTER, + for (String lang : Instance.getConfig().getList(Config.CONF_CHAPTER)) { + String chapter = Instance.getConfig().getStringX(Config.CONF_CHAPTER, lang); if (chapter != null && !chapter.isEmpty()) { chapter = chapter.toUpperCase() + " ";