diff options
Diffstat (limited to '')
101 files changed, 3055 insertions, 1957 deletions
diff --git a/.gitattributes b/.gitattributes index dfe0770..4b350ac 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,4 @@ # Auto detect text files and perform LF normalization * text=auto + +# SPDX-License-Identifier: AGPL-3.0-or-later @@ -1,171 +1,327 @@ -# syntax=docker/dockerfile:1 # 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. -FROM alpine +FROM alpine AS stage-alpine + +# alpine - Official Image | Docker Hub +# https://hub.docker.com/_/alpine WORKDIR /app/ -# Install all dependencies. +# Install all dependencies, including Wget, Rust, Docusaurus, and other required packages. + +RUN \ +apk \ +-- \ +add \ +wget \ +gcc \ +rustup \ +npm \ +; + +# Install the dependencies of Docusaurus and Typescript. + +COPY \ +./docusaurus/package.json \ +./docusaurus/package.json + +RUN \ +npm \ +--prefix ./docusaurus/ \ +-- \ +install \ +; + +RUN \ +npm \ +--prefix ./docusaurus/ \ +-- \ +audit \ +fix \ +; + +COPY \ +./typescript/package.json \ +./typescript/package.json + +RUN \ +npm \ +--prefix ./typescript/ \ +-- \ +install \ +; + +RUN \ +npm \ +--prefix ./typescript/ \ +-- \ +audit \ +fix \ +; + +# Set up the Rust compiler. + +RUN \ +rustup-init \ +-y \ +-- \ +; + +# Download the necessary dependencies for the Rust programs. + +COPY \ +./rust/wolfree_download_dependencies/ \ +./rust/wolfree_download_dependencies/ + +RUN \ +PATH="$HOME/.cargo/bin:$PATH" \ +cargo \ +-- \ +clippy \ +--manifest-path ./rust/wolfree_download_dependencies/Cargo.toml \ +-- \ +--warn clippy::all \ +--warn clippy::cargo \ +--warn clippy::nursery \ +--warn clippy::pedantic \ +--warn clippy::restriction \ +; + +RUN \ +PATH="$HOME/.cargo/bin:$PATH" \ +cargo \ +run \ +--manifest-path ./rust/wolfree_download_dependencies/Cargo.toml \ +-- \ +; + +# Cloudflare and WolframAlpha are invaluable tools for web developers, +# providing easy access to prebuilt JavaScript files. +# To effortlessly obtain these files, you can utilize the Wget command-line utility. +# Cloudflare's web servers offer a vast collection of popular JavaScript libraries. +# On the other hand, +# WolframAlpha's web servers specifically host the essential JavaScript files for the 2-dimensional math input editor. + +RUN \ +wget \ +--directory-prefix=./docusaurus/static/ \ +--no-host-directories \ +--page-requisites \ +--convert-links \ +--no-verbose \ +--input-file=- \ +--base= \ +-- \ +'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js' \ +'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.map' \ +'https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.0.5/purify.min.js' \ +'https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.0.5/purify.min.js.map' \ +'https://www.wolframalpha.com/input/index.html' \ +; \ +: \ +; + +# We use the Sed command to extract the pathnames from the "Webpack" and "buildManifest" files. +# After successfully parsing the pathnames, we proceed to download the files using the Wget command. + +RUN \ +sed \ +-e 's|.*js...static.chunks...........||' \ +-e 's|"........js.....miniCssF.*|.js\n|' \ +-e 's|:"|.|g' \ +-e 's|",|.js\n|g' \ +-- \ +./docusaurus/static/_next/static/chunks/webpack-*.js \ +| \ +wget \ +--directory-prefix=./docusaurus/static/ \ +--no-host-directories \ +--page-requisites \ +--convert-links \ +--no-verbose \ +--input-file=- \ +--base=https://www.wolframalpha.com/_next/static/chunks/ \ +-- \ +; \ +: \ +; + +RUN \ +sed \ +-e 's|.*return.static.css.....||' \ +-e 's|.........css.......function.*|.css\n|' \ +-e 's|[0-9]*:"||g' \ +-e 's|",|.css\n|g' \ +-- \ +./docusaurus/static/_next/static/chunks/webpack-*.js \ +| \ +wget \ +--directory-prefix=./docusaurus/static/ \ +--no-host-directories \ +--page-requisites \ +--convert-links \ +--no-verbose \ +--input-file=- \ +--base=https://www.wolframalpha.com/_next/static/css/ \ +-- \ +; \ +: \ +; RUN \ - apk add \ - -- \ - wget \ - npm \ - gcc \ - rustup \ - ; +sed \ +-e 's|.*sortedPages.*}..||' \ +-e 's|...self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB.*||' \ +-e 's|","|\n|g' \ +-- \ +./docusaurus/static/_next/static/*/_buildManifest.js \ +| \ +wget \ +--directory-prefix=./docusaurus/static/ \ +--no-host-directories \ +--page-requisites \ +--convert-links \ +--no-verbose \ +--input-file=- \ +--base=https://www.wolframalpha.com/_next/ \ +-- \ +; \ +: \ +; + +# Remove unused large files, +# such as decorative images, +# from the static website. RUN \ - rustup-init -y +truncate \ +-s 0 \ +-- \ +./docusaurus/static/_next/static/images/* \ +./docusaurus/static/_next/static/media/*.png \ +./docusaurus/static/_next/static/media/*.gif \ +; + +# Compile and execute the Rust program. +# The Rust program allows customization of the static pages downloaded with Wget. COPY \ - ./docusaurus/package.json \ - ./docusaurus/package.json - -RUN \ - npm install \ - --prefix ./docusaurus/ \ - -- \ - ; - -# WolframAlpha LLC prebuilt the website and kindly deployed it on the Internet. -# We can run Wget to download the web pages and save them as static pages. - -RUN \ - wget \ - --directory-prefix=./docusaurus/static/ \ - --no-host-directories \ - --page-requisites \ - --convert-links \ - --no-verbose \ - -- \ - 'https://www.wolframalpha.com/input/index.html' \ - 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js' \ - 'https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.0.5/purify.min.js' \ - ; \ - : \ - ; - -RUN \ - sed \ - -e 's|.*js...static.chunks...........||' \ - -e 's|"........js.....miniCssF.*|.js\n|' \ - -e 's|:"|.|g' \ - -e 's|",|.js\n|g' \ - -- \ - ./docusaurus/static/_next/static/chunks/webpack-*.js \ - | \ - wget \ - --directory-prefix=./docusaurus/static/ \ - --no-host-directories \ - --page-requisites \ - --convert-links \ - --no-verbose \ - --input-file=- \ - --base=https://www.wolframalpha.com/_next/static/chunks/ \ - -- \ - ; \ - : \ - ; - -RUN \ - sed \ - -e 's|.*return.static.css.....||' \ - -e 's|.........css.......function.*|.css\n|' \ - -e 's|[0-9]*:"||g' \ - -e 's|",|.css\n|g' \ - -- \ - ./docusaurus/static/_next/static/chunks/webpack-*.js \ - | \ - wget \ - --directory-prefix=./docusaurus/static/ \ - --no-host-directories \ - --page-requisites \ - --convert-links \ - --no-verbose \ - --input-file=- \ - --base=https://www.wolframalpha.com/_next/static/css/ \ - -- \ - ; \ - : \ - ; - -# Delete unused large files on the static website. - -RUN \ - truncate \ - -s 0 \ - -- \ - ./docusaurus/static/_next/static/images/* \ - ; - -# Build the Docusaurus static website. +./rust/wolfree_sed_in_place/ \ +./rust/wolfree_sed_in_place/ + +RUN \ +PATH="$HOME/.cargo/bin:$PATH" \ +cargo \ +-- \ +clippy \ +--manifest-path ./rust/wolfree_sed_in_place/Cargo.toml \ +-- \ +--warn clippy::all \ +--warn clippy::cargo \ +--warn clippy::nursery \ +--warn clippy::pedantic \ +--warn clippy::restriction \ +; + +RUN \ +PATH="$HOME/.cargo/bin:$PATH" \ +cargo run \ +--manifest-path ./rust/wolfree_sed_in_place/Cargo.toml \ +-- \ +; + +# Compile the Typescript files and output the JavaScript files. COPY \ - ./docusaurus/ \ - ./docusaurus/ +./typescript/ \ +./typescript/ RUN \ - npm run \ - --prefix ./docusaurus/ \ - -- \ - build \ - ; +npm \ +--prefix ./typescript/ \ +-- \ +exec \ +tsc \ +--project ./typescript/ \ +; -# Lint the source code and run the Rust program. -# The Rust program customizes the static pages. +# Preprocess MDX files. COPY \ - ./rust/ \ - ./rust/ - -RUN \ - PATH="$HOME/.cargo/bin:$PATH" \ - cargo clippy \ - --manifest-path ./rust/wolfree_libredirect_patch/Cargo.toml \ - -- \ - --warn clippy::all \ - --warn clippy::cargo \ - --warn clippy::nursery \ - --warn clippy::pedantic \ - --warn clippy::restriction \ - ; - -RUN \ - PATH="$HOME/.cargo/bin:$PATH" \ - cargo clippy \ - --manifest-path ./rust/wolfree_sed_in_place/Cargo.toml \ - -- \ - --warn clippy::all \ - --warn clippy::cargo \ - --warn clippy::nursery \ - --warn clippy::pedantic \ - --warn clippy::restriction \ - ; - -# Optionally, customize Wolfree instances to suit LibRedirect. -# https://github.com/libredirect/browser_extension/issues/425 -# To integrate Wolfree with LibRedirect, please delete the number sign at the beginning of the following line. -# RUN PATH="$HOME/.cargo/bin:$PATH" cargo run --manifest-path ./rust/wolfree_libredirect_patch/Cargo.toml -- ; - -RUN PATH="$HOME/.cargo/bin:$PATH" cargo run --manifest-path ./rust/wolfree_sed_in_place/Cargo.toml -- ; +./docusaurus/ \ +./docusaurus/ + +# Run the Rust program to customize the Docusaurus pages. + +COPY \ +./rust/wolfree_patch_libredirect/ \ +./rust/wolfree_patch_libredirect/ + +RUN \ +PATH="$HOME/.cargo/bin:$PATH" \ +cargo \ +-- \ +clippy \ +--manifest-path ./rust/wolfree_patch_libredirect/Cargo.toml \ +-- \ +--warn clippy::all \ +--warn clippy::cargo \ +--warn clippy::nursery \ +--warn clippy::pedantic \ +--warn clippy::restriction \ +; + +RUN \ +PATH="$HOME/.cargo/bin:$PATH" \ +cargo run \ +--manifest-path ./rust/wolfree_patch_libredirect/Cargo.toml \ +-- \ +; + +# Create a webpage that lists all repositories and instructions for self-hosting web services. + +COPY \ +./README.md \ +./README.md + +RUN \ +cat \ +-- \ +./README.md \ +>> \ +./docusaurus/docs/source.mdx \ +; + +# Use Docusaurus to build the static website. + +RUN \ +npm \ +--prefix ./docusaurus/ \ +-- \ +run \ +build \ +; + +# Host the static content with a webserver. + +CMD \ +npm \ +--prefix ./docusaurus/ \ +-- \ +run \ +serve \ +--host localhost \ +--port 80 \ +; + +EXPOSE 80 + +# TODO: multi-stage +# https://docs.docker.com/build/building/multi-stage/ +# https://docs.docker.com/build/guide/multi-stage/ # Optimizing builds with cache management | Docker Documentation # https://docs.docker.com/build/cache/ # Because a change causes a rebuild for steps that follow, # try to make expensive steps appear near the beginning of the Dockerfile. # Steps that change often should appear near the end of the Dockerfile to avoid triggering rebuilds of layers that haven't changed. - -CMD \ - npm run \ - --prefix ./docusaurus/ \ - -- \ - serve \ - --port 80 \ - --host localhost \ - ; - -EXPOSE 80 @@ -1,235 +1,661 @@ -GNU AFFERO GENERAL PUBLIC LICENSE -Version 3, 19 November 2007 + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 -Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> - -Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. Preamble -The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. - -The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. - -When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. - -Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. - -A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. - -The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. - -An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. - -The precise terms and conditions for copying, distribution and modification follow. + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. TERMS AND CONDITIONS -0. Definitions. - -"This License" refers to version 3 of the GNU Affero General Public License. - -"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. - -"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. - -To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. - -A "covered work" means either the unmodified Program or a work based on the Program. - -To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. - -To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. - -An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. - -1. Source Code. -The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. - -A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. - -The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. - -The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those subprograms and other parts of the work. -The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. - -The Corresponding Source for a work in source code form is that same work. - -2. Basic Permissions. -All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. - -You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. - -Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. - -3. Protecting Users' Legal Rights From Anti-Circumvention Law. -No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. - -When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. - -4. Conveying Verbatim Copies. -You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. - -You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. - -5. Conveying Modified Source Versions. -You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". - - c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. - -A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. - -6. Conveying Non-Source Forms. -You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: - - a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. - - d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. - -A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. - -A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. - -"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. - -If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). - -The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. - -Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. - -7. Additional Terms. -"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. - -When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. - -Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or authors of the material; or - - e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. - -All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. - -If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. - -Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. - -8. Termination. - -You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). - -However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. - -Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. - -Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. - -9. Acceptance Not Required for Having Copies. - -You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. - -10. Automatic Licensing of Downstream Recipients. - -Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. - -An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. - -You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. - -11. Patents. - -A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". - -A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. - -Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. - -In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. - -If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. - -If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. - -A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. - -Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. - -12. No Surrender of Others' Freedom. - -If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. - -13. Remote Network Interaction; Use with the GNU General Public License. - -Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. - -Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. - -14. Revised Versions of this License. - -The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. - -If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. - -Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. - -15. Disclaimer of Warranty. - -THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -16. Limitation of Liability. - -IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -17. Interpretation of Sections 15 and 16. - -If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. - -END OF TERMS AND CONDITIONS + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs -If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. -To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. - wolfree-dockerfile - Copyright (C) 2023 wolfree + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> - 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 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. + 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 <http://www.gnu.org/licenses/>. + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. -If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. - -You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <http://www.gnu.org/licenses/>. + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +<https://www.gnu.org/licenses/>. @@ -1,75 +1,109 @@ -# Wolfree Dockerfile: Self-Host a Mirror Site of Wolfree Instances +# Self-hosting Wolfree instances with Docker Engine -This repository provides a Dockerfile and instructions for self-hosting a mirror site of Wolfree instances. +This guide provides a step-by-step procedure for self-hosting Wolfree. You will use Docker CLI to interact with the Docker daemon through a terminal emulator. Docker Engine automates the execution of the static site generator and running the web server. -Follow the instructions below to control Docker through terminal emulators. Docker will automatically execute the static site generator and run the web server. +## How to self-host Wolfree -## Prerequisites +To self-host a mirror site of Wolfree instances using Docker Engine, follow these steps: -Before getting started, make sure you have the following prerequisites installed on your computer: +1. Install a terminal emulator. If you are unfamiliar with terminal emulators, refer to the "[Command line crash course](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Understanding_client-side_tools/Command_line)" for guidance. -1. **Terminal Emulator**: If you are unfamiliar with terminal emulators, you can learn how to use them in [Command Line Crash Course - Learn Web Development | MDN](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Understanding_client-side_tools/Command_line). +2. Install [Git](https://git-scm.com/) and [Docker Engine](https://docs.docker.com/). -2. **Docker**: If you don't have Docker installed, download it from [docker.com](https://www.docker.com/). +3. Download the source code by executing one of the following commands. Each command will download the source code from a different web server. If one of the commands fails, try the next one until the download succeeds. -## Instructions + ```shell + git clone https://gitea.com/wolfree/wolfree-dockerfile.git + ``` -Follow the steps below to self-host a mirror site of Wolfree instances: + ```shell + git clone https://try.gitea.io/wolfree/wolfree-dockerfile.git + ``` -1. **Build the Docker Image**: + ```shell + git clone https://codeberg.org/wolfree/wolfree-dockerfile.git + ``` - Open your terminal emulator and execute one of the following commands to build the Docker image. Each command downloads the source code from a different web server. If one of the commands fails, try the next one in the list until the build succeeds. + ```shell + git clone https://git.disroot.org/wolfree/wolfree-dockerfile.git + ``` ```shell - docker build -t wolfree https://try.gitea.io/wolfree/wolfree-dockerfile.git - docker build -t wolfree https://codeberg.org/wolfree/wolfree-dockerfile.git - docker build -t wolfree https://git.disroot.org/wolfree/wolfree-dockerfile.git - docker build -t wolfree https://next.forgejo.org/wolfree/wolfree-dockerfile.git - docker build -t wolfree https://git.kiwifarms.net/wolfree/wolfree-dockerfile.git - docker build -t wolfree http://it7otdanqu7ktntxzm427cba6i53w6wlanlh23v5i3siqmos47pzhvyd.onion/wolfree/wolfree-dockerfile.git + git clone https://next.forgejo.org/wolfree/wolfree-dockerfile.git ``` -2. **Run the Docker Container**: + ```shell + git clone https://git.kiwifarms.net/wolfree/wolfree-dockerfile.git + ``` + + ```shell + git clone http://it7otdanqu7ktntxzm427cba6i53w6wlanlh23v5i3siqmos47pzhvyd.onion/wolfree/wolfree-dockerfile.git + ``` - Execute the following command in your terminal emulator to run the Docker container: + Reference: [git clone](https://git-scm.com/docs/git-clone) + +4. Wait until Git outputs the resolving message similar to the following: + + ```shell + Receiving objects: 100% (100/100), 1.00 KiB | 1.00 KiB/s, done. + Resolving deltas: 100% (100/100), done. + ``` + +5. Build a Docker image by executing the following command: ```shell - docker run -p 80:80 wolfree + docker build --progress=plain --tag wolfree wolfree-dockerfile ``` -3. **Wait for Success Messages**: + This command will generate the website using a static site generator. + + Reference: [docker build](https://docs.docker.com/engine/reference/commandline/build/) - Wait until Docker outputs success messages similar to the following: +6. Wait until Docker Engine outputs the exporting message similar to the following: ```shell - > docusaurus@0.0.0 serve - > docusaurus serve --port 80 --host localhost + #35 exporting to image + #35 exporting layers done + #35 writing image sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef done + #35 naming to docker.io/library/wolfree done + #35 DONE 0.0s + ``` - [SUCCESS] Serving "build" directory at: http://localhost:80/ +7. Run a Docker container by executing the following command: + + ```shell + docker run --publish 80:80 wolfree ``` -4. **Access Your Mirror Site**: + This command will host the website using a web server. + + Reference: [docker run](https://docs.docker.com/engine/reference/commandline/run/) - You can access your mirror site locally on the same computer where the Docker container runs. Open a web browser, navigate to [http://localhost/](http://localhost/) to access your mirror site, and enter math problems in the text box. +8. Wait until the web server outputs the success message similar to the following: -Congratulations! You have successfully self-hosted a mirror site of Wolfree instances. + ```shell + > docusaurus@0.0.0 serve + > docusaurus serve --host localhost --port 80 + + [SUCCESS] Serving "build" directory at: http://localhost:80/ + ``` -## Local Development +9. Access the mirror site locally on the same computer where the Docker container runs. Open a web browser and navigate to [http://localhost/](http://localhost/). -If you wish to contribute to the development of Wolfree instances, follow these steps: +10. On the home page of the mirror site, enter a math problem in the text box and click the submit button. -1. **Prepare the Development Environment**: +Congratulations! You have successfully self-hosted Wolfree. - Install Git and Docker on your local machine. You can download them from the following official websites: +## How to self-host Libredirect-compatible instances - - [Git Official Website](https://git-scm.com/) - - [Docker Official Website](https://www.docker.com/) +By default, Wolfree instances are paywall-bypassing and incompatible with Libredirect. To make them Libredirect-compatible and respect paywalls, follow these steps: -2. **Clone the Repository**: +1. Install [Git](https://git-scm.com/) and [Docker Engine](https://docs.docker.com/). - Run one of the following commands to clone the repository from one of the Gitea and Forgejo servers: +2. Download the source code with Git: ```shell + git clone https://gitea.com/wolfree/wolfree-dockerfile.git git clone https://try.gitea.io/wolfree/wolfree-dockerfile.git git clone https://codeberg.org/wolfree/wolfree-dockerfile.git git clone https://git.disroot.org/wolfree/wolfree-dockerfile.git @@ -78,60 +112,80 @@ If you wish to contribute to the development of Wolfree instances, follow these git clone http://it7otdanqu7ktntxzm427cba6i53w6wlanlh23v5i3siqmos47pzhvyd.onion/wolfree/wolfree-dockerfile.git ``` -3. **Run the Docker Container**: +3. Open the following file with a text editor: - After cloning the repository, navigate to the project directory: + `rust/wolfree_patch_libredirect/src/main.rs` - ```shell - cd wolfree-dockerfile +4. Remove the line containing the `return` keyword. Save the change. The changed code should look like this: + + ```rust + // Remove the following line to make the instances Libredirect-compatible. + // Remove the previous line to make the instances Libredirect-compatible. ``` - Then, run the following commands to build the image and run the container: +5. Build the image and run the container with Docker Engine: ```shell - docker build --tag wolfree --progress=plain . - docker run --publish 80:80 --rm wolfree + docker build --progress=plain --tag wolfree wolfree-dockerfile + docker run --publish 80:80 wolfree ``` -## Configuring Wolfree Instances for LibRedirect +6. Browse [http://localhost/](http://localhost/). Your instances should have become Libredirect-compatible and respect paywalls. If they remain paywall-bypassing and incompatible with Libredirect, please report the problem in the issue trackers of the repositories. + +## Troubleshooting dependency graphs -To configure Wolfree instances to integrate with LibRedirect, follow these steps: +To regenerate `docusaurus/package.json`, follow these steps: -1. Clone the Git repository and open the Dockerfile in a text editor. +1. Install [NPM](https://docs.npmjs.com/). -2. In the Dockerfile, remove the number sign (#) at the beginning of the `RUN` command. After removing the number sign, the `RUN` command should look like this: +2. Initialize a Docusaurus project with the classic template and the TypeScript variant: - ```dockerfile - # Optionally, customize Wolfree instances to suit LibRedirect. - # https://github.com/libredirect/browser_extension/issues/425 - # To integrate Wolfree with LibRedirect, please delete the number sign at the beginning of the following line. - RUN PATH="$HOME/.cargo/bin:$PATH" cargo run --manifest-path ./rust/wolfree_libredirect_patch/Cargo.toml -- ; + ```shell + npm --yes -- init docusaurus docusaurus classic . --typescript ``` -3. Build a Docker image and run a container. +3. Install MUI, a React component library: -## Helpful Resources for New Developers + ```shell + npm --prefix ./docusaurus/ -- install @mui/material @emotion/react @emotion/styled + ``` -If you're new to web development, here are some helpful websites and tools to get you started: +## Glossary of file extensions -- [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Learn): MDN is a comprehensive resource for web developers. It offers guides, tutorials, and references for various web technologies. It's a great place to learn and explore web development concepts. +- `.md`/`.mdx`: [MarkDown XML](https://mdxjs.com/docs/) +- `.js`/`.jsx`: [JavaScript XML](https://react.dev/learn/writing-markup-with-jsx) +- `.ts`/`.tsx`: [TypeScript XML](https://www.typescriptlang.org/docs/handbook/jsx.html) +- `.rs`: [Rust Programming Language](https://www.rust-lang.org/learn) -- [Web Dev](https://web.dev/learn/): Web Dev is a learning platform by Google that offers web development courses. It provides practical examples to help you improve your skills. +## Helpful resources for new developers -- [Chrome DevTools - Chrome Developers](https://developer.chrome.com/docs/devtools/): Chrome DevTools is a set of web developer tools built directly into the Google Chrome browser. It provides powerful features to inspect and debug web applications. +If you're new to web development, here are some websites and tools to get you started: -- [TypeScript: JavaScript With Syntax For Types.](https://www.typescriptlang.org/): TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale. +- [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Learn): A comprehensive resource for web developers, offering guides, tutorials, and references for various web technologies. -- [Writing Markup with JSX – React](https://react.dev/learn/writing-markup-with-jsx): JSX is a syntax extension for JavaScript that allows you to write HTML-like markup inside a JavaScript file. +- [Chrome DevTools - Chrome Developers](https://developer.chrome.com/docs/devtools/): A set of web developer tools built directly into the Google Chrome browser, providing practical features to inspect and debug web applications. -- [Markdown for the component era | MDX](https://mdxjs.com/docs/): MDX is a format that combines markdown, JSX, JavaScript expressions, and import/export statements in JavaScript modules. +- [TypeScript: JavaScript With Syntax For Types.](https://www.typescriptlang.org/): A strongly typed programming language that builds on JavaScript, giving you better tooling at any scale. -- [Desktop/PC - Privacy Guides](https://www.privacyguides.org/en/desktop/): Most Linux distributions have a terminal available by default. You can check out this guide for recommended distributions. +- [Web.Dev](https://web.dev/learn/): A learning platform by Google that offers web development courses, providing practical examples to help you improve your skills. -These resources will help you get started and enhance your skills as a web developer. Happy learning! +- [Desktop/PC - Privacy Guides](https://www.privacyguides.org/en/desktop/): A list of recommended Linux distributions with powerful terminal emulators pre-installed by default, empowering you with automating deployment, scaling, and management of containerized applications. -## License +These resources will help you get started. Happy learning! -SPDX-License-Identifier: AGPL-3.0-or-later +## UX writing tips + +- [Style guide: UX writing best practices](https://m3.material.io/foundations/content-design/style-guide/ux-writing-best-practices): Writing UI text that anyone can understand. + +- [UX writing: study guide](https://www.nngroup.com/articles/ux-writing-study-guide/): How to write and present information that aligns with users' needs and online reading behaviors. + +- [UX basics: study guide](https://www.nngroup.com/articles/ux-basics-study-guide/): The basics of user experience. + +- [Web UX: study guide](https://www.nngroup.com/articles/web-ux-study-guide/): How users interact with the web and how to design web user experiences. + +## License -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 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. diff --git a/docusaurus/.dockerignore b/docusaurus/.dockerignore index 019391a..ecec047 100644 --- a/docusaurus/.dockerignore +++ b/docusaurus/.dockerignore @@ -1,7 +1,3 @@ -# 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. - # Dependencies /node_modules @@ -24,3 +20,5 @@ yarn-debug.log* yarn-error.log* package-lock.json + +# SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/docusaurus/.gitignore b/docusaurus/.gitignore index 019391a..ecec047 100644 --- a/docusaurus/.gitignore +++ b/docusaurus/.gitignore @@ -1,7 +1,3 @@ -# 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. - # Dependencies /node_modules @@ -24,3 +20,5 @@ yarn-debug.log* yarn-error.log* package-lock.json + +# SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/docusaurus/babel.config.js b/docusaurus/babel.config.js index e4fb2e2..6b4342b 100644 --- a/docusaurus/babel.config.js +++ b/docusaurus/babel.config.js @@ -1,9 +1,4 @@ -/** - * @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. - */ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ // @ts-check diff --git a/docusaurus/docs/acknowledgment.mdx b/docusaurus/docs/acknowledgment.mdx index e711148..3e10178 100644 --- a/docusaurus/docs/acknowledgment.mdx +++ b/docusaurus/docs/acknowledgment.mdx @@ -1,87 +1,94 @@ +--- +title: Acknowledgment +hide_title: true +--- + +<!-- SPDX-License-Identifier: AGPL-3.0-or-later --> + # Acknowledgment -We extend our heartfelt gratitude to the communities and projects that promote diversity, equity, and inclusion on the Internet. Their efforts have been instrumental in distributing our free and open-source software. +Wolfree developers extend heartfelt gratitude to the communities and projects that promote diversity, equity, and inclusion on the Internet. Their efforts have been instrumental in distributing free and open-source software for Wolfree developers. ## The Fediverse -Our community distributes source code on the Fediverse. +Wolfree developers distribute source code on the Fediverse. The Fediverse is a federation of numerous independently hosted servers that connect various social media platforms. It enables seamless interactions across compatible platforms, encompassing social media services for blogging, photo sharing, and video sharing. Discover the Fediverse with these resources: -- [**Fediverse Info**](https://fediverse.info/): A beginner-friendly introduction to the Fediverse. -- [**FediDB**](https://fedidb.org/): Visualized network statistics of the Fediverse. -- [**Mastodon Documentation**](https://docs.joinmastodon.org/): Comprehensive documentation for Mastodon, a self-hosted social networking service similar to Twitter. -- [**JoinFediverse Wiki**](https://joinfediverse.wiki/): An informative encyclopedia for the Fediverse. -- [**FediList**](http://demo.fedilist.com/): A simple website to explore instances on the Fediverse and facilitate discovery and connections. -- [**The Federation**](https://the-federation.info/): Indexed instances and statistics for the Fediverse. +- [Fediverse Info](https://fediverse.info/): A beginner-friendly introduction to the Fediverse. +- [Mastodon Documentation](https://docs.joinmastodon.org/): Comprehensive documentation for Mastodon, a self-hosted social networking service similar to Twitter. +- [JoinFediverse Wiki](https://joinfediverse.wiki/): An informative encyclopedia for the Fediverse. +- [FediDB](https://fedidb.org/): Visualized network statistics of the Fediverse. +- [FediList](http://demo.fedilist.com/): A simple website to explore instances on the Fediverse and facilitate discovery and connections. +- [The Federation](https://the-federation.info/): Indexed instances and statistics for the Fediverse. ## ForgeFed -Our community hosts source code on web services compatible with ForgeFed. +Wolfree developers host source code on web services compatible with ForgeFed. ForgeFed specifies an essential federation protocol for version control services, promoting collaboration and cooperation. Explore ForgeFed and related projects: -- [**ForgeFed**](https://forgefed.org/): The canonical website to learn more about the benefits and workings of ForgeFed. -- [**Gitea**](https://about.gitea.com/): A self-hosted Git service powering numerous instances across the Fediverse. -- [**Forgejo**](https://forgejo.org/): A soft fork of Gitea maintained by an inclusive community. +- [ForgeFed](https://forgefed.org/): The canonical website to learn more about the benefits and workings of ForgeFed. +- [Gitea](https://about.gitea.com/): A self-hosted Git service powering numerous instances across the Fediverse. +- [Forgejo](https://forgejo.org/): A soft fork of Gitea maintained by an inclusive community. ## Copyleft -Our community releases source code under a copyleft license. +Wolfree developers release source code under a copyleft license. Copyleft is a legal technique that safeguards the freedom to copy and modify derivative works. Discover the significance of copyleft through these resources: -- [**Blue Oak Council**](https://blueoakcouncil.org/primer): A comprehensive guide to open software licensing, making it accessible and understandable. -- [**What is Copyleft**](https://www.gnu.org/licenses/copyleft.html.en): An explanation of copyleft, reinforcing the importance of free software. -- [**Why Copyleft**](https://www.gnu.org/philosophy/why-copyleft.html.en): A showcase of the benefits of copyleft licenses to inspire more creators to embrace copyleft licensing. -- [**Why I Use the GPL and Not Cuck Licenses**](https://lukesmith.xyz/articles/why-i-use-the-gpl-and-not-cuck-licenses/): An elaboration on the advantages of copyleft. +- [Blue Oak Council](https://blueoakcouncil.org/primer): A comprehensive guide to open software licensing, making it accessible and understandable. +- [What is Copyleft](https://www.gnu.org/licenses/copyleft.html.en): An explanation of copyleft, reinforcing the importance of free software. +- [Why Copyleft](https://www.gnu.org/philosophy/why-copyleft.html.en): A showcase of the benefits of copyleft licenses to inspire more creators to embrace copyleft licensing. +- [Why I Use the GPL and Not Cuck Licenses](https://lukesmith.xyz/articles/why-i-use-the-gpl-and-not-cuck-licenses/): An elaboration on the advantages of copyleft. ## Anna's Archive Anna's Archive is a non-profit online shadow library metasearch engine that provides access to a curated collection of book resources managed by anonymous archivists. Anna's Archive keeps backups of popular shadow libraries like Sci-Hub, Library Genesis, and Z-Library. -- [**Anna's Archive - Wikipedia**](https://en.wikipedia.org/wiki/Anna's_Archive): A wiki page about Anna's Archive on the free encyclopedia. +- [Anna's Archive - Wikipedia](https://en.wikipedia.org/wiki/Anna's_Archive): A wiki page about Anna's Archive on the free encyclopedia. ## The Internet Archive -Our community archives source code on the Internet Archive. +Wolfree developers archive source code on the Internet Archive. The Internet Archive is a non-profit library that lends digital copies of books. Despite facing challenges related to copyright issues, they continue to fight for the rights of libraries to own and lend ebooks. Learn more about their ongoing efforts through these articles: -- [**Hachette v. Internet Archive**](https://www.eff.org/cases/hachette-v-Internet-archive) -- [**Fair Use Creep Is A Feature, Not a Bug**](https://www.eff.org/deeplinks/2023/01/fair-use-creep-feature-not-bug) -- [**The Fight Continues**](https://blog.archive.org/2023/03/25/the-fight-continues/) +- [Hachette v. Internet Archive](https://www.eff.org/cases/hachette-v-internet-archive) +- [Fair Use Creep Is A Feature, Not a Bug](https://www.eff.org/deeplinks/2023/01/fair-use-creep-feature-not-bug) +- [Internet Archive Seeks Summary Judgment in Federal Lawsuit Filed By Publishing Companies](https://blog.archive.org/2022/07/08/internet-archive-seeks-summary-judgment-in-federal-lawsuit-filed-by-publishing-companies/) +- [What the Hachette v. Internet Archive Decision Means for Our Library](https://blog.archive.org/2023/08/17/what-the-hachette-v-internet-archive-decision-means-for-our-library/) -## Censorship Circumvention +## Censorship circumvention Safely circumventing censorship is crucial in fostering diversity, equity, and inclusion on the Internet. Enhance your knowledge of safety measures for censorship circumvention with these resources: -- [**Privacy Guides**](https://privacyguides.org/): A user-friendly guide promoting data security and privacy. -- [**Mullvad Browser**](https://mullvad.net/en/browser): A privacy-focused web browser developed in collaboration between Mullvad VPN and the Tor Project. -- [**Tor Browser**](https://torproject.org/): A web browser capable of accessing the Tor network. -- [**Tails**](https://tails.net/): A Linux distribution aimed at preserving privacy and anonymity. -- [**Qubes OS**](https://qubes-os.org/): A Linux distribution that provides security through isolation. -- [**The Hitchhiker's Guide to Online Anonymity**](https://anonymousplanet.org/): An in-depth guide detailing online anonymity methods. +- [Privacy Guides](https://privacyguides.org/): A user-friendly guide promoting data security and privacy. +- [Mullvad Browser](https://mullvad.net/en/browser): A privacy-focused web browser developed in collaboration between Mullvad VPN and the Tor Project. +- [Tor Browser](https://torproject.org/): A web browser capable of accessing the Tor network. +- [Tails](https://tails.net/): A Linux distribution aimed at preserving privacy and anonymity. +- [Qubes OS](https://qubes-os.org/): A Linux distribution that provides security through isolation. +- [The Hitchhiker's Guide to Online Anonymity](https://anonymousplanet.org/): An in-depth guide detailing online anonymity methods. -## Net Neutrality +## Net neutrality -Upholding net neutrality is pivotal in nurturing diversity, equity, and inclusion on the Internet. It ensures that broadband Internet access services do not impair or degrade lawful Internet traffic based on content, application, or service, subject to reasonable network management. +Upholding net neutrality is pivotal in nurturing diversity, equity, and inclusion on the Internet. Net neutrality ensures that broadband Internet access services do not impair or degrade lawful Internet traffic based on content, application, or service, subject to reasonable network management. Learn more about net neutrality and its importance through these articles: -- [**We Need to Talk About Infrastructure**](https://www.eff.org/deeplinks/2022/12/we-need-talk-about-infrastructure): The importance of content-neutral essential Internet infrastructure and the challenges in defining what falls under this category. -- [**The Internet Is Not Facebook: Why Infrastructure Providers Should Stay Out of Content Policing**](https://www.eff.org/deeplinks/2022/10/Internet-not-facebook-why-infrastructure-providers-should-stay-out-content): The content policing of infrastructure providers due to complex challenges and potential harm to marginalized communities. -- [**International Coalition of Rights Groups Call on Internet Infrastructure Providers to Avoid Content Policing**](https://www.eff.org/press/releases/international-coalition-rights-groups-call-Internet-infrastructure-providers-avoid): Urging Internet infrastructure providers to avoid content policing, citing harm to users and human rights risks. -- [**Where the Sidewalk Ends: The Death of the Internet**](https://madattheInternet.substack.com/p/where-the-sidewalk-ends-the-death): The fragmenting of the Internet as national borders and government regulations stifle its openness and connectivity. - -<!-- SPDX-License-Identifier: AGPL-3.0-or-later --> +- [We Need to Talk About Infrastructure](https://www.eff.org/deeplinks/2022/12/we-need-talk-about-infrastructure): The importance of content-neutral essential Internet infrastructure and the challenges in defining what falls under this category. +- [The Internet Is Not Facebook: Why Infrastructure Providers Should Stay Out of Content Policing](https://www.eff.org/deeplinks/2022/10/Internet-not-facebook-why-infrastructure-providers-should-stay-out-content): The content policing of infrastructure providers due to complex challenges and potential harm to marginalized communities. +- [International Coalition of Rights Groups Call on Internet Infrastructure Providers to Avoid Content Policing](https://www.eff.org/press/releases/international-coalition-rights-groups-call-Internet-infrastructure-providers-avoid): Urging Internet infrastructure providers to avoid content policing, citing harm to users and human rights risks. +- [ISPs Should Not Police Online Speech - No Matter How Awful It Is.](https://www.eff.org/deeplinks/2023/08/isps-should-not-police-online-speech-no-matter-how-awful-it): Why ISPs should not be responsible for policing online speech, regardless of how offensive or harmful it may be. How endorsing censorship by ISPs sets a dangerous precedent against marginalized speakers and forums. +- [Where the Sidewalk Ends: The Death of the Internet](https://madattheInternet.substack.com/p/where-the-sidewalk-ends-the-death): The fragmenting of the Internet as national borders and government regulations stifle its openness and connectivity. diff --git a/docusaurus/docs/community.mdx b/docusaurus/docs/community.mdx index aebf053..4d848b9 100644 --- a/docusaurus/docs/community.mdx +++ b/docusaurus/docs/community.mdx @@ -1,21 +1,17 @@ -# Community +--- +title: Community +hide_title: true +--- -Welcome to our diverse and inclusive community! We encourage open discussions and warmly invite you to join the conversations. 🎉 - -:::note - -Our community thrives on the Fediverse, a decentralized social network that encompasses various platforms such as: +<!-- SPDX-License-Identifier: AGPL-3.0-or-later --> -- [Mastodon](https://joinmastodon.org/) -- [Pleroma](https://pleroma.social/) -- [Gitea](https://about.gitea.com/) -- [Forgejo](https://forgejo.org/) +# Wolfree community -::: +Welcome to the Wolfree community, a diverse and inclusive space where we encourage open discussions and invite you to join the conversations. 🎉 -## Mastodon and Pleroma +## Mastodon / Pleroma -We would love to hear your thoughts! Express yourself freely on Mastodon and Pleroma. +We would love to hear your thoughts. Express yourself freely on Mastodon and Pleroma. 1. https://poa.st/@wolfree 2. https://sb.bae.st/@wolfree @@ -23,19 +19,25 @@ We would love to hear your thoughts! Express yourself freely on Mastodon and Ple 4. https://spinster.xyz/@wolfree 5. https://freespeechextremist.com/wolfree -## Gitea and Forgejo +## Gitea / Forgejo -Feel free to contribute and [report issues](https://docs.github.com/en/issues) on Gitea and Forgejo. +Feel free to [report issues](https://docs.github.com/en/issues) on Gitea and Forgejo. -1. https://try.gitea.io/wolfree/issues/issues -2. https://codeberg.org/wolfree/issues/issues -3. https://git.disroot.org/wolfree/issues/issues -4. https://next.forgejo.org/wolfree/issues/issues -5. https://git.kiwifarms.net/wolfree/issues/issues -6. http://it7otdanqu7ktntxzm427cba6i53w6wlanlh23v5i3siqmos47pzhvyd.onion/wolfree/issues/issues +1. https://gitea.com/wolfree/issues/issues +2. https://try.gitea.io/wolfree/issues/issues +3. https://codeberg.org/wolfree/issues/issues +4. https://git.disroot.org/wolfree/issues/issues +5. https://next.forgejo.org/wolfree/issues/issues +6. https://git.kiwifarms.net/wolfree/issues/issues +7. http://it7otdanqu7ktntxzm427cba6i53w6wlanlh23v5i3siqmos47pzhvyd.onion/wolfree/issues/issues -## Diversity, Equity, and Inclusion +## Embracing diversity, equity, and inclusion -At our core, we strive to cultivate an environment that celebrates diversity, promotes equity, and upholds inclusion on the Internet. ❤️ We value and respect every voice. Let's connect and build a healthy, supportive community! +The Wolfree community thrives on the Fediverse, a decentralized social network that encompasses various platforms such as: -<!-- SPDX-License-Identifier: AGPL-3.0-or-later --> +- [Mastodon](https://joinmastodon.org/) +- [Pleroma](https://pleroma.social/) +- [Gitea](https://about.gitea.com/) +- [Forgejo](https://forgejo.org/) + +Wolfree developers strive to cultivate an environment that celebrates diversity, promotes equity, and upholds inclusion on the Internet. Let's connect and build a healthy, supportive community. ❤️ diff --git a/docusaurus/docs/dmca.mdx b/docusaurus/docs/dmca.mdx deleted file mode 100644 index 4bffc1e..0000000 --- a/docusaurus/docs/dmca.mdx +++ /dev/null @@ -1,12 +0,0 @@ -# DMCA takedown - -Below are some of the DMCA takedown notices issued by Wolfram Alpha LLC: - -1. [2021-08-11-wolfram.md](https://github.com/github/dmca/blob/master/2021/08/2021-08-11-wolfram.md) -2. [2021-08-16-wolfram.md](https://github.com/github/dmca/blob/master/2021/08/2021-08-16-wolfram.md) -3. [2022-09-22-wolfram.md](https://github.com/github/dmca/blob/master/2022/09/2022-09-22-wolfram.md) - -If you believe someone is using your copyrighted content unauthorizedly on GitHub or npm.js, please fill out the [Copyright claims form](https://github.com/contact/dmca) to submit a DMCA takedown notice to request that the content be changed or removed. -Before you begin, please read [GitHub's Copyright - DMCA Takedown Policy](https://docs.github.com/en/site-policy/content-removal-policies/dmca-takedown-policy). - -As with all legal matters, it is always best to consult a professional about your questions or situation. We strongly encourage you to do so before taking action that might impact your rights. This guide isn't legal advice. diff --git a/docusaurus/docs/index.mdx b/docusaurus/docs/index.mdx index 487c0b8..c6c6673 100644 --- a/docusaurus/docs/index.mdx +++ b/docusaurus/docs/index.mdx @@ -1,97 +1,90 @@ --- -slug: / title: Home page +hide_title: true +slug: / --- -# <br /> Free Wolfram Alpha Step-by-Step Solutions - -Get free access to **step-by-step** solutions. Unlock the power of **Wolfram|Alpha Pro** for free. Wolfree is **free** and **open-source** software. Thousands of learners use Wolfree to bypass paywalls. +<!-- SPDX-License-Identifier: AGPL-3.0-or-later --> import FormCTA from "../src/components/FormCTA.tsx"; -import FormQuickStart from "../src/components/FormQuickStart.tsx"; +import submitMathInputForm from "../src/functions/submitMathInputForm.ts"; +import InputMathProblems from "../src/components/InputMathProblems.tsx"; +import SubmitButton from "../src/components/SubmitButton.tsx"; import ButtonLink from "../src/components/ButtonLink.tsx"; -<FormCTA autoFocus={true} /> +# Free Wolfram Alpha step-by-step solutions + +Get free access to **step-by-step** solutions. Unlock the power of **Wolfram|Alpha Pro** for free. Wolfree is **free** and **open-source** software. Thousands of learners use Wolfree to bypass paywalls. + +<FormCTA autoFocus={true} submitText="Show Steps" /> + +## How to get Wolfram Alpha step-by-step solutions for free + +<form onSubmit={submitMathInputForm}> -<br /> -<br /> +1. Type your math problem in the text box. -## How To Use Wolfree + <InputMathProblems autoFocus={false} defaultValue="y'=y" /> -<FormQuickStart /> +2. Click the "Show Steps" button. -<br /> -<br /> + <SubmitButton text="Show Steps" /> -## Mirror Sites +3. Explore the step-by-step solution provided. 🎉 -Wolfree operates through a network of mirror sites to ensure uninterrupted access to step-by-step solutions. If you can't access this web page, visit one of our [mirror sites](/mirror) to continue your learning journey. +</form> -<p> - <ButtonLink to="./mirror" text="Access Mirror Sites" /> -</p> +## Mirror sites -<br /> -<br /> +If you can't access this web page, visit one of the [mirror sites](/mirror) to continue your learning journey. Wolfree operates through a network of mirror sites to ensure uninterrupted access to step-by-step solutions. -## Source Code +<ButtonLink to="./mirror" text="Access mirror sites" /> -Wolfree is **free** and **open-source** software. Our inclusive community welcomes individuals from diverse backgrounds to collaborate on our [source code](/source). Let's foster diversity, equity, and inclusion on the Internet. ❤️ +## Source code -<p> - <ButtonLink to="./source" text="Explore Source Code" /> -</p> +Wolfree is **free** and **open-source** software built on transparency and openness, welcoming individuals from diverse backgrounds to collaborate on [source code](/source). Let's foster diversity, equity, and inclusion on the Internet. ❤️ -<br /> -<br /> +<ButtonLink to="./source" text="Explore source code" /> -## How Wolfree Works +## How Wolfree works Here's a simplified breakdown of how Wolfree works: 1. Programmers distribute the Dockerfile on Fediverse, including platforms compatible with ForgeFed, like Forgejo and Gitea. -2. Website operators install and run Docker. -3. Docker automatically downloads the Dockerfile from Fediverse and builds a Docker image. +2. Website operators install and run Docker Engine. +3. Docker Engine automatically downloads the Dockerfile from Fediverse and builds a Docker image. 4. Web hosting service providers deploy Wolfree mirror sites. 5. Internet service providers allow your web browser to connect to Wolfree mirror sites. -6. You gain **free** access to the computational capabilities of **Wolfram|Alpha Pro**. 🎉 +6. You gain access to the computational capabilities of **Wolfram|Alpha Pro**. 🎉 Wolfree leverages a [shadow library](https://en.wikipedia.org/wiki/Shadow_library) that shares **step-by-step** solutions, ensuring you have free access to the learning resources you need. -<br /> -<br /> - -## Testimonials - -Here's what our community has to say about Wolfree: +## Trusted by thousands of learners > "Wolfree has been a transformative addition to my academic journey. The **step-by-step** solutions powered by **Wolfram|Alpha Pro** have profoundly enriched my understanding of complex math concepts. Thanks to Wolfree, my grades have seen remarkable improvement. I now approach math confidently." - Olivia (they/them), Student. -> "As a math teacher, I wholeheartedly endorse Wolfree for my students. The **step-by-step** solutions promote genuine comprehension of math concepts. By incorporating the computational capabilities of **Wolfram|Alpha Pro** into my classroom, Wolfree has significantly elevated my students' learning experiences." - Mx. Smith (they/them), Educator. - -<br /> -<br /> +> "As a math teacher, I wholeheartedly endorse Wolfree for my students. The **step-by-step** solutions promote genuine comprehension of math concepts. By incorporating the computational capabilities of **Wolfram|Alpha Pro** into my classroom, Wolfree has measurably enhanced my students' learning outcomes." - Mx. Smith, Educator. -## What You'll Get with Wolfree +## What you'll get with Wolfree -By using Wolfree, you'll get **free** access to the full potential of **Wolfram|Alpha Pro**, including: +By using Wolfree, you'll get **free** access to the full power of **Wolfram|Alpha Pro**, including: -- Get answers and hints for your math homework problems. -- Use **step-by-step** calculators for chemistry, calculus, algebra, trigonometry, and equation solving. -- Develop a deeper understanding of your homework with detailed steps and hints guiding you from problems to answers. +- **Step-by-step** calculators for calculus, differential equations, and linear algebra. +- Immediate feedback and guidance hints for your math homework problems. +- Detailed, comprehensible steps guiding you from problems to answers. Unleash the full potential of your learning with Wolfree and elevate your studies to a whole new level. 🚀 -It's **free**! Type your math problem and click "**Show Steps**" now! +It's **free**. Type your math problem and click "**Show Steps**" now. -<FormCTA /> - -<br /> -<br /> +<FormCTA autoFocus={false} submitText="Show Steps" /> <!-- What Is a Landing Page? Landing Pages Explained | Unbounce https://unbounce.com/landing-page-articles/what-is-a-landing-page/ +--> + +<!-- Is Your Landing Page Good Enough to get into Y Combinator? https://yourlandingpagesucks.com/startup-landing-page-teardown-yc/ --> @@ -105,5 +98,3 @@ It's **free**! Type your math problem and click "**Show Steps**" now! My pronouns are: they/them • Pronouns.page https://en.pronouns.page/they --> - -<!-- SPDX-License-Identifier: AGPL-3.0-or-later --> diff --git a/docusaurus/docs/mirror.mdx b/docusaurus/docs/mirror.mdx index 8af5f77..1bf5d88 100644 --- a/docusaurus/docs/mirror.mdx +++ b/docusaurus/docs/mirror.mdx @@ -1,10 +1,13 @@ --- title: Mirror site +hide_title: true --- -# Mirror Sites: Alternative Instances +<!-- SPDX-License-Identifier: AGPL-3.0-or-later --> + +# Mirror sites: alternative instances -Wolfree operates through a network of mirror sites to ensure uninterrupted access to step-by-step solutions. If you can't access this web page, visit one of our mirror sites to continue your learning journey. +Wolfree operates through a network of mirror sites. If you can't access this web page, visit the mirror sites. 1. https://wolfree.chickenkiller.com/ 2. https://wolfree.crabdance.com/ @@ -38,13 +41,16 @@ Wolfree operates through a network of mirror sites to ensure uninterrupted acces 30. https://wolfreealpha.twilightparadox.com/ 31. https://wolfreealpha.uk.to/ 32. https://wolfreealpha.us.to/ +33. https://wf.opnxng.com/ + +## Bookmarking all mirror sites -:::note Please note that Internet Service Providers may block access to this website without prior notice. Therefore, we recommend bookmarking the mirror sites in advance to ensure easier access. -::: -If you cannot access any of the mirror sites, we recommend installing the [Tor Browser](https://www.torproject.org/) to bypass censorship. +## Fetching JSON list of instances If you have programming knowledge, you can deserialize the [instances.json](pathname://../instances.json) file. -<!-- SPDX-License-Identifier: AGPL-3.0-or-later --> +## Accessing Wolfree in censored countries + +If you cannot access any of the mirror sites, we recommend installing the [Tor Browser](https://www.torproject.org/) to bypass censorship. diff --git a/docusaurus/docs/source.mdx b/docusaurus/docs/source.mdx index e9d0192..8314422 100644 --- a/docusaurus/docs/source.mdx +++ b/docusaurus/docs/source.mdx @@ -1,32 +1,37 @@ --- title: Source code +hide_title: true --- -# Access and Download the Source Code of Wolfree +<!-- SPDX-License-Identifier: AGPL-3.0-or-later --> -Wolfree is free and open-source software. You can access and download the source code from the following websites: +# Accessing the source code of Wolfree -1. https://try.gitea.io/wolfree -2. https://codeberg.org/wolfree -3. https://git.disroot.org/wolfree -4. https://next.forgejo.org/wolfree -5. https://git.kiwifarms.net/wolfree -6. http://it7otdanqu7ktntxzm427cba6i53w6wlanlh23v5i3siqmos47pzhvyd.onion/wolfree +Wolfree is **free** and **open-source** software. You can access and download the source code from the following websites: -## The Unreliability of GitHub +1. https://gitea.com/wolfree +2. https://try.gitea.io/wolfree +3. https://codeberg.org/wolfree +4. https://git.disroot.org/wolfree +5. https://next.forgejo.org/wolfree +6. https://git.kiwifarms.net/wolfree +7. http://it7otdanqu7ktntxzm427cba6i53w6wlanlh23v5i3siqmos47pzhvyd.onion/wolfree + +## The unreliability of GitHub We do not recommend pushing the source code to GitHub. Their [DMCA Takedown Policy](https://docs.github.com/en/site-policy/content-removal-policies/dmca-takedown-policy) makes storing the source code on GitHub unreliable. -## The High Availability of ForgeFed +## The high availability of ForgeFed For a more reliable and collaborative development experience, we recommend using [Gitea](https://about.gitea.com/) and [Forgejo](https://forgejo.org/). These platforms support [ActivityPub](https://www.w3.org/TR/activitypub/) and [ForgeFed](https://forgefed.org/) protocols, enabling seamless collaboration and communication among developers. -:::note -If you cannot access Gitea or Forgejo, we recommend installing the [Tor Browser](https://www.torproject.org/). The Tor Browser is a reputable tool designed to bypass censorship. -::: +## Accessing the source code in censored countries + +If you cannot access Gitea or Forgejo, we recommend installing the [Tor Browser](https://www.torproject.org/) to bypass censorship. -## License +## Submitting a DMCA takedown notice -SPDX-License-Identifier: AGPL-3.0-or-later +If you believe someone is using your copyrighted content unauthorizedly on GitHub or npm.js, please fill out the [Copyright claims form](https://github.com/contact/dmca) to submit a DMCA takedown notice to request that the content be changed or removed. +Before you begin, please read [GitHub's Copyright - DMCA Takedown Policy](https://docs.github.com/en/site-policy/content-removal-policies/dmca-takedown-policy). -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. +As with all legal matters, it is always best to consult a professional about your questions or situation. We strongly encourage you to do so before taking action that might impact your rights. This guide isn't legal advice. diff --git a/docusaurus/docusaurus.config.js b/docusaurus/docusaurus.config.js index 1cb19b7..0c1833c 100644 --- a/docusaurus/docusaurus.config.js +++ b/docusaurus/docusaurus.config.js @@ -1,15 +1,17 @@ -/** - * @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. - */ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ // @ts-check +/** @type { { config: { libredirect: false } } } */ +const wolfree = require("./wolfree.config.js"); +const lightCodeTheme = require("prism-react-renderer/themes/github"); +const darkCodeTheme = require("prism-react-renderer/themes/dracula"); + /** @type {import('@docusaurus/types').Config} */ module.exports = { - title: "Wolfree - Free WolframAlpha step-by-step solution", + title: wolfree.config.libredirect + ? "Paywall-respecting instances: Wolfree instances that do not bypass paywalls" + : "Wolfree - Free WolframAlpha step-by-step solution", url: "http://example.com", baseUrl: "/", favicon: "data:,", @@ -19,7 +21,7 @@ module.exports = { /** @type {import('@docusaurus/preset-classic').Options} */ { docs: { - sidebarPath: require.resolve("./sidebars.js"), + sidebarPath: require.resolve("./sidebars.config.js"), routeBasePath: "/", breadcrumbs: false, }, @@ -46,7 +48,9 @@ module.exports = { items: [ { to: "/", - label: "Wolfree", + label: wolfree.config.libredirect + ? "Paywall-respecting instances" + : "Wolfree", position: "left", }, { @@ -55,16 +59,6 @@ module.exports = { position: "right", target: "_self", }, - { - to: "/mirror", - label: "Mirror", - position: "right", - }, - { - to: "/source", - label: "Source", - position: "right", - }, ], }, footer: { @@ -92,11 +86,12 @@ module.exports = { label: "Acknowledgment", href: "/acknowledgment", }, - { - label: "DMCA takedown", - href: "/dmca", - }, ], + copyright: "SPDX-License-Identifier: AGPL-3.0-or-later", + }, + prism: { + theme: lightCodeTheme, + darkTheme: darkCodeTheme, }, }, }; diff --git a/docusaurus/package.json b/docusaurus/package.json index 2e58a5e..a27490d 100644 --- a/docusaurus/package.json +++ b/docusaurus/package.json @@ -15,21 +15,19 @@ "typecheck": "tsc" }, "dependencies": { - "@docusaurus/core": "2.4.1", - "@docusaurus/preset-classic": "2.4.1", + "@docusaurus/core": "2.4.3", + "@docusaurus/preset-classic": "2.4.3", "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", "@mdx-js/react": "^1.6.22", - "@mui/material": "^5.14.1", - "@types/dompurify": "^3.0.2", - "@types/jquery": "^3.5.16", + "@mui/material": "^5.14.10", "clsx": "^1.2.1", "prism-react-renderer": "^1.3.5", "react": "^17.0.2", "react-dom": "^17.0.2" }, "devDependencies": { - "@docusaurus/module-type-aliases": "2.4.1", + "@docusaurus/module-type-aliases": "2.4.3", "@tsconfig/docusaurus": "^1.0.5", "typescript": "^4.7.4" }, diff --git a/docusaurus/sidebars.config.js b/docusaurus/sidebars.config.js new file mode 100644 index 0000000..7d4711a --- /dev/null +++ b/docusaurus/sidebars.config.js @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +// @ts-check + +/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ +module.exports = { + sidebarId: [ + "index", + { + type: "html", + value: '<a class="menu__link" href="/input/">Input math problems</a>', + className: "menu__list-item", + }, + "mirror", + "source", + "community", + "acknowledgment", + ], +}; diff --git a/docusaurus/sidebars.js b/docusaurus/sidebars.js deleted file mode 100644 index 3a62009..0000000 --- a/docusaurus/sidebars.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @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. - */ - -// @ts-check - -/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ -module.exports = { - sidebarId: [ - "index", - { - type: "html", - value: '<a class="menu__link" href="/input/">Input math problems</a>', - className: "menu__list-item", - }, - "mirror", - "source", - { - type: "category", - label: "Detail", - collapsible: true, - collapsed: true, - items: ["community", "acknowledgment", "dmca"], - }, - ], -}; diff --git a/docusaurus/src/components/ButtonLink.tsx b/docusaurus/src/components/ButtonLink.tsx index 12fc559..5fd69e1 100644 --- a/docusaurus/src/components/ButtonLink.tsx +++ b/docusaurus/src/components/ButtonLink.tsx @@ -1,25 +1,26 @@ -/** - * @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. - */ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ -import React from "react"; +import Button from "@mui/material/Button"; import Link from "@docusaurus/Link"; -import { Button } from "@mui/material"; +import React from "react"; -const ButtonLink = ({ to = String(), text = String() }) => ( - <Link to={to}> - <Button size="large" sx={{ textTransform: "capitalize" }}> - <strong>{text}</strong> - » - </Button> - </Link> +export default ({ + to = "", + text = "", +}: Readonly<{ + to: string; + text: string; +}>): React.JSX.Element => ( + <p> + <Link to={to}> + <Button size="large" sx={{ textTransform: "capitalize" }}> + <strong>{text}</strong> + » + </Button> + </Link> + </p> ); -export default ButtonLink; - // Typography - MUI System // https://mui.com/system/typography/ diff --git a/docusaurus/src/components/FormCTA.tsx b/docusaurus/src/components/FormCTA.tsx index 1b5a81e..0912dec 100644 --- a/docusaurus/src/components/FormCTA.tsx +++ b/docusaurus/src/components/FormCTA.tsx @@ -1,23 +1,20 @@ -/** - * @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. - */ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ +import InputMathProblems from "./InputMathProblems"; import React from "react"; +import SubmitButton from "./SubmitButton"; import submitMathInputForm from "../functions/submitMathInputForm"; -import InputMathProblems from "./InputMathProblems"; -import ShowStepButton from "./ShowStepButton"; -const FormCTA = ({ autoFocus = Boolean() }) => ( +export default ({ + autoFocus = false, + submitText = "", +}: Readonly<{ + autoFocus: boolean; + submitText: string; +}>): React.JSX.Element => ( <form onSubmit={submitMathInputForm}> + <InputMathProblems autoFocus={autoFocus} defaultValue="" /> <p></p> - <InputMathProblems autoFocus={autoFocus} /> - <p></p> - <ShowStepButton /> - <p></p> + <SubmitButton text={submitText} /> </form> ); - -export default FormCTA; diff --git a/docusaurus/src/components/FormQuickStart.tsx b/docusaurus/src/components/FormQuickStart.tsx deleted file mode 100644 index 60589fb..0000000 --- a/docusaurus/src/components/FormQuickStart.tsx +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @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 index c7b49ce..27313d2 100644 --- a/docusaurus/src/components/InputMathProblems.tsx +++ b/docusaurus/src/components/InputMathProblems.tsx @@ -1,19 +1,15 @@ -/** - * @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. - */ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ 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(), -}) => ( +export default ({ + autoFocus = false, + defaultValue = "", +}: Readonly<{ + autoFocus: boolean; + defaultValue: string; +}>): React.JSX.Element => ( <TextField name="i" type="search" @@ -30,4 +26,8 @@ const InputMathProblems = ({ /> ); -export default InputMathProblems; +// TextField API - Material UI +// https://mui.com/material-ui/api/text-field/ + +// <input>: The Input (Form Input) element - HTML: HyperText Markup Language | MDN +// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input diff --git a/docusaurus/src/components/ShowStepButton.tsx b/docusaurus/src/components/ShowStepButton.tsx deleted file mode 100644 index 3ae7ba3..0000000 --- a/docusaurus/src/components/ShowStepButton.tsx +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @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/components/SubmitButton.tsx b/docusaurus/src/components/SubmitButton.tsx new file mode 100644 index 0000000..e9b1c72 --- /dev/null +++ b/docusaurus/src/components/SubmitButton.tsx @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +import Button from "@mui/material/Button"; +import React from "react"; + +export default ({ + text = "", +}: Readonly<{ text: string }>): React.JSX.Element => ( + <p> + <Button + type="submit" + size="large" + variant="contained" + sx={{ textTransform: "capitalize" }} + > + {text} + </Button> + </p> +); + +// Typography - MUI System +// https://mui.com/system/typography/ diff --git a/docusaurus/src/css/custom.css b/docusaurus/src/css/custom.css index a027863..ce621e1 100644 --- a/docusaurus/src/css/custom.css +++ b/docusaurus/src/css/custom.css @@ -1,15 +1,51 @@ -/** - * @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. - */ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +.markdown { + --ifm-h2-vertical-rhythm-top: 4; +} :root { --ifm-menu-link-padding-vertical: calc(var(--ifm-menu-link-padding-horizontal) * 1.5); + --ifm-toc-padding-vertical: calc(var(--ifm-toc-padding-horizontal) * 2); --ifm-color-primary: blue; - --ifm-color-gray-900: var(--ifm-color-gray-900); - --ifm-color-secondary-contrast-foreground: var(--ifm-color-gray-900); + --ifm-color-gray-700: black; + --ifm-color-gray-800: black; + --ifm-color-gray-900: black; + --ifm-color-secondary-contrast-foreground: black; + --ifm-color-content-secondary: black; +} + +.markdown>h1 { + /* Style the <h1> on http://localhost/source */ + margin-top: calc(var(--ifm-h2-vertical-rhythm-top) * var(--ifm-leading)); +} + +:root { + --wolfree-heading-zoom: 0.75; +} + +h1 { + font-size: calc(max(1rem, var(--ifm-h1-font-size) * var(--wolfree-heading-zoom))); +} + +h2 { + font-size: calc(max(1rem, var(--ifm-h2-font-size) * var(--wolfree-heading-zoom))); +} + +h3 { + font-size: calc(max(1rem, var(--ifm-h3-font-size) * var(--wolfree-heading-zoom))); +} + +h4 { + font-size: calc(max(1rem, var(--ifm-h4-font-size) * var(--wolfree-heading-zoom))); +} + +h5 { + font-size: calc(max(1rem, var(--ifm-h5-font-size) * var(--wolfree-heading-zoom))); +} + +h6 { + font-size: calc(max(1rem, var(--ifm-h6-font-size) * var(--wolfree-heading-zoom))); } .footer__link-item { diff --git a/docusaurus/src/functions/submitMathInputForm.ts b/docusaurus/src/functions/submitMathInputForm.ts new file mode 100644 index 0000000..cf3294b --- /dev/null +++ b/docusaurus/src/functions/submitMathInputForm.ts @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +import React from "react"; + +export default (event: React.FormEvent<HTMLFormElement>): void => { + event.preventDefault(); + const htmlFormElement = event.currentTarget; + const formData = new FormData(htmlFormElement); + const i = formData.get("i"); + + const url = new URL("/input/", window.location.href); + + if (typeof i === "string") { + url.searchParams.set("i", i); + } else if (i instanceof File) { + console.warn({ i }); + } else { + const typescriptExhaustivenessCheck: never = i; + console.warn({ typescriptExhaustivenessCheck }); + } + + window.location.assign(url); +}; diff --git a/docusaurus/src/functions/submitMathInputForm.tsx b/docusaurus/src/functions/submitMathInputForm.tsx deleted file mode 100644 index a90894e..0000000 --- a/docusaurus/src/functions/submitMathInputForm.tsx +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @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/functions/typescriptNever.ts b/docusaurus/src/functions/typescriptNever.ts new file mode 100644 index 0000000..42becd5 --- /dev/null +++ b/docusaurus/src/functions/typescriptNever.ts @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +export default (typescriptNeverValue: never): never => { + console.warn({ typescriptNeverValue }); + + return typescriptNeverValue; +}; + +// How do I check that a switch block is exhaustive in TypeScript? - Stack Overflow +// https://stackoverflow.com/questions/39419170/how-do-i-check-that-a-switch-block-is-exhaustive-in-typescript diff --git a/docusaurus/src/theme/Footer/InputPreloader.tsx b/docusaurus/src/theme/Footer/InputPreloader.tsx index 325f8a7..2ba2e19 100644 --- a/docusaurus/src/theme/Footer/InputPreloader.tsx +++ b/docusaurus/src/theme/Footer/InputPreloader.tsx @@ -1,35 +1,31 @@ -/** - * @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); - }; +/* SPDX-License-Identifier: AGPL-3.0-or-later */ - window.scroll(0, 0); +import React from "react"; + +export default (): React.JSX.Element => { + const [insertIframe, setInsertIframe] = React.useState(false); + + React.useEffect((): (() => void) => { + const handleIframeLoad = (): (() => void) => { + // Insert the iframe after a 3000ms delay. + const timerId = setTimeout((): void => setInsertIframe(true), 3000); + + // Cleanup the timer when the component unmounts. + return (): void => clearTimeout(timerId); + }; 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 + window.scroll(0, 0); + + // Cleanup the event listener when the component unmounts. + return (): void => window.removeEventListener("load", handleIframeLoad); + }, []); // Empty dependency array means the effect runs only once after initial render. return ( <> {/* Use a descriptive title for accessibility */} - {showIframe && ( + {insertIframe && ( <iframe title="Input Page Preloader" src="/input/" @@ -39,5 +35,3 @@ const InputPreloader = () => { </> ); }; - -export default InputPreloader; diff --git a/docusaurus/src/theme/Footer/index.tsx b/docusaurus/src/theme/Footer/index.tsx index 2edef40..e4063c5 100644 --- a/docusaurus/src/theme/Footer/index.tsx +++ b/docusaurus/src/theme/Footer/index.tsx @@ -1,21 +1,14 @@ -/** - * @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. - */ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ -import React from "react"; import Footer from "@theme-original/Footer"; import InputPreloader from "./InputPreloader"; +import React from "react"; -const FooterWrapper = (props: React.JSX.IntrinsicAttributes) => { - return ( - <> - <Footer {...props} /> - <InputPreloader /> - </> - ); -}; - -export default FooterWrapper; +export default ( + props: React.JSX.ElementAttributesProperty +): React.JSX.Element => ( + <> + <Footer {...props} /> + <InputPreloader /> + </> +); diff --git a/docusaurus/src/theme/NotFound/DDoSProtection.tsx b/docusaurus/src/theme/NotFound/DDoSProtection.tsx index 6cd8c04..b861669 100644 --- a/docusaurus/src/theme/NotFound/DDoSProtection.tsx +++ b/docusaurus/src/theme/NotFound/DDoSProtection.tsx @@ -1,19 +1,14 @@ -/** - * @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. - */ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ import React from "react"; -const DDoSProtection = () => ( +export default (): React.JSX.Element => ( <center style={{ display: "flex", justifyContent: "center", alignItems: "center", - height: 100 + "vh", + height: "99vh", }} > <center> @@ -30,5 +25,3 @@ const DDoSProtection = () => ( </center> </center> ); - -export default DDoSProtection; diff --git a/docusaurus/src/theme/NotFound/redirectInput.tsx b/docusaurus/src/theme/NotFound/Redirection.tsx index 4e29b4a..3fe2d6d 100644 --- a/docusaurus/src/theme/NotFound/redirectInput.tsx +++ b/docusaurus/src/theme/NotFound/Redirection.tsx @@ -1,41 +1,30 @@ -/** - * @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"; +/* SPDX-License-Identifier: AGPL-3.0-or-later */ -const redirectInput = () => { - useEffect(() => { - const redirectToInputPage = () => { - const pathname = window.location.pathname; +import React from "react"; +import typescriptNever from "../../functions/typescriptNever"; - const isExample = pathname.includes("/example"); - if (!isExample) { - window.location.href = "/"; - return; - } +export default (): React.JSX.Element => { + React.useEffect((): void => { + const pathname = window.location.pathname; - const filename = pathname.split("/").pop(); - if (!filename) { - window.location.href = "/"; - return; - } + const isExample = pathname.includes("/example"); - const topic = "topic " + filename.replace(/-/g, " "); + if (isExample === true) { + const topic = "topic " + pathname.split("/").pop().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 + window.location.replace(url); + } else if (isExample === false) { + window.location.replace("/"); + } else { + window.location.replace("/"); + typescriptNever(isExample); + } + }, []); // Empty dependency array means the effect runs only once after initial render. + + return <></>; }; -export default redirectInput; - /* * test case: * diff --git a/docusaurus/src/theme/NotFound/index.tsx b/docusaurus/src/theme/NotFound/index.tsx index d5e0208..15e9fe6 100644 --- a/docusaurus/src/theme/NotFound/index.tsx +++ b/docusaurus/src/theme/NotFound/index.tsx @@ -1,28 +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. - */ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ -import React from "react"; -import NotFound from "@theme-original/NotFound"; -import redirectInput from "./redirectInput"; import DDoSProtection from "./DDoSProtection"; +import NotFound from "@theme-original/NotFound"; +import React from "react"; +import Redirection from "./Redirection"; -const NotFoundWrapper = (props: React.JSX.IntrinsicAttributes) => { - redirectInput(); - return ( - <> - <DDoSProtection /> - <div style={{ display: "none" }}> - <NotFound {...props} /> - </div> - </> - ); -}; - -export default NotFoundWrapper; +export default ( + props: React.JSX.ElementAttributesProperty +): React.JSX.Element => ( + <> + <Redirection /> + <DDoSProtection /> + <div style={{ display: "none" }}> + <NotFound {...props} /> + </div> + </> +); // How can I customize the 404 page? · facebook/docusaurus · Discussion #6030 // https://github.com/facebook/docusaurus/discussions/6030 diff --git a/docusaurus/static/.htaccess b/docusaurus/static/.htaccess new file mode 100644 index 0000000..de377bf --- /dev/null +++ b/docusaurus/static/.htaccess @@ -0,0 +1 @@ +ErrorDocument 404 /404.html diff --git a/docusaurus/static/n/v1/api/samplefiles/fileinput/examples b/docusaurus/static/_next/static/chunks/pages/examples-26aec7eb12db3258.js index e69de29..e69de29 100644 --- a/docusaurus/static/n/v1/api/samplefiles/fileinput/examples +++ b/docusaurus/static/_next/static/chunks/pages/examples-26aec7eb12db3258.js diff --git a/docusaurus/static/_next/static/images/blueLaptopLarge_2mT4E7sC.png b/docusaurus/static/_next/static/images/blueLaptopLarge_2mT4E7sC.png new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/docusaurus/static/_next/static/images/blueLaptopLarge_2mT4E7sC.png diff --git a/docusaurus/static/_next/static/images/blueLaptopSmall_2HE8DlL-.png b/docusaurus/static/_next/static/images/blueLaptopSmall_2HE8DlL-.png new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/docusaurus/static/_next/static/images/blueLaptopSmall_2HE8DlL-.png diff --git a/docusaurus/static/_next/static/images/purpleLaptopLarge_3J6pajKV.png b/docusaurus/static/_next/static/images/purpleLaptopLarge_3J6pajKV.png new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/docusaurus/static/_next/static/images/purpleLaptopLarge_3J6pajKV.png diff --git a/docusaurus/static/_next/static/images/purpleLaptopSmall_QQ5wFSVR.png b/docusaurus/static/_next/static/images/purpleLaptopSmall_QQ5wFSVR.png new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/docusaurus/static/_next/static/images/purpleLaptopSmall_QQ5wFSVR.png diff --git a/docusaurus/static/_next/static/images/tealLaptopLarge_2Y_KGBw9.png b/docusaurus/static/_next/static/images/tealLaptopLarge_2Y_KGBw9.png new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/docusaurus/static/_next/static/images/tealLaptopLarge_2Y_KGBw9.png diff --git a/docusaurus/static/_next/static/images/tealLaptopSmall_1Xxic2d8.png b/docusaurus/static/_next/static/images/tealLaptopSmall_1Xxic2d8.png new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/docusaurus/static/_next/static/images/tealLaptopSmall_1Xxic2d8.png diff --git a/docusaurus/static/ajax/libs/wolfree/23.7.8/css/Placeholder.css b/docusaurus/static/ajax/libs/wolfree/2023.8.31/css/Placeholder.css index b7553e2..bcb9311 100644 --- a/docusaurus/static/ajax/libs/wolfree/23.7.8/css/Placeholder.css +++ b/docusaurus/static/ajax/libs/wolfree/2023.8.31/css/Placeholder.css @@ -1,9 +1,4 @@ -/** - * @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. - */ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ .wolfree-placeholder { display: flex; diff --git a/docusaurus/static/ajax/libs/wolfree/23.7.8/css/PodsParser.css b/docusaurus/static/ajax/libs/wolfree/2023.8.31/css/PodsParser.css index 179b1c6..34a43ad 100644 --- a/docusaurus/static/ajax/libs/wolfree/23.7.8/css/PodsParser.css +++ b/docusaurus/static/ajax/libs/wolfree/2023.8.31/css/PodsParser.css @@ -1,9 +1,4 @@ -/** - * @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. - */ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ .wolfree-pods { display: flex; diff --git a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/AJAX.js b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/AJAX.js deleted file mode 100644 index 465787d..0000000 --- a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/AJAX.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @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. - */ - -// @ts-check - -import SearchParams from "./SearchParams.js"; - -export default class AJAX { - ajax = async ({ - input = String(), - i2d = Boolean(), - extraPodstates = Array(), - } = {}) => { - try { - const data = new SearchParams().getSearchParams({ - input, - extraPodstates, - i2d, - }); - - const options = { - url: "https://api.wolframalpha.com/v2/query", - dataType: "jsonp", - traditional: true, - data, - }; - - try { - /** - * https://www.npmjs.com/package/@types/jquery - * @type {import('jQuery')} - */ - const response = await jQuery.ajax(options); - return ( - console.assert(response instanceof Object), - console.assert(response.hasOwnProperty("queryresult")), - { response } - ); - } catch (error) { - return ( - console.error( - { error }, - "We encountered an issue while attempting to retrieve a response from the Wolfram Alpha API using the jQuery library." - ), - { error } - ); - } - } catch (error) { - return console.error({ error }), { error }; - } - }; -} diff --git a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/AppID.js b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/AppID.js deleted file mode 100644 index 070e4e1..0000000 --- a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/AppID.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @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. - */ - -// @ts-check - -// To generate a new AppID: -// 1. Open Tor Browser and go to: https://products.wolframalpha.com/api/ -// 2. Click the orangish "Get API Access" button. You will go to: https://account.wolfram.com/login/oauth2/sign-in -// 3. Click the reddish "Create one" hyperlink to create a new Wolfram ID. You will go to: https://account.wolfram.com/login/create -// 4. Fill out the form using random alphanumeric characters. -// 5. Click the reddish "Create Wolfram ID" button. You will go to: https://developer.wolframalpha.com/portal/myapps/index.html -// 6. Click the orangish "Sign up to get your first AppID" button. -// 7. Fill out the form using random alphanumeric characters. -// 8. Click the orangish "Sign up" button. -// 9. Click the orangish "Get an AppID" button. -// 10. Fill out the form using random alphanumeric characters. -// 11. Click the orangish "Get AppID" button. - -export default class AppID { - appIDArray = Array(); - - constructor( - appIDArray = ["H9V325-HTALUWHKGK", "AKJTJT-LR5LL8WTG6", "LKY83U-XW6ATU9URU"] - ) { - (this.appIDArray = appIDArray), - Array.from(this.appIDArray).forEach( - (appID) => ( - console.assert(17 === appID.length), - console.assert(/[0-9A-Z]{6}-[0-9A-Z]{10}/.test(appID)) - ) - ); - } - - getAppID = ({ - appID = this.appIDArray[this.getRandomInt() % this.appIDArray.length], - } = {}) => { - try { - return appID; - } catch (error) { - return console.error({ error }), String(); - } - }; - - getRandomInt = ({ - randomInt = crypto.getRandomValues(new Uint32Array(1))[0], - } = {}) => { - try { - return randomInt; - } catch (error) { - return console.error({ error }), Number(); - } - }; -} diff --git a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Entrypoint.js b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Entrypoint.js deleted file mode 100644 index 0fe9d31..0000000 --- a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Entrypoint.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @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. - */ - -// @ts-check - -import Processor from "./Processor.js"; -import Preprocessor from "./Preprocessor.js"; -import PostProcessor from "./PostProcessor.js"; - -export default async ({ - input = String(), - i2d = Boolean(), - extraPodstates = Array(), -} = {}) => { - try { - new Preprocessor().process(); - await new Processor().process({ input, i2d, extraPodstates }); - new PostProcessor().process({ input, i2d }); - } catch (error) { - console.error({ error }); - } -}; diff --git a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Placeholder.js b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Placeholder.js deleted file mode 100644 index d5b45a6..0000000 --- a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Placeholder.js +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @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. - */ - -// @ts-check - -export default class Placeholder { - className = "wolfree-placeholder"; - - placeholderHTML = ` - <div class="${this.className}"> - <div> - <div> - <div><div></div></div> - <div><div></div></div> - <div><div></div></div> - </div> - </div> - </div> - `; - - insert = ({ - container = document.querySelector( - "html > body > #__next > div > main > main > div:nth-of-type(1)" - ), - } = {}) => { - try { - return ( - container instanceof HTMLDivElement - ? container.insertAdjacentHTML("afterend", this.placeholderHTML) - : console.error({ container }), - { container } - ); - } catch (error) { - return ( - console.error( - { error }, - "Fail to insert the skeleton placeholder components." - ), - { error } - ); - } - }; - - remove = ({ - allPlaceholders = document.querySelectorAll( - `html > body > #__next > div > main > main > div.${this.className}` - ), - } = {}) => { - try { - return ( - console.assert(allPlaceholders.length === 1), - allPlaceholders.forEach((placeholder) => placeholder.remove()), - { allPlaceholders } - ); - } catch (error) { - return ( - console.error( - { error }, - "Fail to remove the skeleton placeholder components." - ), - { error } - ); - } - }; -} diff --git a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Pods.js b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Pods.js deleted file mode 100644 index 7b31e48..0000000 --- a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Pods.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @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. - */ - -// @ts-check - -export default class Pods { - insert = ({ - container = document.querySelector("main > div:nth-of-type(1)"), - html = String(), - } = {}) => { - try { - /** - * https://www.npmjs.com/package/@types/dompurify - * @type {import('DOMPurify')} - */ - return ( - container instanceof HTMLDivElement - ? container.insertAdjacentHTML( - "afterend", - globalThis.DOMPurify.sanitize(html) - ) - : console.error({ container }), - { container, html } - ); - } catch (error) { - return ( - console.error( - { error }, - "Fail to insert the results of the calculation." - ), - { error } - ); - } - }; - - remove = ({ - pods = document.querySelectorAll("main > div.wolfree-pods"), - } = {}) => { - try { - pods.forEach((element) => { - element.remove(); - }); - return { pods }; - } catch (error) { - console.error( - "Fail to remove the results of the previous calculation.", - error - ); - return { error }; - } - }; -} diff --git a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/PodsParser.js b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/PodsParser.js deleted file mode 100644 index bfb0ab0..0000000 --- a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/PodsParser.js +++ /dev/null @@ -1,201 +0,0 @@ -/** - * @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. - */ - -// @ts-check - -export default class PodsParser { - parse = ({ - input = String(), - i2d = Boolean(), - extraPodstates = Array(), - response = { queryresult: { pods: Array() } }, - } = {}) => { - try { - return { html: this.buildHTML({ input, i2d, extraPodstates, response }) }; - } catch (error) { - return console.error({ error }), { error }; - } - }; - - buildHTML = ({ - input = String(), - i2d = Boolean(), - extraPodstates = Array(), - response = { queryresult: { pods: Array() } }, - } = {}) => { - return ` - <div class="wolfree-pods"> - <div> - <div> - <section> - ${this.parseQueryResult({ response })} - ${this.buildTechnicalInfo({ - input, - i2d, - extraPodstates, - response, - })} - </section> - </div> - </div> - </div> - `; - }; - - parseQueryResult = ({ response = { queryresult: { pods: Array() } } }) => { - const { queryresult } = response; - const { pods } = queryresult; - if (pods) { - return pods.map(this.parsePod).join(""); - } - return ""; - }; - - parsePod = ( - pod = { - title: String(), - states: Array(), - subpods: Array(), - } - ) => { - return ` - <section> - ${this.buildPodHeader(pod)} - <div></div> - ${pod.subpods.map(this.buildSubpod).join("")} - </section> - `; - }; - - buildPodHeader = (pod = { title: String(), states: Array() }) => { - return ` - <div> - <h2>${this.escapeHTML(pod.title)}</h2> - ${pod.states ? pod.states.map(this.buildSelectElement).join("") : ""} - </div> - `; - }; - - buildSubpod = ( - subpod = { img: { src: String(), alt: String() }, plaintext: String() } - ) => { - return ` - <div><div> - <img - src="${this.escapeHTML(subpod.img.src)}" - alt="${this.escapeHTML(subpod.img.alt)}" - > - </div></div> - <div style="font-family: monospace; overflow: auto;"> - <div><div>${this.buildSubpodDetails(subpod)}</div></div> - </div> - `; - }; - - buildSubpodDetails = (subpod = { plaintext: String() }) => { - return ` - <details> - <summary style="direction: rtl;"></summary> - <div><pre>${this.escapeHTML(subpod.plaintext)}</pre></div> - <br> - </details> - `; - }; - - buildSelectElement = (state = { value: String(), states: Array() }) => { - if (state.states) { - return ` - <select name="pod-states"> - <option>${this.escapeHTML(state.value)}</option> - ${state.states.map(this.buildOption).join("")} - </select> - `; - } - return ""; - }; - - buildOption = (state = { name: String() }) => { - return ` - <option>${this.escapeHTML(state.name)}</option> - `; - }; - - buildTechnicalInfo = ({ - input = String(), - i2d = Boolean(), - extraPodstates = Array(), - response = { queryresult: { pods: Array() } }, - }) => { - return ` - <section> - <div><h2>Technical information</h2></div> - <div></div> - <div><div><div>${this.buildTechnicalInfoDetails({ - input, - i2d, - extraPodstates, - response, - })}</div></div></div> - <div></div> - </section> - `; - }; - - buildTechnicalInfoDetails = ({ - input = String(), - i2d = Boolean(), - extraPodstates = Array(), - response = { queryresult: { pods: Array() } }, - }) => { - return ` - <details> - <div> - If you have programming knowledge, feel free to explore the technical information provided below: - </div> - ${this.buildTextarea({ input, i2d, extraPodstates, response })} - </details> - `; - }; - - buildTextarea = ({ - input = String(), - i2d = Boolean(), - extraPodstates = Array(), - response = { queryresult: { pods: Array() } }, - }) => { - return ` - <textarea name="technical-information">${this.escapeHTML( - JSON.stringify( - { - document, - input, - i2d, - extraPodstates, - response, - }, - null, - 4 - ) - )}</textarea> - `; - }; - - escapeHTML = (unsafe = String()) => { - return unsafe - .replace(/&/g, "&") - .replace(/</g, "<") - .replace(/>/g, ">") - .replace(/"/g, """) - .replace(/'/g, "'"); - }; -} - -// Can I escape HTML special chars in JavaScript? - Stack Overflow -// https://stackoverflow.com/questions/6234773/can-i-escape-html-special-chars-in-javascript - -// test case: -// https://www.wolframalpha.com/input?i=solve+%7By%27%28x%29+%3D+-2+y%2C+y%280%29%3D1%7D+from+0+to+10+using+r+k+f+algorithm diff --git a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/PostProcessor.js b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/PostProcessor.js deleted file mode 100644 index 1061d8a..0000000 --- a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/PostProcessor.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @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. - */ - -// @ts-check - -import Placeholder from "./Placeholder.js"; -import Entrypoint from "./Entrypoint.js"; - -export default class PostProcessor { - process = ({ input = String(), i2d = Boolean() } = {}) => { - try { - new Placeholder().remove(); - - try { - document - .querySelectorAll( - "html > body > div#__next > div > main > main > div.wolfree-pods > div > div > section > section > div > div > div > details > div" - ) - .forEach((element = new HTMLElement()) => - element.setAttribute("contenteditable", "") - ); - } catch (error) { - console.error( - "Fail to make the plaintext in details tags easy to copy.", - error - ); - } - - try { - document - .querySelectorAll( - "html > body > div#__next > div > main > main > div.wolfree-pods > div > div > section > section > div:is(:first-child) > select" - ) - .forEach((element = new HTMLSelectElement()) => - element.addEventListener( - "change", - async (event = new Event(String())) => - Entrypoint({ - input, - i2d, - extraPodstates: [ - event.target instanceof HTMLSelectElement - ? event.target.value - : (console.error({ event }), String()), - ], - }) - ) - ); - } catch (error) { - console.error( - "Fail to set up the drop-down menu for problem-solving strategies.", - error - ); - } - } catch (error) { - console.error({ error }); - } - }; -} diff --git a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Preprocessor.js b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Preprocessor.js deleted file mode 100644 index 5d88bbc..0000000 --- a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Preprocessor.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @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. - */ - -// @ts-check - -import Placeholder from "./Placeholder.js"; -import Pods from "./Pods.js"; - -export default class Preprocessor { - process = () => { - try { - try { - window.scroll(0, 0); - } catch (error) { - console.error({ error }, "Fail to scroll to the top of the webpage."); - } - - new Placeholder().insert(); - - new Pods().remove(); - } catch (error) { - console.error({ error }); - } - }; -} diff --git a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Processor.js b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Processor.js deleted file mode 100644 index eaf9c2a..0000000 --- a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Processor.js +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @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. - */ - -// @ts-check - -import AJAX from "./AJAX.js"; -import PodsParser from "./PodsParser.js"; -import Pods from "./Pods.js"; - -export default class Processor { - process = async ({ - input = String(), - i2d = Boolean(), - extraPodstates = Array(), - } = {}) => { - try { - const { response } = await new AJAX().ajax({ - input, - i2d, - extraPodstates, - }); - - try { - const { html } = new PodsParser().parse({ - input, - i2d, - extraPodstates, - /** @type {any} */ - response, - }); - - try { - new Pods().remove(); - } catch (error) { - console.error(error); - } - - try { - new Pods().insert({ html }); - } catch (error) { - console.error(error); - } - } catch (error) { - console.error(error); - } - } catch (error) { - console.error(error); - } - }; -} diff --git a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/SearchParams.js b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/SearchParams.js deleted file mode 100644 index 828d06f..0000000 --- a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/SearchParams.js +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @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. - */ - -// @ts-check - -import AppID from "./AppID.js"; - -export default class SearchParams { - constructor({ getAppID = new AppID().getAppID } = {}) { - this.getAppID = getAppID; - } - - getSearchParams = ({ - input = String(), - i2d = Boolean(), - extraPodstates = Array(), - } = {}) => { - const appid = this.getAppID(); - return { - ...(appid && { appid }), - ...(input && { input }), - ...(i2d && { i2d }), - podstate: [ - "Step-by-step solution", - "Step-by-step", - "Show all steps", - ...extraPodstates, - // Note: extraPodstates must be the last item in the array. - // Otherwise, the Wolfram Alpha API may ignore the pod states in extraPodstates. - ], - output: "json", - reinterpret: true, - podtimeout: 30, - scantimeout: 30, - parsetimeout: 30, - totaltimeout: 30, - formattimeout: 30, - }; - }; -} diff --git a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/onload.js b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/onload.js deleted file mode 100644 index 5767c4e..0000000 --- a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/onload.js +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @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. - */ - -// @ts-check - -export default addEventListener( - "load", - () => ( - setTimeout( - () => - document - .querySelectorAll( - "html > body > #__next > div > main > main > div > div > section > form > div > div > input" - ) - .forEach((input) => - input instanceof HTMLInputElement - ? input.focus() - : console.error({ input }) - ), - 1000 - ), - [ - () => - document - .querySelectorAll( - 'html > body > #__next > div > main > main > div > div > div > section > section > div:is(:first-child) > ul > li' - ) - .forEach( - (li) => - li.innerHTML.includes("Step-by-step") && - (li instanceof HTMLElement - ? (li.style.display = "none") - : console.error({ li })) - ), - () => - (document.title = document.title.replace( - "- Wolfram|Alpha", - "- Free Wolfram|Alpha Step-by-step Solution - Wolfree" - )), - ].forEach( - (callback) => ( - setInterval(callback, 2000), addEventListener("click", callback) - ) - ), - scroll(0, 0) - ) -); diff --git a/docusaurus/static/instances.json b/docusaurus/static/instances.json index 89b54df..8e24e7e 100644 --- a/docusaurus/static/instances.json +++ b/docusaurus/static/instances.json @@ -39,4 +39,4 @@ "i2p": [], "loki": [] } -} +}
\ No newline at end of file diff --git a/docusaurus/static/n/v1/api/autocomplete/index.html b/docusaurus/static/n/v1/api/autocomplete/index.html index e69de29..118947e 100644 --- a/docusaurus/static/n/v1/api/autocomplete/index.html +++ b/docusaurus/static/n/v1/api/autocomplete/index.html @@ -0,0 +1,5 @@ +{ + "query": "", + "instantMath": null, + "results": [] +}
\ No newline at end of file diff --git a/docusaurus/static/n/v1/api/randomizer b/docusaurus/static/n/v1/api/randomizer index e69de29..f860a92 100644 --- a/docusaurus/static/n/v1/api/randomizer +++ b/docusaurus/static/n/v1/api/randomizer @@ -0,0 +1,14 @@ +{ + "en": { + "id": 0, + "query": "" + }, + "ja": { + "id": 0, + "query": "" + }, + "es": { + "id": 0, + "query": "" + } +}
\ No newline at end of file diff --git a/docusaurus/static/n/v1/api/sourcer/dataSources b/docusaurus/static/n/v1/api/sourcer/dataSources index e69de29..6b56a3e 100644 --- a/docusaurus/static/n/v1/api/sourcer/dataSources +++ b/docusaurus/static/n/v1/api/sourcer/dataSources @@ -0,0 +1,12 @@ +[ + { + "name": "", + "display": [ + { + "type": "", + "value": "" + } + ], + "url": "" + } +]
\ No newline at end of file diff --git a/docusaurus/static/n/v1/api/sourcer/index.html b/docusaurus/static/n/v1/api/sourcer/index.html index e69de29..5138297 100644 --- a/docusaurus/static/n/v1/api/sourcer/index.html +++ b/docusaurus/static/n/v1/api/sourcer/index.html @@ -0,0 +1,10 @@ +[ + { + "name": "", + "value": { + "primarySourceItems": [], + "title": "", + "items": [] + } + } +]
\ No newline at end of file diff --git a/docusaurus/static/users/me/account b/docusaurus/static/users/me/account index e69de29..824480a 100644 --- a/docusaurus/static/users/me/account +++ b/docusaurus/static/users/me/account @@ -0,0 +1,388 @@ +{ + "message": "Invalid request", + "internalCode": 1, + "httpCode": 500, + "arguments": {}, + "cause": null, + "stackTrace": [ + { + "methodName": "filter_aroundBody12", + "fileName": "AuthFilter.scala", + "lineNumber": 47, + "className": "com.wolframalpha.common.filters.AuthFilter", + "nativeMethod": false + }, + { + "methodName": "filter_aroundBody13$advice", + "fileName": "AuthFilter.scala", + "lineNumber": 49, + "className": "com.wolframalpha.common.filters.AuthFilter", + "nativeMethod": false + }, + { + "methodName": "filter_aroundBody14", + "fileName": "AuthFilter.scala", + "lineNumber": 1, + "className": "com.wolframalpha.common.filters.AuthFilter", + "nativeMethod": false + }, + { + "methodName": "filter_aroundBody15$advice", + "fileName": "AuthFilter.scala", + "lineNumber": 28, + "className": "com.wolframalpha.common.filters.AuthFilter", + "nativeMethod": false + }, + { + "methodName": "filter_aroundBody16", + "fileName": "AuthFilter.scala", + "lineNumber": 1, + "className": "com.wolframalpha.common.filters.AuthFilter", + "nativeMethod": false + }, + { + "methodName": "filter_aroundBody17$advice", + "fileName": "AuthFilter.scala", + "lineNumber": 25, + "className": "com.wolframalpha.common.filters.AuthFilter", + "nativeMethod": false + }, + { + "methodName": "filter", + "fileName": "AuthFilter.scala", + "lineNumber": 1, + "className": "com.wolframalpha.common.filters.AuthFilter", + "nativeMethod": false + }, + { + "methodName": "apply", + "fileName": "ContainerFilteringStage.java", + "lineNumber": 171, + "className": "org.glassfish.jersey.server.ContainerFilteringStage", + "nativeMethod": false + }, + { + "methodName": "apply", + "fileName": "ContainerFilteringStage.java", + "lineNumber": 74, + "className": "org.glassfish.jersey.server.ContainerFilteringStage", + "nativeMethod": false + }, + { + "methodName": "process", + "fileName": "Stages.java", + "lineNumber": 197, + "className": "org.glassfish.jersey.process.internal.Stages", + "nativeMethod": false + }, + { + "methodName": "run", + "fileName": "ServerRuntime.java", + "lineNumber": 250, + "className": "org.glassfish.jersey.server.ServerRuntime$1", + "nativeMethod": false + }, + { + "methodName": "call", + "fileName": "Errors.java", + "lineNumber": 271, + "className": "org.glassfish.jersey.internal.Errors$1", + "nativeMethod": false + }, + { + "methodName": "call", + "fileName": "Errors.java", + "lineNumber": 267, + "className": "org.glassfish.jersey.internal.Errors$1", + "nativeMethod": false + }, + { + "methodName": "process", + "fileName": "Errors.java", + "lineNumber": 315, + "className": "org.glassfish.jersey.internal.Errors", + "nativeMethod": false + }, + { + "methodName": "process", + "fileName": "Errors.java", + "lineNumber": 297, + "className": "org.glassfish.jersey.internal.Errors", + "nativeMethod": false + }, + { + "methodName": "process", + "fileName": "Errors.java", + "lineNumber": 267, + "className": "org.glassfish.jersey.internal.Errors", + "nativeMethod": false + }, + { + "methodName": "runInScope", + "fileName": "RequestScope.java", + "lineNumber": 319, + "className": "org.glassfish.jersey.process.internal.RequestScope", + "nativeMethod": false + }, + { + "methodName": "process", + "fileName": "ServerRuntime.java", + "lineNumber": 236, + "className": "org.glassfish.jersey.server.ServerRuntime", + "nativeMethod": false + }, + { + "methodName": "handle", + "fileName": "ApplicationHandler.java", + "lineNumber": 1028, + "className": "org.glassfish.jersey.server.ApplicationHandler", + "nativeMethod": false + }, + { + "methodName": "service", + "fileName": "WebComponent.java", + "lineNumber": 373, + "className": "org.glassfish.jersey.servlet.WebComponent", + "nativeMethod": false + }, + { + "methodName": "service", + "fileName": "ServletContainer.java", + "lineNumber": 381, + "className": "org.glassfish.jersey.servlet.ServletContainer", + "nativeMethod": false + }, + { + "methodName": "service", + "fileName": "ServletContainer.java", + "lineNumber": 344, + "className": "org.glassfish.jersey.servlet.ServletContainer", + "nativeMethod": false + }, + { + "methodName": "service", + "fileName": "ServletContainer.java", + "lineNumber": 219, + "className": "org.glassfish.jersey.servlet.ServletContainer", + "nativeMethod": false + }, + { + "methodName": "internalDoFilter", + "fileName": "ApplicationFilterChain.java", + "lineNumber": 303, + "className": "org.apache.catalina.core.ApplicationFilterChain", + "nativeMethod": false + }, + { + "methodName": "doFilter", + "fileName": "ApplicationFilterChain.java", + "lineNumber": 208, + "className": "org.apache.catalina.core.ApplicationFilterChain", + "nativeMethod": false + }, + { + "methodName": "doFilter", + "fileName": "WsFilter.java", + "lineNumber": 52, + "className": "org.apache.tomcat.websocket.server.WsFilter", + "nativeMethod": false + }, + { + "methodName": "internalDoFilter", + "fileName": "ApplicationFilterChain.java", + "lineNumber": 241, + "className": "org.apache.catalina.core.ApplicationFilterChain", + "nativeMethod": false + }, + { + "methodName": "doFilter", + "fileName": "ApplicationFilterChain.java", + "lineNumber": 208, + "className": "org.apache.catalina.core.ApplicationFilterChain", + "nativeMethod": false + }, + { + "methodName": "doFilter", + "fileName": "MonitoringFilter.java", + "lineNumber": 232, + "className": "net.bull.javamelody.MonitoringFilter", + "nativeMethod": false + }, + { + "methodName": "doFilter", + "fileName": "MonitoringFilter.java", + "lineNumber": 209, + "className": "net.bull.javamelody.MonitoringFilter", + "nativeMethod": false + }, + { + "methodName": "internalDoFilter", + "fileName": "ApplicationFilterChain.java", + "lineNumber": 241, + "className": "org.apache.catalina.core.ApplicationFilterChain", + "nativeMethod": false + }, + { + "methodName": "doFilter", + "fileName": "ApplicationFilterChain.java", + "lineNumber": 208, + "className": "org.apache.catalina.core.ApplicationFilterChain", + "nativeMethod": false + }, + { + "methodName": "invoke", + "fileName": "StandardWrapperValve.java", + "lineNumber": 220, + "className": "org.apache.catalina.core.StandardWrapperValve", + "nativeMethod": false + }, + { + "methodName": "invoke", + "fileName": "StandardContextValve.java", + "lineNumber": 122, + "className": "org.apache.catalina.core.StandardContextValve", + "nativeMethod": false + }, + { + "methodName": "invoke", + "fileName": "AuthenticatorBase.java", + "lineNumber": 501, + "className": "org.apache.catalina.authenticator.AuthenticatorBase", + "nativeMethod": false + }, + { + "methodName": "invoke", + "fileName": "StandardHostValve.java", + "lineNumber": 170, + "className": "org.apache.catalina.core.StandardHostValve", + "nativeMethod": false + }, + { + "methodName": "invoke", + "fileName": "ErrorReportValve.java", + "lineNumber": 98, + "className": "org.apache.catalina.valves.ErrorReportValve", + "nativeMethod": false + }, + { + "methodName": "invoke", + "fileName": "AccessLogValve.java", + "lineNumber": 950, + "className": "org.apache.catalina.valves.AccessLogValve", + "nativeMethod": false + }, + { + "methodName": "invoke", + "fileName": "StandardEngineValve.java", + "lineNumber": 116, + "className": "org.apache.catalina.core.StandardEngineValve", + "nativeMethod": false + }, + { + "methodName": "service", + "fileName": "CoyoteAdapter.java", + "lineNumber": 408, + "className": "org.apache.catalina.connector.CoyoteAdapter", + "nativeMethod": false + }, + { + "methodName": "process", + "fileName": "AbstractHttp11Processor.java", + "lineNumber": 1040, + "className": "org.apache.coyote.http11.AbstractHttp11Processor", + "nativeMethod": false + }, + { + "methodName": "process", + "fileName": "AbstractProtocol.java", + "lineNumber": 607, + "className": "org.apache.coyote.AbstractProtocol$AbstractConnectionHandler", + "nativeMethod": false + }, + { + "methodName": "run", + "fileName": "AprEndpoint.java", + "lineNumber": 2378, + "className": "org.apache.tomcat.util.net.AprEndpoint$SocketWithOptionsProcessor", + "nativeMethod": false + }, + { + "methodName": "runWorker", + "fileName": "ThreadPoolExecutor.java", + "lineNumber": 1145, + "className": "java.util.concurrent.ThreadPoolExecutor", + "nativeMethod": false + }, + { + "methodName": "run", + "fileName": "ThreadPoolExecutor.java", + "lineNumber": 615, + "className": "java.util.concurrent.ThreadPoolExecutor$Worker", + "nativeMethod": false + }, + { + "methodName": "run", + "fileName": "Thread.java", + "lineNumber": 745, + "className": "java.lang.Thread", + "nativeMethod": false + } + ], + "response": { + "context": { + "headers": {}, + "entity": null, + "entityType": null, + "entityAnnotations": [], + "entityStream": { + "isCommitted": false, + "isClosed": false + }, + "mediaType": null, + "requestCookies": {}, + "acceptableMediaTypes": [ + { + "type": "*", + "subtype": "*", + "parameters": {}, + "quality": 1000, + "wildcardType": true, + "wildcardSubtype": true + } + ], + "acceptableLanguages": [ + "*" + ], + "entityClass": null, + "allowedMethods": [], + "responseCookies": {}, + "entityTag": null, + "links": [], + "stringHeaders": {}, + "length": -1, + "language": null, + "location": null, + "date": null, + "lastModified": null, + "committed": false + }, + "status": 500, + "metadata": {}, + "mediaType": null, + "statusInfo": "INTERNAL_SERVER_ERROR", + "allowedMethods": [], + "entityTag": null, + "links": [], + "stringHeaders": {}, + "entity": null, + "length": -1, + "language": null, + "location": null, + "date": null, + "lastModified": null, + "cookies": {}, + "headers": {} + }, + "localizedMessage": "Invalid request", + "suppressed": [] +}
\ No newline at end of file diff --git a/docusaurus/tsconfig.json b/docusaurus/tsconfig.json index 50e4989..9685ccf 100644 --- a/docusaurus/tsconfig.json +++ b/docusaurus/tsconfig.json @@ -1,18 +1,11 @@ -/** - * @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. - */ - -// @ts-check - { // This file is not used in compilation. It is here just for a nice editor experience. "extends": "@tsconfig/docusaurus/tsconfig.json", "compilerOptions": { - "baseUrl": ".", - "strict": true, - "forceConsistentCasingInFileNames": true + "module": "Node16", // Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + "jsx": "react", // Cannot use JSX unless the '--jsx' flag is provided. + "baseUrl": "." } } + +/* SPDX-License-Identifier: AGPL-3.0-or-later */ diff --git a/docusaurus/wolfree.config.js b/docusaurus/wolfree.config.js new file mode 100644 index 0000000..d2c4ef3 --- /dev/null +++ b/docusaurus/wolfree.config.js @@ -0,0 +1,6 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +// dependents: +// ../rust/wolfree_patch_libredirect/src/main.rs +/** @type { { config: { libredirect: false } } } */ +module.exports = { config: { libredirect: false } }; diff --git a/rust/wolfree_download_dependencies/Cargo.toml b/rust/wolfree_download_dependencies/Cargo.toml new file mode 100644 index 0000000..a76607d --- /dev/null +++ b/rust/wolfree_download_dependencies/Cargo.toml @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later + +[package] +name = "wolfree_download_dependencies" +version = "2023.8.31" +authors = [ + "See the commit history of the Git repositories.", + "https://git.kiwifarms.net/wolfree", +] +categories = ["development-tools::build-utils"] +edition = "2021" +keywords = ["Wolfree", "Docker", "download", "compile", "dependency"] +license = "AGPL-3.0-or-later" +readme = "README.md" +repository = "https://git.kiwifarms.net/wolfree" +description = "Download and compile dependencies." + +[dependencies] +regex = "1" +walkdir = "2" diff --git a/rust/wolfree_download_dependencies/src/main.rs b/rust/wolfree_download_dependencies/src/main.rs new file mode 100644 index 0000000..9fdc1ab --- /dev/null +++ b/rust/wolfree_download_dependencies/src/main.rs @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +//! rust - Can Cargo download and build dependencies without also building the application? - Stack Overflow +//! <https://stackoverflow.com/questions/42130132/can-cargo-download-and-build-dependencies-without-also-building-the-application> +//! +//! cargo build --dependencies-only · Issue #2644 · rust-lang/cargo · GitHub +//! <https://github.com/rust-lang/cargo/issues/2644> + +#![allow(clippy::blanket_clippy_restriction_lints)] +#![allow(clippy::implicit_return)] +#![allow(clippy::question_mark_used)] + +use regex::Regex; +use std::error; +use walkdir::WalkDir; + +/// Entry point of the program. +fn main() -> Result<(), Box<dyn error::Error>> { + let _: Regex = Regex::new("")?; + let _: WalkDir = WalkDir::new(""); + Ok(()) +} diff --git a/rust/wolfree_libredirect_patch/Cargo.toml b/rust/wolfree_libredirect_patch/Cargo.toml deleted file mode 100644 index 5b587d5..0000000 --- a/rust/wolfree_libredirect_patch/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -# 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. - -[package] -name = "wolfree_libredirect_patch" -version = "23.7.31" -edition = "2021" - -authors = ["See the commit history of the Git repositories: <https://try.gitea.io/wolfree>"] -description = "The Rust crate provides lightweight wrappers around the `fs::write` and `fs::remove_dir_all` functions from the standard library's `fs` module." -license = "AGPL-3.0-or-later" -repository = "https://try.gitea.io/wolfree" -readme = "README.md" -keywords = ["rust", "wrapper", "write", "remove", "file"] -categories = ["command-line-utilities", "development-tools::build-utils", "web-programming"] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -markdown = "1.0.0-alpha" diff --git a/rust/wolfree_libredirect_patch/src/body.md b/rust/wolfree_libredirect_patch/src/body.md deleted file mode 100644 index 69ccfc1..0000000 --- a/rust/wolfree_libredirect_patch/src/body.md +++ /dev/null @@ -1,68 +0,0 @@ -# Paywall-Respecting Instances: Wolfree instances that do not bypass any paywall - -Welcome to Paywall-Respecting Instances, where we provide Wolfree instances that **do not bypass any paywall**. - -## The Problem with Other Wolfree Instances - -Most other Wolfree instances can bypass paywalls, which raises concerns about Microsoft GitHub's [DMCA Takedown Policy](https://docs.github.com/en/site-policy/content-removal-policies/dmca-takedown-policy). - -Unfortunately, this means that developers of [LibRedirect](https://libredirect.github.io/) cannot redirect users to such instances. - -To learn more about this issue, please refer to [issue #425](https://github.com/libredirect/browser_extension/issues/425) on Microsoft GitHub. - -## The Solution: Paywall-Respecting Instances - -Unlike other Wolfree instances, Paywall-Respecting Instances prioritize ethical practices and **do not bypass any paywall**. So developers of LibRedirect can confidently redirect their users to Paywall-Respecting Instances. - -## Instance List - -Here are some Paywall-Respecting Instances you can access: - -1. https://gqq.gitlab.io/ -2. https://jqq.gitlab.io/ -3. https://rqq.gitlab.io/ -4. https://sqq.gitlab.io/ -5. https://uqq.gitlab.io/ - -JSON: [instances.json](/instances.json) - -## Source Code - -Paywall-Respecting Instances is free and open-source software. You can access and download its source code from the following websites: - -1. https://try.gitea.io/wolfree -2. https://codeberg.org/wolfree -3. https://git.disroot.org/wolfree -4. https://next.forgejo.org/wolfree -5. https://git.kiwifarms.net/wolfree -6. http://it7otdanqu7ktntxzm427cba6i53w6wlanlh23v5i3siqmos47pzhvyd.onion/wolfree - -SPDX-License-Identifier: AGPL-3.0-or-later - -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. - -## How it Works - -1. Install [LibRedirect](https://libredirect.github.io/) on your web browser. -2. LibRedirect automatically redirects you from Wolfram to our instances, safeguarding your privacy. -3. Enjoy accessing Wolfree instances that uphold ethical practices and **do not bypass any paywall**. - -## Key Features - -### Compliance with Microsoft GitHub - -Paywall-Respecting Instances **do not bypass any paywall**, empowering LibRedirect developers with the confidence to redirect users to our instances. - -### Protect Your Privacy - -Once you install LibRedirect on your web browser, LibRedirect automatically redirects you from Wolfram to our instances, securing your digital privacy. - -### Ethical Practices - -By accessing our instances, you actively promote ethical practices and support the work of content creators. - -## Get Started Now! - -Install LibRedirect to access Paywall-Respecting Instances. Enjoy Wolfree instances that **do not bypass any paywall**. - -- [Install LibRedirect](https://libredirect.github.io/) diff --git a/rust/wolfree_libredirect_patch/src/head.html b/rust/wolfree_libredirect_patch/src/head.html deleted file mode 100644 index d67963c..0000000 --- a/rust/wolfree_libredirect_patch/src/head.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> - -<head> - <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <meta name="description" - content="With our seamless integration with LibRedirect, a web browser extension that protects your digital privacy, you can ensure that your access to Wolfree instances preserves your privacy and complies with Microsoft GitHub's DMCA Takedown Policy." /> - <title> - Wolfree instances that do not bypass any paywall | Paywall-Respecting Instances - </title> - <style> - html { - margin: 1rem; - font-family: sans-serif; - } - - body { - max-width: 30rem; - margin: 5rem auto; - } - - h1, - h2 { - margin-top: 5rem; - line-height: 1.5; - } - - p, - li { - line-height: 2; - } - - a { - text-decoration: none; - word-wrap: break-word; - } - </style> - <link rel="icon" href="data:," /> -</head> - -</html> -<!-- SPDX-License-Identifier: AGPL-3.0-or-later -->
\ No newline at end of file diff --git a/rust/wolfree_libredirect_patch/src/main.rs b/rust/wolfree_libredirect_patch/src/main.rs deleted file mode 100644 index 65f1b93..0000000 --- a/rust/wolfree_libredirect_patch/src/main.rs +++ /dev/null @@ -1,95 +0,0 @@ -//! The Rust crate provides lightweight wrappers around the `fs::write` and `fs::remove_dir_all` functions from the standard library's `fs` module. -//! The crate is designed to simplify file writing and directory removal operations by encapsulating the error handling logic and providing a more convenient interface. -//! It is particularly useful for tasks that involve writing multiple files or removing directories with their contents. - -#![allow(clippy::blanket_clippy_restriction_lints)] -#![allow(clippy::exit)] -#![allow(clippy::print_stderr)] -#![allow(clippy::implicit_return)] - -/* 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. - */ - -use markdown::to_html_with_options; -use markdown::Options; -use std::fs; - -/// A lightweight wrapper around `fs::write`. -fn wolfree_write(file_path: &str, contents: &str) { - match fs::write(file_path, contents) { - Ok(_) => (), - Err(err) => { - eprintln!("Error: {err}",); - std::process::exit(1); - } - }; -} - -/// A lightweight wrapper around `fs::remove_dir_all`. -fn wolfree_remove_dir_all(dir_path: &str) { - match fs::remove_dir_all(dir_path) { - Ok(_) => (), - Err(err) => { - eprintln!("Error: {err}",); - std::process::exit(1); - } - }; -} - -/// A lightweight wrapper around `markdown::to_html_with_options`. -fn wolfree_to_html_with_options(value: &str) -> String { - match to_html_with_options(value, &Options::gfm()) { - Ok(result) => result, - Err(err) => { - eprintln!("Error: {err}",); - std::process::exit(1); - } - } -} - -/// Entry point of the program. -fn main() { - wolfree_write( - "./docusaurus/build/ajax/libs/wolfree/23.7.8/js/Entrypoint.js", - "export default () => {}", - ); - wolfree_write( - "./docusaurus/build/index.html", - &format!( - "{}{}", - include_str!("head.html"), - wolfree_to_html_with_options(include_str!("body.md")), - ), - ); - wolfree_write( - "./docusaurus/build/instances.json", - include_str!("instances.json"), - ); - wolfree_write( - "./docusaurus/build/404.html", - "<script>location='/'</script>", - ); - wolfree_write( - "./docusaurus/build/acknowledgment/index.html", - "<script>location='/'</script>", - ); - wolfree_write( - "./docusaurus/build/community/index.html", - "<script>location='/'</script>", - ); - wolfree_write( - "./docusaurus/build/dmca/index.html", - "<script>location='/'</script>", - ); - wolfree_write( - "./docusaurus/build/mirror/index.html", - "<script>location='/'</script>", - ); - wolfree_write( - "./docusaurus/build/source/index.html", - "<script>location='/'</script>", - ); - wolfree_remove_dir_all("./docusaurus/build/assets/"); -} diff --git a/rust/wolfree_patch_libredirect/Cargo.toml b/rust/wolfree_patch_libredirect/Cargo.toml new file mode 100644 index 0000000..cf55e4d --- /dev/null +++ b/rust/wolfree_patch_libredirect/Cargo.toml @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later + +[package] +name = "wolfree_patch_libredirect" +version = "2023.8.31" +authors = [ + "See the commit history of the Git repositories.", + "https://git.kiwifarms.net/wolfree", +] +categories = [ + "command-line-utilities", + "development-tools::build-utils", + "web-programming", +] +edition = "2021" +keywords = [ + "rust", + "customize", + "Wolfree", + "LibRedirect", + "write", + "remove", + "file", +] +license = "AGPL-3.0-or-later" +readme = "README.md" +repository = "https://git.kiwifarms.net/wolfree" +description = "Customize Wolfree instances to suit Libredirect." diff --git a/rust/wolfree_patch_libredirect/src/docusaurus/docs/index.mdx b/rust/wolfree_patch_libredirect/src/docusaurus/docs/index.mdx new file mode 100644 index 0000000..3cefc82 --- /dev/null +++ b/rust/wolfree_patch_libredirect/src/docusaurus/docs/index.mdx @@ -0,0 +1,81 @@ +--- +title: Home page +hide_title: true +slug: / +--- + +<!-- SPDX-License-Identifier: AGPL-3.0-or-later --> + +import FormCTA from "../src/components/FormCTA.tsx"; +import submitMathInputForm from "../src/functions/submitMathInputForm.ts"; +import InputMathProblems from "../src/components/InputMathProblems.tsx"; +import SubmitButton from "../src/components/SubmitButton.tsx"; +import ButtonLink from "../src/components/ButtonLink.tsx"; + +# Wolfree instances that do not bypass paywalls + +Wolfree is a free and open-source software for accessing the calculation results computed by Wolfram Alpha. Wolfree operates through a network of websites known as "instances." Unlike most instances, this instance **does not bypass paywalls**. + +<FormCTA autoFocus={true} submitText="Compute Input" /> + +## How to access the calculation results generated by Wolfram Alpha + +<form onSubmit={submitMathInputForm}> + +1. Type your math problem in the text box. + + <InputMathProblems autoFocus={false} defaultValue="y'=y" /> + +2. Click the "Compute Input" button. + + <SubmitButton text="Compute Input" /> + +3. Explore the calculation result provided. 🎉 + +</form> + +## The problem with other Wolfree instances + +Most other Wolfree instances can bypass paywalls, which raises concerns about Microsoft GitHub's [DMCA Takedown Policy](https://docs.github.com/en/site-policy/content-removal-policies/dmca-takedown-policy). Unfortunately, this means that developers of [LibRedirect](https://libredirect.github.io/) cannot redirect users to such instances. For details about this issue, refer to [issue #425](https://github.com/libredirect/browser_extension/issues/425) on Microsoft GitHub. + +## How this instance resolves the problem + +Unlike most Wolfree instances, this instance prioritizes ethical values and **does not bypass paywalls**. + +## Mirror sites + +Wolfree operates through a network of mirror sites. If you can't access this web page, visit the [mirror sites](/mirror). + +<ButtonLink to="./mirror" text="Access mirror sites" /> + +## Source code + +Wolfree is **free** and **open-source** software built on transparency and openness, welcoming individuals from diverse backgrounds to collaborate on [source code](/source). ❤️ + +<ButtonLink to="./source" text="Explore source code" /> + +## How it works + +1. Install [LibRedirect](https://libredirect.github.io/) on your web browser. +2. Enable auto-redirection from Wolfram to this instance. +3. Enjoy accessing Wolfree instances that **do not bypass paywalls**. + +## Key benefits + +### Compliance with Microsoft GitHub + +This instance **does not bypass paywalls**, resolving [the GitHub issues](https://github.com/libredirect/browser_extension/issues/425) LibRedirect developers encounter. + +### Auto-redirection + +Once you install LibRedirect on your web browser, you can enable auto-redirection from Wolfram to this instance. + +### Cyber Ethics + +By accessing this instance, you actively promote ethical practices and support the work of content creators. + +## Get started now + +Install LibRedirect and enable auto-redirection. Enjoy Wolfree instances that **do not bypass paywalls**. + +<ButtonLink to="https://libredirect.github.io/" text="Install LibRedirect" /> diff --git a/rust/wolfree_patch_libredirect/src/docusaurus/docs/mirror.mdx b/rust/wolfree_patch_libredirect/src/docusaurus/docs/mirror.mdx new file mode 100644 index 0000000..a55cd77 --- /dev/null +++ b/rust/wolfree_patch_libredirect/src/docusaurus/docs/mirror.mdx @@ -0,0 +1,24 @@ +--- +title: Mirror site +hide_title: true +--- + +<!-- SPDX-License-Identifier: AGPL-3.0-or-later --> + +# Mirror sites: alternative instances + +Wolfree operates through a network of mirror sites. If you can't access this web page, visit the mirror sites. + +1. https://gqq.gitlab.io/ +2. https://jqq.gitlab.io/ +3. https://rqq.gitlab.io/ +4. https://sqq.gitlab.io/ +5. https://uqq.gitlab.io/ + +## Fetching JSON list of instances + +If you have programming knowledge, you can deserialize the [instances.json](pathname://../instances.json) file. + +## Accessing Wolfree in censored countries + +If you cannot access any of the mirror sites, we recommend installing the [Tor Browser](https://www.torproject.org/) to bypass censorship. diff --git a/rust/wolfree_patch_libredirect/src/docusaurus/docs/source.mdx b/rust/wolfree_patch_libredirect/src/docusaurus/docs/source.mdx new file mode 100644 index 0000000..66e222a --- /dev/null +++ b/rust/wolfree_patch_libredirect/src/docusaurus/docs/source.mdx @@ -0,0 +1,22 @@ +--- +title: Source code +hide_title: true +--- + +<!-- SPDX-License-Identifier: AGPL-3.0-or-later --> + +# Accessing the source code of Wolfree + +Wolfree is **free** and **open-source** software. You can access and download the source code from the following websites: + +1. https://gitea.com/wolfree +2. https://try.gitea.io/wolfree +3. https://codeberg.org/wolfree +4. https://git.disroot.org/wolfree +5. https://next.forgejo.org/wolfree +6. https://git.kiwifarms.net/wolfree +7. http://it7otdanqu7ktntxzm427cba6i53w6wlanlh23v5i3siqmos47pzhvyd.onion/wolfree + +## Accessing the source code in censored countries + +If you cannot access Gitea or Forgejo, we recommend installing the [Tor Browser](https://www.torproject.org/) to bypass censorship. diff --git a/rust/wolfree_libredirect_patch/src/instances.json b/rust/wolfree_patch_libredirect/src/docusaurus/static/instances.json index 8cdd008..8cdd008 100644 --- a/rust/wolfree_libredirect_patch/src/instances.json +++ b/rust/wolfree_patch_libredirect/src/docusaurus/static/instances.json diff --git a/rust/wolfree_patch_libredirect/src/main.rs b/rust/wolfree_patch_libredirect/src/main.rs new file mode 100644 index 0000000..907dc36 --- /dev/null +++ b/rust/wolfree_patch_libredirect/src/main.rs @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +//! Customize Wolfree instances to suit Libredirect. + +#![allow(clippy::blanket_clippy_restriction_lints)] +#![allow(clippy::implicit_return)] +#![allow(clippy::question_mark_used)] + +use std::error; +use std::fs; + +/// By default, the main function do nothing as most Wolfree users do not use Libredirect. +#[allow(unreachable_code)] +fn main() -> Result<(), Box<dyn error::Error>> { + // Remove the following line to make the instances Libredirect-compatible. + return Ok(()); + // Remove the previous line to make the instances Libredirect-compatible. + + // Disable the entrypoint of the JavaScript modules. + fs::write( + "./docusaurus/static/ajax/libs/wolfree/2023.8.31/js/entrypoint.js", + "export default () => {};" + )?; + + fs::write( + "./docusaurus/wolfree.config.js", + "module.exports = { config: { libredirect: true } };" + )?; + + fs::write( + "./docusaurus/static/instances.json", + include_str!("./docusaurus/static/instances.json") + )?; + + fs::write("./docusaurus/docs/index.mdx", include_str!("./docusaurus/docs/index.mdx"))?; + fs::write("./docusaurus/docs/mirror.mdx", include_str!("./docusaurus/docs/mirror.mdx"))?; + fs::write("./docusaurus/docs/source.mdx", include_str!("./docusaurus/docs/source.mdx"))?; + + Ok(()) +} diff --git a/rust/wolfree_sed_in_place/Cargo.toml b/rust/wolfree_sed_in_place/Cargo.toml index ab2b32f..0a8bf1d 100644 --- a/rust/wolfree_sed_in_place/Cargo.toml +++ b/rust/wolfree_sed_in_place/Cargo.toml @@ -1,21 +1,24 @@ # 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. [package] name = "wolfree_sed_in_place" -version = "23.7.31" +version = "2023.8.31" +authors = [ + "See the commit history of the Git repositories.", + "https://git.kiwifarms.net/wolfree", +] +categories = [ + "command-line-utilities", + "development-tools::build-utils", + "web-programming", + "template-engine", +] edition = "2021" - -authors = ["See the commit history of the Git repositories: <https://try.gitea.io/wolfree>"] -description = "This Rust program performs in-place search and replaces operations on all files within specified directories. It uses regular expressions to find occurrences of a given pattern in each file's contents and replaces them with the replacement text." +keywords = ["rust", "search", "replace", "regular expressions", "regex", "file"] license = "AGPL-3.0-or-later" -repository = "https://try.gitea.io/wolfree" readme = "README.md" -keywords = ["rust", "search", "replace", "regular expressions", "regex", "file", "in-place"] -categories = ["command-line-utilities", "development-tools::build-utils", "web-programming", "template-engine"] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +repository = "https://git.kiwifarms.net/wolfree" +description = "Perform in-place search and replaces operations on all files within specified directories." [dependencies] regex = "1" diff --git a/rust/wolfree_sed_in_place/src/include_str.html b/rust/wolfree_sed_in_place/src/include_str.html index 2fbe0f4..f09b167 100644 --- a/rust/wolfree_sed_in_place/src/include_str.html +++ b/rust/wolfree_sed_in_place/src/include_str.html @@ -1,13 +1,15 @@ +<!-- SPDX-License-Identifier: AGPL-3.0-or-later --> + <meta name="referrer" content="no-referrer" /> -<script type="module" src="/ajax/libs/jquery/3.7.0/jquery.min.js"></script> +<script type="module" src="/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script type="module" src="/ajax/libs/dompurify/3.0.5/purify.min.js"></script> -<script type="module" src="/ajax/libs/wolfree/23.7.8/js/onload.js"></script> +<script type="module" src="/ajax/libs/wolfree/2023.8.31/js/onload.js"></script> <link rel="preload" as="style" onload="this.onload = null; this.rel = 'stylesheet';" - href="/ajax/libs/wolfree/23.7.8/css/Placeholder.css" /> + href="/ajax/libs/wolfree/2023.8.31/css/Placeholder.css" /> <link rel="preload" as="style" onload="this.onload = null; this.rel = 'stylesheet';" - href="/ajax/libs/wolfree/23.7.8/css/PodsParser.css" /> + href="/ajax/libs/wolfree/2023.8.31/css/PodsParser.css" /> <style> html>body>#__next>div>header { @@ -64,6 +66,10 @@ } </style> +<!-- + Regex in regex - Rust + https://docs.rs/regex/latest/regex/struct.Regex.html#replacement-string-syntax +--> $0 <header> @@ -72,5 +78,4 @@ $0 <a href="../mirror">Mirror</a> <a href="../source">Source</a> </nav> -</header> -<!-- SPDX-License-Identifier: AGPL-3.0-or-later -->
\ No newline at end of file +</header>
\ No newline at end of file diff --git a/rust/wolfree_sed_in_place/src/include_str.tsx b/rust/wolfree_sed_in_place/src/include_str.js index 3c8ff4e..9ef3a31 100644 --- a/rust/wolfree_sed_in_place/src/include_str.tsx +++ b/rust/wolfree_sed_in_place/src/include_str.js @@ -1,14 +1,10 @@ -/** - * @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. - */ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ // @ts-check const wolfreeLexicalScopeName = (() => { - const possibleLetters = Array(); + /** @type {string[]} */ + const possibleLetters = []; for (let i = 32; i < 127; i++) { possibleLetters.push(String.fromCharCode(i)); @@ -18,7 +14,7 @@ const wolfreeLexicalScopeName = (() => { possibleLetters.map((y) => x + y) ); - const isValid = (name = String()) => { + const isValid = (name = "") => { try { return ( typeof eval(name).value === "string" && @@ -32,7 +28,7 @@ const wolfreeLexicalScopeName = (() => { const wolfreeLexicalScopeName = possibleNames.find(isValid); if (typeof wolfreeLexicalScopeName !== "string") { - console.error({ wolfreeLexicalScopeName }); + console.warn({ wolfreeLexicalScopeName }); return ""; } @@ -40,7 +36,7 @@ const wolfreeLexicalScopeName = (() => { })(); (() => { - const get = (params = String()) => { + const get = (params = "") => { return new URLSearchParams(location.search).get(params); }; @@ -51,8 +47,6 @@ const wolfreeLexicalScopeName = (() => { /** * Regex in regex - Rust * https://docs.rs/regex/latest/regex/struct.Regex.html#replacement-string-syntax - * All instances of $ref in the replacement string are replaced with the substring corresponding to the capture group identified by ref. - * ref may be an integer corresponding to the index of the capture group (counted by order of opening parenthesis where 0 is the entire match) or it can be a name (consisting of letters, digits or underscores) corresponding to a named capture group. */ // @ts-ignore $0; @@ -61,11 +55,11 @@ $0; ( await import( // @ts-ignore - "../../../ajax/libs/wolfree/23.7.8/js/Entrypoint.js" + "/ajax/libs/wolfree/2023.8.31/js/entrypoint.js" ) ).default({ input: eval(wolfreeLexicalScopeName).value, - i2d: eval(wolfreeLexicalScopeName).i2d, - extraPodstates: [], + ...(eval(wolfreeLexicalScopeName).i2d ? { i2d: true } : {}), + podstate: ["Step-by-step solution", "Step-by-step", "Show all steps"], }); })(); diff --git a/rust/wolfree_sed_in_place/src/main.rs b/rust/wolfree_sed_in_place/src/main.rs index 7d56889..f20393f 100644 --- a/rust/wolfree_sed_in_place/src/main.rs +++ b/rust/wolfree_sed_in_place/src/main.rs @@ -1,17 +1,14 @@ -//! The `wolfree_sed_in_place` crate provides a function for performing in-place replacements of patterns in multiple files using regular expressions. +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +//! This crate provides a function for performing in-place replacements of patterns in multiple files using regular expressions. //! It allows you to recursively process all files within a specified directory and replace occurrences of a given pattern with a specified replacement string. #![allow(clippy::blanket_clippy_restriction_lints)] -#![allow(clippy::exit)] -#![allow(clippy::print_stderr)] #![allow(clippy::implicit_return)] - -/* 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. - */ +#![allow(clippy::question_mark_used)] use regex::Regex; +use std::error; use std::fs; use walkdir::WalkDir; @@ -21,94 +18,52 @@ use walkdir::WalkDir; /// filters out directories, and applies a regular expression-based replacement /// on the contents of each file. /// -/// # Arguments -/// /// * `directory_path`: A string slice representing the path of the directory to traverse. /// * `pattern`: A string slice containing the regular expression pattern to search for. /// * `replacement`: A string slice representing the replacement for each matched pattern. -/// -/// # Examples -/// -/// ```rust -/// // Replace a specific pattern in the file contents in the "./data/" directory. -/// wolfree_sed_in_place("./data/", r"\bFoo\b", "Bar"); -/// ``` -/// -/// This example replaces all occurrences of the word "Foo" with "Bar" in the files inside the "data" directory. -fn wolfree_sed_in_place(directory_path: &str, pattern: &str, replacement: &str) { - // Compile the regular expression pattern - let regex = match Regex::new(pattern) { - Ok(re) => re, - Err(err) => { - eprintln!("Error: {err}",); - std::process::exit(1); - } - }; - - // Create a directory walker and filter out non-file entries - let walker = WalkDir::new(directory_path) +fn sed( + directory_path: &str, + pattern: &str, + replacement: &str +) -> Result<(), Box<dyn error::Error>> { + // Compile the regular expression pattern. + let regex = Regex::new(pattern)?; + // Create a directory walker and filter out non-file entries. + for entry in WalkDir::new(directory_path) .into_iter() .filter_map(Result::ok) - .filter(|entry| !entry.file_type().is_dir()); - - // Process each file in the directory - for entry in walker { + .filter(|entry| !entry.file_type().is_dir()) { let file_path = entry.path(); - - // Read the file's contents into a string - let file_contents = match fs::read_to_string(file_path) { - Ok(contents) => contents, - Err(err) => { - eprintln!("Error: {err}",); - std::process::exit(1); - } - }; - - // Perform the regex replacement on the file's contents - let modified_contents = regex.replace(&file_contents, replacement); - let modified_contents_as_ref = modified_contents.as_ref(); - - // Write the modified contents back to the file, overwriting its previous contents - match fs::write(file_path, modified_contents_as_ref) { - Ok(_) => (), - Err(err) => { - eprintln!("Error: {err}",); - std::process::exit(1); - } - }; + // Read the file's contents into a string. + // Perform the regex replacement on the file's contents. + // Write the modified contents back to the file, overwriting its previous contents. + fs::write(file_path, &*regex.replace(&fs::read_to_string(file_path)?, replacement))?; } + Ok(()) } /// Entry point of the program. -/// Demonstrates using `wolfree_sed_in_place` function to perform in-place replacements on files in specific directories. -fn main() { - wolfree_sed_in_place( - "./docusaurus/build/input/", - "</head><body>", - include_str!("include_str.html"), - ); +/// Demonstrates using `sed` function to perform in-place replacements on files in specific directories. +fn main() -> Result<(), Box<dyn error::Error>> { + sed("./docusaurus/static/input/", "</head><body>", include_str!("include_str.html"))?; - wolfree_sed_in_place( - "./docusaurus/build/_next/static/chunks/", + sed( + "./docusaurus/static/_next/static/chunks/", r"try(.{0,100}?)generateEncodedJSONFromValue(.*?)unescapeForUrl(.*?)catch(.*?)\{}", - include_str!("include_str.tsx"), - ); + include_str!("include_str.js") + )?; // console error: - // _app-daabd76ef4fe402d.js:5 // WebSocket connection to 'wss://localhost/n/v1/api/fetcher/results' failed: - // startWebsocket @ _app-daabd76ef4fe402d.js:5 - // send @ _app-daabd76ef4fe402d.js:5 - // sendMessage @ 1695-ae743311a23f8eb5.js:1 - // newQuery @ 1695-ae743311a23f8eb5.js:78 - // newQuery @ 1695-ae743311a23f8eb5.js:78 // fix: - // Override the hostname in the minified JavaScript source code. - wolfree_sed_in_place( - "./docusaurus/build/_next/static/chunks/pages/", + // override the hostname + sed( + "./docusaurus/static/_next/static/chunks/pages/", "window.location.hostname", - "'www.wolframalpha.com'", - ); + "'www.wolframalpha.com'" + )?; + + Ok(()) } // regex101: build, test, and debug regex diff --git a/typescript/.dockerignore b/typescript/.dockerignore new file mode 100644 index 0000000..ecec047 --- /dev/null +++ b/typescript/.dockerignore @@ -0,0 +1,24 @@ +# Dependencies +/node_modules + +# Production +/build + +# Generated files +.docusaurus +.cache-loader + +# Misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +package-lock.json + +# SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/typescript/.gitignore b/typescript/.gitignore new file mode 100644 index 0000000..ecec047 --- /dev/null +++ b/typescript/.gitignore @@ -0,0 +1,24 @@ +# Dependencies +/node_modules + +# Production +/build + +# Generated files +.docusaurus +.cache-loader + +# Misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +package-lock.json + +# SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/typescript/package.json b/typescript/package.json new file mode 100644 index 0000000..36e9180 --- /dev/null +++ b/typescript/package.json @@ -0,0 +1,7 @@ +{ + "devDependencies": { + "@types/dompurify": "^3.0.2", + "@types/jquery": "^3.5.19", + "typescript": "^5.2.2" + } +} diff --git a/typescript/src/AjaxResponse.ts b/typescript/src/AjaxResponse.ts new file mode 100644 index 0000000..8b578a8 --- /dev/null +++ b/typescript/src/AjaxResponse.ts @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +import type Pod from "./Pod.js"; + +export default AjaxResponse; + +type AjaxResponse = Readonly<{ + queryresult?: { + pods?: Pod[]; + }; +}>; diff --git a/typescript/src/AjaxSettings.ts b/typescript/src/AjaxSettings.ts new file mode 100644 index 0000000..b5b4cf4 --- /dev/null +++ b/typescript/src/AjaxSettings.ts @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +import AppID from "./AppID.js"; +import EntrypointParameter from "./EntrypointParameter.js"; + +export default AjaxSettings; + +type AjaxSettings = Readonly<{ + url: "https://api.wolframalpha.com/v2/query"; + dataType: "jsonp"; + traditional: true; + data: Readonly< + EntrypointParameter & { + appid: AppID; + output: "json"; + reinterpret: true; + podtimeout: 30; + scantimeout: 30; + parsetimeout: 30; + totaltimeout: 30; + formattimeout: 30; + } + >; +}>; + +// Wolfram|Alpha Full Results API Reference +// https://products.wolframalpha.com/api/documentation + +// jQuery.ajax() | jQuery API Documentation +// https://api.jquery.com/jQuery.ajax/ diff --git a/typescript/src/AppID.ts b/typescript/src/AppID.ts new file mode 100644 index 0000000..af4edb2 --- /dev/null +++ b/typescript/src/AppID.ts @@ -0,0 +1,5 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +export default AppID; + +type AppID = "H9V325-HTALUWHKGK" | "AKJTJT-LR5LL8WTG6" | "LKY83U-XW6ATU9URU"; diff --git a/typescript/src/EntrypointParameter.ts b/typescript/src/EntrypointParameter.ts new file mode 100644 index 0000000..f78f1fc --- /dev/null +++ b/typescript/src/EntrypointParameter.ts @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +export default EntrypointParameter; + +type EntrypointParameter = Readonly<{ + input: string; + i2d?: true; + podstate: Readonly< + ["Step-by-step solution", "Step-by-step", "Show all steps", string?] + >; +}>; diff --git a/typescript/src/Pod.ts b/typescript/src/Pod.ts new file mode 100644 index 0000000..169ff5a --- /dev/null +++ b/typescript/src/Pod.ts @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +import type State from "./State.js"; +import type SubPod from "./SubPod.js"; + +export default Pod; + +type Pod = Readonly<{ + title?: string; + states?: State[]; + subpods?: SubPod[]; +}>; diff --git a/typescript/src/State.ts b/typescript/src/State.ts new file mode 100644 index 0000000..e3bb35e --- /dev/null +++ b/typescript/src/State.ts @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +export default State; + +type State = Readonly<{ + value?: string; + states?: { + name?: string; + }[]; +}>; diff --git a/typescript/src/SubPod.ts b/typescript/src/SubPod.ts new file mode 100644 index 0000000..1e26a87 --- /dev/null +++ b/typescript/src/SubPod.ts @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +export default SubPod; + +type SubPod = Readonly<{ + img?: { + src?: string; + alt?: string; + }; + plaintext?: string; +}>; diff --git a/typescript/src/entrypoint.ts b/typescript/src/entrypoint.ts new file mode 100644 index 0000000..e939d92 --- /dev/null +++ b/typescript/src/entrypoint.ts @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +import type EntrypointParameter from "./EntrypointParameter.js"; +import getAjaxResponse from "./getAjaxResponse.js"; +import getAjaxSettings from "./getAjaxSettings.js"; +import getNewHTML from "./getNewHTML.js"; +import listenToChangeEvent from "./listenToChangeEvent.js"; +import placeholder from "./placeholder.js"; +import reRenderComponent from "./reRenderComponent.js"; +import setContentEditable from "./setContentEditable.js"; +import typescriptExhaustive from "./typescriptExhaustive.js"; + +export default async ( + EntrypointParameter: EntrypointParameter +): Promise<void> => { + try { + Object.freeze(EntrypointParameter); + typescriptExhaustive(EntrypointParameter); + + window.scroll(0, 0); + reRenderComponent(placeholder); + + const AjaxSettings = getAjaxSettings(EntrypointParameter); + const AjaxResponse = await getAjaxResponse(AjaxSettings); + const newHTML = getNewHTML(AjaxSettings, AjaxResponse); + reRenderComponent(newHTML); + + listenToChangeEvent(EntrypointParameter); + setContentEditable(); + } catch (error) { + console.warn({ error }); + } +}; diff --git a/typescript/src/getAjaxResponse.ts b/typescript/src/getAjaxResponse.ts new file mode 100644 index 0000000..1459114 --- /dev/null +++ b/typescript/src/getAjaxResponse.ts @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +import AjaxResponse from "./AjaxResponse.js"; +import type AjaxSettings from "./AjaxSettings.js"; + +export default async (AjaxSettings: AjaxSettings): Promise<AjaxResponse> => { + try { + Object.freeze(AjaxSettings); + + // npm i @types/jquery + return Object.freeze(await jQuery.ajax(AjaxSettings)); + } catch (error) { + console.warn({ error }); + return {}; + } +}; diff --git a/typescript/src/getAjaxSettings.ts b/typescript/src/getAjaxSettings.ts new file mode 100644 index 0000000..5899637 --- /dev/null +++ b/typescript/src/getAjaxSettings.ts @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +import AjaxSettings from "./AjaxSettings.js"; +import EntrypointParameter from "./EntrypointParameter.js"; +import getAppID from "./getAppID.js"; + +export default (EntrypointParameter: EntrypointParameter): AjaxSettings => + Object.freeze({ + url: "https://api.wolframalpha.com/v2/query", + dataType: "jsonp", + traditional: true, + data: Object.freeze({ + ...EntrypointParameter, + appid: getAppID(), + output: "json", + reinterpret: true, + podtimeout: 30, + scantimeout: 30, + parsetimeout: 30, + totaltimeout: 30, + formattimeout: 30, + }), + }); diff --git a/typescript/src/getAppID.ts b/typescript/src/getAppID.ts new file mode 100644 index 0000000..eed7e1b --- /dev/null +++ b/typescript/src/getAppID.ts @@ -0,0 +1,67 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +import AppID from "./AppID.js"; +import typescriptNever from "./typescriptNever.js"; + +/** + * To generate a new AppID, please follow these steps: + * + * 1. Open Tor Browser and go to: + * https://products.wolframalpha.com/api/ + * 2. Click the orange "Get API Access" button. + * Tor Browser will redirect you to: + * https://account.wolfram.com/login/oauth2/sign-in + * 3. Click the red "Create one" hyperlink to create a new Wolfram ID. + * Tor Browser will redirect you to: + * https://account.wolfram.com/login/create + * 4. Fill out the form with random alphanumeric characters. + * 5. Click the red "Create Wolfram ID" button. + * Tor Browser will redirect you to: + * https://developer.wolframalpha.com/portal/myapps/index.html + * 6. Click the orange "Sign up to get your first AppID" button. + * 7. Fill out the form with random alphanumeric characters. + * 8. Click the orange "Sign up" button. + * 9. Click the orange "Get an AppID" button. + * 10. Fill out the form with random alphanumeric characters. + * 11. Click the orange "Get AppID" button. + */ +const appIDArray: Readonly<AppID[]> = Object.freeze([ + "H9V325-HTALUWHKGK", + "AKJTJT-LR5LL8WTG6", + "LKY83U-XW6ATU9URU", +]); + +console.assert(appIDArray.length > 0); + +appIDArray.forEach((appID) => { + console.assert(appID.length === 17); + console.assert(/[0-9A-Z]{6}-[0-9A-Z]{10}/.test(appID)); +}); + +export default (): AppID => { + const random = appIDArray[getRandomInt() % appIDArray.length]; + + if (typeof random === "string") { + return random; + } else if (random === undefined) { + console.warn({ random }); + } else { + typescriptNever(random); + } + + return "H9V325-HTALUWHKGK"; +}; + +const getRandomInt = (): number => { + const random = crypto.getRandomValues(new Uint32Array(1))[0]; + + if (typeof random === "number") { + return random; + } else if (random === undefined) { + console.warn({ random }); + } else { + typescriptNever(random); + } + + return 0; +}; diff --git a/typescript/src/getNewHTML.ts b/typescript/src/getNewHTML.ts new file mode 100644 index 0000000..f5d2070 --- /dev/null +++ b/typescript/src/getNewHTML.ts @@ -0,0 +1,199 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +import type AjaxResponse from "./AjaxResponse.js"; +import type AjaxSettings from "./AjaxSettings.js"; +import type Pod from "./Pod.js"; +import PodsClassName from "./podsClassName.js"; +import type State from "./State.js"; +import type SubPod from "./SubPod.js"; + +export default ( + AjaxSettings: AjaxSettings, + AjaxResponse: AjaxResponse +): string => + ` + <div class="${PodsClassName}"> + <div> + <div> + <section> + ${ + // Wolfram Alpha does have some limitations when it comes to processing certain types of input. + // When "input" is an empty string, + // the "pods" property will not be present in the "queryresult" object. + // To see an example of an empty input string, + // visit the following URL: + // https://www.wolframalpha.com/input?i= + Object.freeze(AjaxResponse) === undefined + ? (console.warn({ AjaxResponse }), "") + : AjaxResponse.queryresult === undefined + ? (console.warn({ AjaxResponse }), "") + : AjaxResponse.queryresult.pods === undefined + ? "" // console.warn + : AjaxResponse.queryresult.pods.map(buildPod).join("") + } + <section> + <div> + <h2> + Technical information + </h2> + </div> + <div> </div> + <div> + <div> + <div> + <details> + <div> + If you have programming knowledge, feel free to explore the technical information provided below: + </div> + <textarea name="technical-information">${ + Object.freeze(AjaxSettings) === undefined + ? (console.warn({ AjaxSettings }), "") + : Object.freeze(AjaxResponse) === undefined + ? (console.warn({ AjaxResponse }), "") + : escapeHTML(tryStringify(AjaxSettings, AjaxResponse)) + }</textarea> + </details> + </div> + </div> + </div> + <div> </div> + </section> + </section> + </div> + </div> + </div> + `; + +const buildPod = (pod: Pod): string => + ` + <section> + <div> + ${ + pod.title === undefined + ? (console.warn({ pod }), "") + : `<h2>${escapeHTML(pod.title)}</h2>` + } + ${ + // In most cases, pods are stateless and do not have specific states. + // As a result, the "states" property of "pod" is typically undefined. + pod.states === undefined + ? "" // console.warn + : pod.states.map(buildSelectElement).join("") + } + </div> + <div> </div> + ${ + pod.subpods === undefined + ? (console.warn({ pod }), "") + : pod.subpods.map(buildSubpod).join("") + } + </section> + `; + +const buildSelectElement = (state: State): string => + // Although it is possible to handle the scenario where the "states" property is undefined, + // implementing the necessary logic may result in a cluttered user interface. + // This challenge is primarily due to my limited expertise in front-end design. + // Consequently, the current implementation of the parsing logic is still insufficient in addressing the situation where the "states" property is undefined. + state.states === undefined + ? "" // console.warn + : ` + <select name="pod-states"> + ${ + state.value === undefined + ? (console.warn({ state }), "") + : ` + <option>${escapeHTML(state.value)}</option> + ` + } + ${state.states.map(buildOption).join("")} + </select> + `; + +const buildOption = (state: { name?: string }): string => + state.name === undefined + ? (console.warn({ state }), "") + : ` + <option>${escapeHTML(state.name)}</option> + `; + +const buildSubpod = (subpod: SubPod): string => + ` + ${ + subpod.img === undefined + ? (console.warn({ subpod }), "") + : ` + <div> + <div> + <img + src="${escapeHTML( + subpod.img.src === undefined + ? (console.warn({ subpod }), "") + : subpod.img.src + )}" + alt="${escapeHTML( + subpod.img.alt === undefined + ? (console.warn({ subpod }), "") + : subpod.img.alt + )}" + > + </div> + </div> + ` + } + ${ + subpod.plaintext === undefined + ? (console.warn({ subpod }), "") + : ` + <div style="font-family: monospace; overflow: auto;"> + <div> + <div> + <details> + <summary style="direction: rtl;"></summary> + <div> + <pre>${escapeHTML(subpod.plaintext)}</pre> + </div> + <br /> + </details> + </div> + </div> + </div> + ` + } + `; + +const tryStringify = ( + AjaxSettings: AjaxSettings, + AjaxResponse: AjaxResponse +): string => { + try { + return JSON.stringify( + { + document, + AjaxSettings, + AjaxResponse, + }, + null, + 4 + ); + } catch (error) { + console.warn({ error }); + return error instanceof TypeError ? error.message + "\n" + error.stack : ""; + // JSON.stringify() - JavaScript | MDN + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#exceptions + } +}; + +const escapeHTML = (unsafeHTML: string): string => + unsafeHTML + .replace(/&/g, "&") + .replace(/</g, "<") + .replace(/>/g, ">") + .replace(/"/g, """) + .replace(/'/g, "'"); + +// Can I escape HTML special chars in JavaScript? - Stack Overflow +// https://stackoverflow.com/questions/6234773/can-i-escape-html-special-chars-in-javascript + +// test case: +// https://www.wolframalpha.com/input?i=solve+%7By%27%28x%29+%3D+-2+y%2C+y%280%29%3D1%7D+from+0+to+10+using+r+k+f+algorithm diff --git a/typescript/src/listenToChangeEvent.ts b/typescript/src/listenToChangeEvent.ts new file mode 100644 index 0000000..7f091a9 --- /dev/null +++ b/typescript/src/listenToChangeEvent.ts @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +import type EntrypointParameter from "./EntrypointParameter.js"; +import entrypoint from "./entrypoint.js"; +import podsClassName from "./podsClassName.js"; +import typescriptNever from "./typescriptNever.js"; + +export default (EntrypointParameter: EntrypointParameter): void => { + try { + Object.freeze(EntrypointParameter); + + Array.from( + document.querySelectorAll( + `html > body > div#__next > div > main > main > div.${podsClassName} > div > div > section > section > div:is(:first-child) > select` + ) + ) + .filter((element: Element): boolean => { + if (element instanceof HTMLSelectElement) { + return true; + } else if (element instanceof Element) { + console.warn({ element }); + } else { + typescriptNever(element); + } + + return false; + }) + .map((element: Element): void => { + element.addEventListener("change", async (event): Promise<void> => { + if (event.target instanceof HTMLSelectElement) { + await entrypoint({ + ...EntrypointParameter, + podstate: [ + "Step-by-step solution", + "Step-by-step", + "Show all steps", + event.target.value, + ], + }); + } else if (event.target instanceof EventTarget) { + console.warn({ event }); + } else if (event.target === null) { + console.warn({ event }); + } else { + typescriptNever(event.target); + } + }); + }); + } catch (error) { + console.warn({ error }); + } +}; diff --git a/typescript/src/onload.ts b/typescript/src/onload.ts new file mode 100644 index 0000000..6c864ad --- /dev/null +++ b/typescript/src/onload.ts @@ -0,0 +1,94 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +import typescriptNever from "./typescriptNever.js"; + +export default addEventListener( + "load", + (): void => ( + setTimeout( + (): void => + console.assert( + Array.from( + document.querySelectorAll( + // To select the form element, we use different selectors depending on the input mode. + // If the input mode is "natural language", the form is a direct child of the section element, so we use the selector "section > form". + // However, if the input mode is "math input", the form is a direct child of the div element, so we use the selector "div > form". + ` + html > body > #__next > div > main > main > div > div > section > form > div > div > input, + html > body > #__next > div > main > main > div > div > div form > div > div > input + ` + ) + ) + .filter((element: Element): boolean => { + if (element instanceof HTMLInputElement) { + return true; + } else if (element instanceof Element) { + console.warn({ element }); + } else { + typescriptNever(element); + } + + return false; + }) + .map((element: Element): void => { + if (element instanceof HTMLElement) { + element.focus(); + } else if (element instanceof Element) { + console.warn({ element }); + } else { + typescriptNever(element); + } + }).length === 1 + ), + 1000 + ), + [ + (): void => + Array.from( + document.querySelectorAll( + // The positioning of the ul element is dynamically adjusted to ensure it adapts well to different viewport widths. + // To specifically target the ul element when the viewport width is larger, we use the selector "div:is(:first-child) > ul". + // Conversely, to target the ul element when the viewport width is smaller, we use the selector "div:is(:first-child) + ul". + ` + html > body > #__next > div > main > main > div > div > div > section > section > div:is(:first-child) > ul > li, + html > body > #__next > div > main > main > div > div > div > section > section > div:is(:first-child) + ul > li + ` + ) + ) + .filter((element: Element): boolean => { + if (element instanceof HTMLLIElement) { + return true; + } else if (element instanceof Element) { + console.warn({ element }); + } else { + typescriptNever(element); + } + + return false; + }) + .forEach((element: Element): void => { + if (element instanceof HTMLElement) { + if (element.innerHTML.includes("Step-by-step")) { + element.style.display = "none"; + } else { + } + } else if (element instanceof Element) { + console.warn({ element }); + } else { + typescriptNever(element); + } + }), + (): void => { + document.title = document.title.replace( + "- Wolfram|Alpha", + "- Free Wolfram|Alpha Step-by-step Solution - Wolfree" + ); + }, + ].map( + (callback: () => void): void => ( + setInterval(callback, 2000), addEventListener("click", callback) + ) + ), + scroll(0, 0) + ) +); diff --git a/typescript/src/placeholder.ts b/typescript/src/placeholder.ts new file mode 100644 index 0000000..083226c --- /dev/null +++ b/typescript/src/placeholder.ts @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +export default ` + <div class="wolfree-pods wolfree-placeholder"> + <div> + <div> + <div><div></div></div> + <div><div></div></div> + <div><div></div></div> + </div> + </div> + </div> +`; diff --git a/typescript/src/podsClassName.ts b/typescript/src/podsClassName.ts new file mode 100644 index 0000000..fea9f4c --- /dev/null +++ b/typescript/src/podsClassName.ts @@ -0,0 +1,3 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +export default "wolfree-pods"; diff --git a/typescript/src/reRenderComponent.ts b/typescript/src/reRenderComponent.ts new file mode 100644 index 0000000..f73fd1a --- /dev/null +++ b/typescript/src/reRenderComponent.ts @@ -0,0 +1,70 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +import podsClassName from "./podsClassName.js"; +import typescriptNever from "./typescriptNever.js"; + +export default (newHTML: string): void => { + try { + console.assert( + Array.from( + document.querySelectorAll( + `html > body > #__next > div > main > main > div.${podsClassName}` + ) + ) + .filter((element: Element): boolean => { + if (element instanceof HTMLDivElement) { + return true; + } else if (element instanceof Element) { + console.warn({ element }); + } else { + typescriptNever(element); + } + + return false; + }) + .map((element: Element): void => { + if (element instanceof Element) { + element.remove(); + } else { + typescriptNever(element); + } + }).length <= 1 + ); + + console.assert( + Array.from( + document.querySelectorAll( + "html > body > #__next > div > main > main > div:nth-of-type(1)" + ) + ) + .filter((element: Element): boolean => { + if (element instanceof HTMLDivElement) { + return true; + } else if (element instanceof Element) { + console.warn({ element }); + } else if (element === null) { + console.warn({ element }); + } else { + typescriptNever(element); + } + + return false; + }) + .map((element: Element): void => { + if (element instanceof Element) { + element.insertAdjacentHTML( + "afterend", + // npm i @types/dompurify + globalThis.DOMPurify.sanitize(newHTML) + ); + } else if (element === null) { + console.warn({ element }); + } else { + typescriptNever(element); + } + }).length === 1 + ); + } catch (error) { + console.warn({ error }); + } +}; diff --git a/typescript/src/setContentEditable.ts b/typescript/src/setContentEditable.ts new file mode 100644 index 0000000..ebfe423 --- /dev/null +++ b/typescript/src/setContentEditable.ts @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +import podsClassName from "./podsClassName.js"; +import typescriptNever from "./typescriptNever.js"; + +export default (): void => { + try { + Array.from( + document.querySelectorAll( + `html > body > div#__next > div > main > main > div.${podsClassName} > div > div > section > section > div > div > div > details > div` + ) + ) + .filter((element: Element): boolean => { + if (element instanceof HTMLDivElement) { + return true; + } else if (element instanceof Element) { + console.warn({ element }); + } else { + typescriptNever(element); + } + + return false; + }) + .map((element: Element): void => { + if (element instanceof Element) { + element.setAttribute("contenteditable", ""); + } else { + typescriptNever(element); + } + }); + } catch (error) { + console.warn({ error }); + } +}; diff --git a/typescript/src/typescriptExhaustive.ts b/typescript/src/typescriptExhaustive.ts new file mode 100644 index 0000000..656a419 --- /dev/null +++ b/typescript/src/typescriptExhaustive.ts @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +import type EntrypointParameter from "./EntrypointParameter.js"; +import typescriptNever from "./typescriptNever.js"; + +export default (EntrypointParameter: EntrypointParameter): void => { + Object.freeze(EntrypointParameter); + + if (typeof EntrypointParameter.input !== "string") { + typescriptNever(EntrypointParameter.input); + } + + if (EntrypointParameter.i2d !== true) { + if (EntrypointParameter.i2d !== undefined) { + typescriptNever(EntrypointParameter.i2d); + } + } + + if (!(EntrypointParameter.podstate instanceof Array)) { + typescriptNever(EntrypointParameter.podstate); + } + + if (EntrypointParameter.podstate.length !== 3) { + if (EntrypointParameter.podstate.length !== 4) { + typescriptNever(EntrypointParameter.podstate.length); + } + } + + if (EntrypointParameter.podstate[0] !== "Step-by-step solution") { + typescriptNever(EntrypointParameter.podstate[0]); + } + + if (EntrypointParameter.podstate[1] !== "Step-by-step") { + typescriptNever(EntrypointParameter.podstate[1]); + } + + if (EntrypointParameter.podstate[2] !== "Show all steps") { + typescriptNever(EntrypointParameter.podstate[2]); + } + + if (typeof EntrypointParameter.podstate[3] !== "string") { + if (typeof EntrypointParameter.podstate[3] !== "undefined") { + typescriptNever(EntrypointParameter.podstate[3]); + } + } +}; diff --git a/typescript/src/typescriptNever.ts b/typescript/src/typescriptNever.ts new file mode 100644 index 0000000..42becd5 --- /dev/null +++ b/typescript/src/typescriptNever.ts @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +export default (typescriptNeverValue: never): never => { + console.warn({ typescriptNeverValue }); + + return typescriptNeverValue; +}; + +// How do I check that a switch block is exhaustive in TypeScript? - Stack Overflow +// https://stackoverflow.com/questions/39419170/how-do-i-check-that-a-switch-block-is-exhaustive-in-typescript diff --git a/typescript/tsconfig.json b/typescript/tsconfig.json new file mode 100644 index 0000000..71ac60a --- /dev/null +++ b/typescript/tsconfig.json @@ -0,0 +1,34 @@ +{ + "compilerOptions": { + "strict": true, + "allowUnusedLabels": false, + "allowUnreachableCode": false, + "exactOptionalPropertyTypes": true, + "noFallthroughCasesInSwitch": true, + "noImplicitOverride": true, + "noImplicitReturns": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + + "isolatedModules": true, + + "checkJs": true, + + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + + "target": "ES6", + "outDir": "../docusaurus/static/ajax/libs/wolfree/2023.8.31/js/" + }, + "$schema": "https://json.schemastore.org/tsconfig", + "display": "Strictest", + "_version": "2.0.0" +} + +// GitHub - tsconfig/bases: Hosts TSConfigs to extend in a TypeScript app, tuned to a particular runtime environment +// https://github.com/tsconfig/bases/blob/main/bases/strictest.json + +/* SPDX-License-Identifier: AGPL-3.0-or-later */ |