X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Foutput%2FBasicOutput.java;h=33a42c574bed176d90556bce1c447fba61ed26fe;hp=2e77eaebdc6d13de7d24bd42e19061b28131bc41;hb=92fb0719f84f5b6734b51e528332546d78e9ccec;hpb=08fe2e33007063e30fe22dc1d290f8afaa18eb1d diff --git a/src/be/nikiroo/fanfix/output/BasicOutput.java b/src/be/nikiroo/fanfix/output/BasicOutput.java index 2e77eae..33a42c5 100644 --- a/src/be/nikiroo/fanfix/output/BasicOutput.java +++ b/src/be/nikiroo/fanfix/output/BasicOutput.java @@ -36,7 +36,12 @@ public abstract class BasicOutput { /** ZIP with (PNG) images */ CBZ, /** LaTeX file with "book" template */ - LATEX; + LATEX, + /** HTML files in a dedicated directory */ + HTML, + + ; + public String toString() { return super.toString().toLowerCase(); } @@ -58,6 +63,20 @@ public abstract class BasicOutput { return desc; } + /** + * The default extension to add to the output files. + * + * @return the extension + */ + public String getDefaultExtension() { + BasicOutput output = BasicOutput.getOutput(this, false); + if (output != null) { + return output.getDefaultExtension(); + } + + return null; + } + /** * Call {@link OutputType#valueOf(String.toUpperCase())}. * @@ -73,7 +92,7 @@ public abstract class BasicOutput { /** * Call {@link OutputType#valueOf(String.toUpperCase())} but return NULL - * for NULL instead of raising exception. + * for NULL and empty instead of raising an exception. * * @param typeName * the possible type name @@ -81,7 +100,7 @@ public abstract class BasicOutput { * @return NULL or the type */ public static OutputType valueOfNullOkUC(String typeName) { - if (typeName == null) { + if (typeName == null || typeName.isEmpty()) { return null; } @@ -208,12 +227,10 @@ public abstract class BasicOutput { /** * The default extension to add to the output files. - *

- * Cannot be NULL! * * @return the extension */ - protected String getDefaultExtension() { + public String getDefaultExtension() { return ""; } @@ -240,6 +257,10 @@ public abstract class BasicOutput { String paragraphNumber = String.format("%04d", 0); imageName = paragraphNumber + "_" + chapterNameNum + ".png"; + if (story.getMeta() != null) { + story.getMeta().setType("" + getType()); + } + if (writeCover) { InfoCover.writeCover(targetDir, targetName, story.getMeta()); } @@ -419,6 +440,8 @@ public abstract class BasicOutput { return new Cbz().setType(type, infoCover, infoCover); case LATEX: return new LaTeX().setType(type, infoCover, infoCover); + case HTML: + return new Html().setType(type, infoCover, infoCover); } }