From: Niki Roo Date: Sat, 18 Feb 2017 16:15:30 +0000 (+0100) Subject: Version 1.1.0 X-Git-Tag: fanfix-swing-0.0.1~12^2~527 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=92fb0719f84f5b6734b51e528332546d78e9ccec;p=fanfix-swing.git Version 1.1.0 - new Progress reporting system (currently only in CLI mode) - fix on e621 for "pending" pools, which were not downloaded before - unit tests system added (but no test yet, as all tests were moved into nikiroo-utils before release) --- diff --git a/VERSION b/VERSION index 3eefcb9d..9084fa2f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0 +1.1.0 diff --git a/changelog.md b/changelog.md new file mode 100644 index 00000000..a22be0ea --- /dev/null +++ b/changelog.md @@ -0,0 +1,43 @@ +# Fanfix + +## Version 1.1.0 + +- new Progress reporting system (currently only in CLI mode) +- fix on e621 for "pending" pools, which were not downloaded before +- unit tests system added (but no test yet, as all tests were moved into nikiroo-utils) + +## Version 1.0.0 + +The GUI is now good enough to be released (export is still CLI-only though). + +- bugs fixed +- GUI improved (a lot) +- should be good enough for 1.0.0 + +## Version 0.9.5 + +- bugs fixed +- WIN32 compatibility (tested on Windows 10) + +## Version 0.9.4 + +- bugs fixed (lots of) +- perf improved +- use less cache files +- GUI improvement (still not really OK, but OK enough I guess) + +## Version 0.9.3 + +- bugs fixed (lots of) +- first GUI implementation (which is ugly and buggy -- the buggly GUI) + +## Version 0.9.2 + +Minimum JVM version: Java 1.6 (all binary JAR files will be released in 1.6). + +- bugs fixed + +## Version 0.9.1 + +Initial version + diff --git a/configure.sh b/configure.sh index 1da9835f..ffdf4985 100755 --- a/configure.sh +++ b/configure.sh @@ -44,7 +44,7 @@ else fi; echo "MAIN = be/nikiroo/fanfix/Main" > Makefile -echo "TEST = " >> Makefile +echo "TEST = be/nikiroo/fanfix/test/Test" >> Makefile echo "TEST_PARAMS = $cols $ok $ko" >> Makefile echo "NAME = fanfix" >> Makefile echo "PREFIX = $PREFIX" >> Makefile diff --git a/libs/nikiroo-utils-1.0.0-sources.jar b/libs/nikiroo-utils-1.1.0-sources.jar similarity index 70% rename from libs/nikiroo-utils-1.0.0-sources.jar rename to libs/nikiroo-utils-1.1.0-sources.jar index ab8360ec..63466abe 100644 Binary files a/libs/nikiroo-utils-1.0.0-sources.jar and b/libs/nikiroo-utils-1.1.0-sources.jar differ diff --git a/src/be/nikiroo/fanfix/Library.java b/src/be/nikiroo/fanfix/Library.java index 0d9e067f..03b584cf 100644 --- a/src/be/nikiroo/fanfix/Library.java +++ b/src/be/nikiroo/fanfix/Library.java @@ -14,6 +14,7 @@ import be.nikiroo.fanfix.data.Story; import be.nikiroo.fanfix.output.BasicOutput; import be.nikiroo.fanfix.output.BasicOutput.OutputType; import be.nikiroo.fanfix.supported.BasicSupport; +import be.nikiroo.utils.ui.Progress; import be.nikiroo.fanfix.supported.BasicSupport.SupportType; import be.nikiroo.fanfix.supported.InfoReader; @@ -135,10 +136,12 @@ public class Library { * * @param luid * the Library UID of the story + * @param pg + * the optional progress reporter * * @return the corresponding {@link Story} or NULL if not found */ - public Story getStory(String luid) { + public Story getStory(String luid, Progress pg) { if (luid != null) { for (Entry entry : getStories().entrySet()) { if (luid.equals(entry.getKey().getLuid())) { @@ -147,7 +150,8 @@ public class Library { .getKey().getType()); URL url = entry.getValue().toURI().toURL(); if (type != null) { - return BasicSupport.getSupport(type).process(url); + return BasicSupport.getSupport(type).process(url, + pg); } else { throw new IOException("Unknown type: " + entry.getKey().getType()); @@ -163,6 +167,11 @@ public class Library { } } + if (pg != null) { + pg.setMinMax(0, 1); + pg.setProgress(1); + } + return null; } @@ -172,19 +181,21 @@ public class Library { * * @param url * the {@link URL} to import + * @param pg + * the optional progress reporter * * @return the imported {@link Story} * * @throws IOException * in case of I/O error */ - public Story imprt(URL url) throws IOException { + public Story imprt(URL url, Progress pg) throws IOException { BasicSupport support = BasicSupport.getSupport(url); if (support == null) { throw new IOException("URL not supported: " + url.toString()); } - return save(support.process(url), null); + return save(support.process(url, pg), null); } /** @@ -196,25 +207,27 @@ public class Library { * the {@link OutputType} to transform it to * @param target * the target to save to + * @param pg + * the optional progress reporter * * @return the saved resource (the main saved {@link File}) * * @throws IOException * in case of I/O error */ - public File export(String luid, OutputType type, String target) + public File export(String luid, OutputType type, String target, Progress pg) throws IOException { BasicOutput out = BasicOutput.getOutput(type, true); if (out == null) { throw new IOException("Output type not supported: " + type); } - Story story = getStory(luid); + Story story = getStory(luid, pg); if (story == null) { throw new IOException("Cannot find story to export: " + luid); } - return out.process(getStory(luid), target); + return out.process(story, target); } /** diff --git a/src/be/nikiroo/fanfix/Main.java b/src/be/nikiroo/fanfix/Main.java index f51071d5..ed5664a7 100644 --- a/src/be/nikiroo/fanfix/Main.java +++ b/src/be/nikiroo/fanfix/Main.java @@ -15,6 +15,7 @@ import be.nikiroo.fanfix.reader.BasicReader.ReaderType; import be.nikiroo.fanfix.supported.BasicSupport; import be.nikiroo.fanfix.supported.BasicSupport.SupportType; import be.nikiroo.utils.UIUtils; +import be.nikiroo.utils.ui.Progress; /** * Main program entry point. @@ -161,17 +162,40 @@ public class Main { } } + final Progress mainProgress = new Progress(0, 80); + mainProgress.addProgressListener(new Progress.ProgressListener() { + private int current = mainProgress.getMin(); + + public void progress(Progress progress, String name) { + int diff = progress.getProgress() - current; + current += diff; + + StringBuilder builder = new StringBuilder(); + for (int i = 0; i < diff; i++) { + builder.append('.'); + } + + System.err.print(builder.toString()); + + if (progress.isDone()) { + System.err.println(""); + } + } + }); + Progress pg = new Progress(); + mainProgress.addProgress(pg, mainProgress.getMax()); + if (exitCode != 255) { switch (action) { case IMPORT: - exitCode = imprt(urlString); + exitCode = imprt(urlString, pg); break; case EXPORT: - exitCode = export(luid, typeString, target); + exitCode = export(luid, typeString, target, pg); break; case CONVERT: exitCode = convert(urlString, typeString, target, - plusInfo == null ? false : plusInfo); + plusInfo == null ? false : plusInfo, pg); break; case LIST: exitCode = list(typeString); @@ -238,12 +262,14 @@ public class Main { * * @param urlString * the resource to import + * @param pg + * the optional progress reporter * * @return the exit return code (0 = success) */ - public static int imprt(String urlString) { + public static int imprt(String urlString, Progress pg) { try { - Story story = Instance.getLibrary().imprt(getUrl(urlString)); + Story story = Instance.getLibrary().imprt(getUrl(urlString), pg); System.out.println(story.getMeta().getLuid() + ": \"" + story.getMeta().getTitle() + "\" imported."); } catch (IOException e) { @@ -263,10 +289,13 @@ public class Main { * the {@link OutputType} to use * @param target * the target + * @param pg + * the optional progress reporter * * @return the exit return code (0 = success) */ - public static int export(String luid, String typeString, String target) { + public static int export(String luid, String typeString, String target, + Progress pg) { OutputType type = OutputType.valueOfNullOkUC(typeString); if (type == null) { Instance.syserr(new Exception(trans(StringId.OUTPUT_DESC, @@ -275,7 +304,7 @@ public class Main { } try { - Instance.getLibrary().export(luid, type, target); + Instance.getLibrary().export(luid, type, target, pg); } catch (IOException e) { Instance.syserr(e); return 4; @@ -318,9 +347,9 @@ public class Main { try { BasicReader reader = BasicReader.getReader(); if (library) { - reader.setStory(story); + reader.setStory(story, null); } else { - reader.setStory(getUrl(story)); + reader.setStory(getUrl(story), null); } if (chapString != null) { @@ -354,11 +383,13 @@ public class Main { * @param infoCover * TRUE to also export the cover and info file, even if the given * {@link OutputType} does not usually save them + * @param pg + * the optional progress reporter * * @return the exit return code (0 = success) */ private static int convert(String urlString, String typeString, - String target, boolean infoCover) { + String target, boolean infoCover, Progress pg) { int exitCode = 0; String sourceName = urlString; @@ -380,7 +411,7 @@ public class Main { BasicSupport support = BasicSupport.getSupport(source); if (support != null) { - Story story = support.process(source); + Story story = support.process(source, pg); try { target = new File(target).getAbsolutePath(); diff --git a/src/be/nikiroo/fanfix/reader/BasicReader.java b/src/be/nikiroo/fanfix/reader/BasicReader.java index eabbe7e4..bc3bf72f 100644 --- a/src/be/nikiroo/fanfix/reader/BasicReader.java +++ b/src/be/nikiroo/fanfix/reader/BasicReader.java @@ -8,6 +8,7 @@ import be.nikiroo.fanfix.Library; import be.nikiroo.fanfix.bundles.Config; import be.nikiroo.fanfix.data.Story; import be.nikiroo.fanfix.supported.BasicSupport; +import be.nikiroo.utils.ui.Progress; /** * The class that handles the different {@link Story} readers you can use. @@ -78,23 +79,16 @@ public abstract class BasicReader { * * @param luid * the {@link Story} ID + * @param pg + * the optional progress reporter + * * @throws IOException * in case of I/O error */ - public void setStory(String luid) throws IOException { - story = Instance.getLibrary().getStory(luid); + public void setStory(String luid, Progress pg) throws IOException { + story = Instance.getLibrary().getStory(luid, pg); if (story == null) { - // if the LUID is wrong and < 3, pad it to 3 chars with "0" then - // retry (since LUIDs are %03d) - if (luid != null && luid.length() < 3) { - while (luid.length() < 3) { - luid = "0" + luid; - } - setStory(luid); - } else { - throw new IOException("Cannot retrieve story from library: " - + luid); - } + throw new IOException("Cannot retrieve story from library: " + luid); } } @@ -103,16 +97,19 @@ public abstract class BasicReader { * * @param source * the {@link Story} {@link URL} + * @param pg + * the optional progress reporter + * * @throws IOException * in case of I/O error */ - public void setStory(URL source) throws IOException { + public void setStory(URL source, Progress pg) throws IOException { BasicSupport support = BasicSupport.getSupport(source); if (support == null) { throw new IOException("URL not supported: " + source.toString()); } - story = support.process(source); + story = support.process(source, pg); if (story == null) { throw new IOException( "Cannot retrieve story from external source: " diff --git a/src/be/nikiroo/fanfix/reader/LocalReader.java b/src/be/nikiroo/fanfix/reader/LocalReader.java index c17e83ea..88ffc5d4 100644 --- a/src/be/nikiroo/fanfix/reader/LocalReader.java +++ b/src/be/nikiroo/fanfix/reader/LocalReader.java @@ -9,6 +9,7 @@ import be.nikiroo.fanfix.Library; import be.nikiroo.fanfix.bundles.UiConfig; import be.nikiroo.fanfix.data.Story; import be.nikiroo.fanfix.output.BasicOutput.OutputType; +import be.nikiroo.utils.ui.Progress; class LocalReader extends BasicReader { private Library lib; @@ -46,10 +47,20 @@ class LocalReader extends BasicReader { public void read(int chapter) { } - // keep same luid - public void imprt(String luid) throws IOException { + /** + * Import the story into the local reader library, and keep the same LUID. + * + * @param luid + * the Library UID + * @param pg + * the optional progress reporter + * + * @throws IOException + * in case of I/O error + */ + public void imprt(String luid, Progress pg) throws IOException { try { - Story story = Instance.getLibrary().getStory(luid); + Story story = Instance.getLibrary().getStory(luid, pg); if (story != null) { story = lib.save(story, luid); } else { @@ -62,10 +73,23 @@ class LocalReader extends BasicReader { } } - public File getTarget(String luid) throws IOException { + /** + * Get the target file related to this {@link Story}. + * + * @param luid + * the LUID of the {@link Story} + * @param pg + * the optional progress reporter + * + * @return the target file + * + * @throws IOException + * in case of I/O error + */ + public File getTarget(String luid, Progress pg) throws IOException { File file = lib.getFile(luid); if (file == null) { - imprt(luid); + imprt(luid, pg); file = lib.getFile(luid); } diff --git a/src/be/nikiroo/fanfix/reader/LocalReaderBook.java b/src/be/nikiroo/fanfix/reader/LocalReaderBook.java index 8e353d91..e7bea6aa 100644 --- a/src/be/nikiroo/fanfix/reader/LocalReaderBook.java +++ b/src/be/nikiroo/fanfix/reader/LocalReaderBook.java @@ -31,7 +31,7 @@ class LocalReaderBook extends JPanel { * * @author niki */ - interface BookActionListner extends EventListener { + interface BookActionListener extends EventListener { /** * The book was selected (single click). * @@ -67,7 +67,7 @@ class LocalReaderBook extends JPanel { private boolean hovered; private Date lastClick; private long doubleClickDelay = 200; // in ms - private List listeners; + private List listeners; public LocalReaderBook(MetaData meta) { if (meta.getCover() != null) { @@ -134,7 +134,7 @@ class LocalReaderBook extends JPanel { } private void setupListeners() { - listeners = new ArrayList(); + listeners = new ArrayList(); addMouseListener(new MouseListener() { public void mouseReleased(MouseEvent e) { } @@ -164,7 +164,7 @@ class LocalReaderBook extends JPanel { } private void click(boolean doubleClick) { - for (BookActionListner listener : listeners) { + for (BookActionListener listener : listeners) { if (doubleClick) { listener.action(this); } else { @@ -173,7 +173,7 @@ class LocalReaderBook extends JPanel { } } - public void addActionListener(BookActionListner listener) { + public void addActionListener(BookActionListener listener) { listeners.add(listener); } diff --git a/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java b/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java index a7c743cf..d431d8e4 100644 --- a/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java +++ b/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java @@ -24,7 +24,7 @@ import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.Main; import be.nikiroo.fanfix.bundles.UiConfig; import be.nikiroo.fanfix.data.MetaData; -import be.nikiroo.fanfix.reader.LocalReaderBook.BookActionListner; +import be.nikiroo.fanfix.reader.LocalReaderBook.BookActionListener; import be.nikiroo.utils.WrapLayout; class LocalReaderFrame extends JFrame { @@ -89,7 +89,7 @@ class LocalReaderFrame extends JFrame { books.add(book); final String luid = meta.getLuid(); - book.addActionListener(new BookActionListner() { + book.addActionListener(new BookActionListener() { public void select(LocalReaderBook book) { for (LocalReaderBook abook : books) { abook.setSelected(abook == book); @@ -98,8 +98,8 @@ class LocalReaderFrame extends JFrame { public void action(LocalReaderBook book) { try { - File target = LocalReaderFrame.this.reader - .getTarget(luid); + File target = LocalReaderFrame.this.reader.getTarget( + luid, null); Desktop.getDesktop().browse(target.toURI()); } catch (IOException e) { Instance.syserr(e); @@ -128,7 +128,7 @@ class LocalReaderFrame extends JFrame { + "unresponsive until it is downloaded...", "Importing from URL", JOptionPane.QUESTION_MESSAGE); if (url != null && !url.isEmpty()) { - if (Main.imprt(url) != 0) { + if (Main.imprt(url, null) != 0) { JOptionPane.showMessageDialog(LocalReaderFrame.this, "Cannot import: " + url, "Imort error", JOptionPane.ERROR_MESSAGE); diff --git a/src/be/nikiroo/fanfix/supported/BasicSupport.java b/src/be/nikiroo/fanfix/supported/BasicSupport.java index 93155961..c47d05e6 100644 --- a/src/be/nikiroo/fanfix/supported/BasicSupport.java +++ b/src/be/nikiroo/fanfix/supported/BasicSupport.java @@ -24,6 +24,7 @@ import be.nikiroo.fanfix.data.Paragraph.ParagraphType; import be.nikiroo.fanfix.data.Story; import be.nikiroo.utils.IOUtils; import be.nikiroo.utils.StringUtils; +import be.nikiroo.utils.ui.Progress; /** * This class is the base class used by the other support classes. It can be @@ -328,26 +329,42 @@ public abstract class BasicSupport { * * @param url * the story resource + * @param pg + * the optional progress reporter * * @return the {@link Story} * * @throws IOException * in case of I/O error */ - public Story process(URL url) throws IOException { + public Story process(URL url, Progress pg) throws IOException { + if (pg == null) { + pg = new Progress(); + } else { + pg.setMinMax(0, 100); + } + setCurrentReferer(url); + pg.setProgress(1); try { Story story = processMeta(url, false, true); + pg.setProgress(10); if (story == null) { + pg.setProgress(100); return null; } story.setChapters(new ArrayList()); List> chapters = getChapters(url, getInput()); + pg.setProgress(20); + int i = 1; if (chapters != null) { + Progress pgChaps = new Progress(0, chapters.size()); + pg.addProgress(pgChaps, 80); + for (Entry chap : chapters) { setCurrentReferer(chap.getValue()); InputStream chapIn = Instance.getCache().open( @@ -360,8 +377,11 @@ public abstract class BasicSupport { chapIn.close(); } + pgChaps.setProgress(i); i++; } + } else { + pg.setProgress(100); } return story; diff --git a/src/be/nikiroo/fanfix/supported/Cbz.java b/src/be/nikiroo/fanfix/supported/Cbz.java index 1080ad27..295dc15a 100644 --- a/src/be/nikiroo/fanfix/supported/Cbz.java +++ b/src/be/nikiroo/fanfix/supported/Cbz.java @@ -14,6 +14,7 @@ import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.data.Chapter; import be.nikiroo.fanfix.data.Paragraph; import be.nikiroo.fanfix.data.Story; +import be.nikiroo.utils.ui.Progress; /** * Support class for CBZ files (works better with CBZ created with this program, @@ -54,7 +55,13 @@ class Cbz extends Epub { } @Override - public Story process(URL url) throws IOException { + public Story process(URL url, Progress pg) throws IOException { + if (pg == null) { + pg = new Progress(); + } else { + pg.setMinMax(0, 100); + } + Story story = processMeta(url, false, true); story.setChapters(new ArrayList()); Chapter chap = new Chapter(1, null); @@ -62,6 +69,7 @@ class Cbz extends Epub { ZipInputStream zipIn = new ZipInputStream(getInput()); + pg.setProgress(10); List images = new ArrayList(); for (ZipEntry entry = zipIn.getNextEntry(); entry != null; entry = zipIn .getNextEntry()) { @@ -87,8 +95,11 @@ class Cbz extends Epub { } } + pg.setProgress(80); + // ZIP order is not sure Collections.sort(images); + pg.setProgress(90); for (String uuid : images) { try { @@ -99,6 +110,7 @@ class Cbz extends Epub { } } + pg.setProgress(100); return story; } } diff --git a/src/be/nikiroo/fanfix/supported/E621.java b/src/be/nikiroo/fanfix/supported/E621.java index 665bdd51..5ebd6b31 100644 --- a/src/be/nikiroo/fanfix/supported/E621.java +++ b/src/be/nikiroo/fanfix/supported/E621.java @@ -14,6 +14,7 @@ import be.nikiroo.fanfix.data.Chapter; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.data.Story; import be.nikiroo.utils.StringUtils; +import be.nikiroo.utils.ui.Progress; /** * Support class for e621.net and