mirror of
https://github.com/hkalexling/Mango.git
synced 2026-04-03 00:03:14 -04:00
Finish tagging
This commit is contained in:
@@ -160,6 +160,12 @@ class APIRouter < Router
|
||||
"ids" => "$strAry",
|
||||
}
|
||||
|
||||
Koa.object "tagsResult", {
|
||||
"success" => "boolean",
|
||||
"tags" => "$strAry?",
|
||||
"error" => "string?",
|
||||
}
|
||||
|
||||
Koa.describe "Returns a page in a manga entry"
|
||||
Koa.path "tid", desc: "Title ID"
|
||||
Koa.path "eid", desc: "Entry ID"
|
||||
@@ -685,6 +691,27 @@ class APIRouter < Router
|
||||
end
|
||||
end
|
||||
|
||||
Koa.describe "Gets the tags of a title"
|
||||
Koa.path "tid", desc: "A title ID"
|
||||
Koa.response 200, ref: "$tagsResult"
|
||||
get "/api/tags/:tid" do |env|
|
||||
begin
|
||||
title = (@context.library.get_title env.params.url["tid"]).not_nil!
|
||||
tags = title.tags
|
||||
|
||||
send_json env, {
|
||||
"success" => true,
|
||||
"tags" => tags,
|
||||
}.to_json
|
||||
rescue e
|
||||
@context.error e
|
||||
send_json env, {
|
||||
"success" => false,
|
||||
"error" => e.message,
|
||||
}.to_json
|
||||
end
|
||||
end
|
||||
|
||||
Koa.describe "Adds a new tag to a title"
|
||||
Koa.path "tid", desc: "A title ID"
|
||||
Koa.response 200, ref: "$result"
|
||||
|
||||
@@ -132,13 +132,25 @@ class MainRouter < Router
|
||||
titles = sort_titles titles, sort_opt, username
|
||||
percentage = titles.map &.load_percentage username
|
||||
|
||||
layout "tags"
|
||||
layout "tag"
|
||||
rescue e
|
||||
@context.error e
|
||||
env.response.status_code = 404
|
||||
end
|
||||
end
|
||||
|
||||
get "/tags" do |env|
|
||||
tags = Storage.default.list_tags
|
||||
encoded_tags = tags.map do |t|
|
||||
URI.encode_www_form t, space_to_plus: false
|
||||
end
|
||||
counts = tags.map do |t|
|
||||
Storage.default.get_tag_titles(t).size
|
||||
end
|
||||
|
||||
layout "tags"
|
||||
end
|
||||
|
||||
get "/api" do |env|
|
||||
render "src/views/api.html.ecr"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user