mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-26 11:58:14 +01:00
add a new page for web search results to make the search faster
This commit is contained in:
parent
311880a0a2
commit
65c9953f05
1 changed files with 62 additions and 23 deletions
|
@ -119,24 +119,6 @@ module.exports = function (app, config, renderTemplate) {
|
|||
didYouMean = JSON.parse(searchJson.Search.Results.DynamicItem.Title);
|
||||
}
|
||||
|
||||
if (tab) {
|
||||
search({ query: `${req.query.query}` })
|
||||
.then((results) => {
|
||||
renderTemplate(res, req, "search.ejs", {
|
||||
j: searchJson,
|
||||
IsOldWindows,
|
||||
h: didYouMean,
|
||||
tab,
|
||||
continuation,
|
||||
results: results,
|
||||
q: query,
|
||||
summary: "",
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
} else {
|
||||
renderTemplate(res, req, "search.ejs", {
|
||||
j: searchJson,
|
||||
IsOldWindows,
|
||||
|
@ -147,7 +129,64 @@ module.exports = function (app, config, renderTemplate) {
|
|||
q: query,
|
||||
summary: "",
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Error while searching for '${query}':`, error);
|
||||
res.redirect("/");
|
||||
}
|
||||
});
|
||||
|
||||
app.get("/web", async (req, res) => {
|
||||
const query = req.query.query;
|
||||
const tab = req.query.tab;
|
||||
|
||||
const search = require("google-it");
|
||||
|
||||
var uaos = req.useragent.os;
|
||||
var IsOldWindows;
|
||||
|
||||
if (uaos == "Windows 7" && req.useragent.browser == "Firefox") {
|
||||
IsOldWindows = true;
|
||||
} else if (uaos == "Windows 8" && req.useragent.browser == "Firefox") {
|
||||
IsOldWindows = true;
|
||||
} else {
|
||||
IsOldWindows = false;
|
||||
}
|
||||
|
||||
const poketube_universe_value = "poketube_smart_search";
|
||||
|
||||
if (query?.includes("youtube.com/watch?v=")) {
|
||||
try {
|
||||
var videoid = query?.split("v=");
|
||||
|
||||
res.redirect("/watch?v=" + videoid[1]);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (query && query.startsWith("!") && query.length > 2) {
|
||||
res.redirect("https://lite.duckduckgo.com/lite/?q=" + query);
|
||||
}
|
||||
|
||||
if (!query) {
|
||||
return res.redirect("/");
|
||||
}
|
||||
|
||||
let continuation = req.query.continuation || "";
|
||||
|
||||
try {
|
||||
search({ query: `${req.query.query}` }).then((results) => {
|
||||
renderTemplate(res, req, "search-web.ejs", {
|
||||
j: "",
|
||||
IsOldWindows,
|
||||
h: "",
|
||||
tab,
|
||||
continuation,
|
||||
results: results,
|
||||
q: query,
|
||||
summary: "",
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Error while searching for '${query}':`, error);
|
||||
res.redirect("/");
|
||||
|
|
Loading…
Reference in a new issue