X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Foutput%2FHtml.java;h=756eb8d328907e3d02eb19cede3c57dd51082ce4;hb=32c2174930419cfa6c3b6cb0d78cad1804ca6d69;hp=fcffec67a2a5403c300b19a5d712f487d2817f6d;hpb=5ced20e4bd8a7d175e044fe5cdbf02e1bd8e1d26;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/output/Html.java b/src/be/nikiroo/fanfix/output/Html.java index fcffec6..756eb8d 100644 --- a/src/be/nikiroo/fanfix/output/Html.java +++ b/src/be/nikiroo/fanfix/output/Html.java @@ -1,11 +1,11 @@ package be.nikiroo.fanfix.output; +import java.io.BufferedWriter; import java.io.File; -import java.io.FileWriter; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; - -import javax.imageio.ImageIO; +import java.io.OutputStreamWriter; import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.bundles.Config; @@ -19,7 +19,7 @@ import be.nikiroo.utils.StringUtils; class Html extends BasicOutput { private File dir; - protected FileWriter writer; + protected BufferedWriter writer; private boolean inDialogue = false; private boolean inNormal = false; @@ -32,12 +32,10 @@ class Html extends BasicOutput { target.mkdir(); dir = target; - targetName = new File(targetName, "index").getPath(); - targetName += getDefaultExtension(); - - target = new File(targetDir, targetName); + target = new File(targetDir, targetName + getDefaultExtension(true)); - writer = new FileWriter(target); + writer = new BufferedWriter(new OutputStreamWriter( + new FileOutputStream(target), "UTF-8")); try { super.process(story, targetDir, targetNameOrig); } finally { @@ -45,19 +43,27 @@ class Html extends BasicOutput { writer = null; } - String format = Instance.getConfig() - .getString(Config.IMAGE_FORMAT_COVER).toLowerCase(); + // write a copy of the originals inside + InfoCover.writeInfo(dir, targetName, story.getMeta()); + InfoCover.writeCover(dir, targetName, story.getMeta()); + BasicOutput.getOutput(OutputType.TEXT, isWriteInfo(), isWriteCover()) + .process(story, dir, targetNameOrig); + if (story.getMeta().getCover() != null) { - ImageIO.write(story.getMeta().getCover(), format, new File(dir, - "cover." + format)); + Instance.getCache().saveAsImage(story.getMeta().getCover(), + new File(dir, "cover"), true); } return target; } @Override - public String getDefaultExtension() { - return File.separator + "index.html"; + public String getDefaultExtension(boolean readerTarget) { + if (readerTarget) { + return File.separator + "index.html"; + } + + return ""; } @Override @@ -202,7 +208,7 @@ class Html extends BasicOutput { writer.write("
"); break; case BREAK: - writer.write("