From: Niki Roo Date: Mon, 20 May 2019 20:12:13 +0000 (+0200) Subject: change config bundle to better work with new nikiroo-utils X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=b7cd9db81ba27c67fdd8dd5a42b5f9e4137622db;p=nikiroo-utils.git change config bundle to better work with new nikiroo-utils --- diff --git a/libs/nikiroo-utils-4.7.2-dev-sources.jar b/libs/nikiroo-utils-4.7.2-dev-sources.jar index cd1504c..f6df43a 100644 Binary files a/libs/nikiroo-utils-4.7.2-dev-sources.jar and b/libs/nikiroo-utils-4.7.2-dev-sources.jar differ diff --git a/src/be/nikiroo/fanfix/Instance.java b/src/be/nikiroo/fanfix/Instance.java index 96d5d6f..2479c61 100644 --- a/src/be/nikiroo/fanfix/Instance.java +++ b/src/be/nikiroo/fanfix/Instance.java @@ -114,11 +114,10 @@ public class Instance { // Could have used: System.getProperty("java.io.tmpdir") tmp = new File(configDir, "tmp"); } - String ua = config.getString(Config.USER_AGENT); + String ua = config.getString(Config.USER_AGENT, ""); try { - int hours = config.getInteger(Config.CACHE_MAX_TIME_CHANGING, -1); - int hoursLarge = config - .getInteger(Config.CACHE_MAX_TIME_STABLE, -1); + int hours = config.getInteger(Config.CACHE_MAX_TIME_CHANGING, 0); + int hoursLarge = config.getInteger(Config.CACHE_MAX_TIME_STABLE, 0); cache = new DataLoader(tmp, ua, hours, hoursLarge); } catch (IOException e) { tracer.error(new IOException( @@ -332,7 +331,7 @@ public class Instance { */ public static boolean isVersionCheckNeeded() { try { - long wait = config.getInteger(Config.UPDATE_INTERVAL, 1) * 24 * 60 + long wait = config.getInteger(Config.UPDATE_INTERVAL, 0) * 24 * 60 * 60 * 1000; if (wait >= 0) { String lastUpString = IOUtils.readSmallFile(new File(configDir, diff --git a/src/be/nikiroo/fanfix/bundles/Config.java b/src/be/nikiroo/fanfix/bundles/Config.java index 70bf322..99655a8 100644 --- a/src/be/nikiroo/fanfix/bundles/Config.java +++ b/src/be/nikiroo/fanfix/bundles/Config.java @@ -10,80 +10,111 @@ import be.nikiroo.utils.resources.Meta.Format; */ @SuppressWarnings("javadoc") public enum Config { - @Meta(description = "language (example: en-GB, fr-BE...) or nothing for default system language", format = Format.LOCALE, info = "Force the language (can be overwritten again with the env variable $LANG)") + @Meta(description = "The language (example: en-GB, fr-BE...) or nothing for default system language (can be overwritten with the variable $LANG)",// + format = Format.LOCALE) LANG, // - @Meta(description = "reader type (CLI = simple output to console, TUI = Text User Interface with menus and windows, GUI = a GUI with locally stored files)", format = Format.FIXED_LIST, list = { - "CLI", "GUI", "TUI" }, info = "Select the default reader to use to read stories") + @Meta(description = "The default reader type to use to read stories:\nCLI = simple output to console\nTUI = a Text User Interface with menus and windows, based upon Jexer\nGUI = a GUI with locally stored files, based upon Swing", // + format = Format.FIXED_LIST, list = { "CLI", "GUI", "TUI" }, def = "GUI") READER_TYPE, // - @Meta(def = "INFO_TEXT", format = Format.COMBO_LIST, list = { "INFO_TEXT", - "EPUB", "HTML", "TEXT" }, info = "One of the known output type", description = "The type of output for the Local Reader for non-images documents") + @Meta(description = "The type of output for the Local Reader for non-images documents",// + format = Format.FIXED_LIST, list = { "INFO_TEXT", "EPUB", "HTML", "TEXT" }, def = "INFO_TEXT") NON_IMAGES_DOCUMENT_TYPE, // - @Meta(def = "CBZ", format = Format.COMBO_LIST, list = { "CBZ", "HTML" }, description = "The type of output for the Local Reader for images documents") + @Meta(description = "The type of output for the Local Reader for non-images documents",// + format = Format.FIXED_LIST, list = { "CBZ", "HTML" }, def = "CBZ") IMAGES_DOCUMENT_TYPE, // - @Meta(description = "absolute path, $HOME variable supported, / is always accepted as dir separator", format = Format.DIRECTORY, info = "The directory where to store temporary files, defaults to directory 'tmp' in the conig directory (usually $HOME/.fanfix)") + @Meta(description = "The directory where to store temporary files (defaults to directory 'tmp' in the conig directory, usually $HOME/.fanfix/tmp); it must be an absolute path, $HOME notation is supported, / is always accepted as directory separator",// + format = Format.DIRECTORY) CACHE_DIR, // - @Meta(def = "24", description = "delay in hours, or 0 for no cache, or -1 for infinite time (default)", format = Format.INT, info = "The delay after which a cached resource that is thought to change ~often is considered too old and triggers a refresh") + @Meta(description = "The delay in hours after which a cached resource that is thought to change ~often is considered too old and triggers a refresh delay (or 0 for no cache, or -1 for infinite time)", // + format = Format.INT, def = "24") CACHE_MAX_TIME_CHANGING, // - @Meta(def = "720", description = "delay in hours, or 0 for no cache, or -1 for infinite time (default)", format = Format.INT, info = "The delay after which a cached resource that is thought to change rarely is considered too old and triggers a refresh") + @Meta(description = "The delay in hours after which a cached resource that is thought to change rarely is considered too old and triggers a refresh delay (or 0 for no cache, or -1 for infinite time)", // + format = Format.INT, def = "720") CACHE_MAX_TIME_STABLE, // - @Meta(def = "Mozilla/5.0 (X11; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0 -- ELinks/0.9.3 (Linux 2.6.11 i686; 80x24)", description = "string", info = "The user-agent to use to download files") + @Meta(description = "The user-agent to use to download files",// + def = "Mozilla/5.0 (X11; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0 -- ELinks/0.9.3 (Linux 2.6.11 i686; 80x24) -- Fanfix (https://github.com/nikiroo/fanfix/)") USER_AGENT, // - @Meta(def = "$HOME/.fanfix/covers/", description = "absolute path, $HOME variable supported, / is always accepted as dir separator", format = Format.DIRECTORY, info = "The directory where to get the default story covers") + @Meta(description = "The directory where to get the default story covers; it must be an absolute path, $HOME notation is supported, / is always accepted as directory separator",// + format = Format.DIRECTORY, def = "$HOME/.fanfix/covers/") DEFAULT_COVERS_DIR, // - @Meta(description = "string", info = "The default library to use (KEY:SERVER:PORT), or empty for the local library") + @Meta(description = "The default library to use (KEY:SERVER:PORT), or empty for the local library",// + format = Format.STRING, def = "") DEFAULT_LIBRARY, // - @Meta(def = "58365", description = "The port on which we can start the server", format = Format.INT, info = "A valid port") + @Meta(description = "The port on which we can start the server (must be a valid port, from 1 to 65535)", // + format = Format.INT, def = "58365") SERVER_PORT, // - @Meta(def = "", description = "The encryption key for the server (NOT including a subkey)", format = Format.PASSWORD, info = "cannot contain the pipe character (|)") + @Meta(description = "The encryption key for the server (NOT including a subkey), it cannot contain the pipe character \"|\" but can be empty (it is *still* encrypted, but with an empty, easy to guess key)",// + format = Format.PASSWORD, def = "") SERVER_KEY, // - @Meta(def = "TRUE", description = "Allow write access to the clients by default (download story, move story...)", format = Format.BOOLEAN) + @Meta(description = "Allow write access to the clients (download story, move story...) without RW subkeys", // + format = Format.BOOLEAN, def = "true") SERVER_RW, // - @Meta(def = "", description = "If not empty, only the EXACT listed sources will be available for clients", info = "list is comma-separated (,) and values are surrounded by double quotes (\"); any double quote in the value must be backslash-escaped (with \\\")") + @Meta(description = "If not empty, only the EXACT listed sources will be available for clients without BL subkeys",// + array = true, format = Format.STRING, def = "") SERVER_WHITELIST, // - @Meta(def = "", description = "The subkeys that the server will allow, including the modes", info = "list is comma-separated (,) and values are surrounded by double quotes (\"); any double quote in the value must be backslash-escaped (with \\\")") + @Meta(description = "The subkeys that the server will allow, including the modes", // + array = true, format = Format.STRING, def = "") SERVER_ALLOWED_SUBKEYS, // - @Meta(def = "$HOME/Books", description = "absolute path, $HOME variable supported, / is always accepted as dir separator", format = Format.DIRECTORY, info = "The directory where to store the library") + @Meta(description = "The directory where to store the library; it must be an absolute path, $HOME notation is supported, / is always accepted as directory separator",// + format = Format.DIRECTORY, def = "$HOME/Books") LIBRARY_DIR, // - @Meta(def = "false", description = "boolean", format = Format.BOOLEAN, info = "Show debug information on errors") + @Meta(description = "Show debug information on errors",// + format = Format.BOOLEAN, def = "false") DEBUG_ERR, // - @Meta(def = "false", description = "boolean", format = Format.BOOLEAN, info = "Show debug trace information") + @Meta(description = "Show debug trace information",// + format = Format.BOOLEAN, def = "false") DEBUG_TRACE, // - @Meta(def = "PNG", description = "image format", format = Format.COMBO_LIST, list = { - "PNG", "JPG", "BMP" }, info = "Image format to use for cover images") + @Meta(description = "Image format to use for cover images",// + format = Format.FIXED_LIST, list = { "PNG", "JPG", "BMP" }, def = "PNG") IMAGE_FORMAT_COVER, // - @Meta(def = "JPG", description = "image format", format = Format.COMBO_LIST, list = { - "PNG", "JPG", "BMP" }, info = "Image format to use for content images") + @Meta(description = "Image format to use for content images",// + format = Format.FIXED_LIST, list = { "PNG", "JPG", "BMP" }, def = "jpg") IMAGE_FORMAT_CONTENT, // @Meta(group = true) LATEX_LANG, // - @Meta(def = "english", description = "LaTeX output language: English", info = "LaTeX full name") + @Meta(description = "LaTeX output language (full name) for \"English\"",// + format = Format.STRING, def = "english") LATEX_LANG_EN, // - @Meta(def = "french", description = "LaTeX output language: French", info = "LaTeX full name") + @Meta(description = "LaTeX output language (full name) for \"French\"",// + format = Format.STRING, def = "french") LATEX_LANG_FR, // - @Meta(def = "by,par,de,©,(c)", description = "other 'by' prefixes before author name, used to identify the author", array = true) + @Meta(description = "other 'by' prefixes before author name, used to identify the author",// + array = true, format = Format.STRING, def = "\"by\",\"par\",\"de\",\"©\",\"(c)\"") BYS, // - @Meta(def = "EN,FR", description = "List of languages codes used for chapter identification (should not be changed)", array = true, info = "EN,FR") + @Meta(description = "List of languages codes used for chapter identification (should not be changed)", // + array = true, format = Format.STRING, def = "\"EN\",\"FR\"") CHAPTER, // - @Meta(def = "Chapter", description = "Chapter identification String: English", info = "used to identify a starting chapter in text mode") + @Meta(description = "Chapter identification string in English, used to identify a starting chapter in text mode",// + format = Format.STRING, def = "Chapter") CHAPTER_EN, // - @Meta(def = "Chapitre", description = "Chapter identification String: French", info = "used to identify a starting chapter in text mode") + @Meta(description = "Chapter identification string in French, used to identify a starting chapter in text mode",// + format = Format.STRING, def = "Chapitre") CHAPTER_FR, // - @Meta(description = "Login information (username) for YiffStar to have access to all the stories (should not be necessary anymore)") + @Meta(description = "Login for YiffStar to have access to all the stories (should not be necessary anymore, but can still be used)",// + format = Format.STRING) LOGIN_YIFFSTAR_USER, // - @Meta(description = "Login information (password) for YiffStar to have access to all the stories (should not be necessary anymore)", format = Format.PASSWORD) + @Meta(description = "Password for YiffStar to have access to all the stories (should not be necessary anymore, but can still be used)",// + format = Format.PASSWORD) LOGIN_YIFFSTAR_PASS, // - @Meta(description = "If the last update check was done at least that many days, check for updates at startup (-1 for 'no checks' -- default is 1 day)", format = Format.INT) + @Meta(description = "If the last update check was done at least that many days ago, check for updates at startup (-1 for 'no checks')", // + format = Format.INT, def = "1") UPDATE_INTERVAL, // - @Meta(def = "", description = "", info = "Format is ((user(:pass)@)proxy:port), with ':' being system proxy and an empty String being no proxy") + @Meta(description = "The proxy server to use under the format 'user:pass@proxy:port', 'user@proxy:port', 'proxy:port' or ':' alone (system proxy); an empty String means no proxy",// + format = Format.STRING, def = "") USE_PROXY, // - @Meta(group = true, description = "FimFiction APIKEY credentials\nFimFiction can be queried via an API, but requires an API key to do that. One has been created for this program, but if you have another API key you can set it here. You can also set a login and password instead, in that case, a new API key will be generated (and stored) if you still haven't set one.") + @Meta(description = "FimFiction APIKEY credentials\nFimFiction can be queried via an API, but requires an API key to do that. One has been created for this program, but if you have another API key you can set it here. You can also set a login and password instead, in that case, a new API key will be generated (and stored) if you still haven't set one.",// + group = true) LOGIN_FIMFICTION_APIKEY, // - @Meta(description = "An API key required to create a token from FimFiction", format = Format.STRING) + @Meta(description = "The login of the API key used to create a new token from FimFiction", // + format = Format.STRING) LOGIN_FIMFICTION_APIKEY_CLIENT_ID, // - @Meta(description = "An API key required to create a token from FimFiction", format = Format.PASSWORD) + @Meta(description = "The password of the API key used to create a new token from FimFiction", // + format = Format.PASSWORD) LOGIN_FIMFICTION_APIKEY_CLIENT_SECRET, // - @Meta(description = "Do not use the new API, even if we have a token, and force HTML scraping (default is false, use API if token or ID present)", format = Format.BOOLEAN) + @Meta(description = "Do not use the new API, even if we have a token, and force HTML scraping",// + format = Format.BOOLEAN, def = "false") LOGIN_FIMFICTION_APIKEY_FORCE_HTML, // - @Meta(def = "Bearer WnZ5oHlzQoDocv1GcgHfcoqctHkSwL-D", description = "A token is required to use the beta APIv2 from FimFiction (see APIKEY_CLIENT_*)", format = Format.PASSWORD) + @Meta(description = "The token required to use the beta APIv2 from FimFiction (see APIKEY_CLIENT_* if you want to generate a new one from your own API key)", // + format = Format.PASSWORD, def = "Bearer WnZ5oHlzQoDocv1GcgHfcoqctHkSwL-D") LOGIN_FIMFICTION_APIKEY_TOKEN, // } diff --git a/src/be/nikiroo/fanfix/supported/BasicSupportHelper.java b/src/be/nikiroo/fanfix/supported/BasicSupportHelper.java index 2c3c4fe..6525067 100644 --- a/src/be/nikiroo/fanfix/supported/BasicSupportHelper.java +++ b/src/be/nikiroo/fanfix/supported/BasicSupportHelper.java @@ -204,8 +204,7 @@ class BasicSupportHelper { public static 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.getConfig().getList(Config.BYS)) { byString += suffix; if (author.toUpperCase().startsWith(byString.toUpperCase())) { author = author.substring(byString.length()).trim(); diff --git a/src/be/nikiroo/fanfix/supported/BasicSupportPara.java b/src/be/nikiroo/fanfix/supported/BasicSupportPara.java index d3beea5..9795cf6 100644 --- a/src/be/nikiroo/fanfix/supported/BasicSupportPara.java +++ b/src/be/nikiroo/fanfix/supported/BasicSupportPara.java @@ -68,8 +68,7 @@ class BasicSupportPara { // "Chapter 5: - Fun!" after the ": " was automatically added) String chapterName = BasicSupportPara.processPara(name, false) .getContent().trim(); - for (String lang : Instance.getConfig().getString(Config.CHAPTER) - .split(",")) { + for (String lang : Instance.getConfig().getList(Config.CHAPTER)) { String chapterWord = Instance.getConfig().getStringX( Config.CHAPTER, lang); if (chapterName.startsWith(chapterWord)) { diff --git a/src/be/nikiroo/fanfix/supported/BasicSupport_Deprecated.java b/src/be/nikiroo/fanfix/supported/BasicSupport_Deprecated.java index d1dbc00..7a652a4 100644 --- a/src/be/nikiroo/fanfix/supported/BasicSupport_Deprecated.java +++ b/src/be/nikiroo/fanfix/supported/BasicSupport_Deprecated.java @@ -391,8 +391,7 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { // redundant "Chapter x: " in front of it, or "-" (as in // "Chapter 5: - Fun!" after the ": " was automatically added) String chapterName = processPara(name).getContent().trim(); - for (String lang : Instance.getConfig().getString(Config.CHAPTER) - .split(",")) { + for (String lang : Instance.getConfig().getList(Config.CHAPTER)) { String chapterWord = Instance.getConfig().getStringX( Config.CHAPTER, lang); if (chapterName.startsWith(chapterWord)) { diff --git a/src/be/nikiroo/fanfix/supported/Fanfiction.java b/src/be/nikiroo/fanfix/supported/Fanfiction.java index 64df8d3..10c82fc 100644 --- a/src/be/nikiroo/fanfix/supported/Fanfiction.java +++ b/src/be/nikiroo/fanfix/supported/Fanfiction.java @@ -304,8 +304,8 @@ class Fanfiction extends BasicSupport_Deprecated { int pos = line.indexOf("= 0) { boolean chaptered = false; - for (String lang : Instance.getConfig() - .getString(Config.CHAPTER).split(",")) { + for (String lang : Instance.getConfig().getList( + Config.CHAPTER)) { String chapterWord = Instance.getConfig() .getStringX(Config.CHAPTER, lang); int posChap = line.indexOf(chapterWord + " "); diff --git a/src/be/nikiroo/fanfix/supported/Text.java b/src/be/nikiroo/fanfix/supported/Text.java index 5a4188a..34f180e 100644 --- a/src/be/nikiroo/fanfix/supported/Text.java +++ b/src/be/nikiroo/fanfix/supported/Text.java @@ -331,8 +331,7 @@ class Text extends BasicSupport { */ static private String detectChapter(String line, int number) { line = line.toUpperCase(); - for (String lang : Instance.getConfig().getString(Config.CHAPTER) - .split(",")) { + for (String lang : Instance.getConfig().getList(Config.CHAPTER)) { String chapter = Instance.getConfig().getStringX(Config.CHAPTER, lang); if (chapter != null && !chapter.isEmpty()) {