fix a issue about search :3

This commit is contained in:
Ashley 2022-12-30 16:22:29 +00:00
parent 8084da89f2
commit d3412cb114

View file

@ -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);