X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FBasicSupportHelper.java;h=b5c7bb9cdee9ccaf96c1de6c38eeb4aaa76a9537;hb=d66deb8d8b30cff6b54db352eef34a3508939f84;hp=0c9e199fa2695af13d15493e1a121aa37a04f270;hpb=0ffa47548f474c1330d8d723300d9aa7a4894736;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/supported/BasicSupportHelper.java b/src/be/nikiroo/fanfix/supported/BasicSupportHelper.java index 0c9e199..b5c7bb9 100644 --- a/src/be/nikiroo/fanfix/supported/BasicSupportHelper.java +++ b/src/be/nikiroo/fanfix/supported/BasicSupportHelper.java @@ -16,7 +16,7 @@ import be.nikiroo.utils.Image; * * @author niki */ -class BasicSupportHelper { +public class BasicSupportHelper { /** * Get the default cover related to this subject (see .info files). * @@ -25,11 +25,10 @@ class BasicSupportHelper { * * @return the cover if any, or NULL */ - public static Image getDefaultCover(String subject) { - if (subject != null && !subject.isEmpty() - && Instance.getCoverDir() != null) { + public Image getDefaultCover(String subject) { + if (subject != null && !subject.isEmpty() && Instance.getInstance().getCoverDir() != null) { try { - File fileCover = new File(Instance.getCoverDir(), subject); + File fileCover = new File(Instance.getInstance().getCoverDir(), subject); return getImage(null, fileCover.toURI().toURL(), subject); } catch (MalformedURLException e) { } @@ -48,7 +47,7 @@ class BasicSupportHelper { * * @return the extensions */ - public static String[] getImageExt(boolean emptyAllowed) { + public String[] getImageExt(boolean emptyAllowed) { if (emptyAllowed) { return new String[] { "", ".png", ".jpg", ".jpeg", ".gif", ".bmp" }; } @@ -61,16 +60,17 @@ class BasicSupportHelper { * refresh the cache with it if it is. * * @param support - * the linked {@link BasicSupport} + * the linked {@link BasicSupport} (can be NULL) * @param source - * the story source + * the source of the story (for image lookup in the same path if + * the source is a file, can be NULL) * @param line * the resource to check * * @return the image if found, or NULL * */ - public static Image getImage(BasicSupport support, URL source, String line) { + public Image getImage(BasicSupport support, URL source, String line) { URL url = getImageUrl(support, source, line); if (url != null) { if ("file".equals(url.getProtocol())) { @@ -80,8 +80,7 @@ class BasicSupportHelper { } InputStream in = null; try { - in = Instance.getCache().open(url, - BasicSupport.getSupport(url), true); + in = Instance.getInstance().getCache().open(url, support, true); return new Image(in); } catch (IOException e) { } finally { @@ -102,16 +101,17 @@ class BasicSupportHelper { * refresh the cache with it if it is. * * @param support - * the linked {@link BasicSupport} + * the linked {@link BasicSupport} (can be NULL) * @param source - * the story source + * the source of the story (for image lookup in the same path if + * the source is a file, can be NULL) * @param line * the resource to check * * @return the image URL if found, or NULL * */ - public static URL getImageUrl(BasicSupport support, URL source, String line) { + public URL getImageUrl(BasicSupport support, URL source, String line) { URL url = null; if (line != null) { @@ -155,8 +155,7 @@ class BasicSupportHelper { // try for URLs try { for (String ext : getImageExt(true)) { - if (Instance.getCache() - .check(new URL(line + ext), true)) { + if (Instance.getInstance().getCache().check(new URL(line + ext), true)) { url = new URL(line + ext); break; } @@ -167,7 +166,7 @@ class BasicSupportHelper { for (String ext : getImageExt(true)) { try { url = new URL(line + ext); - Instance.getCache().refresh(url, support, true); + Instance.getInstance().getCache().refresh(url, support, true); break; } catch (IOException e) { // no image with this ext @@ -183,7 +182,7 @@ class BasicSupportHelper { // refresh the cached file if (url != null) { try { - Instance.getCache().refresh(url, support, true); + Instance.getInstance().getCache().refresh(url, support, true); } catch (IOException e) { // woops, broken image url = null; @@ -202,11 +201,10 @@ class BasicSupportHelper { * * @return the author without prefixes */ - public static String fixAuthor(String author) { + public String fixAuthor(String author) { if (author != null) { for (String suffix : new String[] { " ", ":" }) { - for (String byString : Instance.getConfig() - .getString(Config.BYS).split(",")) { + for (String byString : Instance.getInstance().getConfig().getList(Config.CONF_BYS)) { byString += suffix; if (author.toUpperCase().startsWith(byString.toUpperCase())) { author = author.substring(byString.length()).trim();