mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-26 00:58:58 +01:00
fix a issue about search :3
This commit is contained in:
parent
8084da89f2
commit
d3412cb114
1 changed files with 32 additions and 27 deletions
|
@ -74,38 +74,43 @@ module.exports = function (app, config, renderTemplate) {
|
|||
var continuation = "";
|
||||
}
|
||||
|
||||
const search = await modules.fetch(
|
||||
`https://tube-srv.ashley143.gay/api/search?query=${query.replace("&", "and")}&continuation=${continuation}`
|
||||
);
|
||||
|
||||
const text = await search.text();
|
||||
const j = JSON.parse(modules.toJson(text));
|
||||
|
||||
if (!query) {
|
||||
return res.redirect("/");
|
||||
}
|
||||
|
||||
h = " ";
|
||||
|
||||
if (j.Search.Results.DynamicItem) {
|
||||
if (j.Search.Results.DynamicItem.id == "didYouMeanRenderer") {
|
||||
var h = JSON.parse(j.Search.Results.DynamicItem.Title);
|
||||
}
|
||||
}
|
||||
|
||||
const summary = await wiki
|
||||
.summary(query + " ")
|
||||
.then((summary_) =>
|
||||
summary_.title !== "Not found." ? summary_ : "none"
|
||||
if (query) {
|
||||
const search = await modules.fetch(
|
||||
`https://tube-srv.ashley143.gay/api/search?query=${query.replace(
|
||||
"&",
|
||||
"and"
|
||||
)}&continuation=${continuation}`
|
||||
);
|
||||
|
||||
renderTemplate(res, req, "search.ejs", {
|
||||
j,
|
||||
h,
|
||||
continuation,
|
||||
q: query,
|
||||
summary,
|
||||
});
|
||||
const text = await search.text();
|
||||
const j = JSON.parse(modules.toJson(text));
|
||||
|
||||
h = " ";
|
||||
|
||||
if (j.Search.Results.DynamicItem) {
|
||||
if (j.Search.Results.DynamicItem.id == "didYouMeanRenderer") {
|
||||
var h = JSON.parse(j.Search.Results.DynamicItem.Title);
|
||||
}
|
||||
}
|
||||
|
||||
const summary = await wiki
|
||||
.summary(query + " ")
|
||||
.then((summary_) =>
|
||||
summary_.title !== "Not found." ? summary_ : "none"
|
||||
);
|
||||
|
||||
renderTemplate(res, req, "search.ejs", {
|
||||
j,
|
||||
h,
|
||||
continuation,
|
||||
q: query,
|
||||
summary,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
app.get("/channel/", async (req, res) => {
|
||||
|
@ -142,7 +147,7 @@ module.exports = function (app, config, renderTemplate) {
|
|||
.fetch(`${config.invapi}/channels/community/${ID}/`)
|
||||
.then((res) => res.text());
|
||||
|
||||
var c = await getJson(community);
|
||||
var c = await getJson(community);
|
||||
|
||||
try {
|
||||
const summary = await wiki.summary(k.Channel.Metadata.Name);
|
||||
|
|
Loading…
Reference in a new issue