Compare commits

..

1 Commits

Author SHA1 Message Date
Leeingnyo 5a17ca07d8 Use yaml-static in Dockerfile 2021-08-18 19:42:32 +09:00
6 changed files with 6 additions and 83 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ FROM crystallang/crystal:0.36.1-alpine AS builder
WORKDIR /Mango
COPY . .
RUN apk add --no-cache yarn yaml sqlite-static libarchive-dev libarchive-static acl-static expat-static zstd-static lz4-static bzip2-static libjpeg-turbo-dev libpng-dev tiff-dev
RUN apk add --no-cache yarn yaml-static sqlite-static libarchive-dev libarchive-static acl-static expat-static zstd-static lz4-static bzip2-static libjpeg-turbo-dev libpng-dev tiff-dev
RUN make static || make static
FROM library/alpine
-12
View File
@@ -46,18 +46,6 @@ class Entry
file.close
end
def to_slim_json : String
JSON.build do |json|
json.object do
{% for str in ["zip_path", "title", "size", "id"] %}
json.field {{str}}, @{{str.id}}
{% end %}
json.field "title_id", @book.id
json.field "pages" { json.number @pages }
end
end
end
def to_json(json : JSON::Builder)
json.object do
{% for str in ["zip_path", "title", "size", "id"] %}
-15
View File
@@ -85,21 +85,6 @@ class Library
titles + titles.flat_map &.deep_titles
end
def to_slim_json : String
JSON.build do |json|
json.object do
json.field "dir", @dir
json.field "titles" do
json.array do
self.titles.each do |title|
json.raw title.to_slim_json
end
end
end
end
end
end
def to_json(json : JSON::Builder)
json.object do
json.field "dir", @dir
-35
View File
@@ -57,41 +57,6 @@ class Title
end
end
def to_slim_json : String
JSON.build do |json|
json.object do
{% for str in ["dir", "title", "id"] %}
json.field {{str}}, @{{str.id}}
{% end %}
json.field "signature" { json.number @signature }
json.field "titles" do
json.array do
self.titles.each do |title|
json.raw title.to_slim_json
end
end
end
json.field "entries" do
json.array do
@entries.each do |entry|
json.raw entry.to_slim_json
end
end
end
json.field "parents" do
json.array do
self.parents.each do |title|
json.object do
json.field "title", title.title
json.field "id", title.id
end
end
end
end
end
end
end
def to_json(json : JSON::Builder)
json.object do
{% for str in ["dir", "title", "id"] %}
+4 -18
View File
@@ -126,11 +126,8 @@ struct APIRouter
end
end
Koa.describe "Returns the book with title `tid`", <<-MD
Supply the `tid` query parameter to strip away "display_name", "cover_url", and "mtime" from the returned object to speed up the loading time
MD
Koa.describe "Returns the book with title `tid`"
Koa.path "tid", desc: "Title ID"
Koa.query "slim"
Koa.response 200, schema: "title"
Koa.response 404, "Title not found"
Koa.tag "library"
@@ -140,11 +137,7 @@ struct APIRouter
title = Library.default.get_title tid
raise "Title ID `#{tid}` not found" if title.nil?
if env.params.query["slim"]?
send_json env, title.to_slim_json
else
send_json env, title.to_json
end
send_json env, title.to_json
rescue e
Logger.error e
env.response.status_code = 404
@@ -152,21 +145,14 @@ struct APIRouter
end
end
Koa.describe "Returns the entire library with all titles and entries", <<-MD
Supply the `tid` query parameter to strip away "display_name", "cover_url", and "mtime" from the returned object to speed up the loading time
MD
Koa.query "slim"
Koa.describe "Returns the entire library with all titles and entries"
Koa.response 200, schema: {
"dir" => String,
"titles" => ["title"],
}
Koa.tag "library"
get "/api/library" do |env|
if env.params.query["slim"]?
send_json env, Library.default.to_slim_json
else
send_json env, Library.default.to_json
end
send_json env, Library.default.to_json
end
Koa.describe "Triggers a library scan"
+1 -2
View File
@@ -30,8 +30,7 @@ struct MainRouter
else
redirect env, "/"
end
rescue e
Logger.error e
rescue
redirect env, "/login"
end
end