mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 03:15:31 -04:00
- move the initialization of config/library/storage to mango.cr
- remove duplicate initialization of server in server.cr
This commit is contained in:
parent
e7583ce788
commit
7c66b05872
@ -14,6 +14,9 @@ class Config
|
|||||||
@[YAML::Field(key: "db_path")]
|
@[YAML::Field(key: "db_path")]
|
||||||
property db_path = File.expand_path "~/mango/mango.db", home: true
|
property db_path = File.expand_path "~/mango/mango.db", home: true
|
||||||
|
|
||||||
|
@[YAML::Field(key: "scan_interval_minutes")]
|
||||||
|
property scan_interval = 5
|
||||||
|
|
||||||
def self.load
|
def self.load
|
||||||
cfg_path = File.expand_path "~/.config/mango/config.yml", home: true
|
cfg_path = File.expand_path "~/.config/mango/config.yml", home: true
|
||||||
if File.exists? cfg_path
|
if File.exists? cfg_path
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
require "./server"
|
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
|
server.start
|
||||||
|
@ -11,10 +11,7 @@ class Server
|
|||||||
property library : Library
|
property library : Library
|
||||||
property storage : Storage
|
property storage : Storage
|
||||||
|
|
||||||
def initialize
|
def initialize(@config, @library, @storage)
|
||||||
@config = Config.load
|
|
||||||
@library = Library.new @config.@library_path
|
|
||||||
@storage = Storage.new @config.db_path
|
|
||||||
|
|
||||||
error 403 do |env|
|
error 403 do |env|
|
||||||
message = "You are not authorized to visit #{env.request.path}"
|
message = "You are not authorized to visit #{env.request.path}"
|
||||||
@ -54,7 +51,6 @@ class Server
|
|||||||
layout "user"
|
layout "user"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
get "/admin/user/edit" do |env|
|
get "/admin/user/edit" do |env|
|
||||||
username = env.params.query["username"]?
|
username = env.params.query["username"]?
|
||||||
admin = env.params.query["admin"]?
|
admin = env.params.query["admin"]?
|
||||||
@ -322,6 +318,3 @@ class Server
|
|||||||
Kemal.run
|
Kemal.run
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
server = Server.new
|
|
||||||
server.start
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user