mirror of
https://github.com/hkalexling/Mango.git
synced 2026-04-25 00:00:52 -04:00
Use singleton in various classes
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
||||
require "./router"
|
||||
|
||||
class AdminRouter < Router
|
||||
def setup
|
||||
def initialize
|
||||
get "/admin" do |env|
|
||||
layout "admin"
|
||||
end
|
||||
@@ -96,7 +96,7 @@ class AdminRouter < Router
|
||||
end
|
||||
|
||||
get "/admin/downloads" do |env|
|
||||
base_url = @context.config.mangadex["base_url"]
|
||||
base_url = Config.current.mangadex["base_url"]
|
||||
layout "download-manager"
|
||||
end
|
||||
end
|
||||
|
||||
+3
-3
@@ -3,7 +3,7 @@ require "../mangadex/*"
|
||||
require "../upload"
|
||||
|
||||
class APIRouter < Router
|
||||
def setup
|
||||
def initialize
|
||||
get "/api/page/:tid/:eid/:page" do |env|
|
||||
begin
|
||||
tid = env.params.url["tid"]
|
||||
@@ -123,7 +123,7 @@ class APIRouter < Router
|
||||
get "/api/admin/mangadex/manga/:id" do |env|
|
||||
begin
|
||||
id = env.params.url["id"]
|
||||
api = MangaDex::API.new @context.config.mangadex["api_url"].to_s
|
||||
api = MangaDex::API.default
|
||||
manga = api.get_manga id
|
||||
send_json env, manga.to_info_json
|
||||
rescue e
|
||||
@@ -230,7 +230,7 @@ class APIRouter < Router
|
||||
end
|
||||
|
||||
ext = File.extname filename
|
||||
upload = Upload.new @context.config.upload_path, @context.logger
|
||||
upload = Upload.new Config.current.upload_path
|
||||
url = upload.path_to_url upload.save "img", ext, part.body
|
||||
|
||||
if url.nil?
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
require "./router"
|
||||
|
||||
class MainRouter < Router
|
||||
def setup
|
||||
def initialize
|
||||
get "/login" do |env|
|
||||
render "src/views/login.ecr"
|
||||
end
|
||||
@@ -59,7 +59,7 @@ class MainRouter < Router
|
||||
end
|
||||
|
||||
get "/download" do |env|
|
||||
base_url = @context.config.mangadex["base_url"]
|
||||
base_url = Config.current.mangadex["base_url"]
|
||||
layout "download"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require "./router"
|
||||
|
||||
class ReaderRouter < Router
|
||||
def setup
|
||||
def initialize
|
||||
get "/reader/:title/:entry" do |env|
|
||||
begin
|
||||
title = (@context.library.get_title env.params.url["title"]).not_nil!
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
require "../context"
|
||||
|
||||
class Router
|
||||
def initialize(@context : Context)
|
||||
end
|
||||
@context : Context = Context.default
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user