Merge branch 'dev' into feature/preserve-scanned-titles

This commit is contained in:
Alex Ling
2021-09-15 08:58:24 +00:00
4 changed files with 65 additions and 83 deletions
+6 -14
View File
@@ -49,7 +49,7 @@ class Entry
file.close
end
def to_slim_json : String
def build_json(*, slim = false)
JSON.build do |json|
json.object do
{% for str in ["zip_path", "title", "size", "id"] %}
@@ -57,23 +57,15 @@ class Entry
{% end %}
json.field "title_id", @book.id
json.field "pages" { json.number @pages }
unless slim
json.field "display_name", @book.display_name @title
json.field "cover_url", cover_url
json.field "mtime" { json.number @mtime.to_unix }
end
end
end
end
def to_json(json : JSON::Builder)
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 "display_name", @book.display_name @title
json.field "cover_url", cover_url
json.field "pages" { json.number @pages }
json.field "mtime" { json.number @mtime.to_unix }
end
end
def display_name
@book.display_name @title
end