summaryrefslogtreecommitdiffstats
path: root/docusaurus/src
diff options
context:
space:
mode:
authorname <email@example.com>2023-08-11 07:09:24 +0200
committername <email@example.com>2023-08-11 07:09:24 +0200
commitb6ebc5f88ffe9fb442238f160879ad47dd713d11 (patch)
treecbceadf88ea0fc58299b1efb6b43a0e8eeaf50bf /docusaurus/src
downloadwolfree-dockerfile-b6ebc5f88ffe9fb442238f160879ad47dd713d11.tar
wolfree-dockerfile-b6ebc5f88ffe9fb442238f160879ad47dd713d11.tar.gz
wolfree-dockerfile-b6ebc5f88ffe9fb442238f160879ad47dd713d11.tar.bz2
wolfree-dockerfile-b6ebc5f88ffe9fb442238f160879ad47dd713d11.tar.lz
wolfree-dockerfile-b6ebc5f88ffe9fb442238f160879ad47dd713d11.tar.xz
wolfree-dockerfile-b6ebc5f88ffe9fb442238f160879ad47dd713d11.tar.zst
wolfree-dockerfile-b6ebc5f88ffe9fb442238f160879ad47dd713d11.zip
Diffstat (limited to 'docusaurus/src')
-rw-r--r--docusaurus/src/components/ButtonLink.tsx27
-rw-r--r--docusaurus/src/components/FormCTA.tsx23
-rw-r--r--docusaurus/src/components/FormQuickStart.tsx35
-rw-r--r--docusaurus/src/components/InputMathProblems.tsx33
-rw-r--r--docusaurus/src/components/ShowStepButton.tsx25
-rw-r--r--docusaurus/src/css/custom.css21
-rw-r--r--docusaurus/src/functions/submitMathInputForm.tsx23
-rw-r--r--docusaurus/src/theme/Footer/InputPreloader.tsx43
-rw-r--r--docusaurus/src/theme/Footer/index.tsx21
-rw-r--r--docusaurus/src/theme/NotFound/DDoSProtection.tsx34
-rw-r--r--docusaurus/src/theme/NotFound/index.tsx28
-rw-r--r--docusaurus/src/theme/NotFound/redirectInput.tsx70
12 files changed, 383 insertions, 0 deletions
diff --git a/docusaurus/src/components/ButtonLink.tsx b/docusaurus/src/components/ButtonLink.tsx
new file mode 100644
index 0000000..12fc559
--- /dev/null
+++ b/docusaurus/src/components/ButtonLink.tsx
@@ -0,0 +1,27 @@
+/**
+ * @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 Link from "@docusaurus/Link";
+import { Button } from "@mui/material";
+
+const ButtonLink = ({ to = String(), text = String() }) => (
+ <Link to={to}>
+ <Button size="large" sx={{ textTransform: "capitalize" }}>
+ <strong>{text}</strong>
+ &nbsp; »
+ </Button>
+ </Link>
+);
+
+export default ButtonLink;
+
+// Typography - MUI System
+// https://mui.com/system/typography/
+
+// Docusaurus Client API | Docusaurus
+// https://docusaurus.io/docs/docusaurus-core#link
diff --git a/docusaurus/src/components/FormCTA.tsx b/docusaurus/src/components/FormCTA.tsx
new file mode 100644
index 0000000..1b5a81e
--- /dev/null
+++ b/docusaurus/src/components/FormCTA.tsx
@@ -0,0 +1,23 @@
+/**
+ * @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 submitMathInputForm from "../functions/submitMathInputForm";
+import InputMathProblems from "./InputMathProblems";
+import ShowStepButton from "./ShowStepButton";
+
+const FormCTA = ({ autoFocus = Boolean() }) => (
+ <form onSubmit={submitMathInputForm}>
+ <p></p>
+ <InputMathProblems autoFocus={autoFocus} />
+ <p></p>
+ <ShowStepButton />
+ <p></p>
+ </form>
+);
+
+export default FormCTA;
diff --git a/docusaurus/src/components/FormQuickStart.tsx b/docusaurus/src/components/FormQuickStart.tsx
new file mode 100644
index 0000000..60589fb
--- /dev/null
+++ b/docusaurus/src/components/FormQuickStart.tsx
@@ -0,0 +1,35 @@
+/**
+ * @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 submitMathInputForm from "../functions/submitMathInputForm";
+import InputMathProblems from "./InputMathProblems";
+import ShowStepButton from "./ShowStepButton";
+
+const FormQuickStart = () => (
+ <form onSubmit={submitMathInputForm}>
+ <ol>
+ <li>
+ <p>Type your math problem in the text box.</p>
+ <InputMathProblems defaultValue="y'=y" />
+ </li>
+ <li>
+ <p>
+ Click the "Show Steps" button.
+ </p>
+ <ShowStepButton />
+ </li>
+ <li>
+ <p>
+ Explore the step-by-step solution provided. 🎉
+ </p>
+ </li>
+ </ol>
+ </form>
+);
+
+export default FormQuickStart;
diff --git a/docusaurus/src/components/InputMathProblems.tsx b/docusaurus/src/components/InputMathProblems.tsx
new file mode 100644
index 0000000..c7b49ce
--- /dev/null
+++ b/docusaurus/src/components/InputMathProblems.tsx
@@ -0,0 +1,33 @@
+/**
+ * @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 TextField from "@mui/material/TextField";
+// TextField API - Material UI
+// https://mui.com/material-ui/api/text-field/
+
+const InputMathProblems = ({
+ autoFocus = Boolean(),
+ defaultValue = String(),
+}) => (
+ <TextField
+ name="i"
+ type="search"
+ autoCapitalize="off"
+ autoComplete="off"
+ autoCorrect="off"
+ spellCheck="false"
+ inputProps={{ enterkeyhint: "go" }}
+ autoFocus={autoFocus}
+ label="&nbsp; Input math problems"
+ variant="outlined"
+ fullWidth
+ defaultValue={defaultValue}
+ />
+);
+
+export default InputMathProblems;
diff --git a/docusaurus/src/components/ShowStepButton.tsx b/docusaurus/src/components/ShowStepButton.tsx
new file mode 100644
index 0000000..3ae7ba3
--- /dev/null
+++ b/docusaurus/src/components/ShowStepButton.tsx
@@ -0,0 +1,25 @@
+/**
+ * @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 { Button } from "@mui/material";
+
+const ShowStepButton = () => (
+ <Button
+ type="submit"
+ size="large"
+ variant="contained"
+ sx={{ textTransform: "capitalize" }}
+ >
+ Show Steps
+ </Button>
+);
+
+export default ShowStepButton;
+
+// Typography - MUI System
+// https://mui.com/system/typography/
diff --git a/docusaurus/src/css/custom.css b/docusaurus/src/css/custom.css
new file mode 100644
index 0000000..a027863
--- /dev/null
+++ b/docusaurus/src/css/custom.css
@@ -0,0 +1,21 @@
+/**
+ * @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.
+ */
+
+:root {
+ --ifm-menu-link-padding-vertical: calc(var(--ifm-menu-link-padding-horizontal) * 1.5);
+ --ifm-color-primary: blue;
+ --ifm-color-gray-900: var(--ifm-color-gray-900);
+ --ifm-color-secondary-contrast-foreground: var(--ifm-color-gray-900);
+}
+
+.footer__link-item {
+ line-height: 3;
+}
+
+.alert {
+ --ifm-link-color: unset;
+} \ No newline at end of file
diff --git a/docusaurus/src/functions/submitMathInputForm.tsx b/docusaurus/src/functions/submitMathInputForm.tsx
new file mode 100644
index 0000000..a90894e
--- /dev/null
+++ b/docusaurus/src/functions/submitMathInputForm.tsx
@@ -0,0 +1,23 @@
+/**
+ * @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 { FormEventHandler } from "react";
+
+const submitMathInputForm: FormEventHandler<HTMLFormElement> = (event) => {
+ event.preventDefault();
+ const form = event.currentTarget;
+ const formData = new FormData(form);
+
+ const i = formData.get("i") || "";
+ if (i instanceof File) return;
+
+ const url = new URL("/input/", window.location.href);
+ url.searchParams.set("i", i);
+ window.location.href = url.href;
+};
+
+export default submitMathInputForm;
diff --git a/docusaurus/src/theme/Footer/InputPreloader.tsx b/docusaurus/src/theme/Footer/InputPreloader.tsx
new file mode 100644
index 0000000..325f8a7
--- /dev/null
+++ b/docusaurus/src/theme/Footer/InputPreloader.tsx
@@ -0,0 +1,43 @@
+/**
+ * @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, { useEffect, useState } from "react";
+
+const InputPreloader = () => {
+ const [showIframe, setShowIframe] = useState(false);
+
+ useEffect(() => {
+ const handleIframeLoad = () => {
+ // Show the iframe after a 3000ms delay
+ const timerId = setTimeout(() => setShowIframe(true), 3000);
+ // Cleanup the timer when the component unmounts
+ return () => clearTimeout(timerId);
+ };
+
+ window.scroll(0, 0);
+
+ window.addEventListener("load", handleIframeLoad);
+
+ // Cleanup the event listener when the component unmounts
+ return () => window.removeEventListener("load", handleIframeLoad);
+ }, []); // Empty dependency array means the effect runs only once after initial render
+
+ return (
+ <>
+ {/* Use a descriptive title for accessibility */}
+ {showIframe && (
+ <iframe
+ title="Input Page Preloader"
+ src="/input/"
+ style={{ display: "none" }}
+ />
+ )}
+ </>
+ );
+};
+
+export default InputPreloader;
diff --git a/docusaurus/src/theme/Footer/index.tsx b/docusaurus/src/theme/Footer/index.tsx
new file mode 100644
index 0000000..2edef40
--- /dev/null
+++ b/docusaurus/src/theme/Footer/index.tsx
@@ -0,0 +1,21 @@
+/**
+ * @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 Footer from "@theme-original/Footer";
+import InputPreloader from "./InputPreloader";
+
+const FooterWrapper = (props: React.JSX.IntrinsicAttributes) => {
+ return (
+ <>
+ <Footer {...props} />
+ <InputPreloader />
+ </>
+ );
+};
+
+export default FooterWrapper;
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)
+ *
+ */