diff --git a/dist/index.html b/dist/index.html
index 5de7d51..63b137e 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -11,6 +11,7 @@
Blaze
What is this site?
diff --git a/dist/info_not_blazed.html b/dist/info_not_blazed.html
new file mode 100644
index 0000000..fb7c192
--- /dev/null
+++ b/dist/info_not_blazed.html
@@ -0,0 +1,42 @@
+
+
+
+
+
+ Blaze - ooops
+
+
+
+ Why are some pages unable to be blazed?
+
+ The purpose of Blaze is to allow users to navigate the web and access the
+ content they need even in challenging connection situations or when
+ seeking a minimalistic resource and data usage. However, generating a
+ "pure HTML only content page" from every page is not always possible.
+
+
+ Blaze utilizes the same library that Firefox uses to generate the "read
+ mode" of a page, providing a distraction-free and minimalist version for
+ better content absorption. However, this library is primarily designed for
+ reading purposes. Therefore, when navigating to websites like Amazon that
+ do not contain readable content, Blaze cannot generate a minimalistic
+ version of the website.
+
+ But the page was an article/blog post!
+
+ In such cases, it is possible that Blaze has detected a false positive. It
+ would be greatly appreciated
+ if you could provide the URL of the page
+ where you encountered this message while expecting it to work. This
+ information will help me reduce false positives for other users as well.
+
+
+ Back to blaze
+
+
diff --git a/dist/not_blazed.html b/dist/not_blazed.html
new file mode 100644
index 0000000..c0497c4
--- /dev/null
+++ b/dist/not_blazed.html
@@ -0,0 +1,24 @@
+
+
+
+
+
+ Blaze
+
+
+
+ This page can not be blazed... Sorry!
+ Why does not work?
+
+
diff --git a/index.ts b/index.ts
index 8b47cbb..c6332b2 100644
--- a/index.ts
+++ b/index.ts
@@ -4,7 +4,7 @@ import { JSDOM } from "jsdom";
import got from "got";
import path from "path";
import { fileURLToPath } from "url";
-import fetch from 'node-fetch'
+import fetch from "node-fetch";
import "dotenv/config";
const app = express();
@@ -21,10 +21,10 @@ app.get("/", async (req, res) => {
if (!query) {
res.sendFile(path.join(__dirname + "/dist/index.html"));
- return
+ return;
}
- const key = process.env.CYCLIC_BRAVE_KEY
+ const key = process.env.CYCLIC_BRAVE_KEY;
if (!key) {
throw new Error("No brave key found");
@@ -32,42 +32,46 @@ app.get("/", async (req, res) => {
fetch(`${searchEngine}?q=${query}`, {
headers: {
- "Accept": "*/*",
+ Accept: "*/*",
"Accept-Encoding": "gzip, deflate, br",
"X-Subscription-Token": key,
},
})
.then((page) => {
- page.json().then(response => {
- const results: any[] = []
+ page.json().then((response) => {
+ const results: any[] = [];
+ const url = process.env.DEV_MODE
+ ? "http://localhost:8888/blazed"
+ : "https://blaze.cyclic.app/blazed";
// @ts-ignore
- response.web.results.forEach(result => {
+ response.web.results.forEach((result) => {
results.push(`
`);
- })
+ });
res.send(`
- Blaze The Page
+ Blaze - ${query}
${results.join("")}
`);
- })
+ });
})
.catch((err) => {
console.log(err);
@@ -75,35 +79,39 @@ app.get("/", async (req, res) => {
});
app.get("/blazed", (req, res) => {
-const pageToBlaze = req.query.url as string
-
-got(pageToBlaze)
- .then((response) => {
- const dom = new JSDOM(response.body);
+ const pageToBlaze = req.query.url as string;
- if (!isProbablyReaderable(dom.window.document)) {
- res.send("This page can not be blazed... Sorry!")
- return;
- }
+ got(pageToBlaze)
+ .then((response) => {
+ const dom = new JSDOM(response.body);
- let reader = new Readability(dom.window.document);
- let article = reader.parse();
+ if (!isProbablyReaderable(dom.window.document)) {
+ res.sendFile(path.join(__dirname + "/dist/not_blazed.html"));
+ return;
+ }
- if (!article) {
- res.send("Something went wrong");
- return;
- }
+ let reader = new Readability(dom.window.document);
+ let article = reader.parse();
- res.send(article.content);
- })
- .catch((err) => {
- console.log(err);
- });
-})
+ if (!article) {
+ res.send("Something went wrong");
+ return;
+ }
+
+ res.send(article.content);
+ })
+ .catch((err) => {
+ console.log(err);
+ });
+});
app.get("/info", (_, res) => {
res.sendFile(path.join(__dirname + "/dist/info.html"));
-})
+});
+
+app.get("/ooops", (_, res) => {
+ res.sendFile(path.join(__dirname + "/dist/info_not_blazed.html"));
+});
app.listen(port, () => {
console.log(`Got request`);