From: Niki Roo Date: Fri, 24 Feb 2017 12:50:11 +0000 (+0100) Subject: Version 1.2.3: new supported type: HTML X-Git-Tag: fanfix-1.2.3 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=373da363323d3a9263aa6ebd392ca3272b23b412;p=fanfix.git Version 1.2.3: new supported type: HTML --- diff --git a/README.md b/README.md index 571de10..eddd55e 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,13 @@ Fanfix is a small Java program that can download stories from some supported web ![Main GUI](screenshots/fanfix.png?raw=true "Main GUI") -It will convert from a (supported) URL to an .epub file for stories or a .cbz file for comics (a few other output types are also available, like Plain Text or LaTeX). +It will convert from a (supported) URL to an .epub file for stories or a .cbz file for comics (a few other output types are also available, like Plain Text, LaTeX, HTML...). To help organize your stories, it can also work as a local library. In this mode, you can: -- Import a story from its URL (or even another file) -- Export a story to a file (.epub or .cbz) +- Import a story from its URL (or just from a file) +- Export a story to a file (in any of the supported output types) - Display a story from the local library in text format in the console - Display a story from the local library graphically **by calling a native program to handle it** (though Fanfix can automatically process it into HTML so any browser can open it) @@ -34,6 +34,7 @@ We support a few file types for local story conversion (both as input and as out - a cover image may be present with the same filename as the story, but a .png, .jpeg or .jpg extension - info_text: contains the same information as the text format, but with a companion .info file to store some metadata (the .info file is supposed to be created by Fanfix or compatible with it) - cbz: .cbz (collection of images) files, preferably created with Fanfix (but any .cbz file is supported, though without most of Fanfix metadata, obviously) +- html: HTML files that you can open with any browser; note that it will create a directory structure with ```index.html``` being the file you need to open (or select if you want to convert it into something else) -- we only support importing HTML files created by Fanfix or compatible ## Supported platforms @@ -56,7 +57,7 @@ The following arguments are also allowed: - ```--read [id] ([chapter number])```: read the given story denoted by ID from the library - ```--read-url [URL] ([chapter number])```: convert on the fly and read the story denoted by ID, without saving it - ```--list```: list the stories present in the library and their associated IDs -- ```--set-reader [reader type]```: set the reader type to CLI or LOCAL for this command +- ```--set-reader [reader type]```: set the reader type to CLI or LOCAL for this command (must be the first option) - ```--help```: display the available options ### Environment variables diff --git a/VERSION b/VERSION index 23aa839..0495c4a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2.2 +1.2.3 diff --git a/src/be/nikiroo/fanfix/output/Html.java b/src/be/nikiroo/fanfix/output/Html.java index a02124c..dca0fc4 100644 --- a/src/be/nikiroo/fanfix/output/Html.java +++ b/src/be/nikiroo/fanfix/output/Html.java @@ -34,8 +34,13 @@ class Html extends BasicOutput { target.mkdir(); dir = target; + // write a copy of the originals inside + InfoCover.writeInfo(dir, targetName, story.getMeta()); + InfoCover.writeCover(dir, targetName, story.getMeta()); + new InfoText().process(story, dir, targetNameOrig); + target = new File(targetDir, targetName + getDefaultExtension(true)); - + writer = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(target), "UTF-8")); try { diff --git a/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java b/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java index 16684f9..7d5e5dd 100644 --- a/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java +++ b/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java @@ -491,9 +491,8 @@ class LocalReaderFrame extends JFrame { public void run() { if (!ok) { JOptionPane.showMessageDialog( - LocalReaderFrame.this, + LocalReaderFrame.this, e.getMessage(), "Cannot import: " + url, - e.getMessage(), JOptionPane.ERROR_MESSAGE); } else { refreshBooks(type); diff --git a/src/be/nikiroo/fanfix/supported/BasicSupport.java b/src/be/nikiroo/fanfix/supported/BasicSupport.java index b6fd1e2..169cc5f 100644 --- a/src/be/nikiroo/fanfix/supported/BasicSupport.java +++ b/src/be/nikiroo/fanfix/supported/BasicSupport.java @@ -60,7 +60,9 @@ public abstract class BasicSupport { /** Furry website with comics support */ E621, /** CBZ files */ - CBZ; + CBZ, + /** HTML files */ + HTML; /** * A description of this support type (more information than the @@ -285,7 +287,7 @@ public abstract class BasicSupport { */ protected Story processMeta(URL url, boolean close, boolean getDesc) throws IOException { - in = Instance.getCache().open(url, this, false); + in = openInput(url); if (in == null) { return null; } @@ -765,6 +767,21 @@ public abstract class BasicSupport { return url; } + /** + * Open the input file that will be used through the support. + * + * @param source + * the source {@link URL} + * + * @return the {@link InputStream} + * + * @throws IOException + * in case of I/O error + */ + protected InputStream openInput(URL source) throws IOException { + return Instance.getCache().open(source, this, false); + } + protected InputStream reset(InputStream in) { try { in.reset(); @@ -1105,8 +1122,8 @@ public abstract class BasicSupport { } } - for (SupportType type : new SupportType[] { SupportType.TEXT, - SupportType.INFO_TEXT }) { + for (SupportType type : new SupportType[] { SupportType.INFO_TEXT, + SupportType.TEXT }) { BasicSupport support = getSupport(type); if (support != null && support.supports(url)) { return support; @@ -1142,6 +1159,8 @@ public abstract class BasicSupport { return new E621().setType(type); case CBZ: return new Cbz().setType(type); + case HTML: + return new Html().setType(type); } return null; diff --git a/src/be/nikiroo/fanfix/supported/MangaFox.java b/src/be/nikiroo/fanfix/supported/MangaFox.java index 776c29e..ba42452 100644 --- a/src/be/nikiroo/fanfix/supported/MangaFox.java +++ b/src/be/nikiroo/fanfix/supported/MangaFox.java @@ -11,8 +11,6 @@ import java.util.List; import java.util.Map.Entry; import java.util.Scanner; -import javax.imageio.ImageIO; - import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.utils.IOUtils;