mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 03:15:31 -04:00
Rename plugin function search
to listChapters
This commit is contained in:
parent
ab34fb260c
commit
6e9466c9d2
@ -36,7 +36,7 @@ const search = () => {
|
|||||||
const query = $('#search-input').val();
|
const query = $('#search-input').val();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: base_url + 'api/admin/plugin/search',
|
url: base_url + 'api/admin/plugin/list',
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
query: query,
|
query: query,
|
||||||
plugin: pid
|
plugin: pid
|
||||||
|
@ -153,15 +153,15 @@ class Plugin
|
|||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
|
|
||||||
def search(query : String)
|
def list_chapters(query : String)
|
||||||
json = eval_json "search('#{query}')"
|
json = eval_json "listChapters('#{query}')"
|
||||||
begin
|
begin
|
||||||
check_fields ["title", "chapters"]
|
check_fields ["title", "chapters"]
|
||||||
|
|
||||||
ary = json["chapters"].as_a
|
ary = json["chapters"].as_a
|
||||||
ary.each do |obj|
|
ary.each do |obj|
|
||||||
id = obj["id"]?
|
id = obj["id"]?
|
||||||
raise "Field `id` missing from `search` outputs" if id.nil?
|
raise "Field `id` missing from `listChapters` outputs" if id.nil?
|
||||||
|
|
||||||
unless id.to_s.alphanumeric_underscore?
|
unless id.to_s.alphanumeric_underscore?
|
||||||
raise "The `id` field can only contain alphanumeric characters " \
|
raise "The `id` field can only contain alphanumeric characters " \
|
||||||
@ -169,7 +169,7 @@ class Plugin
|
|||||||
end
|
end
|
||||||
|
|
||||||
title = obj["title"]?
|
title = obj["title"]?
|
||||||
raise "Field `title` missing from `search` outputs" if title.nil?
|
raise "Field `title` missing from `listChapters` outputs" if title.nil?
|
||||||
end
|
end
|
||||||
rescue e
|
rescue e
|
||||||
raise Error.new e.message
|
raise Error.new e.message
|
||||||
|
@ -260,12 +260,12 @@ class APIRouter < Router
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
post "/api/admin/plugin/search" do |env|
|
post "/api/admin/plugin/list" do |env|
|
||||||
begin
|
begin
|
||||||
query = env.params.json["query"].as String
|
query = env.params.json["query"].as String
|
||||||
plugin = Plugin.new env.params.json["plugin"].as String
|
plugin = Plugin.new env.params.json["plugin"].as String
|
||||||
|
|
||||||
json = plugin.search query
|
json = plugin.list_chapters query
|
||||||
chapters = json["chapters"]
|
chapters = json["chapters"]
|
||||||
title = json["title"]
|
title = json["title"]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user