diff --git a/src/config.cr b/src/config.cr index 2ea70f0..a8fe279 100644 --- a/src/config.cr +++ b/src/config.cr @@ -14,6 +14,9 @@ class Config @[YAML::Field(key: "db_path")] property db_path = File.expand_path "~/mango/mango.db", home: true + @[YAML::Field(key: "scan_interval_minutes")] + property scan_interval = 5 + def self.load cfg_path = File.expand_path "~/.config/mango/config.yml", home: true if File.exists? cfg_path diff --git a/src/mango.cr b/src/mango.cr index 8d4d439..4691a53 100644 --- a/src/mango.cr +++ b/src/mango.cr @@ -1,4 +1,11 @@ require "./server" +require "./config" +require "./library" +require "./storage" -server = Server.new +config = Config.load +library = Library.new config.library_path +storage = Storage.new config.db_path + +server = Server.new config, library, storage server.start diff --git a/src/server.cr b/src/server.cr index 1f43ebe..ba860a5 100644 --- a/src/server.cr +++ b/src/server.cr @@ -11,10 +11,7 @@ class Server property library : Library property storage : Storage - def initialize - @config = Config.load - @library = Library.new @config.@library_path - @storage = Storage.new @config.db_path + def initialize(@config, @library, @storage) error 403 do |env| message = "You are not authorized to visit #{env.request.path}" @@ -54,7 +51,6 @@ class Server layout "user" end - get "/admin/user/edit" do |env| username = env.params.query["username"]? admin = env.params.query["admin"]? @@ -322,6 +318,3 @@ class Server Kemal.run end end - -server = Server.new -server.start