X-Git-Url: https://git.nikiroo.be/?a=blobdiff_plain;ds=inline;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Foutput%2FHtml.java;h=f81ea1dc5f643d20de832dcd96b48ec4070172ab;hb=002972e9de731678035d56304d75a6d9e8233635;hp=da79466a40d9cc2fcf80872d77ef6e588398e732;hpb=c55de9d5b566076a4865ba9448c8f25255a49704;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/output/Html.java b/src/be/nikiroo/fanfix/output/Html.java deleted file mode 100644 index da79466..0000000 --- a/src/be/nikiroo/fanfix/output/Html.java +++ /dev/null @@ -1,264 +0,0 @@ -package be.nikiroo.fanfix.output; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStreamWriter; - -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.fanfix.data.Paragraph.ParagraphType; -import be.nikiroo.fanfix.data.Story; -import be.nikiroo.utils.IOUtils; -import be.nikiroo.utils.StringUtils; - -class Html extends BasicOutput { - private File dir; - protected BufferedWriter writer; - private boolean inDialogue = false; - private boolean inNormal = false; - - @Override - public File process(Story story, File targetDir, String targetName) - throws IOException { - String targetNameOrig = targetName; - - File target = new File(targetDir, targetName); - target.mkdir(); - dir = target; - - target = new File(targetDir, targetName + getDefaultExtension(true)); - - writer = new BufferedWriter(new OutputStreamWriter( - new FileOutputStream(target), "UTF-8")); - try { - super.process(story, targetDir, targetNameOrig); - } finally { - writer.close(); - writer = null; - } - - // 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) { - Instance.getInstance().getCache().saveAsImage(story.getMeta().getCover(), new File(dir, "cover"), true); - } - - return target; - } - - @Override - public String getDefaultExtension(boolean readerTarget) { - if (readerTarget) { - return File.separator + "index.html"; - } - - return ""; - } - - @Override - protected void writeStoryHeader(Story story) throws IOException { - String title = ""; - String tags = ""; - String author = ""; - Chapter resume = null; - if (story.getMeta() != null) { - MetaData meta = story.getMeta(); - title = meta.getTitle(); - resume = meta.getResume(); - if (meta.getTags() != null) { - for (String tag : meta.getTags()) { - if (!tags.isEmpty()) { - tags += ", "; - } - tags += tag; - } - - if (!tags.isEmpty()) { - tags = "(" + tags + ")"; - } - } - author = meta.getAuthor(); - } - - String format = Instance.getInstance().getConfig() - .getString(Config.FILE_FORMAT_IMAGE_FORMAT_COVER).toLowerCase(); - - InputStream inStyle = getClass().getResourceAsStream("html.style.css"); - if (inStyle == null) { - throw new IOException("Cannot find style.css resource"); - } - try { - IOUtils.write(inStyle, new File(dir, "style.css")); - } finally { - inStyle.close(); - } - - writer.write(""); - writer.write("\n"); - writer.write("\n
"); - writer.write("\n "); - writer.write("\n "); - writer.write("\n "); - writer.write("\n