From 45557cdd61850abc30959c39054d29b45fefb8c2 Mon Sep 17 00:00:00 2001 From: Minteck Date: Thu, 16 Dec 2021 23:06:28 +0100 Subject: It's finally done! --- htdocs/public/search/index.ejs | 86 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 htdocs/public/search/index.ejs (limited to 'htdocs/public/search') diff --git a/htdocs/public/search/index.ejs b/htdocs/public/search/index.ejs new file mode 100644 index 0000000..6d12596 --- /dev/null +++ b/htdocs/public/search/index.ejs @@ -0,0 +1,86 @@ +<% + + if (typeof get["q"] !== "undefined") { + query = get["q"].toLowerCase().substr(0, 200).replace(/[^A-Za-z0-9 \-]/, '').replace(/[\.]/, ' ').trim(); + } else { + res.writeHead(301, {"Location": "/" + slang}); + res.end(); + } + + if (query === "") { + res.writeHead(301, {"Location": "/" + slang}); + res.end(); + } + +global.title = query; %> +<%- await include(`${private}/header.ejs`) %> + +
+ +
+ + +
+
+ +
+ +<% + +start = new Date(); +qres = await axios.post("https://api.wolfeye.minteck.org/api/tocorrect", { string: query }); +cdata = qres.data; +time = new Date() - start; + +if (cdata.corrected) { %> + +
+ <%- lang.results.didyoumean.replace("$1", query).replace("$2", '' + cdata.res + '') %> +
+ +<% } + +sres = await axios.post("https://api.wolfeye.minteck.org/api/search", { query, page: 0 }); +sdata = sres.data; + +%> + +

<%- lang.results.debug.replace("$1", sdata.res.length).replace("$2", (time / 1000).toFixed(2)) %>

+ +
+
+
<%- lang.results.load %>
+
+
+ + + +<% + +if (sdata.res.length > 0) { %> +
+ <% for (item of sdata.res) { %> + +<% } %> +
+<% } %> +<% if (sdata.res.length <= 0) { %> +
+

<%- lang.results.none.title %>

+

<%- lang.results.none.description.replace("$1", query) %> +

+
+<% } %> + +<%- await include(`${private}/footer.ejs`) %> \ No newline at end of file -- cgit