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