mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-17 04:14:39 -05:00
add web search~ :3
This commit is contained in:
parent
7c90af5004
commit
c85b0d0b06
1 changed files with 14 additions and 3 deletions
|
@ -63,6 +63,10 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
|
|
||||||
app.get("/search", async (req, res) => {
|
app.get("/search", async (req, res) => {
|
||||||
const query = req.query.query;
|
const query = req.query.query;
|
||||||
|
const tab = req.query.tab
|
||||||
|
|
||||||
|
const search = require('google-it')
|
||||||
|
|
||||||
|
|
||||||
var uaos = req.useragent.os;
|
var uaos = req.useragent.os;
|
||||||
var IsOldWindows;
|
var IsOldWindows;
|
||||||
|
@ -113,14 +117,21 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
if ( searchJson.Search?.Results?.DynamicItem?.id === "didYouMeanRenderer" ) { didYouMean = JSON.parse(searchJson.Search.Results.DynamicItem.Title);
|
if ( searchJson.Search?.Results?.DynamicItem?.id === "didYouMeanRenderer" ) { didYouMean = JSON.parse(searchJson.Search.Results.DynamicItem.Title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
search({'query': `${req.query.query}`}).then(results => {
|
||||||
renderTemplate(res, req, "search.ejs", {
|
renderTemplate(res, req, "search.ejs", {
|
||||||
j: searchJson,
|
j: searchJson,
|
||||||
IsOldWindows,
|
IsOldWindows,
|
||||||
h: didYouMean,
|
h: didYouMean,
|
||||||
|
tab,
|
||||||
continuation,
|
continuation,
|
||||||
|
results:results,
|
||||||
q: query,
|
q: query,
|
||||||
summary: "",
|
summary: "",
|
||||||
});
|
});
|
||||||
|
}).catch(e => {
|
||||||
|
console.log(e)
|
||||||
|
})
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error while searching for '${query}':`, error);
|
console.error(`Error while searching for '${query}':`, error);
|
||||||
res.redirect("/");
|
res.redirect("/");
|
||||||
|
|
Loading…
Reference in a new issue