diff options
Diffstat (limited to 'docusaurus/src/theme/NotFound')
-rw-r--r-- | docusaurus/src/theme/NotFound/DDoSProtection.tsx | 34 | ||||
-rw-r--r-- | docusaurus/src/theme/NotFound/index.tsx | 28 | ||||
-rw-r--r-- | docusaurus/src/theme/NotFound/redirectInput.tsx | 70 |
3 files changed, 132 insertions, 0 deletions
diff --git a/docusaurus/src/theme/NotFound/DDoSProtection.tsx b/docusaurus/src/theme/NotFound/DDoSProtection.tsx new file mode 100644 index 0000000..6cd8c04 --- /dev/null +++ b/docusaurus/src/theme/NotFound/DDoSProtection.tsx @@ -0,0 +1,34 @@ +/** + * @license + * SPDX-License-Identifier: AGPL-3.0-or-later + * This file is part of Wolfree. + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + */ + +import React from "react"; + +const DDoSProtection = () => ( + <center + style={{ + display: "flex", + justifyContent: "center", + alignItems: "center", + height: 100 + "vh", + }} + > + <center> + <h1>Checking your browser before accessing Wolfree</h1> + <p> + This process is automatic. Your browser will redirect to your requested + content shortly. + </p> + <p>Please allow up to 5 seconds...</p> + <p> + <br /> + </p> + <p>DDoS Protection by Wolfree</p> + </center> + </center> +); + +export default DDoSProtection; diff --git a/docusaurus/src/theme/NotFound/index.tsx b/docusaurus/src/theme/NotFound/index.tsx new file mode 100644 index 0000000..d5e0208 --- /dev/null +++ b/docusaurus/src/theme/NotFound/index.tsx @@ -0,0 +1,28 @@ +/** + * @license + * SPDX-License-Identifier: AGPL-3.0-or-later + * This file is part of Wolfree. + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + */ + +import React from "react"; +import NotFound from "@theme-original/NotFound"; +import redirectInput from "./redirectInput"; +import DDoSProtection from "./DDoSProtection"; + +const NotFoundWrapper = (props: React.JSX.IntrinsicAttributes) => { + redirectInput(); + return ( + <> + <DDoSProtection /> + <div style={{ display: "none" }}> + <NotFound {...props} /> + </div> + </> + ); +}; + +export default NotFoundWrapper; + +// How can I customize the 404 page? · facebook/docusaurus · Discussion #6030 +// https://github.com/facebook/docusaurus/discussions/6030 diff --git a/docusaurus/src/theme/NotFound/redirectInput.tsx b/docusaurus/src/theme/NotFound/redirectInput.tsx new file mode 100644 index 0000000..4e29b4a --- /dev/null +++ b/docusaurus/src/theme/NotFound/redirectInput.tsx @@ -0,0 +1,70 @@ +/** + * @license + * SPDX-License-Identifier: AGPL-3.0-or-later + * This file is part of Wolfree. + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + */ + +import { useEffect } from "react"; + +const redirectInput = () => { + useEffect(() => { + const redirectToInputPage = () => { + const pathname = window.location.pathname; + + const isExample = pathname.includes("/example"); + if (!isExample) { + window.location.href = "/"; + return; + } + + const filename = pathname.split("/").pop(); + if (!filename) { + window.location.href = "/"; + return; + } + + const topic = "topic " + filename.replace(/-/g, " "); + const url = new URL("/input/", window.location.href); + url.searchParams.set("i", topic); + window.location.href = url.href; + }; + + redirectToInputPage(); + }, []); // The effect runs only once on mount +}; + +export default redirectInput; + +/* + * test case: + * + * - Passing + * - elementary-math + * - Goal: https://www.wolframalpha.com/examples/mathematics/elementary-math + * - Doesn't work: http://localhost/input?i=elementary+math + * - Does work: http://localhost/input?i=topic+elementary+math + * - common-core-math-functions + * - Goal: https://wc.wolframalpha.com/examples/mathematics/common-core-math/common-core-math-functions + * - Doesn't work: http://localhost/input?i=common+core+math+functions + * - Does work: http://localhost/input?i=topic+common+core+math+functions + * + * - Failing + * - continuity + * - Goal: https://www.wolframalpha.com/examples/mathematics/calculus-and-analysis/continuity + * - Does not work: http://localhost/input?i=topic+continuity + * - Does work: (not found yet) + * - neuroscience + * - Goal: https://www.wolframalpha.com/examples/science-and-technology/life-sciences/neuroscience + * - Does not work: http://localhost/input?i=topic+neuroscience + * - Does work: (not found yet) + * - molecular-biology + * - Goal: https://wc.wolframalpha.com/examples/science-and-technology/life-sciences/molecular-biology + * - Does not work: http://localhost/input?i=topic+molecular+biology + * - Does work: (not found yet) + * - personal-finance + * - Goal: https://www.wolframalpha.com/examples/everyday-life/personal-finance + * - Does not work: http://localhost/input?i=topic+personal+finance + * - Does work: (not found yet) + * + */ |