Story story = support.process(source, pgIn);
try {
target = new File(target).getAbsolutePath();
- BasicOutput.getOutput(type, infoCover).process(
- story, target, pgOut);
+ BasicOutput.getOutput(type, infoCover, infoCover)
+ .process(story, target, pgOut);
} catch (IOException e) {
Instance.getTraceHandler().error(
new IOException(trans(StringId.ERR_SAVING,
pg.addProgress(pgOut, 1);
}
- BasicOutput out = BasicOutput.getOutput(type, false);
+ BasicOutput out = BasicOutput.getOutput(type, false, false);
if (out == null) {
throw new IOException("Output type not supported: " + type);
}
File expectedTarget = getExpectedFile(meta);
expectedTarget.getParentFile().mkdirs();
- BasicOutput it = BasicOutput.getOutput(getOutputType(meta), true);
+ BasicOutput it = BasicOutput.getOutput(getOutputType(meta), true, true);
it.process(story, expectedTarget.getPath(), pg);
return story;
* @return the extension
*/
public String getDefaultExtension(boolean readerTarget) {
- BasicOutput output = BasicOutput.getOutput(this, false);
+ BasicOutput output = BasicOutput.getOutput(this, false, false);
if (output != null) {
return output.getDefaultExtension(readerTarget);
}
*
* @param type
* the new type
- * @param writeInfo
- * TRUE to enable the creation of a .info file
* @param writeCover
* TRUE to enable the creation of a cover if possible
+ * @param writeInfo
+ * TRUE to enable the creation of a .info file
*
* @return this
*/
- protected BasicOutput setType(OutputType type, boolean writeCover,
- boolean writeInfo) {
+ protected BasicOutput setType(OutputType type, boolean writeInfo,
+ boolean writeCover) {
this.type = type;
- this.writeCover = writeCover;
this.writeInfo = writeInfo;
+ this.writeCover = writeCover;
return this;
}
story.getMeta().setType("" + getType());
}
+ System.out.println(story.getMeta().getTitle() + " -> write cover: "
+ + writeCover);
+ new Exception().printStackTrace();
+
if (writeCover) {
InfoCover.writeCover(targetDir, targetName, story.getMeta());
}
*
* @param type
* the type
- * @param infoCover
- * force the <tt>.info</tt> file and the cover to be saved next
+ * @param writeCover
+ * TRUE to enable the creation of a cover if possible to be saved
+ * next to the main target file
+ * @param writeInfo
+ * TRUE to enable the creation of a .info file to be saved next
* to the main target file
*
* @return the {@link BasicOutput}
*/
- public static BasicOutput getOutput(OutputType type, boolean infoCover) {
+ public static BasicOutput getOutput(OutputType type, boolean writeInfo,
+ boolean writeCover) {
if (type != null) {
switch (type) {
case EPUB:
- return new Epub().setType(type, infoCover, infoCover);
+ return new Epub().setType(type, writeInfo, writeCover);
case TEXT:
- return new Text().setType(type, true, infoCover);
+ return new Text().setType(type, writeInfo, true);
case INFO_TEXT:
return new InfoText().setType(type, true, true);
case SYSOUT:
return new Sysout().setType(type, false, false);
case CBZ:
- return new Cbz().setType(type, infoCover, infoCover);
+ return new Cbz().setType(type, writeInfo, writeCover);
case LATEX:
- return new LaTeX().setType(type, infoCover, infoCover);
+ return new LaTeX().setType(type, writeInfo, writeCover);
case HTML:
- return new Html().setType(type, infoCover, infoCover);
+ return new Html().setType(type, writeInfo, writeCover);
}
}
dir.delete();
dir.mkdir();
try {
- // will also save the images!
- BasicOutput.getOutput(OutputType.TEXT, isWriteInfo()).process(
- story, dir, targetNameOrig);
+ // will also save the images! (except the cover -> false)
+ BasicOutput
+ .getOutput(OutputType.TEXT, isWriteInfo(), isWriteCover())
+ // Force cover to FALSE:
+ .setType(OutputType.TEXT, isWriteInfo(), false)
+ .process(story, dir, targetNameOrig);
InfoCover.writeInfo(dir, targetNameOrig, story.getMeta());
if (story.getMeta() != null && !story.getMeta().isFakeCover()) {
// "Originals"
File data = new File(tmpDir, "DATA");
data.mkdir();
- BasicOutput.getOutput(OutputType.TEXT, isWriteInfo()).process(story,
- data, targetNameOrig);
+ BasicOutput.getOutput(OutputType.TEXT, isWriteInfo(), isWriteCover())
+ .process(story, data, targetNameOrig);
InfoCover.writeInfo(data, targetNameOrig, story.getMeta());
IOUtils.writeSmallFile(data, "version", "3.0");
// write a copy of the originals inside
InfoCover.writeInfo(dir, targetName, story.getMeta());
InfoCover.writeCover(dir, targetName, story.getMeta());
- BasicOutput.getOutput(OutputType.TEXT, isWriteInfo()).process(story,
- dir, targetNameOrig);
+ BasicOutput.getOutput(OutputType.TEXT, isWriteInfo(), isWriteCover())
+ .process(story, dir, targetNameOrig);
target = new File(targetDir, targetName + getDefaultExtension(true));
* <p>
* Of those, only {@link be.nikiroo.fanfix.output.BasicOutput} is public,
* but it contains a method
- * ({@link be.nikiroo.fanfix.output.BasicOutput#getOutput(be.nikiroo.fanfix.output.BasicOutput.OutputType, boolean)})
+ * ({@link be.nikiroo.fanfix.output.BasicOutput#getOutput(be.nikiroo.fanfix.output.BasicOutput.OutputType, boolean,boolean)})
* to get all the other
* {@link be.nikiroo.fanfix.output.BasicOutput.OutputType}s.
*
new Thread(new Runnable() {
@Override
public void run() {
- run.run();
- refreshBooks();
- reload.done();
- if (!pg.isDone()) {
- // will trigger pgBar ActionListener:
- pg.done();
+ try {
+ run.run();
+ refreshBooks();
+ } finally {
+ reload.done();
+ if (!pg.isDone()) {
+ // will trigger pgBar ActionListener:
+ pg.done();
+ }
}
}
}, "outOfUi thread").start();
pgOnSuccess.setProgress(0);
if (!ok) {
if (e instanceof UnknownHostException) {
- error("Failed to import " + url, "Cannot import URL",
+ error("URL not supported: " + url, "Cannot import URL",
null);
} else {
error("Failed to import " + url + ": \n"
if (meta.getCover() == null && !images.isEmpty()) {
meta.setCover(images.get(imagesList.get(0)));
+ meta.setFakeCover(true);
}
pg.setProgress(100);