diff options
author | name <email@example.com> | 2023-08-11 07:09:24 +0200 |
---|---|---|
committer | name <email@example.com> | 2023-08-11 07:09:24 +0200 |
commit | b6ebc5f88ffe9fb442238f160879ad47dd713d11 (patch) | |
tree | cbceadf88ea0fc58299b1efb6b43a0e8eeaf50bf | |
download | wolfree-dockerfile-b6ebc5f88ffe9fb442238f160879ad47dd713d11.tar wolfree-dockerfile-b6ebc5f88ffe9fb442238f160879ad47dd713d11.tar.gz wolfree-dockerfile-b6ebc5f88ffe9fb442238f160879ad47dd713d11.tar.bz2 wolfree-dockerfile-b6ebc5f88ffe9fb442238f160879ad47dd713d11.tar.lz wolfree-dockerfile-b6ebc5f88ffe9fb442238f160879ad47dd713d11.tar.xz wolfree-dockerfile-b6ebc5f88ffe9fb442238f160879ad47dd713d11.tar.zst wolfree-dockerfile-b6ebc5f88ffe9fb442238f160879ad47dd713d11.zip |
60 files changed, 3029 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ff86675 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,171 @@ +# 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 + +WORKDIR /app/ + +# Install all dependencies. + +RUN \ + apk add \ + -- \ + wget \ + npm \ + gcc \ + rustup \ + ; + +RUN \ + rustup-init -y + +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. + +COPY \ + ./docusaurus/ \ + ./docusaurus/ + +RUN \ + npm run \ + --prefix ./docusaurus/ \ + -- \ + build \ + ; + +# Lint the source code and run the Rust program. +# The Rust program customizes the static pages. + +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 -- ; + +# 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 @@ -0,0 +1,235 @@ +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. + + 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. + + 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 +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 + + 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. + +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 + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://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/>. diff --git a/README.md b/README.md new file mode 100644 index 0000000..6d20724 --- /dev/null +++ b/README.md @@ -0,0 +1,137 @@ +# Wolfree Dockerfile: Self-Host a Mirror Site of Wolfree Instances + +This repository provides a Dockerfile and instructions for self-hosting a mirror site of Wolfree instances. + +Follow the instructions below to control Docker through terminal emulators. Docker will automatically execute the static site generator and run the web server. + +## Prerequisites + +Before getting started, make sure you have the following prerequisites installed on your computer: + +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. **Docker**: If you don't have Docker installed, download it from [docker.com](https://www.docker.com/). + +## Instructions + +Follow the steps below to self-host a mirror site of Wolfree instances: + +1. **Build the Docker Image**: + + 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 + 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 + ``` + +2. **Run the Docker Container**: + + Execute the following command in your terminal emulator to run the Docker container: + + ```shell + docker run -p 80:80 wolfree + ``` + +3. **Wait for Success Messages**: + + Wait until Docker outputs success messages similar to the following: + + ```shell + > docusaurus@0.0.0 serve + > docusaurus serve --port 80 --host localhost + + [SUCCESS] Serving "build" directory at: http://localhost:80/ + ``` + +4. **Access Your Mirror Site**: + + 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. + +Congratulations! You have successfully self-hosted a mirror site of Wolfree instances. + +## Local Development + +If you wish to contribute to the development of Wolfree instances, follow these steps: + +1. **Prepare the Development Environment**: + + Install Git and Docker on your local machine. You can download them from the following official websites: + + - [Git Official Website](https://git-scm.com/) + - [Docker Official Website](https://www.docker.com/) + +2. **Clone the Repository**: + + Run one of the following commands to clone the repository from one of the Gitea and Forgejo servers: + + ```shell + 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 + git clone https://next.forgejo.org/wolfree/wolfree-dockerfile.git + git clone https://git.kiwifarms.net/wolfree/wolfree-dockerfile.git + git clone http://it7otdanqu7ktntxzm427cba6i53w6wlanlh23v5i3siqmos47pzhvyd.onion/wolfree/wolfree-dockerfile.git + ``` + +3. **Run the Docker Container**: + + After cloning the repository, navigate to the project directory: + + ```shell + cd wolfree-dockerfile + ``` + + Then, run the following commands to build the image and run the container: + + ```shell + docker build --tag wolfree --progress=plain . + docker run --publish 80:80 --rm wolfree + ``` + +## Configuring Wolfree Instances for LibRedirect + +To configure Wolfree instances to integrate with LibRedirect, follow these steps: + +1. Clone the Git repository and open the Dockerfile in a text editor. + +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: + + ```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 -- ; + ``` + +3. Build a Docker image and run a container. + +## Helpful Resources for New Developers + +If you're new to web development, here are some helpful websites and tools to get you started: + +- [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. + +- [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. + +- [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. + +- [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. + +- [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. + +- [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. + +- [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. + +These resources will help you get started and enhance your skills as a web developer. Happy learning! + +## License + +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. diff --git a/docusaurus/.dockerignore b/docusaurus/.dockerignore new file mode 100644 index 0000000..019391a --- /dev/null +++ b/docusaurus/.dockerignore @@ -0,0 +1,26 @@ +# 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 + +# 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 diff --git a/docusaurus/.gitignore b/docusaurus/.gitignore new file mode 100644 index 0000000..019391a --- /dev/null +++ b/docusaurus/.gitignore @@ -0,0 +1,26 @@ +# 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 + +# 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 diff --git a/docusaurus/babel.config.js b/docusaurus/babel.config.js new file mode 100644 index 0000000..e4fb2e2 --- /dev/null +++ b/docusaurus/babel.config.js @@ -0,0 +1,12 @@ +/** + * @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 + +module.exports = { + presets: [require.resolve("@docusaurus/core/lib/babel/preset")], +}; diff --git a/docusaurus/docs/acknowledgment.mdx b/docusaurus/docs/acknowledgment.mdx new file mode 100644 index 0000000..e711148 --- /dev/null +++ b/docusaurus/docs/acknowledgment.mdx @@ -0,0 +1,87 @@ +# 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. + +## The Fediverse + +Our community distributes 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. + +## ForgeFed + +Our community hosts 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. + +## Copyleft + +Our community releases 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. + +## 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. + +## The Internet Archive + +Our community archives 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/) + +## 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. + +## 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. + +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 --> diff --git a/docusaurus/docs/community.mdx b/docusaurus/docs/community.mdx new file mode 100644 index 0000000..aebf053 --- /dev/null +++ b/docusaurus/docs/community.mdx @@ -0,0 +1,41 @@ +# Community + +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: + +- [Mastodon](https://joinmastodon.org/) +- [Pleroma](https://pleroma.social/) +- [Gitea](https://about.gitea.com/) +- [Forgejo](https://forgejo.org/) + +::: + +## 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 +3. https://kiwifarms.cc/wolfree +4. https://spinster.xyz/@wolfree +5. https://freespeechextremist.com/wolfree + +## Gitea and Forgejo + +Feel free to contribute and [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 + +## 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! + +<!-- SPDX-License-Identifier: AGPL-3.0-or-later --> diff --git a/docusaurus/docs/dmca.mdx b/docusaurus/docs/dmca.mdx new file mode 100644 index 0000000..4bffc1e --- /dev/null +++ b/docusaurus/docs/dmca.mdx @@ -0,0 +1,12 @@ +# 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 new file mode 100644 index 0000000..487c0b8 --- /dev/null +++ b/docusaurus/docs/index.mdx @@ -0,0 +1,109 @@ +--- +slug: / +title: Home page +--- + +# <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. + +import FormCTA from "../src/components/FormCTA.tsx"; +import FormQuickStart from "../src/components/FormQuickStart.tsx"; +import ButtonLink from "../src/components/ButtonLink.tsx"; + +<FormCTA autoFocus={true} /> + +<br /> +<br /> + +## How To Use Wolfree + +<FormQuickStart /> + +<br /> +<br /> + +## Mirror Sites + +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. + +<p> + <ButtonLink to="./mirror" text="Access Mirror Sites" /> +</p> + +<br /> +<br /> + +## Source Code + +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. ❤️ + +<p> + <ButtonLink to="./source" text="Explore Source Code" /> +</p> + +<br /> +<br /> + +## 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. +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**. 🎉 + +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: + +> "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 /> + +## What You'll Get with Wolfree + +By using Wolfree, you'll get **free** access to the full potential 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. + +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! + +<FormCTA /> + +<br /> +<br /> + +<!-- + 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/ +--> + +<!-- + Diversity, equity, and inclusion - Wikipedia + https://en.wikipedia.org/wiki/Diversity,_equity,_and_inclusion +--> + +<!-- + 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 new file mode 100644 index 0000000..8af5f77 --- /dev/null +++ b/docusaurus/docs/mirror.mdx @@ -0,0 +1,50 @@ +--- +title: Mirror site +--- + +# 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. + +1. https://wolfree.chickenkiller.com/ +2. https://wolfree.crabdance.com/ +3. https://wolfree.gitlab.io/ +4. https://wolfree.glitch.me/ +5. https://wolfree.ignorelist.com/ +6. https://wolfree.jumpingcrab.com/ +7. https://wolfree.my.to/ +8. https://wolfree.netlify.app/ +9. https://wolfree.on.fleek.co/ +10. https://wolfree.onrender.com/ +11. https://wolfree.pages.dev/ +12. https://wolfree.privatedns.org/ +13. https://wolfree.strangled.net/ +14. https://wolfree.twilightparadox.com/ +15. https://wolfree.uk.to/ +16. https://wolfree.us.to/ +17. https://wolfreealpha.chickenkiller.com/ +18. https://wolfreealpha.crabdance.com/ +19. https://wolfreealpha.gitlab.io/ +20. https://wolfreealpha.glitch.me/ +21. https://wolfreealpha.ignorelist.com/ +22. https://wolfreealpha.jumpingcrab.com/ +23. https://wolfreealpha.my.to/ +24. https://wolfreealpha.netlify.app/ +25. https://wolfreealpha.on.fleek.co/ +26. https://wolfreealpha.onrender.com/ +27. https://wolfreealpha.pages.dev/ +28. https://wolfreealpha.privatedns.org/ +29. https://wolfreealpha.strangled.net/ +30. https://wolfreealpha.twilightparadox.com/ +31. https://wolfreealpha.uk.to/ +32. https://wolfreealpha.us.to/ + +:::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. + +If you have programming knowledge, you can deserialize the [instances.json](pathname://../instances.json) file. + +<!-- SPDX-License-Identifier: AGPL-3.0-or-later --> diff --git a/docusaurus/docs/source.mdx b/docusaurus/docs/source.mdx new file mode 100644 index 0000000..e9d0192 --- /dev/null +++ b/docusaurus/docs/source.mdx @@ -0,0 +1,32 @@ +--- +title: Source code +--- + +# Access and Download 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://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 + +## 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 + +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. +::: + +## License + +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. diff --git a/docusaurus/docusaurus.config.js b/docusaurus/docusaurus.config.js new file mode 100644 index 0000000..1cb19b7 --- /dev/null +++ b/docusaurus/docusaurus.config.js @@ -0,0 +1,102 @@ +/** + * @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/types').Config} */ +module.exports = { + title: "Wolfree - Free WolframAlpha step-by-step solution", + url: "http://example.com", + baseUrl: "/", + favicon: "data:,", + presets: [ + [ + "classic", + /** @type {import('@docusaurus/preset-classic').Options} */ + { + docs: { + sidebarPath: require.resolve("./sidebars.js"), + routeBasePath: "/", + breadcrumbs: false, + }, + blog: false, + pages: false, + theme: { + customCss: [require.resolve("./src/css/custom.css")], + }, + }, + ], + ], + /** @type {import('@docusaurus/preset-classic').ThemeConfig} */ + themeConfig: { + colorMode: { + disableSwitch: true, + }, + docs: { + sidebar: { + hideable: true, + }, + }, + navbar: { + hideOnScroll: true, + items: [ + { + to: "/", + label: "Wolfree", + position: "left", + }, + { + to: "pathname:///input/", + label: "Input", + position: "right", + target: "_self", + }, + { + to: "/mirror", + label: "Mirror", + position: "right", + }, + { + to: "/source", + label: "Source", + position: "right", + }, + ], + }, + footer: { + links: [ + { + label: "Home page", + href: "/", + }, + { + html: '<a class="footer__link-item" href="/input/">Input math problems</a>', + }, + { + label: "Mirror site", + href: "/mirror", + }, + { + label: "Source code", + href: "/source", + }, + { + label: "Community", + href: "/community", + }, + { + label: "Acknowledgment", + href: "/acknowledgment", + }, + { + label: "DMCA takedown", + href: "/dmca", + }, + ], + }, + }, +}; diff --git a/docusaurus/package.json b/docusaurus/package.json new file mode 100644 index 0000000..2e58a5e --- /dev/null +++ b/docusaurus/package.json @@ -0,0 +1,51 @@ +{ + "name": "docusaurus", + "version": "0.0.0", + "private": true, + "scripts": { + "docusaurus": "docusaurus", + "start": "docusaurus start", + "build": "docusaurus build", + "swizzle": "docusaurus swizzle", + "deploy": "docusaurus deploy", + "clear": "docusaurus clear", + "serve": "docusaurus serve", + "write-translations": "docusaurus write-translations", + "write-heading-ids": "docusaurus write-heading-ids", + "typecheck": "tsc" + }, + "dependencies": { + "@docusaurus/core": "2.4.1", + "@docusaurus/preset-classic": "2.4.1", + "@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", + "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", + "@tsconfig/docusaurus": "^1.0.5", + "typescript": "^4.7.4" + }, + "browserslist": { + "production": [ + ">0.5%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + }, + "engines": { + "node": ">=16.14" + } +} diff --git a/docusaurus/sidebars.js b/docusaurus/sidebars.js new file mode 100644 index 0000000..3a62009 --- /dev/null +++ b/docusaurus/sidebars.js @@ -0,0 +1,29 @@ +/** + * @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 new file mode 100644 index 0000000..12fc559 --- /dev/null +++ b/docusaurus/src/components/ButtonLink.tsx @@ -0,0 +1,27 @@ +/** + * @license + * SPDX-License-Identifier: AGPL-3.0-or-later + * This file is part of Wolfree. + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + */ + +import React from "react"; +import Link from "@docusaurus/Link"; +import { Button } from "@mui/material"; + +const ButtonLink = ({ to = String(), text = String() }) => ( + <Link to={to}> + <Button size="large" sx={{ textTransform: "capitalize" }}> + <strong>{text}</strong> + » + </Button> + </Link> +); + +export default ButtonLink; + +// Typography - MUI System +// https://mui.com/system/typography/ + +// Docusaurus Client API | Docusaurus +// https://docusaurus.io/docs/docusaurus-core#link diff --git a/docusaurus/src/components/FormCTA.tsx b/docusaurus/src/components/FormCTA.tsx new file mode 100644 index 0000000..1b5a81e --- /dev/null +++ b/docusaurus/src/components/FormCTA.tsx @@ -0,0 +1,23 @@ +/** + * @license + * SPDX-License-Identifier: AGPL-3.0-or-later + * This file is part of Wolfree. + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + */ + +import React from "react"; +import submitMathInputForm from "../functions/submitMathInputForm"; +import InputMathProblems from "./InputMathProblems"; +import ShowStepButton from "./ShowStepButton"; + +const FormCTA = ({ autoFocus = Boolean() }) => ( + <form onSubmit={submitMathInputForm}> + <p></p> + <InputMathProblems autoFocus={autoFocus} /> + <p></p> + <ShowStepButton /> + <p></p> + </form> +); + +export default FormCTA; diff --git a/docusaurus/src/components/FormQuickStart.tsx b/docusaurus/src/components/FormQuickStart.tsx new file mode 100644 index 0000000..60589fb --- /dev/null +++ b/docusaurus/src/components/FormQuickStart.tsx @@ -0,0 +1,35 @@ +/** + * @license + * SPDX-License-Identifier: AGPL-3.0-or-later + * This file is part of Wolfree. + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + */ + +import React from "react"; +import submitMathInputForm from "../functions/submitMathInputForm"; +import InputMathProblems from "./InputMathProblems"; +import ShowStepButton from "./ShowStepButton"; + +const FormQuickStart = () => ( + <form onSubmit={submitMathInputForm}> + <ol> + <li> + <p>Type your math problem in the text box.</p> + <InputMathProblems defaultValue="y'=y" /> + </li> + <li> + <p> + Click the "Show Steps" button. + </p> + <ShowStepButton /> + </li> + <li> + <p> + Explore the step-by-step solution provided. 🎉 + </p> + </li> + </ol> + </form> +); + +export default FormQuickStart; diff --git a/docusaurus/src/components/InputMathProblems.tsx b/docusaurus/src/components/InputMathProblems.tsx new file mode 100644 index 0000000..c7b49ce --- /dev/null +++ b/docusaurus/src/components/InputMathProblems.tsx @@ -0,0 +1,33 @@ +/** + * @license + * SPDX-License-Identifier: AGPL-3.0-or-later + * This file is part of Wolfree. + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + */ + +import React from "react"; +import TextField from "@mui/material/TextField"; +// TextField API - Material UI +// https://mui.com/material-ui/api/text-field/ + +const InputMathProblems = ({ + autoFocus = Boolean(), + defaultValue = String(), +}) => ( + <TextField + name="i" + type="search" + autoCapitalize="off" + autoComplete="off" + autoCorrect="off" + spellCheck="false" + inputProps={{ enterkeyhint: "go" }} + autoFocus={autoFocus} + label=" Input math problems" + variant="outlined" + fullWidth + defaultValue={defaultValue} + /> +); + +export default InputMathProblems; diff --git a/docusaurus/src/components/ShowStepButton.tsx b/docusaurus/src/components/ShowStepButton.tsx new file mode 100644 index 0000000..3ae7ba3 --- /dev/null +++ b/docusaurus/src/components/ShowStepButton.tsx @@ -0,0 +1,25 @@ +/** + * @license + * SPDX-License-Identifier: AGPL-3.0-or-later + * This file is part of Wolfree. + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + */ + +import React from "react"; +import { Button } from "@mui/material"; + +const ShowStepButton = () => ( + <Button + type="submit" + size="large" + variant="contained" + sx={{ textTransform: "capitalize" }} + > + Show Steps + </Button> +); + +export default ShowStepButton; + +// Typography - MUI System +// https://mui.com/system/typography/ diff --git a/docusaurus/src/css/custom.css b/docusaurus/src/css/custom.css new file mode 100644 index 0000000..a027863 --- /dev/null +++ b/docusaurus/src/css/custom.css @@ -0,0 +1,21 @@ +/** + * @license + * SPDX-License-Identifier: AGPL-3.0-or-later + * This file is part of Wolfree. + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + */ + +:root { + --ifm-menu-link-padding-vertical: calc(var(--ifm-menu-link-padding-horizontal) * 1.5); + --ifm-color-primary: blue; + --ifm-color-gray-900: var(--ifm-color-gray-900); + --ifm-color-secondary-contrast-foreground: var(--ifm-color-gray-900); +} + +.footer__link-item { + line-height: 3; +} + +.alert { + --ifm-link-color: unset; +}
\ No newline at end of file diff --git a/docusaurus/src/functions/submitMathInputForm.tsx b/docusaurus/src/functions/submitMathInputForm.tsx new file mode 100644 index 0000000..a90894e --- /dev/null +++ b/docusaurus/src/functions/submitMathInputForm.tsx @@ -0,0 +1,23 @@ +/** + * @license + * SPDX-License-Identifier: AGPL-3.0-or-later + * This file is part of Wolfree. + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + */ + +import { FormEventHandler } from "react"; + +const submitMathInputForm: FormEventHandler<HTMLFormElement> = (event) => { + event.preventDefault(); + const form = event.currentTarget; + const formData = new FormData(form); + + const i = formData.get("i") || ""; + if (i instanceof File) return; + + const url = new URL("/input/", window.location.href); + url.searchParams.set("i", i); + window.location.href = url.href; +}; + +export default submitMathInputForm; diff --git a/docusaurus/src/theme/Footer/InputPreloader.tsx b/docusaurus/src/theme/Footer/InputPreloader.tsx new file mode 100644 index 0000000..325f8a7 --- /dev/null +++ b/docusaurus/src/theme/Footer/InputPreloader.tsx @@ -0,0 +1,43 @@ +/** + * @license + * SPDX-License-Identifier: AGPL-3.0-or-later + * This file is part of Wolfree. + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + */ + +import React, { useEffect, useState } from "react"; + +const InputPreloader = () => { + const [showIframe, setShowIframe] = useState(false); + + useEffect(() => { + const handleIframeLoad = () => { + // Show the iframe after a 3000ms delay + const timerId = setTimeout(() => setShowIframe(true), 3000); + // Cleanup the timer when the component unmounts + return () => clearTimeout(timerId); + }; + + window.scroll(0, 0); + + window.addEventListener("load", handleIframeLoad); + + // Cleanup the event listener when the component unmounts + return () => window.removeEventListener("load", handleIframeLoad); + }, []); // Empty dependency array means the effect runs only once after initial render + + return ( + <> + {/* Use a descriptive title for accessibility */} + {showIframe && ( + <iframe + title="Input Page Preloader" + src="/input/" + style={{ display: "none" }} + /> + )} + </> + ); +}; + +export default InputPreloader; diff --git a/docusaurus/src/theme/Footer/index.tsx b/docusaurus/src/theme/Footer/index.tsx new file mode 100644 index 0000000..2edef40 --- /dev/null +++ b/docusaurus/src/theme/Footer/index.tsx @@ -0,0 +1,21 @@ +/** + * @license + * SPDX-License-Identifier: AGPL-3.0-or-later + * This file is part of Wolfree. + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + */ + +import React from "react"; +import Footer from "@theme-original/Footer"; +import InputPreloader from "./InputPreloader"; + +const FooterWrapper = (props: React.JSX.IntrinsicAttributes) => { + return ( + <> + <Footer {...props} /> + <InputPreloader /> + </> + ); +}; + +export default FooterWrapper; diff --git a/docusaurus/src/theme/NotFound/DDoSProtection.tsx b/docusaurus/src/theme/NotFound/DDoSProtection.tsx new file mode 100644 index 0000000..6cd8c04 --- /dev/null +++ b/docusaurus/src/theme/NotFound/DDoSProtection.tsx @@ -0,0 +1,34 @@ +/** + * @license + * SPDX-License-Identifier: AGPL-3.0-or-later + * This file is part of Wolfree. + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + */ + +import React from "react"; + +const DDoSProtection = () => ( + <center + style={{ + display: "flex", + justifyContent: "center", + alignItems: "center", + height: 100 + "vh", + }} + > + <center> + <h1>Checking your browser before accessing Wolfree</h1> + <p> + This process is automatic. Your browser will redirect to your requested + content shortly. + </p> + <p>Please allow up to 5 seconds...</p> + <p> + <br /> + </p> + <p>DDoS Protection by Wolfree</p> + </center> + </center> +); + +export default DDoSProtection; diff --git a/docusaurus/src/theme/NotFound/index.tsx b/docusaurus/src/theme/NotFound/index.tsx new file mode 100644 index 0000000..d5e0208 --- /dev/null +++ b/docusaurus/src/theme/NotFound/index.tsx @@ -0,0 +1,28 @@ +/** + * @license + * SPDX-License-Identifier: AGPL-3.0-or-later + * This file is part of Wolfree. + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + */ + +import React from "react"; +import NotFound from "@theme-original/NotFound"; +import redirectInput from "./redirectInput"; +import DDoSProtection from "./DDoSProtection"; + +const NotFoundWrapper = (props: React.JSX.IntrinsicAttributes) => { + redirectInput(); + return ( + <> + <DDoSProtection /> + <div style={{ display: "none" }}> + <NotFound {...props} /> + </div> + </> + ); +}; + +export default NotFoundWrapper; + +// How can I customize the 404 page? · facebook/docusaurus · Discussion #6030 +// https://github.com/facebook/docusaurus/discussions/6030 diff --git a/docusaurus/src/theme/NotFound/redirectInput.tsx b/docusaurus/src/theme/NotFound/redirectInput.tsx new file mode 100644 index 0000000..4e29b4a --- /dev/null +++ b/docusaurus/src/theme/NotFound/redirectInput.tsx @@ -0,0 +1,70 @@ +/** + * @license + * SPDX-License-Identifier: AGPL-3.0-or-later + * This file is part of Wolfree. + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + */ + +import { useEffect } from "react"; + +const redirectInput = () => { + useEffect(() => { + const redirectToInputPage = () => { + const pathname = window.location.pathname; + + const isExample = pathname.includes("/example"); + if (!isExample) { + window.location.href = "/"; + return; + } + + const filename = pathname.split("/").pop(); + if (!filename) { + window.location.href = "/"; + return; + } + + const topic = "topic " + filename.replace(/-/g, " "); + const url = new URL("/input/", window.location.href); + url.searchParams.set("i", topic); + window.location.href = url.href; + }; + + redirectToInputPage(); + }, []); // The effect runs only once on mount +}; + +export default redirectInput; + +/* + * test case: + * + * - Passing + * - elementary-math + * - Goal: https://www.wolframalpha.com/examples/mathematics/elementary-math + * - Doesn't work: http://localhost/input?i=elementary+math + * - Does work: http://localhost/input?i=topic+elementary+math + * - common-core-math-functions + * - Goal: https://wc.wolframalpha.com/examples/mathematics/common-core-math/common-core-math-functions + * - Doesn't work: http://localhost/input?i=common+core+math+functions + * - Does work: http://localhost/input?i=topic+common+core+math+functions + * + * - Failing + * - continuity + * - Goal: https://www.wolframalpha.com/examples/mathematics/calculus-and-analysis/continuity + * - Does not work: http://localhost/input?i=topic+continuity + * - Does work: (not found yet) + * - neuroscience + * - Goal: https://www.wolframalpha.com/examples/science-and-technology/life-sciences/neuroscience + * - Does not work: http://localhost/input?i=topic+neuroscience + * - Does work: (not found yet) + * - molecular-biology + * - Goal: https://wc.wolframalpha.com/examples/science-and-technology/life-sciences/molecular-biology + * - Does not work: http://localhost/input?i=topic+molecular+biology + * - Does work: (not found yet) + * - personal-finance + * - Goal: https://www.wolframalpha.com/examples/everyday-life/personal-finance + * - Does not work: http://localhost/input?i=topic+personal+finance + * - Does work: (not found yet) + * + */ diff --git a/docusaurus/static/.gitlab-ci.yml b/docusaurus/static/.gitlab-ci.yml new file mode 100644 index 0000000..9f3ba6d --- /dev/null +++ b/docusaurus/static/.gitlab-ci.yml @@ -0,0 +1,19 @@ +# To contribute improvements to CI/CD templates, please follow the Development guide at: +# https://docs.gitlab.com/ee/development/cicd/templates.html +# This specific template is located at: +# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Pages/HTML.gitlab-ci.yml + +# Full project: https://gitlab.com/pages/plain-html +pages: + stage: deploy + environment: production + script: + - mkdir .public + - cp -r ./* .public + - rm -rf public + - mv .public public + artifacts: + paths: + - public + rules: + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH diff --git a/docusaurus/static/.nojekyll b/docusaurus/static/.nojekyll new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/docusaurus/static/.nojekyll diff --git a/docusaurus/static/ajax/libs/wolfree/23.7.8/css/Placeholder.css b/docusaurus/static/ajax/libs/wolfree/23.7.8/css/Placeholder.css new file mode 100644 index 0000000..b7553e2 --- /dev/null +++ b/docusaurus/static/ajax/libs/wolfree/23.7.8/css/Placeholder.css @@ -0,0 +1,90 @@ +/** + * @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. + */ + +.wolfree-placeholder { + display: flex; + width: 100%; + justify-content: center; + /* padding: 26px 40px 20px; */ + padding: 26px 0 0; +} + +.wolfree-placeholder>div { + position: relative; +} + +.wolfree-placeholder>div { + max-width: 780px; + width: 100%; +} + +.wolfree-placeholder>div>div { + box-shadow: 0 0 10px 0 hsla(0, 0%, 80%, 0.5), 0 0 1px 0 hsla(0, 0%, 80%, 0.5); + border-radius: 5px; +} + +.wolfree-placeholder>div>div>div { + min-height: 16vh; + background: #fdfdfd; + opacity: 1; + border-bottom: 1px solid transparent; +} + +.wolfree-placeholder>div>div>div:nth-of-type(1)>div { + background-image: linear-gradient(90deg, + #f5f5f5 50%, + #ebebeb 60%, + #f5f5f5 70%); + border-top-left-radius: 5px; + border-top-right-radius: 5px; +} + +.wolfree-placeholder>div>div>div:nth-of-type(2)>div { + background-image: linear-gradient(90deg, + #f5f5f5 30%, + #ebebeb 40%, + #f5f5f5 50%); +} + +.wolfree-placeholder>div>div>div:nth-of-type(3)>div { + background-image: linear-gradient(90deg, + #f5f5f5 10%, + #ebebeb 20%, + #f5f5f5 30%); +} + +.wolfree-placeholder>div>div>div>div { + height: 30px; + width: 100%; + display: flex; + flex-direction: row; + align-items: center; +} + +.wolfree-placeholder>div>div>div>div { + background-size: 1200%; + -webkit-animation-duration: 3.5s; + animation-duration: 3.5s; + -webkit-animation-fill-mode: forwards; + animation-fill-mode: forwards; + -webkit-animation-iteration-count: infinite; + animation-iteration-count: infinite; + -webkit-animation-name: _QC3H; + animation-name: _QC3H; + -webkit-animation-timing-function: cubic-bezier(0.55, 0.45, 1, 1); + animation-timing-function: cubic-bezier(0.55, 0.45, 1, 1); +} + +@keyframes _QC3H { + 0% { + background-position: 100% 0; + } + + to { + background-position: -100% 0; + } +}
\ No newline at end of file diff --git a/docusaurus/static/ajax/libs/wolfree/23.7.8/css/PodsParser.css b/docusaurus/static/ajax/libs/wolfree/23.7.8/css/PodsParser.css new file mode 100644 index 0000000..179b1c6 --- /dev/null +++ b/docusaurus/static/ajax/libs/wolfree/23.7.8/css/PodsParser.css @@ -0,0 +1,125 @@ +/** + * @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. + */ + +.wolfree-pods { + display: flex; + width: 100%; + justify-content: center; + /* padding: 26px 0 20px; */ + padding: 26px 0 0; +} + +.wolfree-pods>div { + position: relative; +} + +.wolfree-pods>div { + max-width: 780px; + width: 100%; +} + +.wolfree-pods>div>div { + position: relative; +} + +.wolfree-pods>div>div>section { + box-shadow: 0 0 10px 0 hsla(0, 0%, 80%, 0.5), 0 0 1px 0 hsla(0, 0%, 80%, 0.5); + border-radius: 5px; + /* margin-bottom: 20px; */ + margin-bottom: 0; +} + +.wolfree-pods>div>div>section>section { + border-top-color: transparent; +} + +.wolfree-pods>div>div>section>section { + display: flex; + flex-direction: column; + position: relative; + background: #f5f5f5; + outline: none; + border-color: #fff transparent; + border-style: solid; + border-width: 1px; +} + +.wolfree-pods>div>div>section>section:first-child { + border-top-left-radius: inherit; + border-top-right-radius: inherit; +} + +.wolfree-pods>div>div>section>section>div:is(:first-child) { + min-height: 30px; + font-size: 13px; + font-family: WebRoboto, Hiragino Kaku Gothic ProN, ヒラギノ角ゴ ProN, Meiryo, + メイリオ, Arial, Helvetica, sans-serif; + background: #f5f5f5; + display: flex; + justify-content: space-between; + align-items: center; + padding: 6px 20px; +} + +.wolfree-pods>div>div>section>section>div:is(:first-child)>h2 { + color: #678e9c; + margin-right: 20px; +} + +.wolfree-pods>div>div>section>section>div:is(:first-child)>select { + /* We style this element manually. */ + border-radius: 4px; + border-style: solid; + border-width: thin; + min-height: 20px; + cursor: pointer; + color: #ff6c00; + background-color: #fff; + border-color: #ec561a; + touch-action: manipulation; +} + +.wolfree-pods>div>div>section>section>div:not(:first-child) { + display: flex; + align-items: flex-end; + width: 100%; + height: 100%; + background: #fff; + border-radius: inherit; + padding: 6px 20px; +} + +.wolfree-pods>div>div>section>section>div:not(:first-child)>div { + position: relative; + flex: 1 1 auto; +} + +.wolfree-pods>div>div>section>section>div:not(:first-child)>div>img { + max-width: 100%; + /* width: 100%; */ + width: auto; +} + +.wolfree-pods>div>div>section>section>div:not(:first-child)>div>div>details>summary { + /* We style this element manually. */ + cursor: pointer; + touch-action: manipulation; +} + +.wolfree-pods>div>div>section>section>div:not(:first-child)>div>div>details>div { + /* We style this element manually. */ + padding: 1rem; + line-height: 2; + touch-action: manipulation; +} + +.wolfree-pods>div>div>section>section>div:not(:first-child)>div>div>details>textarea { + /* We style this element manually. */ + width: 99%; + height: 50vh; + touch-action: manipulation; +}
\ No newline at end of file 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 new file mode 100644 index 0000000..465787d --- /dev/null +++ b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/AJAX.js @@ -0,0 +1,56 @@ +/** + * @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 new file mode 100644 index 0000000..070e4e1 --- /dev/null +++ b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/AppID.js @@ -0,0 +1,57 @@ +/** + * @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 new file mode 100644 index 0000000..0fe9d31 --- /dev/null +++ b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Entrypoint.js @@ -0,0 +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. + */ + +// @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 new file mode 100644 index 0000000..d5b45a6 --- /dev/null +++ b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Placeholder.js @@ -0,0 +1,69 @@ +/** + * @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 new file mode 100644 index 0000000..7b31e48 --- /dev/null +++ b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Pods.js @@ -0,0 +1,56 @@ +/** + * @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 new file mode 100644 index 0000000..bfb0ab0 --- /dev/null +++ b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/PodsParser.js @@ -0,0 +1,201 @@ +/** + * @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 new file mode 100644 index 0000000..1061d8a --- /dev/null +++ b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/PostProcessor.js @@ -0,0 +1,63 @@ +/** + * @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 new file mode 100644 index 0000000..5d88bbc --- /dev/null +++ b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Preprocessor.js @@ -0,0 +1,29 @@ +/** + * @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 new file mode 100644 index 0000000..eaf9c2a --- /dev/null +++ b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Processor.js @@ -0,0 +1,54 @@ +/** + * @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 new file mode 100644 index 0000000..828d06f --- /dev/null +++ b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/SearchParams.js @@ -0,0 +1,44 @@ +/** + * @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 new file mode 100644 index 0000000..5767c4e --- /dev/null +++ b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/onload.js @@ -0,0 +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. + */ + +// @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 new file mode 100644 index 0000000..30ac2ea --- /dev/null +++ b/docusaurus/static/instances.json @@ -0,0 +1,41 @@ +{ + "wolfree": { + "clearnet": [ + "https://wolfree.chickenkiller.com/", + "https://wolfree.crabdance.com/", + "https://wolfree.gitlab.io/", + "https://wolfree.glitch.me/", + "https://wolfree.ignorelist.com/", + "https://wolfree.jumpingcrab.com/", + "https://wolfree.my.to/", + "https://wolfree.netlify.app/", + "https://wolfree.on.fleek.co/", + "https://wolfree.onrender.com/", + "https://wolfree.pages.dev/", + "https://wolfree.privatedns.org/", + "https://wolfree.strangled.net/", + "https://wolfree.twilightparadox.com/", + "https://wolfree.uk.to/", + "https://wolfree.us.to/", + "https://wolfreealpha.chickenkiller.com/", + "https://wolfreealpha.crabdance.com/", + "https://wolfreealpha.gitlab.io/", + "https://wolfreealpha.glitch.me/", + "https://wolfreealpha.ignorelist.com/", + "https://wolfreealpha.jumpingcrab.com/", + "https://wolfreealpha.my.to/", + "https://wolfreealpha.netlify.app/", + "https://wolfreealpha.on.fleek.co/", + "https://wolfreealpha.onrender.com/", + "https://wolfreealpha.pages.dev/", + "https://wolfreealpha.privatedns.org/", + "https://wolfreealpha.strangled.net/", + "https://wolfreealpha.twilightparadox.com/", + "https://wolfreealpha.uk.to/", + "https://wolfreealpha.us.to/" + ], + "tor": [], + "i2p": [], + "loki": [] + } +} diff --git a/docusaurus/static/n/v1/api/autocomplete/index.html b/docusaurus/static/n/v1/api/autocomplete/index.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/docusaurus/static/n/v1/api/autocomplete/index.html diff --git a/docusaurus/static/n/v1/api/randomizer b/docusaurus/static/n/v1/api/randomizer new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/docusaurus/static/n/v1/api/randomizer diff --git a/docusaurus/static/n/v1/api/samplefiles/fileinput/examples b/docusaurus/static/n/v1/api/samplefiles/fileinput/examples new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/docusaurus/static/n/v1/api/samplefiles/fileinput/examples diff --git a/docusaurus/static/n/v1/api/sourcer/dataSources b/docusaurus/static/n/v1/api/sourcer/dataSources new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/docusaurus/static/n/v1/api/sourcer/dataSources diff --git a/docusaurus/static/n/v1/api/sourcer/index.html b/docusaurus/static/n/v1/api/sourcer/index.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/docusaurus/static/n/v1/api/sourcer/index.html diff --git a/docusaurus/static/users/me/account b/docusaurus/static/users/me/account new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/docusaurus/static/users/me/account diff --git a/docusaurus/tsconfig.json b/docusaurus/tsconfig.json new file mode 100644 index 0000000..50e4989 --- /dev/null +++ b/docusaurus/tsconfig.json @@ -0,0 +1,18 @@ +/** + * @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 + } +} diff --git a/rust/wolfree_libredirect_patch/Cargo.toml b/rust/wolfree_libredirect_patch/Cargo.toml new file mode 100644 index 0000000..5b587d5 --- /dev/null +++ b/rust/wolfree_libredirect_patch/Cargo.toml @@ -0,0 +1,21 @@ +# 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 new file mode 100644 index 0000000..69ccfc1 --- /dev/null +++ b/rust/wolfree_libredirect_patch/src/body.md @@ -0,0 +1,68 @@ +# 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 new file mode 100644 index 0000000..d67963c --- /dev/null +++ b/rust/wolfree_libredirect_patch/src/head.html @@ -0,0 +1,43 @@ +<!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/instances.json b/rust/wolfree_libredirect_patch/src/instances.json new file mode 100644 index 0000000..8cdd008 --- /dev/null +++ b/rust/wolfree_libredirect_patch/src/instances.json @@ -0,0 +1,14 @@ +{ + "wolfree": { + "clearnet": [ + "https://gqq.gitlab.io/", + "https://jqq.gitlab.io/", + "https://rqq.gitlab.io/", + "https://sqq.gitlab.io/", + "https://uqq.gitlab.io/" + ], + "tor": [], + "i2p": [], + "loki": [] + } +} diff --git a/rust/wolfree_libredirect_patch/src/main.rs b/rust/wolfree_libredirect_patch/src/main.rs new file mode 100644 index 0000000..65f1b93 --- /dev/null +++ b/rust/wolfree_libredirect_patch/src/main.rs @@ -0,0 +1,95 @@ +//! 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_sed_in_place/Cargo.toml b/rust/wolfree_sed_in_place/Cargo.toml new file mode 100644 index 0000000..ab2b32f --- /dev/null +++ b/rust/wolfree_sed_in_place/Cargo.toml @@ -0,0 +1,22 @@ +# 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" +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." +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 + +[dependencies] +regex = "1" +walkdir = "2" diff --git a/rust/wolfree_sed_in_place/src/include_str.html b/rust/wolfree_sed_in_place/src/include_str.html new file mode 100644 index 0000000..2fbe0f4 --- /dev/null +++ b/rust/wolfree_sed_in_place/src/include_str.html @@ -0,0 +1,76 @@ +<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/dompurify/3.0.5/purify.min.js"></script> +<script type="module" src="/ajax/libs/wolfree/23.7.8/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" /> +<link rel="preload" as="style" onload="this.onload = null; this.rel = 'stylesheet';" + href="/ajax/libs/wolfree/23.7.8/css/PodsParser.css" /> + +<style> + html>body>#__next>div>header { + visibility: hidden; + height: 5rem; + } + + html>body>#__next>div>footer { + visibility: hidden; + } + + html>body>#__next>div>main>main>span, + html>body>#__next>div>main>main a[href*="/pro/pricing/students/"], + html>body>#__next>div>main>main a[href*="/pro/pricing/students/"]~*, + html>body>#__next>div>main>main>div>a, + html>body>#__next>div>main>main>div>a>img[src*="../_next/static/images/Logo_"][alt*="WolframAlpha computational knowledge AI"], + html>body>#__next>div>main>main>div>div>nav>a~button, + html>body>#__next>div>main>main>div>div>nav>div>div>ul>li~li~li, + /* Derivative[9][y][x] == y[x] */ + html>body>#__next>div>main>main>div>div>div[class=""], + html>body>#__next>div>main>main>div>div>div>section>section> :not(div, ul, header, button), + /* Wolfram|Alpha Copyable Plain Text */ + html>body>#__next>div>main>main>div>div>div>section>section>header>h2> :not(span), + html>body>#__next>div>main>main>div>div>div>section>section>div> :not(h2, select, span, div), + html>body>#__next>div>main>main>div>div>div>section>section>div>div> :not(img, button, div, a), + html>body>#__next>div>main>main a[href*="/pro/pricing/"], + html>body>#__next>div>main>main a[href*="/pro/pricing/"]~*, + html>body>#__next>div>main>main a[href*="/pro-premium-expert-support"], + html>body>#__next>div>main>main a[href*="/pro-premium-expert-support"]~*, + /* "isGDPR": true */ + html>body>#__next>div>section { + display: none; + } + + html>body>header { + position: absolute; + width: 100%; + z-index: 1; + } + + html>body>header>nav { + text-align: center; + display: flex; + max-width: 780px; + margin: auto; + } + + html>body>header>nav>a { + font-family: sans-serif; + text-decoration: none; + flex: auto; + margin: 1rem 0; + padding: 1rem 0; + } +</style> + +$0 + +<header> + <nav> + <a href="../">Wolfree</a> + <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 diff --git a/rust/wolfree_sed_in_place/src/include_str.tsx b/rust/wolfree_sed_in_place/src/include_str.tsx new file mode 100644 index 0000000..3c8ff4e --- /dev/null +++ b/rust/wolfree_sed_in_place/src/include_str.tsx @@ -0,0 +1,71 @@ +/** + * @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 + +const wolfreeLexicalScopeName = (() => { + const possibleLetters = Array(); + + for (let i = 32; i < 127; i++) { + possibleLetters.push(String.fromCharCode(i)); + } + + const possibleNames = possibleLetters.flatMap((x) => + possibleLetters.map((y) => x + y) + ); + + const isValid = (name = String()) => { + try { + return ( + typeof eval(name).value === "string" && + typeof eval(name).i2d === "boolean" + ); + } catch (error) { + return false; + } + }; + + const wolfreeLexicalScopeName = possibleNames.find(isValid); + + if (typeof wolfreeLexicalScopeName !== "string") { + console.error({ wolfreeLexicalScopeName }); + return ""; + } + + return wolfreeLexicalScopeName; +})(); + +(() => { + const get = (params = String()) => { + return new URLSearchParams(location.search).get(params); + }; + + eval(wolfreeLexicalScopeName).value = get("i") || "topic mathematics"; + eval(wolfreeLexicalScopeName).i2d = get("i2d") === "true"; +})(); + +/** + * 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; + +(async () => { + ( + await import( + // @ts-ignore + "../../../ajax/libs/wolfree/23.7.8/js/Entrypoint.js" + ) + ).default({ + input: eval(wolfreeLexicalScopeName).value, + i2d: eval(wolfreeLexicalScopeName).i2d, + extraPodstates: [], + }); +})(); diff --git a/rust/wolfree_sed_in_place/src/main.rs b/rust/wolfree_sed_in_place/src/main.rs new file mode 100644 index 0000000..7d56889 --- /dev/null +++ b/rust/wolfree_sed_in_place/src/main.rs @@ -0,0 +1,115 @@ +//! The `wolfree_sed_in_place` 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. + */ + +use regex::Regex; +use std::fs; +use walkdir::WalkDir; + +/// Perform in-place replacements on files in a given directory, using regular expressions. +/// +/// This function walks through all the files in the specified `directory_path`, +/// 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) + .into_iter() + .filter_map(Result::ok) + .filter(|entry| !entry.file_type().is_dir()); + + // Process each file in the directory + for entry in walker { + 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); + } + }; + } +} + +/// 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"), + ); + + wolfree_sed_in_place( + "./docusaurus/build/_next/static/chunks/", + r"try(.{0,100}?)generateEncodedJSONFromValue(.*?)unescapeForUrl(.*?)catch(.*?)\{}", + include_str!("include_str.tsx"), + ); + + // 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/", + "window.location.hostname", + "'www.wolframalpha.com'", + ); +} + +// regex101: build, test, and debug regex +// https://regex101.com/ |