nitiwiki: Update to new INI api
authorAlexandre Terrasa <alexandre@moz-code.org>
Sat, 15 Jun 2019 18:55:56 +0000 (14:55 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Thu, 20 Jun 2019 23:12:03 +0000 (19:12 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

contrib/nitiwiki/src/wiki_base.nit

index 2e93a74..f1fb6ae 100644 (file)
@@ -612,7 +612,13 @@ end
 #
 # This class provides services that ensure static typing when accessing the `config.ini` file.
 class WikiConfig
-       super ConfigTree
+       super IniFile
+       autoinit ini_file
+
+       # Path to this file
+       var ini_file: String
+
+       init do load_file(ini_file)
 
        # Returns the config value at `key` or return `default` if no key was found.
        protected fun value_or_default(key: String, default: String): String do
@@ -779,8 +785,8 @@ class WikiConfig
        var sidebar_blocks: Array[String] is lazy do
                var res = new Array[String]
                if not has_key("wiki.sidebar.blocks") then return res
-               for val in at("wiki.sidebar.blocks").as(not null).values do
-                       res.add val
+               for val in section("wiki.sidebar.blocks").as(not null).values do
+                       res.add val.as(not null)
                end
                return res
        end
@@ -834,7 +840,13 @@ end
 # Each section can provide its own config file to customize
 # appearance or behavior.
 class SectionConfig
-       super ConfigTree
+       super IniFile
+       autoinit ini_file
+
+       # Path to this file
+       var ini_file: String
+
+       init do load_file(ini_file)
 
        # Returns the config value at `key` or `null` if no key was found.
        private fun value_or_null(key: String): nullable String do