From be4da1823fbb5654af4b837dbb444b9fffe17ef8 Mon Sep 17 00:00:00 2001 From: Ishan Jain Date: Sat, 11 Feb 2023 21:37:33 +0530 Subject: [PATCH] updates! 1. Removed all codes which adds ability to execute programs and display results 2. Added more options for the save duration --- Cargo.lock | 172 +--- Cargo.toml | 3 +- __tests__/StandardInput.test.tsx | 31 - js/create-editor.tsx | 4 - js/models/Wrapper.ts | 24 - js/models/WrapperOptions.ts | 23 - js/options.ts | 2 +- js/views/App.tsx | 60 +- js/views/CodeMirrorEditor/index.tsx | 18 +- js/views/CodeMirrorEditor/languages.ts | 110 --- js/views/CodeMirrorEditor/markdown.ts | 15 - js/views/Editor.tsx | 6 +- js/views/LanguageSelector.tsx | 48 -- js/views/Output.tsx | 96 --- js/views/OutputBox.tsx | 91 -- js/views/Spinner/index.tsx | 21 - js/views/Spinner/spinner.css | 18 - js/views/StandardInput.tsx | 37 - js/views/WrapperBar.tsx | 125 --- js/views/WrapperBarButton.tsx | 48 -- migrations/2023-02-11_output/down.sql | 2 + migrations/2023-02-11_output/up.sql | 5 + package-lock.json | 1089 ------------------------ package.json | 13 - src/main.rs | 48 +- src/migration.rs | 160 ---- src/models/language.rs | 35 - src/models/mod.rs | 1 - src/models/paste.rs | 134 +-- src/routes/api_insert_paste_route.rs | 10 +- src/routes/api_language_route.rs | 133 --- src/routes/api_languages_route.rs | 64 -- src/routes/display_paste_route.rs | 20 +- src/routes/index_route.rs | 10 +- src/routes/insert_paste_route.rs | 63 +- src/routes/mod.rs | 6 - src/routes/raw_paste_route.rs | 45 +- src/routes/run_route.rs | 106 --- src/schema.rs | 19 +- templates/base.html.tera | 7 +- templates/display-paste.html.tera | 22 +- templates/index.html.tera | 7 - 42 files changed, 106 insertions(+), 2845 deletions(-) delete mode 100644 __tests__/StandardInput.test.tsx delete mode 100644 js/models/Wrapper.ts delete mode 100644 js/models/WrapperOptions.ts delete mode 100644 js/views/CodeMirrorEditor/languages.ts delete mode 100644 js/views/CodeMirrorEditor/markdown.ts delete mode 100644 js/views/LanguageSelector.tsx delete mode 100644 js/views/Output.tsx delete mode 100644 js/views/OutputBox.tsx delete mode 100644 js/views/Spinner/index.tsx delete mode 100644 js/views/Spinner/spinner.css delete mode 100644 js/views/StandardInput.tsx delete mode 100644 js/views/WrapperBar.tsx delete mode 100644 js/views/WrapperBarButton.tsx create mode 100644 migrations/2023-02-11_output/down.sql create mode 100644 migrations/2023-02-11_output/up.sql delete mode 100644 src/migration.rs delete mode 100644 src/models/language.rs delete mode 100644 src/routes/api_language_route.rs delete mode 100644 src/routes/api_languages_route.rs delete mode 100644 src/routes/run_route.rs diff --git a/Cargo.lock b/Cargo.lock index 00405be..cdc0704 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -46,19 +46,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ammonia" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e6d1c7838db705c9b756557ee27c384ce695a1c51a6fe528784cb1c6840170" -dependencies = [ - "html5ever", - "maplit", - "once_cell", - "tendril", - "url", -] - [[package]] name = "android_system_properties" version = "0.1.5" @@ -257,7 +244,7 @@ checksum = "29c39203181991a7dd4343b8005bd804e7a9a37afb8ac070e43771e8c820bbde" dependencies = [ "chrono", "chrono-tz-build", - "phf 0.11.1", + "phf", ] [[package]] @@ -267,8 +254,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f509c3a87b33437b05e2458750a0700e5bdd6956176773e6c7d6dd15a283a0c" dependencies = [ "parse-zoneinfo", - "phf 0.11.1", - "phf_codegen 0.11.1", + "phf", + "phf_codegen", ] [[package]] @@ -674,16 +661,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -[[package]] -name = "futf" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df420e2e84819663797d1ec6544b13c5be84629e7bb00dc960d6917db2987843" -dependencies = [ - "mac", - "new_debug_unreachable", -] - [[package]] name = "futures" version = "0.1.31" @@ -920,20 +897,6 @@ dependencies = [ "digest", ] -[[package]] -name = "html5ever" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bea68cab48b8459f17cf1c944c67ddc572d272d9f2b274140f223ecb1da4a3b7" -dependencies = [ - "log", - "mac", - "markup5ever", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "http" version = "0.2.8" @@ -1271,32 +1234,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "mac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" - -[[package]] -name = "maplit" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" - -[[package]] -name = "markup5ever" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2629bb1404f3d34c2e921f21fd34ba00b206124c81f65c50b43b6aaefeb016" -dependencies = [ - "log", - "phf 0.10.1", - "phf_codegen 0.10.0", - "string_cache", - "string_cache_codegen", - "tendril", -] - [[package]] name = "matchers" version = "0.1.0" @@ -1460,12 +1397,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "new_debug_unreachable" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" - [[package]] name = "nom" version = "5.1.2" @@ -1668,7 +1599,6 @@ dependencies = [ name = "pastebinrun" version = "0.1.0" dependencies = [ - "ammonia", "chrono", "diesel", "diesel_migrations", @@ -1765,32 +1695,13 @@ dependencies = [ "sha2", ] -[[package]] -name = "phf" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" -dependencies = [ - "phf_shared 0.10.0", -] - [[package]] name = "phf" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "928c6535de93548188ef63bb7c4036bd415cd8f36ad25af44b9789b2ee72a48c" dependencies = [ - "phf_shared 0.11.1", -] - -[[package]] -name = "phf_codegen" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd" -dependencies = [ - "phf_generator 0.10.0", - "phf_shared 0.10.0", + "phf_shared", ] [[package]] @@ -1799,18 +1710,8 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a56ac890c5e3ca598bbdeaa99964edb5b0258a583a9eb6ef4e89fc85d9224770" dependencies = [ - "phf_generator 0.11.1", - "phf_shared 0.11.1", -] - -[[package]] -name = "phf_generator" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" -dependencies = [ - "phf_shared 0.10.0", - "rand", + "phf_generator", + "phf_shared", ] [[package]] @@ -1819,19 +1720,10 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1181c94580fa345f50f19d738aaa39c0ed30a600d95cb2d3e23f94266f14fbf" dependencies = [ - "phf_shared 0.11.1", + "phf_shared", "rand", ] -[[package]] -name = "phf_shared" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" -dependencies = [ - "siphasher", -] - [[package]] name = "phf_shared" version = "0.11.1" @@ -1887,12 +1779,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "precomputed-hash" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" - [[package]] name = "proc-macro2" version = "1.0.51" @@ -2562,32 +2448,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "string_cache" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213494b7a2b503146286049378ce02b482200519accc31872ee8be91fa820a08" -dependencies = [ - "new_debug_unreachable", - "once_cell", - "parking_lot 0.12.1", - "phf_shared 0.10.0", - "precomputed-hash", - "serde", -] - -[[package]] -name = "string_cache_codegen" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988" -dependencies = [ - "phf_generator 0.10.0", - "phf_shared 0.10.0", - "proc-macro2", - "quote", -] - [[package]] name = "strsim" version = "0.10.0" @@ -2625,17 +2485,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "tendril" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d24a120c5fc464a3458240ee02c299ebcb9d67b5249c8848b09d639dca8d7bb0" -dependencies = [ - "futf", - "mac", - "utf-8", -] - [[package]] name = "tera" version = "1.17.1" @@ -2771,7 +2620,6 @@ dependencies = [ "memchr", "mio 0.8.5", "num_cpus", - "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", "socket2", @@ -3119,12 +2967,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "utf-8" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" - [[package]] name = "valuable" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 72411f6..dd4d629 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,6 @@ license = "AGPL-3.0-or-later" build = "buildSrc/build.rs" [dependencies] -ammonia = "3.3.0" chrono = "0.4.23" diesel = { version = "1.4.6", features = ["chrono"] } diesel_migrations = "1.4.0" @@ -31,7 +30,7 @@ serde = { version = "1.0.152", features = ["derive"] } serde_json = "1.0.93" serde_with = "2.2.0" time-parse = "0.2.0" -tokio = { version = "1.25.0", features = ["full"] } +tokio = { version = "1.25.0", features = ["rt"] } tokio-signal = "0.2.9" [build-dependencies] diff --git a/__tests__/StandardInput.test.tsx b/__tests__/StandardInput.test.tsx deleted file mode 100644 index dd66f54..0000000 --- a/__tests__/StandardInput.test.tsx +++ /dev/null @@ -1,31 +0,0 @@ -// pastebin.run -// Copyright (C) 2022 Konrad Borowski -// -// 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. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -import { createSignal } from "solid-js"; -import { render, screen } from "solid-testing-library"; -import { expect, test } from "vitest"; -import StandardInput from "../js/views/StandardInput"; - -test("StandardInput can become visible", async () => { - const [visible, setVisible] = createSignal(false); - const [, setStandardInput] = createSignal(""); - render(() => ( - - )); - expect(screen.queryByRole("textbox")).toBeNull(); - setVisible(true); - expect(screen.getByRole("textbox")).toBeEmptyDOMElement(); -}); diff --git a/js/create-editor.tsx b/js/create-editor.tsx index f12df68..320471b 100644 --- a/js/create-editor.tsx +++ b/js/create-editor.tsx @@ -18,8 +18,6 @@ import { render } from "solid-js/web"; import App from "./views/App"; export default function createEditor(editor: Element) { - const markdown = editor.querySelector("#markdown") as Element; - const languages = editor.querySelector("select") as HTMLSelectElement; const autoDelete = editor.querySelector(".autodelete-text") as Element; const rawPasteElement = editor.querySelector(".rawpaste-text") as Element; const code = (editor.querySelector("textarea") as HTMLTextAreaElement).value; @@ -27,8 +25,6 @@ export default function createEditor(editor: Element) { render( () => ( . - -type Wrapper = { - identifier: string; - label: string; - isAsm: boolean; - isFormatter: boolean; -}; - -export default Wrapper; diff --git a/js/models/WrapperOptions.ts b/js/models/WrapperOptions.ts deleted file mode 100644 index 551aeb9..0000000 --- a/js/models/WrapperOptions.ts +++ /dev/null @@ -1,23 +0,0 @@ -// pastebin.run -// Copyright (C) 2022 Konrad Borowski -// -// 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. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -import Wrapper from "./Wrapper"; - -type WrapperOptions = { - wrapper: Wrapper; - compilerOptions: string; -}; -export default WrapperOptions; diff --git a/js/options.ts b/js/options.ts index aa1b87a..9820010 100644 --- a/js/options.ts +++ b/js/options.ts @@ -39,5 +39,5 @@ export function getEditorTypeSignal(): Signal { } export function getTabIndentationSignal(): Signal { - return createLocalStorageState("tabIndentation", "false"); + return createLocalStorageState("tabIndentation", "true"); } diff --git a/js/views/App.tsx b/js/views/App.tsx index 19af482..25ad43f 100644 --- a/js/views/App.tsx +++ b/js/views/App.tsx @@ -15,60 +15,36 @@ // along with this program. If not, see . import { createSignal, Show } from "solid-js"; -import WrapperOptions from "../models/WrapperOptions"; import Editor from "./Editor"; -import LanguageSelector from "./LanguageSelector"; -import Output from "./Output"; -import StandardInput from "./StandardInput"; -import WrapperBar from "./WrapperBar"; export default function App({ - markdown, - languages, autoDelete, rawPasteElement, code, }: { - markdown: Element | null; - languages: HTMLSelectElement; autoDelete: Element | null; rawPasteElement: Element | null; code: string; }) { let form: HTMLFormElement | undefined; const [isPaste, setIsPaste] = createSignal(true); - const [currentLanguage, setCurrentLanguage] = createSignal( - languages.selectedOptions[0]?.value - ); - const [standardInputVisible, setStandardInputVisible] = createSignal(false); - const [codeView, setCodeView] = createSignal({ code: "" }); - const [standardInput, setStandardInput] = createSignal(""); - const [wrapperOptions, setWrapperOptions] = createSignal(); + const [_, setCodeView] = createSignal({ code: "" }); const [label, setLabel] = createSignal(); return (
(form = e)}> - {markdown} {autoDelete}
- - { - setWrapperOptions(); - setWrapperOptions({ wrapper, compilerOptions }); - }} - /> {rawPasteElement} - {" "} - @@ -81,29 +57,13 @@ export default function App({ code={code} onInput={() => { setIsPaste(false); - setWrapperOptions(); }} - currentLanguage={currentLanguage} form={form as HTMLFormElement} setCodeView={setCodeView} setLabel={setLabel} />
- - - {(wrapperOptions) => ( - - )} - ); diff --git a/js/views/CodeMirrorEditor/index.tsx b/js/views/CodeMirrorEditor/index.tsx index 1ded8ed..09b512c 100644 --- a/js/views/CodeMirrorEditor/index.tsx +++ b/js/views/CodeMirrorEditor/index.tsx @@ -14,29 +14,26 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -import { EditorView, basicSetup } from "codemirror"; import { indentWithTab } from "@codemirror/commands"; -import { indentUnit } from "@codemirror/language"; import { Compartment } from "@codemirror/state"; import { keymap } from "@codemirror/view"; +import { basicSetup, EditorView } from "codemirror"; import { Accessor, createEffect, createUniqueId, JSXElement, onCleanup, - Setter, + Setter } from "solid-js"; import CodeView from "../../models/CodeView"; import { getTabIndentationSignal } from "../../options"; import "./codemirror.css"; -import languagesMap from "./languages"; export default function CodeMirrorEditor({ code, setCode, onInput, - currentLanguage, form, setCodeView, setLabel, @@ -44,7 +41,6 @@ export default function CodeMirrorEditor({ code: Accessor; setCode: Setter; onInput(): void; - currentLanguage: Accessor; form: HTMLFormElement; setCodeView: Setter; setLabel: Setter; @@ -56,7 +52,6 @@ export default function CodeMirrorEditor({ : []; } const tabIndentation = new Compartment(); - const language = new Compartment(); let avoidChangeNotifications = false; const labelId = createUniqueId(); const view = new EditorView({ @@ -72,8 +67,6 @@ export default function CodeMirrorEditor({ } }), EditorView.lineWrapping, - indentUnit.of(" ".repeat(4)), - language.of([]), ], }); createEffect(() => { @@ -81,13 +74,6 @@ export default function CodeMirrorEditor({ effects: tabIndentation.reconfigure(getTabIndentationExtension()), }); }); - createEffect(async () => { - const callback = languagesMap[currentLanguage()]; - const extension = callback ? await callback() : []; - view.dispatch({ - effects: language.reconfigure(extension), - }); - }); const getValue = () => view.state.doc.toString(); setCodeView({ get code() { diff --git a/js/views/CodeMirrorEditor/languages.ts b/js/views/CodeMirrorEditor/languages.ts deleted file mode 100644 index 77809fd..0000000 --- a/js/views/CodeMirrorEditor/languages.ts +++ /dev/null @@ -1,110 +0,0 @@ -// pastebin.run -// Copyright (C) 2022 Konrad Borowski -// -// 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. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -import { StreamLanguage } from "@codemirror/language"; -import { Extension } from "@codemirror/state"; - -const languagesMap: { [name: string]: () => Promise } = { - async c() { - return (await import("@codemirror/lang-cpp")).cpp(); - }, - async cpp() { - return (await import("@codemirror/lang-cpp")).cpp(); - }, - async csharp() { - return StreamLanguage.define( - (await import("@codemirror/legacy-modes/mode/clike")).csharp - ); - }, - async go() { - return StreamLanguage.define( - (await import("@codemirror/legacy-modes/mode/go")).go - ); - }, - async haskell() { - return StreamLanguage.define( - (await import("@codemirror/legacy-modes/mode/haskell")).haskell - ); - }, - async html() { - return (await import("@codemirror/lang-html")).html(); - }, - async java() { - return (await import("@codemirror/lang-java")).java(); - }, - async javascript() { - return (await import("@codemirror/lang-javascript")).javascript(); - }, - async jinja2() { - return StreamLanguage.define( - (await import("@codemirror/legacy-modes/mode/jinja2")).jinja2 - ); - }, - async jsx() { - return (await import("@codemirror/lang-javascript")).javascript({ - jsx: true, - }); - }, - async markdown() { - return (await import("./markdown")).default; - }, - async nix() { - return (await import("@replit/codemirror-lang-nix")).nix(); - }, - async perl() { - return StreamLanguage.define( - (await import("@codemirror/legacy-modes/mode/perl")).perl - ); - }, - async php() { - return (await import("@codemirror/lang-php")).php(); - }, - async postgresql() { - const { sql, PostgreSQL } = await import("@codemirror/lang-sql"); - return sql({ dialect: PostgreSQL }); - }, - async python() { - return (await import("@codemirror/lang-python")).python(); - }, - async rust() { - return (await import("@codemirror/lang-rust")).rust(); - }, - async sh() { - return StreamLanguage.define( - (await import("@codemirror/legacy-modes/mode/shell")).shell - ); - }, - async sql() { - return (await import("@codemirror/lang-sql")).sql(); - }, - async sqlite() { - const { sql, SQLite } = await import("@codemirror/lang-sql"); - return sql({ dialect: SQLite }); - }, - async typescript() { - return (await import("@codemirror/lang-javascript")).javascript({ - typescript: true, - }); - }, - async tsx() { - return (await import("@codemirror/lang-javascript")).javascript({ - jsx: true, - typescript: true, - }); - }, -}; - -export default languagesMap; diff --git a/js/views/CodeMirrorEditor/markdown.ts b/js/views/CodeMirrorEditor/markdown.ts deleted file mode 100644 index 8ebae31..0000000 --- a/js/views/CodeMirrorEditor/markdown.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { markdown } from "@codemirror/lang-markdown"; -import { LanguageDescription } from "@codemirror/language"; -import { languages } from "@codemirror/language-data"; - -export default markdown({ - codeLanguages: languages.concat( - LanguageDescription.of({ - name: "Nix", - extensions: ["nix"], - async load() { - return (await import("@replit/codemirror-lang-nix")).nix(); - }, - }) - ), -}); diff --git a/js/views/Editor.tsx b/js/views/Editor.tsx index 71a83f8..a35394f 100644 --- a/js/views/Editor.tsx +++ b/js/views/Editor.tsx @@ -15,11 +15,10 @@ // along with this program. If not, see . import { - Accessor, createResource, createSignal, JSXElement, - Setter, + Setter } from "solid-js"; import CodeView from "../models/CodeView"; import { getEditorTypeSignal } from "../options"; @@ -28,14 +27,12 @@ import TextAreaEditor from "./TextAreaEditor"; export default function Editor({ code: initialCode, onInput, - currentLanguage, form, setCodeView: setCodeView, setLabel, }: { code: string; onInput(): void; - currentLanguage: Accessor; form: HTMLFormElement; setCodeView: Setter; setLabel: Setter; @@ -56,7 +53,6 @@ export default function Editor({ code, setCode, onInput, - currentLanguage, form, setCodeView, setLabel, diff --git a/js/views/LanguageSelector.tsx b/js/views/LanguageSelector.tsx deleted file mode 100644 index 385a43b..0000000 --- a/js/views/LanguageSelector.tsx +++ /dev/null @@ -1,48 +0,0 @@ -// pastebin.run -// Copyright (C) 2022 Konrad Borowski -// -// 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. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -import { For, Setter } from "solid-js"; - -export default function LanguageSelector({ - setCurrentLanguage, - languages, -}: { - setCurrentLanguage: Setter; - languages: HTMLSelectElement; -}) { - return ( -
- -
- ); -} diff --git a/js/views/Output.tsx b/js/views/Output.tsx deleted file mode 100644 index 07c9bc2..0000000 --- a/js/views/Output.tsx +++ /dev/null @@ -1,96 +0,0 @@ -// pastebin.run -// Copyright (C) 2022 Konrad Borowski -// -// 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. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -import { - createEffect, - createResource, - Match, - onCleanup, - Setter, - Switch, -} from "solid-js"; -import CodeView from "../models/CodeView"; -import WrapperOptions from "../models/WrapperOptions"; -import OutputBox from "./OutputBox"; -import Spinner from "./Spinner"; - -export default function Output(props: { - codeView: CodeView; - stdin: string; - wrapperOptions: WrapperOptions; - setWrapperOptions: Setter; -}) { - const abortController = new AbortController(); - const [output, { refetch }] = createResource(async () => { - const body = new URLSearchParams(); - body.append("compilerOptions", props.wrapperOptions.compilerOptions); - body.append("code", props.codeView.code); - body.append("stdin", props.stdin); - return ( - await fetch(`/api/v0/run/${props.wrapperOptions.wrapper.identifier}`, { - method: "POST", - body, - headers: { - "Content-Type": "application/x-www-form-urlencoded", - }, - signal: abortController.signal, - }) - ).json(); - }); - createEffect(() => { - if (props.wrapperOptions.wrapper.isFormatter && output()?.status === 0) { - props.codeView.code = output().output.replace( - /\x7F(?:E[^\x7F]*|O)?/g, - "" - ); - if (!output().output.includes("\x7F")) { - props.setWrapperOptions(); - } - } - }); - onCleanup(() => abortController.abort()); - return ( -
-
- - } - > - - - - - {"An error occured while running the code. "} - { - e.preventDefault(); - refetch(); - }} - > - Try again - - . - - -
-
- ); -} diff --git a/js/views/OutputBox.tsx b/js/views/OutputBox.tsx deleted file mode 100644 index 306b5f7..0000000 --- a/js/views/OutputBox.tsx +++ /dev/null @@ -1,91 +0,0 @@ -// pastebin.run -// Copyright (C) 2022 Konrad Borowski -// -// 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. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -import { For, Show } from "solid-js"; -import Wrapper from "../models/Wrapper"; -import { createLocalStorageState } from "../options"; - -function parseOutput(wrapper: Wrapper, output: string) { - return ( - x.length > 1 && (!wrapper.isFormatter || !x.startsWith("O")) - )} - fallback={(no output)} - > - {(item) => { - const firstChar = item[0]; - if (firstChar === "O") { - return item.substring(1); - } - if (firstChar === "E") { - return {item.substring(1)}; - } - return item; - }} - - ); -} - -function runAsmFilter(output: string) { - return output.replace( - /(?:\t\.(?:text|file|section|globl|p2align|type|cfi_.*|size|section)\b|.Lfunc_end).*\n?/g, - "" - ); -} - -export default function OutputBox({ - output, - wrapper, -}: { - output: { output: string; status: number | null }; - wrapper: Wrapper; -}) { - const [filterAsmDirectivesOrig, setFilterAsmDirectives] = - createLocalStorageState("filterAsmDirectives", "true"); - const filterAsmDirectives = () => JSON.parse(filterAsmDirectivesOrig()); - return ( - <> -
- -

{`Output (exit code ${output.status})`}

-
- - - -
-
-        {parseOutput(
-          wrapper,
-          wrapper.isAsm && filterAsmDirectives()
-            ? runAsmFilter(output.output)
-            : output.output
-        )}
-      
- - ); -} diff --git a/js/views/Spinner/index.tsx b/js/views/Spinner/index.tsx deleted file mode 100644 index 22799f7..0000000 --- a/js/views/Spinner/index.tsx +++ /dev/null @@ -1,21 +0,0 @@ -// pastebin.run -// Copyright (C) 2022 Konrad Borowski -// -// 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. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -import "./spinner.css"; - -export default function Spinner() { - return
; -} diff --git a/js/views/Spinner/spinner.css b/js/views/Spinner/spinner.css deleted file mode 100644 index 02e4637..0000000 --- a/js/views/Spinner/spinner.css +++ /dev/null @@ -1,18 +0,0 @@ -@keyframes spinner { - 0% { - transform: rotate(0deg); - } - - 100% { - transform: rotate(360deg); - } -} - -.spinner { - animation: 1s linear infinite spinner; - border: solid 3px #f5f2f0; - border-bottom-color: #c7c75c; - border-radius: 50%; - width: 50px; - height: 50px; -} diff --git a/js/views/StandardInput.tsx b/js/views/StandardInput.tsx deleted file mode 100644 index 64e644b..0000000 --- a/js/views/StandardInput.tsx +++ /dev/null @@ -1,37 +0,0 @@ -// pastebin.run -// Copyright (C) 2022 Konrad Borowski -// -// 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. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -import { Accessor, Setter, Show } from "solid-js"; - -export default function StandardInput({ - visible, - setStandardInput, -}: { - visible: Accessor; - setStandardInput: Setter; -}) { - return ( - -
- Standard input -