commit a43d377930921483130202cdbee71b7fb522142a Author: Pelican Installer Bot Date: Sun May 17 13:43:33 2026 +0000 feat: forged-plugs — 17 plugins for Forge Panel Separated from pelican-dev/plugins, rebranded for Forge. Includes manifest.json for in-panel store browsing. diff --git a/README.md b/README.md new file mode 100644 index 0000000..d5c867e --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# 🔧 Forged Plugs + +Official plugin repository for [Forge Panel](https://github.com/everestmcarthur/panel). + +## Plugins + +| Plugin | Author | Description | +|--------|--------|-------------| +| [Announcements](./announcements) | Boy132 | Create panel-wide announcements | +| [Billing](./billing) | Boy132 | Purchase servers via Stripe (PoC) | +| [Generic OIDC Providers](./generic-oidc-providers) | Boy132 | Create generic OIDC authentication providers | +| [Legal Pages](./legal-pages) | Boy132 | Imprint, Privacy Policy, ToS pages | +| [MCLogs Uploader](./mclogs-uploader) | Boy132 | Upload console logs to mclo.gs | +| [Minecraft Modrinth](./minecraft-modrinth) | Boy132 | Download mods & plugins from Modrinth | +| [Pirate Language](./pirate-language) | Boy132 | Arrr, matey! | +| [Player Counter](./player-counter) | Boy132 | Show connected player count | +| [Register](./register) | Boy132 | User self-registration | +| [Robo Avatars](./robo-avatars) | Boy132 | RoboHash avatar provider | +| [Rust uMod](./rust-umod) | Boy132 | Download Rust plugins from uMod | +| [Snowflakes](./snowflakes) | Boy132 | CSS snowflake effects | +| [Subdomains](./subdomains) | Boy132 | Cloudflare subdomains for servers | +| [Tawk.to Widget](./tawkto-widget) | Boy132 | Live chat widget | +| [Theme Customizer](./theme-customizer) | Boy132 | Customize panel font and colors | +| [Tickets](./tickets) | Boy132 | Simple ticket system | +| [User Creatable Servers](./user-creatable-servers) | Boy132 | Let users create their own servers | + +## Installation + +Plugins can be installed directly from the Forge Panel admin area: + +**Admin → Plugins → Plugin Store → Browse & Install** + +Or manually: +1. Download the plugin folder +2. Place it in `/var/www/forge/plugins/` +3. Go to Admin → Plugins → Install + +## For Themes + +See [forged-themes](https://github.com/everestmcarthur/forged-themes) for panel themes. diff --git a/announcements/LICENSE b/announcements/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/announcements/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + 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 GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/announcements/README.md b/announcements/README.md new file mode 100644 index 0000000..0b37ce4 --- /dev/null +++ b/announcements/README.md @@ -0,0 +1,11 @@ +# Announcements (by Boy132) + +Create panel-wide announcements to inform your users about important updates, maintenance schedules, or any other information. + +## Features + +- Create announcements with customizable titles and body text +- Support for different announcement types (info, warning, danger, success) +- Target specific panels (admin, app, server) or display on all panels +- Schedule announcements with valid from/to dates +- Announcements are displayed as alert banners across the panel diff --git a/announcements/database/migrations/001_create_announcements_table.php b/announcements/database/migrations/001_create_announcements_table.php new file mode 100644 index 0000000..31d2b41 --- /dev/null +++ b/announcements/database/migrations/001_create_announcements_table.php @@ -0,0 +1,27 @@ +increments('id'); + $table->string('title'); + $table->string('body')->nullable(); + $table->string('type')->default('info'); + $table->json('panels')->nullable(); + $table->timestamp('valid_from')->nullable(); + $table->timestamp('valid_to')->nullable(); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('announcements'); + } +}; diff --git a/announcements/lang/en/strings.php b/announcements/lang/en/strings.php new file mode 100644 index 0000000..e09629a --- /dev/null +++ b/announcements/lang/en/strings.php @@ -0,0 +1,16 @@ + 'No Announcements', + 'announcement' => 'Announcement|Announcements', + 'title' => 'Title', + 'body' => 'Body', + 'no_body' => 'No Body', + 'type' => 'Type', + 'panels' => 'Panels', + 'all_panels' => 'All Panels', + 'valid_from' => 'Valid from', + 'no_valid_from' => 'No valid from', + 'valid_to' => 'Valid to', + 'no_valid_to' => 'No valid to', +]; diff --git a/announcements/plugin.json b/announcements/plugin.json new file mode 100644 index 0000000..05aa7d8 --- /dev/null +++ b/announcements/plugin.json @@ -0,0 +1,15 @@ +{ + "id": "announcements", + "name": "Announcements", + "author": "Boy132", + "version": "1.0.0", + "description": "Create panel wide announcements to inform your users about stuff", + "category": "plugin", + "url": "https://github.com/everestmcarthur/forged-plugs/tree/main/announcements", + "update_url": null, + "namespace": "Boy132\\Announcements", + "class": "AnnouncementsPlugin", + "panels": null, + "panel_version": null, + "composer_packages": null +} \ No newline at end of file diff --git a/announcements/src/AnnouncementsPlugin.php b/announcements/src/AnnouncementsPlugin.php new file mode 100644 index 0000000..41ae695 --- /dev/null +++ b/announcements/src/AnnouncementsPlugin.php @@ -0,0 +1,38 @@ +getId())->title(); + + $panel->discoverResources(plugin_path($this->getId(), "src/Filament/$id/Resources"), "Boy132\\Announcements\\Filament\\$id\\Resources"); + } + + public function boot(Panel $panel): void + { + foreach (Announcement::all() as $announcement) { + if (!$announcement->shouldDisplay($panel)) { + continue; + } + + AlertBanner::make('announcement_' . $announcement->id) + ->title($announcement->title) + ->body($announcement->body) + ->status($announcement->type) + ->send(); + } + } +} diff --git a/announcements/src/Filament/Admin/Resources/Announcements/AnnouncementResource.php b/announcements/src/Filament/Admin/Resources/Announcements/AnnouncementResource.php new file mode 100644 index 0000000..a570b40 --- /dev/null +++ b/announcements/src/Filament/Admin/Resources/Announcements/AnnouncementResource.php @@ -0,0 +1,163 @@ +count() ?: null; + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + TextColumn::make('title') + ->label(trans('announcements::strings.title')), + TextColumn::make('body') + ->label(trans('announcements::strings.body')) + ->placeholder(trans('announcements::strings.no_body')), + TextColumn::make('type') + ->label(trans('announcements::strings.type')) + ->color(fn ($state) => $state) + ->badge(), + TextColumn::make('panels') + ->label(trans('announcements::strings.panels')) + ->placeholder(trans('announcements::strings.all_panels')) + ->badge(), + TextColumn::make('valid_from') + ->label(trans('announcements::strings.valid_from')) + ->placeholder(trans('announcements::strings.no_valid_from')) + ->dateTime(), + TextColumn::make('valid_to') + ->label(trans('announcements::strings.valid_to')) + ->placeholder(trans('announcements::strings.no_valid_to')) + ->dateTime(), + ]) + ->recordActions([ + ViewAction::make() + ->hidden(fn ($record) => static::getEditAuthorizationResponse($record)->allowed()), + EditAction::make(), + DeleteAction::make(), + ]) + ->toolbarActions([ + CreateAction::make() + ->createAnother(false), + ]) + ->emptyStateIcon('tabler-speakerphone') + ->emptyStateDescription('') + ->emptyStateHeading(trans('announcements::strings.no_announcements')); + } + + public static function form(Schema $schema): Schema + { + return $schema + ->components([ + TextInput::make('title') + ->label(trans('announcements::strings.title')) + ->required() + ->columnSpanFull(), + TextInput::make('body') + ->label(trans('announcements::strings.body')) + ->placeholder(trans('announcements::strings.no_body')) + ->nullable() + ->columnSpanFull(), + Select::make('type') + ->label(trans('announcements::strings.type')) + ->selectablePlaceholder(false) + ->default('info') + ->options([ + 'info' => 'Info', + 'success' => 'Success', + 'warning' => 'Warning', + 'danger' => 'Danger', + ]), + Select::make('panels') + ->label(trans('announcements::strings.panels')) + ->multiple() + ->options([ + 'admin' => 'Admin Area', + 'server' => 'Client Area', + 'app' => 'Server List', + ]), + DateTimePicker::make('valid_from') + ->label(trans('announcements::strings.valid_from')) + ->placeholder(trans('announcements::strings.no_valid_from')) + ->nullable(), + DateTimePicker::make('valid_to') + ->label(trans('announcements::strings.valid_to')) + ->placeholder(trans('announcements::strings.no_valid_to')) + ->nullable(), + ]); + } + + public static function infolist(Schema $schema): Schema + { + return $schema + ->components([ + TextEntry::make('title') + ->label(trans('announcements::strings.title')) + ->columnSpanFull(), + TextEntry::make('body') + ->label(trans('announcements::strings.body')) + ->placeholder(trans('announcements::strings.no_body')) + ->columnSpanFull(), + TextEntry::make('type') + ->label(trans('announcements::strings.type')) + ->color(fn ($state) => $state) + ->badge(), + TextEntry::make('panels') + ->label(trans('announcements::strings.panels')) + ->placeholder(trans('announcements::strings.all_panels')) + ->badge(), + TextEntry::make('valid_from') + ->label(trans('announcements::strings.valid_from')) + ->placeholder(trans('announcements::strings.no_valid_from')), + TextEntry::make('valid_to') + ->label(trans('announcements::strings.valid_to')) + ->placeholder(trans('announcements::strings.no_valid_to')), + ]); + } + + public static function getPages(): array + { + return [ + 'index' => ManageAnnouncements::route('/'), + ]; + } +} diff --git a/announcements/src/Filament/Admin/Resources/Announcements/Pages/ManageAnnouncements.php b/announcements/src/Filament/Admin/Resources/Announcements/Pages/ManageAnnouncements.php new file mode 100644 index 0000000..621819c --- /dev/null +++ b/announcements/src/Filament/Admin/Resources/Announcements/Pages/ManageAnnouncements.php @@ -0,0 +1,11 @@ + '[]', + ]; + + protected function casts(): array + { + return [ + 'panels' => 'array', + ]; + } + + public function shouldDisplay(Panel $panel): bool + { + if (!empty($this->panels) && !in_array($panel->getId(), $this->panels)) { + return false; + } + + if (!empty($this->valid_from) && now() < $this->valid_from) { + return false; + } + + if (!empty($this->valid_to) && now() > $this->valid_to) { + return false; + } + + return true; + } +} diff --git a/announcements/src/Policies/AnnouncementPolicy.php b/announcements/src/Policies/AnnouncementPolicy.php new file mode 100644 index 0000000..bb755c2 --- /dev/null +++ b/announcements/src/Policies/AnnouncementPolicy.php @@ -0,0 +1,12 @@ + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + 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 GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/billing/README.md b/billing/README.md new file mode 100644 index 0000000..62936e7 --- /dev/null +++ b/billing/README.md @@ -0,0 +1,16 @@ +# Billing (by Boy132) + +A simple billing plugin that allows users to purchase servers using Stripe as the payment processor. + +**WARNING: This plugin is incomplete! Do NOT use this plugin in production!** + +## Features + +- Stripe integration for payment processing +- Product management with customizable pricing intervals (monthly, yearly, etc.) +- Coupon system with percentage and fixed amount discounts +- Customer management linked to user accounts +- Order tracking and management +- Dashboard widget for users to view and purchase products +- Multi-currency support (USD, EUR, GBP) +- Configurable deployment tags for automatic server provisioning diff --git a/billing/config/billing.php b/billing/config/billing.php new file mode 100644 index 0000000..6da8d17 --- /dev/null +++ b/billing/config/billing.php @@ -0,0 +1,10 @@ + env('STRIPE_KEY'), + 'secret' => env('STRIPE_SECRET'), + + 'currency' => env('BILLING_CURRENCY', 'USD'), + + 'deployment_tags' => env('BILLING_DEPLOYMENT_TAGS'), +]; diff --git a/billing/database/migrations/001_create_coupons_table.php b/billing/database/migrations/001_create_coupons_table.php new file mode 100644 index 0000000..8569494 --- /dev/null +++ b/billing/database/migrations/001_create_coupons_table.php @@ -0,0 +1,29 @@ +increments('id'); + $table->string('stripe_coupon_id')->nullable(); + $table->string('stripe_promotion_id')->nullable(); + $table->string('name'); + $table->string('code')->unique(); + $table->integer('amount_off')->nullable(); + $table->integer('percent_off')->nullable(); + $table->integer('max_redemptions')->nullable(); + $table->dateTime('redeem_by')->nullable(); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('coupons'); + } +}; diff --git a/billing/database/migrations/002_create_customers_table.php b/billing/database/migrations/002_create_customers_table.php new file mode 100644 index 0000000..55bb130 --- /dev/null +++ b/billing/database/migrations/002_create_customers_table.php @@ -0,0 +1,26 @@ +increments('id'); + $table->string('first_name'); + $table->string('last_name'); + $table->integer('balance')->default(0); + $table->unsignedInteger('user_id'); + $table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete(); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('customers'); + } +}; diff --git a/billing/database/migrations/003_create_products_table.php b/billing/database/migrations/003_create_products_table.php new file mode 100644 index 0000000..bdf3abd --- /dev/null +++ b/billing/database/migrations/003_create_products_table.php @@ -0,0 +1,37 @@ +increments('id'); + $table->string('stripe_id')->nullable(); + $table->string('name'); + $table->text('description'); + $table->unsignedInteger('cpu')->default(0); + $table->unsignedInteger('memory')->default(0); + $table->unsignedInteger('disk')->default(0); + $table->unsignedInteger('swap')->default(0); + $table->json('ports'); + $table->json('tags'); + $table->unsignedInteger('allocation_limit')->default(0); + $table->unsignedInteger('database_limit')->default(0); + $table->unsignedInteger('backup_limit')->default(0); + + $table->unsignedInteger('egg_id'); + $table->foreign('egg_id')->references('id')->on('eggs')->cascadeOnDelete(); + + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('products'); + } +}; diff --git a/billing/database/migrations/004_create_product_prices_table.php b/billing/database/migrations/004_create_product_prices_table.php new file mode 100644 index 0000000..4c416c4 --- /dev/null +++ b/billing/database/migrations/004_create_product_prices_table.php @@ -0,0 +1,32 @@ +increments('id'); + $table->string('stripe_id')->nullable(); + $table->string('name'); + $table->float('cost', 2); + $table->boolean('renewable')->default(true); + $table->string('interval_type')->default(PriceInterval::Month); + $table->unsignedInteger('interval_value')->default(1); + + $table->unsignedInteger('product_id'); + $table->foreign('product_id')->references('id')->on('products')->cascadeOnDelete(); + + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('product_prices'); + } +}; diff --git a/billing/database/migrations/005_create_orders_table.php b/billing/database/migrations/005_create_orders_table.php new file mode 100644 index 0000000..7fbfd70 --- /dev/null +++ b/billing/database/migrations/005_create_orders_table.php @@ -0,0 +1,36 @@ +increments('id'); + $table->string('stripe_checkout_id')->nullable(); + $table->string('stripe_payment_id')->nullable(); + $table->string('status')->default(OrderStatus::Pending); + $table->timestamp('expires_at')->nullable(); + + $table->unsignedInteger('customer_id'); + $table->foreign('customer_id')->references('id')->on('customers')->cascadeOnDelete(); + + $table->unsignedInteger('product_price_id'); + $table->foreign('product_price_id')->references('id')->on('product_prices')->cascadeOnDelete(); + + $table->unsignedInteger('server_id')->nullable(); + $table->foreign('server_id')->references('id')->on('servers')->nullOnDelete(); + + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('orders'); + } +}; diff --git a/billing/plugin.json b/billing/plugin.json new file mode 100644 index 0000000..5bba4ea --- /dev/null +++ b/billing/plugin.json @@ -0,0 +1,17 @@ +{ + "id": "billing", + "name": "Billing", + "author": "Boy132", + "version": "1.0.0", + "description": "A simple billing plugin which allows users to purchase servers.", + "category": "plugin", + "url": "https://github.com/everestmcarthur/forged-plugs/tree/main/billing", + "update_url": null, + "namespace": "Boy132\\Billing", + "class": "BillingPlugin", + "panels": null, + "panel_version": null, + "composer_packages": { + "stripe/stripe-php": "^20.1" + } +} \ No newline at end of file diff --git a/billing/resources/views/widget.blade.php b/billing/resources/views/widget.blade.php new file mode 100644 index 0000000..9217c6a --- /dev/null +++ b/billing/resources/views/widget.blade.php @@ -0,0 +1,3 @@ + + {{ $this->content }} + \ No newline at end of file diff --git a/billing/src/BillingPlugin.php b/billing/src/BillingPlugin.php new file mode 100644 index 0000000..d9c8004 --- /dev/null +++ b/billing/src/BillingPlugin.php @@ -0,0 +1,98 @@ +getId())->title(); + + if ($panel->getId() === 'app') { + ServerResource::embedServerList(); + + $panel->navigation(true); + $panel->topbar(function () { + $navigationType = user()?->getCustomization(CustomizationKey::TopNavigation); + + return $navigationType === 'topbar' || $navigationType === 'mixed' || $navigationType === true; + }); + + $panel->navigationItems([ + NavigationItem::make(fn () => trans('filament-panels::auth/pages/edit-profile.label')) + ->icon('tabler-user-circle') + ->url(fn () => EditProfile::getUrl(panel: 'app')) + ->isActiveWhen(fn () => request()->routeIs(EditProfile::getRouteName())) + ->sort(99), + ]); + + $panel->clearCachedComponents(); + } + + $panel->discoverResources(plugin_path($this->getId(), "src/Filament/$id/Resources"), "Boy132\\Billing\\Filament\\$id\\Resources"); + $panel->discoverPages(plugin_path($this->getId(), "src/Filament/$id/Pages"), "Boy132\\Billing\\Filament\\$id\\Pages"); + $panel->discoverWidgets(plugin_path($this->getId(), "src/Filament/$id/Widgets"), "Boy132\\Billing\\Filament\\$id\\Widgets"); + } + + public function boot(Panel $panel): void {} + + public function getSettingsForm(): array + { + return [ + TextInput::make('key') + ->label('Stripe Key') + ->required() + ->default(fn () => config('billing.key')), + TextInput::make('secret') + ->label('Stripe Secret') + ->required() + ->default(fn () => config('billing.secret')), + Select::make('currency') + ->label('Currency') + ->required() + ->default(fn () => config('billing.currency')) + ->options([ + 'USD' => 'US Dollar', + 'EUR' => 'Euro', + 'GBP' => 'British Pound', + ]), + TagsInput::make('deployment_tags') + ->label('Default node tags for deployment'), + ]; + } + + public function saveSettings(array $data): void + { + $this->writeToEnvironment([ + 'STRIPE_KEY' => $data['key'], + 'STRIPE_SECRET' => $data['secret'], + 'BILLING_CURRENCY' => $data['currency'], + 'BILLING_DEPLOYMENT_TAGS' => implode(',', $data['deployment_tags']), + ]); + + Notification::make() + ->title('Settings saved') + ->success() + ->send(); + } +} diff --git a/billing/src/Console/Commands/CheckOrdersCommand.php b/billing/src/Console/Commands/CheckOrdersCommand.php new file mode 100644 index 0000000..2d6c445 --- /dev/null +++ b/billing/src/Console/Commands/CheckOrdersCommand.php @@ -0,0 +1,61 @@ +count() < 1) { + $this->line('No orders'); + + return 0; + } + + $bar = $this->output->createProgressBar($orders->count()); + foreach ($orders as $order) { + $bar->clear(); + + if ($order->checkExpire()) { + Notification::make() + ->success() + ->title('Order expired') + ->body($order->getLabel()) + ->actions([ + Action::make('goto_orders') + ->label('Go to orders') + ->markAsRead() + ->url(ListOrders::getUrl(panel: 'app')), + Action::make('renew') + ->visible(fn (Order $order) => $order->status === OrderStatus::Expired && $order->productPrice->renewable) + ->label('Renew') + ->color('warning') + ->requiresConfirmation() + ->markAsRead() + ->action(fn (Order $order) => redirect($order->getCheckoutSession()->url)), + ]) + ->sendToDatabase($order->customer->user); + } + + $bar->advance(); + $bar->display(); + } + + $this->line(''); + + return 0; + } +} diff --git a/billing/src/Enums/CouponType.php b/billing/src/Enums/CouponType.php new file mode 100644 index 0000000..a5b3c1d --- /dev/null +++ b/billing/src/Enums/CouponType.php @@ -0,0 +1,16 @@ +name; + } +} diff --git a/billing/src/Enums/OrderStatus.php b/billing/src/Enums/OrderStatus.php new file mode 100644 index 0000000..530a6fa --- /dev/null +++ b/billing/src/Enums/OrderStatus.php @@ -0,0 +1,40 @@ + 'warning', + self::Active => 'success', + self::Expired => 'warning', + self::Closed => 'danger', + }; + } + + public function getIcon(): string + { + return match ($this) { + self::Pending => 'tabler-circle-dotted', + self::Active => 'tabler-circle-check', + self::Expired => 'tabler-clock-hour-4', + self::Closed => 'tabler-circle-x', + }; + } + + public function getLabel(): string + { + return $this->name; + } +} diff --git a/billing/src/Enums/PriceInterval.php b/billing/src/Enums/PriceInterval.php new file mode 100644 index 0000000..d3c0d0d --- /dev/null +++ b/billing/src/Enums/PriceInterval.php @@ -0,0 +1,18 @@ +name; + } +} diff --git a/billing/src/Filament/Admin/Resources/Coupons/CouponResource.php b/billing/src/Filament/Admin/Resources/Coupons/CouponResource.php new file mode 100644 index 0000000..85cf343 --- /dev/null +++ b/billing/src/Filament/Admin/Resources/Coupons/CouponResource.php @@ -0,0 +1,129 @@ +count() ?: null; + } + + public static function form(Schema $schema): Schema + { + return $schema + ->components([ + TextInput::make('name') + ->required(), + TextInput::make('code') + ->placeholder('Leave empty to generate random code') + ->unique(), + ToggleButtons::make('coupon_type') + ->dehydrated() + ->live() + ->inline() + ->options(CouponType::class) + ->default(CouponType::Amount) + ->afterStateUpdated(function (Set $set) { + $set('amount_off', null); + $set('percent_off', null); + }), + TextInput::make('amount_off') + ->visible(fn (Get $get) => $get('coupon_type') === CouponType::Amount) + ->required() + ->numeric() + ->minValue(1) + ->suffix(config('billing.currency')), + TextInput::make('percent_off') + ->visible(fn (Get $get) => $get('coupon_type') === CouponType::Percentage) + ->required() + ->numeric() + ->minValue(1) + ->maxValue(100) + ->suffix('%'), + TextInput::make('max_redemptions') + ->placeholder('Leave empty for no redemption limit') + ->nullable() + ->numeric() + ->minValue(1), + DateTimePicker::make('redeem_by') + ->placeholder('Leave empty for no time constraint') + ->native(false) + ->nullable(), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->paginated(false) + ->columns([ + TextColumn::make('name') + ->sortable() + ->searchable(), + TextColumn::make('code') + ->badge() + ->sortable(), + TextColumn::make('coupon') + ->badge() + ->state(fn (Coupon $coupon) => $coupon->amount_off ? $coupon->amount_off . ' ' . config('billing.currency') : $coupon->percent_off . ' %'), + TextColumn::make('max_redemptions') + ->placeholder('No redemption limit') + ->sortable(), + DateTimeColumn::make('redeem_by') + ->placeholder('No time constraint') + ->sortable() + ->since(), + ]) + ->recordActions([ + EditAction::make(), + DeleteAction::make(), + ]) + ->toolbarActions([ + CreateAction::make() + ->createAnother(false), + BulkActionGroup::make([ + DeleteBulkAction::make('exclude_bulk_delete'), + ]), + ]) + ->emptyStateHeading('No Coupons') + ->emptyStateDescription('') + ->emptyStateIcon('tabler-receipt-tax'); + } + + public static function getPages(): array + { + return [ + 'index' => ListCoupons::route('/'), + 'create' => CreateCoupon::route('/create'), + 'edit' => EditCoupon::route('/{record}/edit'), + ]; + } +} diff --git a/billing/src/Filament/Admin/Resources/Coupons/Pages/CreateCoupon.php b/billing/src/Filament/Admin/Resources/Coupons/Pages/CreateCoupon.php new file mode 100644 index 0000000..aeba32c --- /dev/null +++ b/billing/src/Filament/Admin/Resources/Coupons/Pages/CreateCoupon.php @@ -0,0 +1,29 @@ +getCreateFormAction()->formId('form') + ->tooltip(fn (Action $action) => $action->getLabel()) + ->hiddenLabel() + ->icon('tabler-plus'), + ]; + } +} diff --git a/billing/src/Filament/Admin/Resources/Coupons/Pages/EditCoupon.php b/billing/src/Filament/Admin/Resources/Coupons/Pages/EditCoupon.php new file mode 100644 index 0000000..1cf2e53 --- /dev/null +++ b/billing/src/Filament/Admin/Resources/Coupons/Pages/EditCoupon.php @@ -0,0 +1,41 @@ +getCancelFormAction()->formId('form') + ->tooltip(fn (Action $action) => $action->getLabel()) + ->hiddenLabel() + ->icon('tabler-arrow-left'), + DeleteAction::make(), + $this->getSaveFormAction()->formId('form') + ->tooltip(fn (Action $action) => $action->getLabel()) + ->hiddenLabel() + ->icon('tabler-device-floppy'), + ]; + } + + protected function mutateFormDataBeforeFill(array $data): array + { + $data['coupon_type'] = $data['amount_off'] ? CouponType::Amount : CouponType::Percentage; + + return $data; + } +} diff --git a/billing/src/Filament/Admin/Resources/Coupons/Pages/ListCoupons.php b/billing/src/Filament/Admin/Resources/Coupons/Pages/ListCoupons.php new file mode 100644 index 0000000..45f197c --- /dev/null +++ b/billing/src/Filament/Admin/Resources/Coupons/Pages/ListCoupons.php @@ -0,0 +1,11 @@ +count() ?: null; + } + + public static function form(Schema $schema): Schema + { + return $schema + ->components([ + Select::make('user_id') + ->prefixIcon('tabler-user') + ->label('User') + ->required() + ->selectablePlaceholder(false) + ->relationship('user', 'username') + ->searchable(['username', 'email']) + ->getOptionLabelFromRecordUsing(fn (User $user) => $user->email . ' | ' . $user->username) + ->preload(), + TextInput::make('balance') + ->required() + ->suffix(config('billing.currency')) + ->numeric() + ->minValue(0) + ->default(0), + TextInput::make('first_name') + ->required(), + TextInput::make('last_name') + ->required(), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->paginated(false) + ->columns([ + TextColumn::make('first_name') + ->sortable(), + TextColumn::make('last_name') + ->sortable(), + TextColumn::make('user.email') + ->label('E-Mail') + ->sortable(), + TextColumn::make('balance') + ->numeric() + ->formatStateUsing(function ($state) { + $formatter = new NumberFormatter(auth()->user()->language, NumberFormatter::CURRENCY); + + return $formatter->formatCurrency($state, config('billing.currency')); + }), + TextColumn::make('orders_count') + ->label('Orders') + ->counts('orders') + ->badge(), + ]) + ->recordActions([ + EditAction::make(), + DeleteAction::make(), + ]) + ->toolbarActions([ + CreateAction::make() + ->createAnother(false), + BulkActionGroup::make([ + DeleteBulkAction::make('exclude_bulk_delete'), + ]), + ]) + ->emptyStateHeading('No Customers') + ->emptyStateDescription('') + ->emptyStateIcon('tabler-user-dollar'); + } + + public static function getPages(): array + { + return [ + 'index' => ListCustomers::route('/'), + 'create' => CreateCustomer::route('/create'), + 'edit' => EditCustomer::route('/{record}/edit'), + ]; + } +} diff --git a/billing/src/Filament/Admin/Resources/Customers/Pages/CreateCustomer.php b/billing/src/Filament/Admin/Resources/Customers/Pages/CreateCustomer.php new file mode 100644 index 0000000..fd57b92 --- /dev/null +++ b/billing/src/Filament/Admin/Resources/Customers/Pages/CreateCustomer.php @@ -0,0 +1,29 @@ +getCreateFormAction()->formId('form') + ->tooltip(fn (Action $action) => $action->getLabel()) + ->hiddenLabel() + ->icon('tabler-plus'), + ]; + } +} diff --git a/billing/src/Filament/Admin/Resources/Customers/Pages/EditCustomer.php b/billing/src/Filament/Admin/Resources/Customers/Pages/EditCustomer.php new file mode 100644 index 0000000..6581301 --- /dev/null +++ b/billing/src/Filament/Admin/Resources/Customers/Pages/EditCustomer.php @@ -0,0 +1,41 @@ +getCancelFormAction()->formId('form') + ->tooltip(fn (Action $action) => $action->getLabel()) + ->hiddenLabel() + ->icon('tabler-arrow-left'), + DeleteAction::make(), + $this->getSaveFormAction()->formId('form') + ->tooltip(fn (Action $action) => $action->getLabel()) + ->hiddenLabel() + ->icon('tabler-device-floppy'), + ]; + } + + public function getRelationManagers(): array + { + return [ + OrderRelationManager::class, + ]; + } +} diff --git a/billing/src/Filament/Admin/Resources/Customers/Pages/ListCustomers.php b/billing/src/Filament/Admin/Resources/Customers/Pages/ListCustomers.php new file mode 100644 index 0000000..03c90ed --- /dev/null +++ b/billing/src/Filament/Admin/Resources/Customers/Pages/ListCustomers.php @@ -0,0 +1,11 @@ +columns([ + TextColumn::make('id') + ->label('ID') + ->sortable(), + TextColumn::make('status') + ->sortable() + ->badge(), + TextColumn::make('server.name') + ->label('Server') + ->placeholder('No server') + ->icon('tabler-brand-docker') + ->sortable() + ->url(fn (Order $order): ?string => $order->server ? EditServer::getUrl(['record' => $order->server]) : null), + TextColumn::make('productPrice.product.name') + ->label('Product') + ->icon('tabler-package') + ->sortable() + ->url(fn (Order $order): string => EditProduct::getUrl(['record' => $order->productPrice->product])), + TextColumn::make('productPrice.name') + ->label('Price') + ->sortable(), + TextColumn::make('productPrice.cost') + ->label('Cost') + ->sortable() + ->formatStateUsing(function ($state) { + $formatter = new NumberFormatter(auth()->user()->language, NumberFormatter::CURRENCY); + + return $formatter->formatCurrency($state, config('billing.currency')); + }), + DateTimeColumn::make('expires_at') + ->label('Expires') + ->placeholder('No expire') + ->color(fn ($state) => $state <= now('UTC') ? 'danger' : null) + ->since(), + ]) + ->recordActions([ + Action::make('activate') + ->visible(fn (Order $order) => $order->status !== OrderStatus::Active) + ->color('success') + ->requiresConfirmation() + ->action(function (Order $order) { + $order->activate(null); + + Notification::make() + ->title('Order activated') + ->body($order->getLabel()) + ->success() + ->send(); + }), + Action::make('create_server') + ->visible(fn (Order $order) => $order->status === OrderStatus::Active && !$order->server) + ->color('primary') + ->requiresConfirmation() + ->action(function (Order $order) { + try { + $order->createServer(); + } catch (Exception $exception) { + Notification::make() + ->title('Could not create server') + ->body($exception->getMessage()) + ->danger() + ->persistent() + ->send(); + } + }), + Action::make('close') + ->visible(fn (Order $order) => $order->status === OrderStatus::Active) + ->color('danger') + ->requiresConfirmation() + ->action(function (Order $order) { + $order->close(); + + Notification::make() + ->title('Order closed') + ->body($order->getLabel()) + ->success() + ->send(); + }), + ]) + ->emptyStateHeading('No Orders') + ->emptyStateDescription('') + ->emptyStateIcon('tabler-truck-delivery'); + } +} diff --git a/billing/src/Filament/Admin/Resources/Orders/OrderResource.php b/billing/src/Filament/Admin/Resources/Orders/OrderResource.php new file mode 100644 index 0000000..0faaf4b --- /dev/null +++ b/billing/src/Filament/Admin/Resources/Orders/OrderResource.php @@ -0,0 +1,168 @@ +count() ?: null; + } + + public static function form(Schema $schema): Schema + { + return $schema + ->components([ + Select::make('customer_id') + ->label('Customer') + ->required() + ->selectablePlaceholder(false) + ->relationship('customer') + ->getOptionLabelFromRecordUsing(fn (Customer $customer) => $customer->getLabel()) + ->preload(), + Select::make('product_price_id') + ->label('Product') + ->required() + ->selectablePlaceholder(false) + ->relationship('productPrice') + ->getOptionLabelFromRecordUsing(fn (ProductPrice $productPrice) => $productPrice->product->getLabel() . ' (' . $productPrice->getLabel() . ')') + ->preload(), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + TextColumn::make('id') + ->label('ID') + ->sortable(), + TextColumn::make('status') + ->sortable() + ->badge() + ->visible(fn ($livewire) => $livewire->activeTab === 'all'), + TextColumn::make('customer') + ->label('Customer') + ->icon('tabler-user-dollar') + ->sortable() + ->url(fn (Order $order) => EditCustomer::getUrl(['record' => $order->customer])), + TextColumn::make('server.name') + ->label('Server') + ->placeholder('No server') + ->icon('tabler-brand-docker') + ->sortable() + ->url(fn (Order $order) => $order->server ? EditServer::getUrl(['record' => $order->server]) : null), + TextColumn::make('productPrice.product.name') + ->label('Product') + ->icon('tabler-package') + ->sortable() + ->url(fn (Order $order) => EditProduct::getUrl(['record' => $order->productPrice->product])), + TextColumn::make('productPrice.name') + ->label('Price') + ->sortable(), + TextColumn::make('productPrice.cost') + ->label('Cost') + ->sortable() + ->formatStateUsing(function ($state) { + $formatter = new NumberFormatter(auth()->user()->language, NumberFormatter::CURRENCY); + + return $formatter->formatCurrency($state, config('billing.currency')); + }), + DateTimeColumn::make('expires_at') + ->label('Expires') + ->placeholder('No expire') + ->color(fn ($state) => $state <= now('UTC') ? 'danger' : null) + ->since(), + ]) + ->recordActions([ + Action::make('activate') + ->visible(fn (Order $order) => $order->status !== OrderStatus::Active) + ->tooltip('Activate') + ->color('success') + ->icon('tabler-check') + ->requiresConfirmation() + ->action(function (Order $order) { + $order->activate(null); + + Notification::make() + ->title('Order activated') + ->body($order->getLabel()) + ->success() + ->send(); + }), + Action::make('create_server') + ->visible(fn (Order $order) => $order->status === OrderStatus::Active && !$order->server) + ->tooltip('Create server') + ->color('primary') + ->icon('tabler-brand-docker') + ->requiresConfirmation() + ->action(function (Order $order) { + try { + $order->createServer(); + } catch (Exception $exception) { + Notification::make() + ->title('Could not create server') + ->body($exception->getMessage()) + ->danger() + ->persistent() + ->send(); + } + }), + Action::make('close') + ->visible(fn (Order $order) => $order->status === OrderStatus::Active) + ->tooltip('Close') + ->color('danger') + ->icon('tabler-x') + ->requiresConfirmation() + ->action(function (Order $order) { + $order->close(); + + Notification::make() + ->title('Order closed') + ->body($order->getLabel()) + ->success() + ->send(); + }), + ]) + ->toolbarActions([ + CreateAction::make() + ->createAnother(false), + ]) + ->emptyStateHeading('No Orders') + ->emptyStateDescription('') + ->emptyStateIcon('tabler-truck-delivery'); + } + + public static function getPages(): array + { + return [ + 'index' => ListOrders::route('/'), + ]; + } +} diff --git a/billing/src/Filament/Admin/Resources/Orders/Pages/ListOrders.php b/billing/src/Filament/Admin/Resources/Orders/Pages/ListOrders.php new file mode 100644 index 0000000..e6e3948 --- /dev/null +++ b/billing/src/Filament/Admin/Resources/Orders/Pages/ListOrders.php @@ -0,0 +1,36 @@ +value; + } + + public function getTabs(): array + { + $tabs = []; + + foreach (OrderStatus::cases() as $orderStatus) { + $tabs[$orderStatus->value] = Tab::make($orderStatus->getLabel()) + ->modifyQueryUsing(fn (Builder $query) => $query->where('status', $orderStatus->value)) + ->badge(fn () => Order::where('status', $orderStatus->value)->count()) + ->icon(fn () => $orderStatus->getIcon()); + } + + $tabs['all'] = Tab::make('All')->badge(fn () => Order::count()); + + return $tabs; + } +} diff --git a/billing/src/Filament/Admin/Resources/Products/Pages/CreateProduct.php b/billing/src/Filament/Admin/Resources/Products/Pages/CreateProduct.php new file mode 100644 index 0000000..8a45f7d --- /dev/null +++ b/billing/src/Filament/Admin/Resources/Products/Pages/CreateProduct.php @@ -0,0 +1,33 @@ +getCreateFormAction()->formId('form') + ->tooltip(fn (Action $action) => $action->getLabel()) + ->hiddenLabel() + ->icon('tabler-plus'), + ]; + } +} diff --git a/billing/src/Filament/Admin/Resources/Products/Pages/EditProduct.php b/billing/src/Filament/Admin/Resources/Products/Pages/EditProduct.php new file mode 100644 index 0000000..7d2ff2f --- /dev/null +++ b/billing/src/Filament/Admin/Resources/Products/Pages/EditProduct.php @@ -0,0 +1,45 @@ +getCancelFormAction()->formId('form') + ->tooltip(fn (Action $action) => $action->getLabel()) + ->hiddenLabel() + ->icon('tabler-arrow-left'), + DeleteAction::make(), + $this->getSaveFormAction()->formId('form') + ->tooltip(fn (Action $action) => $action->getLabel()) + ->hiddenLabel() + ->icon('tabler-device-floppy'), + ]; + } + + public function getRelationManagers(): array + { + return [ + PriceRelationManager::class, + ]; + } +} diff --git a/billing/src/Filament/Admin/Resources/Products/Pages/ListProducts.php b/billing/src/Filament/Admin/Resources/Products/Pages/ListProducts.php new file mode 100644 index 0000000..f16b42f --- /dev/null +++ b/billing/src/Filament/Admin/Resources/Products/Pages/ListProducts.php @@ -0,0 +1,11 @@ +count() ?: null; + } + + public static function form(Schema $schema): Schema + { + return $schema + ->components([ + TextInput::make('name') + ->required(), + Textarea::make('description') + ->required() + ->autosize(), + Fieldset::make('Server') + ->columnSpanFull() + ->schema([ + Select::make('egg_id') + ->prefixIcon('tabler-egg') + ->label('Egg') + ->required() + ->relationship('egg', 'name') + ->searchable() + ->preload() + ->columnSpanFull(), + TextInput::make('cpu') + ->prefixIcon('tabler-cpu') + ->label('CPU') + ->required() + ->suffix('%') + ->numeric() + ->minValue(0) + ->hint('Set to 0 for unlimited.'), + TextInput::make('memory') + ->prefixIcon('tabler-database') + ->required() + ->suffix(config('panel.use_binary_prefix') ? 'MiB' : 'MB') + ->numeric() + ->minValue(0) + ->hint('Set to 0 for unlimited.'), + TextInput::make('disk') + ->prefixIcon('tabler-folder') + ->required() + ->suffix(config('panel.use_binary_prefix') ? 'MiB' : 'MB') + ->numeric() + ->minValue(0) + ->hint('Set to 0 for unlimited.'), + TextInput::make('swap') + ->prefixIcon('tabler-file-database') + ->required() + ->suffix(config('panel.use_binary_prefix') ? 'MiB' : 'MB') + ->numeric() + ->minValue(0) + ->hint('Set to -1 for unlimited or 0 for no swap.'), + ]), + Fieldset::make('Deployment') + ->columnSpanFull() + ->columns(2) + ->schema([ + TagsInput::make('ports') + ->placeholder('New port or port range'), + TagsInput::make('tags') + ->placeholder('New tag for deployment') + ->default(array_filter(explode(',', config('billing.deployment_tags', '')))), + ]), + Fieldset::make('Limits') + ->columnSpanFull() + ->columns(3) + ->schema([ + TextInput::make('allocation_limit') + ->prefixIcon('tabler-network') + ->required() + ->numeric() + ->minValue(0) + ->default(0), + TextInput::make('database_limit') + ->prefixIcon('tabler-database') + ->required() + ->numeric() + ->minValue(0) + ->default(0), + TextInput::make('backup_limit') + ->prefixIcon('tabler-copy-check') + ->required() + ->numeric() + ->minValue(0) + ->default(0), + ]), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->paginated(false) + ->columns([ + TextColumn::make('name') + ->description(fn (Product $product) => $product->description) + ->sortable() + ->searchable(), + TextColumn::make('egg.name') + ->sortable() + ->icon('tabler-egg') + ->url(fn (Product $product): string => route('filament.admin.resources.eggs.edit', ['record' => $product->egg])), + TextColumn::make('cpu') + ->label('CPU') + ->numeric() + ->formatStateUsing(fn ($state) => $state === 0 ? 'Unlimited' : $state . ' %'), + TextColumn::make('memory') + ->numeric() + ->formatStateUsing(fn ($state) => $state === 0 ? 'Unlimited' : Number::format($state / (config('panel.use_binary_prefix') ? 1024 : 1000), 2, locale: auth()->user()->language) . (config('panel.use_binary_prefix') ? ' GiB' : ' GB')), + TextColumn::make('disk') + ->numeric() + ->formatStateUsing(fn ($state) => $state === 0 ? 'Unlimited' : Number::format($state / (config('panel.use_binary_prefix') ? 1024 : 1000), 2, locale: auth()->user()->language) . (config('panel.use_binary_prefix') ? ' GiB' : ' GB')), + TextColumn::make('swap') + ->numeric() + ->formatStateUsing(fn ($state) => $state === 0 ? 'No Swap' : Number::format($state / (config('panel.use_binary_prefix') ? 1024 : 1000), 2, locale: auth()->user()->language) . (config('panel.use_binary_prefix') ? ' GiB' : ' GB')), + ]) + ->recordActions([ + EditAction::make(), + DeleteAction::make(), + ]) + ->toolbarActions([ + CreateAction::make() + ->createAnother(false), + ]) + ->emptyStateHeading('No Products') + ->emptyStateDescription('') + ->emptyStateIcon('tabler-package'); + } + + public static function getPages(): array + { + return [ + 'index' => ListProducts::route('/'), + 'create' => CreateProduct::route('/create'), + 'edit' => EditProduct::route('/{record}/edit'), + ]; + } +} diff --git a/billing/src/Filament/Admin/Resources/Products/RelationManagers/PriceRelationManager.php b/billing/src/Filament/Admin/Resources/Products/RelationManagers/PriceRelationManager.php new file mode 100644 index 0000000..de1afc5 --- /dev/null +++ b/billing/src/Filament/Admin/Resources/Products/RelationManagers/PriceRelationManager.php @@ -0,0 +1,81 @@ +components([ + TextInput::make('name') + ->required() + ->label('Internal Name') + ->columnSpanFull(), + TextInput::make('cost') + ->required() + ->suffix(config('billing.currency')) + ->numeric() + ->minValue(0), + Toggle::make('renewable') + ->label('Can be renewed?') + ->inline(false), + Select::make('interval_type') + ->required() + ->selectablePlaceholder(false) + ->options(PriceInterval::class), + TextInput::make('interval_value') + ->required() + ->numeric() + ->minValue(1), + ]); + } + + public function table(Table $table): Table + { + return $table + ->columns([ + TextColumn::make('name') + ->label('Internal Name') + ->sortable(), + TextColumn::make('cost') + ->sortable() + ->state(fn (ProductPrice $price) => $price->formatCost()), + IconColumn::make('renewable') + ->label('Can be renewed?') + ->boolean(), + TextColumn::make('interval') + ->state(fn (ProductPrice $price) => $price->interval_value . ' ' . $price->interval_type->name), + ]) + ->headerActions([ + CreateAction::make() + ->createAnother(false), + ]) + ->recordActions([ + EditAction::make(), + DeleteAction::make(), + ]) + ->emptyStateHeading('No Prices') + ->emptyStateDescription(''); + } +} diff --git a/billing/src/Filament/App/Pages/Dashboard.php b/billing/src/Filament/App/Pages/Dashboard.php new file mode 100644 index 0000000..0b40c2e --- /dev/null +++ b/billing/src/Filament/App/Pages/Dashboard.php @@ -0,0 +1,27 @@ +prices->count() <= 0) { + continue; + } + + $widgets[] = new WidgetConfiguration(ProductWidget::class, ['product' => $product]); + } + + return $widgets; + } +} diff --git a/billing/src/Filament/App/Resources/Orders/OrdersResource.php b/billing/src/Filament/App/Resources/Orders/OrdersResource.php new file mode 100644 index 0000000..fe68d4b --- /dev/null +++ b/billing/src/Filament/App/Resources/Orders/OrdersResource.php @@ -0,0 +1,113 @@ + user()->id, + ], [ + 'first_name' => user()->username, + 'last_name' => user()->username, + ]); + + return parent::getEloquentQuery()->where('customer_id', $customer->id); + } + + public static function getNavigationBadge(): ?string + { + return (string) static::getEloquentQuery()->count() ?: null; + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + TextColumn::make('status') + ->sortable() + ->badge(), + TextColumn::make('server.name') + ->label('Server') + ->placeholder('No server') + ->icon('tabler-brand-docker') + ->sortable(), + TextColumn::make('productPrice.product.name') + ->label('Product') + ->icon('tabler-package') + ->sortable(), + TextColumn::make('productPrice.name') + ->label('Price') + ->sortable(), + TextColumn::make('productPrice.cost') + ->label('Cost') + ->sortable() + ->formatStateUsing(function ($state) { + $formatter = new NumberFormatter(user()->language, NumberFormatter::CURRENCY); + + return $formatter->formatCurrency($state, config('billing.currency')); + }), + DateTimeColumn::make('expires_at') + ->label('Expires') + ->placeholder('No expire') + ->color(fn ($state) => $state <= now('UTC') ? 'danger' : null) + ->since(), + ]) + ->recordActions([ + ViewAction::make() + ->hidden(fn (Order $order) => !$order->server) + ->url(fn (Order $order) => Console::getUrl(panel: 'server', tenant: $order->server)), + Action::make('activate') + ->visible(fn (Order $order) => $order->status === OrderStatus::Pending) + ->tooltip('Activate') + ->color('success') + ->icon('tabler-check') + ->requiresConfirmation() + ->action(fn (Order $order) => redirect($order->getCheckoutSession()->url)), + Action::make('cancel') + ->visible(fn (Order $order) => $order->status === OrderStatus::Pending || $order->status === OrderStatus::Active) + ->tooltip('Cancel') + ->color('danger') + ->icon('tabler-x') + ->requiresConfirmation() + ->action(fn (Order $order) => $order->close()), + Action::make('renew') + ->visible(fn (Order $order) => $order->status === OrderStatus::Expired && $order->productPrice->renewable) + ->tooltip('Renew') + ->color('warning') + ->icon('tabler-refresh') + ->requiresConfirmation() + ->action(fn (Order $order) => redirect($order->getCheckoutSession()->url)), + ]) + ->emptyStateHeading('No Orders') + ->emptyStateDescription('') + ->emptyStateIcon('tabler-truck-delivery'); + } + + public static function getPages(): array + { + return [ + 'index' => ListOrders::route('/'), + ]; + } +} diff --git a/billing/src/Filament/App/Resources/Orders/Pages/ListOrders.php b/billing/src/Filament/App/Resources/Orders/Pages/ListOrders.php new file mode 100644 index 0000000..83f6c52 --- /dev/null +++ b/billing/src/Filament/App/Resources/Orders/Pages/ListOrders.php @@ -0,0 +1,16 @@ + $prices */ + $prices = $this->product->prices()->orderBy('cost')->get(); + + foreach ($prices as $price) { + $actions[] = Action::make('exclude_' . str_slug($price->name)) + ->label($price->getLabel()) + ->action(function () use ($price) { + $price->sync(); + + /** @var Customer $customer */ + $customer = Customer::firstOrCreate([ + 'user_id' => user()->id, + ]); + + /** @var Order $order */ + $order = Order::create([ + 'customer_id' => $customer->id, + 'product_price_id' => $price->id, + ]); + + if ($price->isFree()) { + $order->activate(null); + $order->refresh(); + + return redirect(Console::getUrl(panel: 'server', tenant: $order->server)); + } + + return $this->redirect($order->getCheckoutSession()->url); + }); + } + + return $schema + ->record($this->product) + ->components([ + Section::make() + ->heading($this->product->getLabel()) + ->description($this->product->description) + ->columns(6) + ->schema([ + TextEntry::make('cpu') + ->label('CPU') + ->icon('tabler-cpu') + ->formatStateUsing(fn ($state) => $state === 0 ? 'Unlimited' : $state . ' %') + ->columnSpan(2), + TextEntry::make('memory') + ->icon('tabler-database') + ->formatStateUsing(fn ($state) => $state === 0 ? 'Unlimited' : Number::format($state / (config('panel.use_binary_prefix') ? 1024 : 1000), 2, locale: auth()->user()->language) . (config('panel.use_binary_prefix') ? ' GiB' : ' GB')) + ->columnSpan(2), + TextEntry::make('disk') + ->icon('tabler-folder') + ->formatStateUsing(fn ($state) => $state === 0 ? 'Unlimited' : Number::format($state / (config('panel.use_binary_prefix') ? 1024 : 1000), 2, locale: auth()->user()->language) . (config('panel.use_binary_prefix') ? ' GiB' : ' GB')) + ->columnSpan(2), + TextEntry::make('backup_limit') + ->inlineLabel() + ->columnSpan(3) + ->visible(fn ($state) => $state > 0), + TextEntry::make('database_limit') + ->inlineLabel() + ->columnSpan(3) + ->visible(fn ($state) => $state > 0), + Actions::make($actions) + ->columnSpanFull() + ->fullWidth(), + ]), + ]); + } +} diff --git a/billing/src/Filament/App/Widgets/WelcomeWidget.php b/billing/src/Filament/App/Widgets/WelcomeWidget.php new file mode 100644 index 0000000..83fea04 --- /dev/null +++ b/billing/src/Filament/App/Widgets/WelcomeWidget.php @@ -0,0 +1,10 @@ +get('session_id'); + + if ($sessionId === null) { + return redirect(Filament::getPanel('app')->getUrl()); + } + + $session = $this->stripeClient->checkout->sessions->retrieve($sessionId); + + if ($session->payment_status === Session::PAYMENT_STATUS_UNPAID) { + return redirect(ListOrders::getUrl(panel: 'app')); + } + + /** @var ?Order $order */ + $order = Order::where('stripe_checkout_id', $session->id)->first(); + + if (!$order) { + return redirect(ListOrders::getUrl(panel: 'app')); + } + + $order->activate($session->payment_intent); + $order->refresh(); + + return redirect(Console::getUrl(panel: 'server', tenant: $order->server)); + } + + public function cancel(Request $request): RedirectResponse + { + $sessionId = $request->get('session_id'); + + if ($sessionId) { + /** @var ?Order $order */ + $order = Order::where('stripe_checkout_id', $sessionId)->first(); + $order?->close(); + } + + return redirect(ListOrders::getUrl(panel: 'app')); + } +} diff --git a/billing/src/Models/Coupon.php b/billing/src/Models/Coupon.php new file mode 100644 index 0000000..e31c31f --- /dev/null +++ b/billing/src/Models/Coupon.php @@ -0,0 +1,119 @@ +code ??= Str::random(8); + }); + + static::created(function (self $model) { + $model->sync(); + }); + + static::updating(function (self $model) { + $model->code ??= Str::random(8); + }); + + static::updated(function (self $model) { + $model->sync(); + }); + + static::deleted(function (self $model) { + if (!is_null($model->stripe_coupon_id)) { + /** @var StripeClient $stripeClient */ + $stripeClient = app(StripeClient::class); + + $stripeClient->coupons->delete($model->stripe_coupon_id); + $stripeClient->coupons->delete($model->stripe_promotion_id); + } + }); + } + + public function sync(): void + { + /** @var StripeClient $stripeClient */ + $stripeClient = app(StripeClient::class); + + if (is_null($this->stripe_coupon_id)) { + $data = [ + 'name' => $this->name, + ]; + + if ($this->amount_off) { + $data['currency'] = config('billing.currency'); + $data['amount_off'] = $this->amount_off; + } + + if ($this->percent_off) { + $data['percent_off'] = $this->percent_off; + } + + if ($this->max_redemptions) { + $data['max_redemptions'] = $this->max_redemptions; + } + + if ($this->redeem_by) { + $data['redeem_by'] = $this->redeem_by->timestamp; + } + + $stripeCoupon = $stripeClient->coupons->create($data); + + $stripePromotionCode = $stripeClient->promotionCodes->create([ + 'code' => $this->code, + 'promotion' => [ + 'type' => 'coupon', + 'coupon' => $stripeCoupon->id, + ], + ]); + + $this->updateQuietly([ + 'stripe_coupon_id' => $stripeCoupon->id, + 'stripe_promotion_id' => $stripePromotionCode->id, + ]); + } else { + $stripeCoupon = $stripeClient->coupons->retrieve($this->stripe_coupon_id); + + // You can't update coupon objects on stripe, so check for changes and recreate the coupon if needed + if ($stripeCoupon->amount_off !== $this->amount_off || $stripeCoupon->percent_off !== $this->percent_off || $stripeCoupon->max_redemptions !== $this->max_redemptions || $stripeCoupon->redeem_by !== $this->redeem_by) { + $stripeClient->coupons->delete($this->stripe_coupon_id); + $stripeClient->coupons->delete($this->stripe_promotion_id); + + $this->stripe_coupon_id = null; + $this->sync(); + } + } + } +} diff --git a/billing/src/Models/Customer.php b/billing/src/Models/Customer.php new file mode 100644 index 0000000..624f2b5 --- /dev/null +++ b/billing/src/Models/Customer.php @@ -0,0 +1,44 @@ +BelongsTo(User::class, 'user_id'); + } + + public function orders(): HasMany + { + return $this->hasMany(Order::class, 'customer_id'); + } + + public function getLabel(): string + { + return $this->first_name . ' ' . $this->last_name; + } +} diff --git a/billing/src/Models/Order.php b/billing/src/Models/Order.php new file mode 100644 index 0000000..69c1c95 --- /dev/null +++ b/billing/src/Models/Order.php @@ -0,0 +1,239 @@ + OrderStatus::class, + 'expires_at' => 'datetime', + ]; + } + + public function customer(): BelongsTo + { + return $this->BelongsTo(Customer::class, 'customer_id'); + } + + public function productPrice(): BelongsTo + { + return $this->BelongsTo(ProductPrice::class, 'product_price_id'); + } + + public function server(): BelongsTo + { + return $this->BelongsTo(Server::class, 'server_id'); + } + + public function getLabel(): string + { + return "Order #{$this->id}"; + } + + public function checkExpire(): bool + { + if ($this->status === OrderStatus::Active && !is_null($this->expires_at) && now('UTC') >= $this->expires_at) { + try { + if ($this->server) { + app(SuspensionService::class)->handle($this->server, SuspendAction::Suspend); + } + } catch (Exception $exception) { + report($exception); + } + + $this->expireCheckoutSession(); + + $this->update([ + 'stripe_checkout_id' => null, + 'status' => OrderStatus::Expired, + ]); + + return true; + } + + return false; + } + + private function expireCheckoutSession(): void + { + if (!is_null($this->stripe_checkout_id)) { + /** @var StripeClient $stripeClient */ + $stripeClient = app(StripeClient::class); + + $session = $stripeClient->checkout->sessions->retrieve($this->stripe_checkout_id); + + if ($session->status === Session::STATUS_OPEN) { + $stripeClient->checkout->sessions->expire($session->id); + } + } + } + + public function getCheckoutSession(): Session + { + /** @var StripeClient $stripeClient */ + $stripeClient = app(StripeClient::class); + + if (is_null($this->stripe_checkout_id)) { + $session = $stripeClient->checkout->sessions->create([ + 'customer_email' => $this->customer->user->email, + 'success_url' => route('billing.checkout.success') . '?session_id={CHECKOUT_SESSION_ID}', + 'cancel_url' => route('billing.checkout.cancel') . '?session_id={CHECKOUT_SESSION_ID}', + 'line_items' => [ + [ + 'price' => $this->productPrice->stripe_id, + 'quantity' => 1, + ], + ], + 'mode' => 'payment', + 'allow_promotion_codes' => true, + 'branding_settings' => [ + 'display_name' => config('app.name'), + 'logo' => [ + 'type' => 'url', + 'url' => asset(config('app.logo') ?? 'pelican.svg'), + ], + ], + ]); + + $this->update([ + 'stripe_checkout_id' => $session->id, + ]); + + return $session; + } + + return $stripeClient->checkout->sessions->retrieve($this->stripe_checkout_id); + } + + public function activate(?string $stripePaymentId): void + { + $expireDate = match ($this->productPrice->interval_type) { + PriceInterval::Day => now('UTC')->addDays($this->productPrice->interval_value), + PriceInterval::Week => now('UTC')->addWeeks($this->productPrice->interval_value), + PriceInterval::Month => now('UTC')->addMonths($this->productPrice->interval_value), + PriceInterval::Year => now('UTC')->addYears($this->productPrice->interval_value), + }; + + $this->expireCheckoutSession(); + + $this->update([ + 'stripe_checkout_id' => null, + 'stripe_payment_id' => $stripePaymentId, + 'status' => OrderStatus::Active, + 'expires_at' => $expireDate, + ]); + + try { + if ($this->server) { + app(SuspensionService::class)->handle($this->server, SuspendAction::Unsuspend); + } else { + $this->createServer(); + } + } catch (Exception $exception) { + report($exception); + } + } + + public function close(): void + { + try { + if ($this->server) { + app(SuspensionService::class)->handle($this->server, SuspendAction::Suspend); + } + } catch (Exception $exception) { + report($exception); + } + + $this->expireCheckoutSession(); + + $this->update([ + 'stripe_checkout_id' => null, + 'status' => OrderStatus::Closed, + ]); + } + + public function createServer(): Server + { + if ($this->server) { + return $this->server; + } + + $product = $this->productPrice->product; + + $environment = []; + foreach ($product->egg->variables as $variable) { + $environment[$variable->env_variable] = $variable->default_value; + } + + $data = [ + 'name' => $this->getLabel() . ' (' . $this->productPrice->product->getLabel() . ')', + 'owner_id' => $this->customer->user->id, + 'egg_id' => $product->egg->id, + 'cpu' => $product->cpu, + 'memory' => $product->memory, + 'disk' => $product->disk, + 'swap' => $product->swap, + 'io' => 500, + 'environment' => $environment, + 'skip_scripts' => false, + 'start_on_completion' => true, + 'oom_killer' => false, + 'database_limit' => $product->database_limit, + 'allocation_limit' => $product->allocation_limit, + 'backup_limit' => $product->backup_limit, + ]; + + $object = new DeploymentObject(); + $object->setDedicated(false); + $object->setTags($product->tags); + $object->setPorts($product->ports); + + $server = app(ServerCreationService::class)->handle($data, $object); + + $this->update([ + 'server_id' => $server->id, + ]); + + return $server; + } +} diff --git a/billing/src/Models/Product.php b/billing/src/Models/Product.php new file mode 100644 index 0000000..d07713b --- /dev/null +++ b/billing/src/Models/Product.php @@ -0,0 +1,120 @@ + $ports + * @property string[] $tags + * @property int $allocation_limit + * @property int $database_limit + * @property int $backup_limit + * @property int $egg_id + * @property Egg $egg + * @property Collection|ProductPrice[] $prices + */ +class Product extends Model implements HasLabel +{ + protected $fillable = [ + 'stripe_id', + 'name', + 'description', + 'egg_id', + 'cpu', + 'memory', + 'disk', + 'swap', + 'ports', + 'tags', + 'allocation_limit', + 'database_limit', + 'backup_limit', + ]; + + protected $attributes = [ + 'ports' => '[]', + 'tags' => '[]', + ]; + + protected function casts(): array + { + return [ + 'ports' => 'array', + 'tags' => 'array', + ]; + } + + protected static function boot(): void + { + parent::boot(); + + static::created(function (self $model) { + $model->sync(); + }); + + static::updated(function (self $model) { + $model->sync(); + }); + + static::deleted(function (self $model) { + if (!is_null($model->stripe_id)) { + /** @var StripeClient $stripeClient */ + $stripeClient = app(StripeClient::class); + + $stripeClient->products->delete($model->stripe_id); + } + }); + } + + public function prices(): HasMany + { + return $this->hasMany(ProductPrice::class, 'product_id'); + } + + public function egg(): BelongsTo + { + return $this->BelongsTo(Egg::class, 'egg_id'); + } + + public function getLabel(): string + { + return $this->name; + } + + public function sync(): void + { + /** @var StripeClient $stripeClient */ + $stripeClient = app(StripeClient::class); + + if (is_null($this->stripe_id)) { + $stripeProduct = $stripeClient->products->create([ + 'name' => $this->name, + 'description' => $this->description, + ]); + + $this->updateQuietly([ + 'stripe_id' => $stripeProduct->id, + ]); + } else { + $stripeClient->products->update($this->stripe_id, [ + 'name' => $this->name, + 'description' => $this->description, + ]); + } + } +} diff --git a/billing/src/Models/ProductPrice.php b/billing/src/Models/ProductPrice.php new file mode 100644 index 0000000..fa4f6a6 --- /dev/null +++ b/billing/src/Models/ProductPrice.php @@ -0,0 +1,110 @@ + 'bool', + 'interval_type' => PriceInterval::class, + ]; + } + + protected static function boot(): void + { + parent::boot(); + + static::created(function (self $model) { + $model->sync(); + }); + + static::updated(function (self $model) { + $model->sync(); + }); + } + + public function product(): BelongsTo + { + return $this->belongsTo(Product::class, 'product_id'); + } + + public function getLabel(): string + { + return $this->interval_value . ' ' . str_plural($this->interval_type->getLabel(), $this->interval_value) . ' - ' . $this->formatCost(); + } + + public function sync(): void + { + $this->product->sync(); + + /** @var StripeClient $stripeClient */ + $stripeClient = app(StripeClient::class); + + if (is_null($this->stripe_id)) { + $stripePrice = $stripeClient->prices->create([ + 'currency' => config('billing.currency'), + 'nickname' => $this->name, + 'product' => $this->product->stripe_id, + 'unit_amount' => $this->cost * 100, // Stripe needs cent/ penny price + ]); + + $this->updateQuietly([ + 'stripe_id' => $stripePrice->id, + ]); + } else { + $stripePrice = $stripeClient->prices->retrieve($this->stripe_id); + + // You can't update price objects on stripe, so check for changes and recreate the price if needed + if ($stripePrice->product !== $this->product->stripe_id || $stripePrice->unit_amount !== $this->cost * 100) { + $this->stripe_id = null; + $this->sync(); + } + } + } + + public function isFree(): bool + { + return !$this->cost; + } + + public function formatCost(): string + { + if ($this->isFree()) { + return 'Free'; + } + + $formatter = new NumberFormatter(user()->language ?? 'en', NumberFormatter::CURRENCY); + + return $formatter->formatCurrency($this->cost, config('billing.currency')); + } +} diff --git a/billing/src/Policies/CustomerPolicy.php b/billing/src/Policies/CustomerPolicy.php new file mode 100644 index 0000000..b1f0f60 --- /dev/null +++ b/billing/src/Policies/CustomerPolicy.php @@ -0,0 +1,12 @@ +app->bind(StripeClient::class, fn () => new StripeClient(config('billing.secret'))); + + Role::registerCustomDefaultPermissions('customer'); + Role::registerCustomModelIcon('customer', 'tabler-user-dollar'); + + Role::registerCustomDefaultPermissions('product'); + Role::registerCustomModelIcon('product', 'tabler-package'); + } + + public function boot(): void + { + Schedule::command(CheckOrdersCommand::class)->everyMinute()->withoutOverlapping(); + } +} diff --git a/billing/src/Providers/BillingRoutesProvider.php b/billing/src/Providers/BillingRoutesProvider.php new file mode 100644 index 0000000..20ae1ad --- /dev/null +++ b/billing/src/Providers/BillingRoutesProvider.php @@ -0,0 +1,20 @@ +routes(function () { + Route::prefix('checkout')->withoutMiddleware(['auth'])->group(function () { + Route::get('/success', [CheckoutController::class, 'success'])->name('billing.checkout.success'); + Route::get('/cancel', [CheckoutController::class, 'cancel'])->name('billing.checkout.cancel'); + }); + }); + } +} diff --git a/generic-oidc-providers/LICENSE b/generic-oidc-providers/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/generic-oidc-providers/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + 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 GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/generic-oidc-providers/README.md b/generic-oidc-providers/README.md new file mode 100644 index 0000000..ed89d62 --- /dev/null +++ b/generic-oidc-providers/README.md @@ -0,0 +1,9 @@ +# Generic OIDC Providers (by Boy132) + +Allows administrators to create and configure generic OpenID Connect (OIDC) providers for authentication. + +## Features + +- Create custom OIDC providers through the admin panel +- Configure client ID, client secret, and authorization endpoints +- Support for multiple OIDC providers simultaneously diff --git a/generic-oidc-providers/database/migrations/001_create_generic_oidc_providers_table.php b/generic-oidc-providers/database/migrations/001_create_generic_oidc_providers_table.php new file mode 100644 index 0000000..ba3aae4 --- /dev/null +++ b/generic-oidc-providers/database/migrations/001_create_generic_oidc_providers_table.php @@ -0,0 +1,31 @@ +string('id')->primary(); + $table->boolean('create_missing_users')->default(false); + $table->boolean('link_missing_users')->default(false); + $table->string('display_name'); + $table->string('display_icon')->nullable(); + $table->string('display_color', 7)->nullable(); + $table->string('base_url'); + $table->string('client_id'); + $table->text('client_secret'); + $table->boolean('verify_jwt')->default(false); + $table->text('jwt_public_key')->nullable(); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('generic_oidc_providers'); + } +}; diff --git a/generic-oidc-providers/lang/en/strings.php b/generic-oidc-providers/lang/en/strings.php new file mode 100644 index 0000000..8509295 --- /dev/null +++ b/generic-oidc-providers/lang/en/strings.php @@ -0,0 +1,13 @@ + 'No Generic OIDC Providers', + 'generic_oidc_provider' => 'Generic OIDC Provider|Generic OIDC Providers', + 'display_name' => 'Display Name', + 'display_color' => 'Display Color', + 'display_icon' => 'Display Icon', + 'base_url' => 'Base URL', + 'redirect_url' => 'Redirect URL', + 'verify_jwt' => 'Verify JWT?', + 'jwt_public_key' => 'JWT Public Key', +]; diff --git a/generic-oidc-providers/plugin.json b/generic-oidc-providers/plugin.json new file mode 100644 index 0000000..898ecc5 --- /dev/null +++ b/generic-oidc-providers/plugin.json @@ -0,0 +1,17 @@ +{ + "id": "generic-oidc-providers", + "name": "Generic OIDC Providers", + "author": "Boy132", + "version": "1.0.0", + "description": "Allows to create generic OIDC providers.", + "category": "plugin", + "url": "https://github.com/everestmcarthur/forged-plugs/tree/main/generic-oidc-providers", + "update_url": null, + "namespace": "Boy132\\GenericOIDCProviders", + "class": "GenericOIDCProvidersPlugin", + "panels": null, + "panel_version": null, + "composer_packages": { + "kovah/laravel-socialite-oidc": "^0.8" + } +} \ No newline at end of file diff --git a/generic-oidc-providers/src/Extensions/OAuth/Schemas/GenericOIDCProviderSchema.php b/generic-oidc-providers/src/Extensions/OAuth/Schemas/GenericOIDCProviderSchema.php new file mode 100644 index 0000000..910622b --- /dev/null +++ b/generic-oidc-providers/src/Extensions/OAuth/Schemas/GenericOIDCProviderSchema.php @@ -0,0 +1,94 @@ +model->id; + } + + public function getSocialiteProvider(): string + { + return Provider::class; + } + + public function getServiceConfig(): array + { + return [ + 'client_id' => $this->model->client_id, + 'client_secret' => $this->model->client_secret, + 'base_url' => $this->model->base_url, + 'verify_jwt' => $this->model->verify_jwt, + 'jwt_public_key' => $this->model->jwt_public_key, + ]; + } + + public function getSetupSteps(): array + { + return [ + Step::make('Generic OIDC Provider') + ->schema([ + TextEntry::make('info') + ->hiddenLabel() + ->state('This a generic OIDC provider and doesn\'t require any setup!'), + ]), + ]; + } + + public function getSettingsForm(): array + { + return [ + TextEntry::make('info') + ->label('Generic OIDC Provider') + ->state('Click here to configure this generic OIDC provider.') + ->url(EditGenericOIDCProvider::getUrl(['record' => $this->model], panel: 'admin')) + ->columnSpanFull(), + ]; + } + + public function getName(): string + { + return $this->model->display_name; + } + + public function getIcon(): ?string + { + return $this->model->display_icon; + } + + public function getHexColor(): ?string + { + return $this->model->display_color; + } + + public function isEnabled(): bool + { + $id = Str::upper($this->getId()); + + return env("OAUTH_{$id}_ENABLED", true); + } + + public function shouldCreateMissingUser(OAuthUser $user): bool + { + return $this->model->create_missing_users; + } + + public function shouldLinkMissingUser(User $user, OAuthUser $oauthUser): bool + { + return $this->model->link_missing_users; + } +} diff --git a/generic-oidc-providers/src/Filament/Admin/Resources/GenericOIDCProviders/GenericOIDCProviderResource.php b/generic-oidc-providers/src/Filament/Admin/Resources/GenericOIDCProviders/GenericOIDCProviderResource.php new file mode 100644 index 0000000..613cf9f --- /dev/null +++ b/generic-oidc-providers/src/Filament/Admin/Resources/GenericOIDCProviders/GenericOIDCProviderResource.php @@ -0,0 +1,215 @@ +count() ?: null; + } + + public static function form(Schema $schema): Schema + { + return $schema + ->components([ + TextInput::make('id') + ->label('ID') + ->required() + ->live(debounce: 500) + ->afterStateUpdated(function ($state, Set $set) { + $state = Str::slug($state, '_'); + + $set('id', $state); + $set('display_name', Str::studly($state)); + }) + ->disabledOn('edit'), + TextInput::make('display_name') + ->label(trans('generic-oidc-providers::strings.display_name')) + ->required(), + ColorPicker::make('display_color') + ->label(trans('generic-oidc-providers::strings.display_color')) + ->placeholder('Default color') + ->hex(), + Select::make('display_icon') + ->label(trans('generic-oidc-providers::strings.display_icon')) + ->live() + ->options(TablerIcon::class) + ->suffixIcon(fn ($state) => $state) + ->searchable(), + TextInput::make('base_url') + ->label(trans('generic-oidc-providers::strings.base_url')) + ->required() + ->url() + ->autocomplete(false) + ->columnSpan(fn ($operation) => $operation === 'create' ? 2 : 1), + TextInput::make('redirect_url') + ->label(trans('generic-oidc-providers::strings.redirect_url')) + ->saved(false) + ->formatStateUsing(fn (Get $get) => url('/auth/oauth/callback/' . $get('id'))) + ->disabled() + ->hiddenOn('create'), + TextInput::make('client_id') + ->label(trans('admin/setting.oauth.client_id')) + ->required() + ->password() + ->revealable() + ->autocomplete(false), + TextInput::make('client_secret') + ->label(trans('admin/setting.oauth.client_secret')) + ->required() + ->password() + ->revealable() + ->autocomplete(false), + Group::make() + ->columns(3) + ->columnSpanFull() + ->schema([ + Toggle::make('create_missing_users') + ->label(trans('admin/setting.oauth.create_missing_users')) + ->inline(false) + ->onIcon('tabler-check') + ->offIcon('tabler-x') + ->onColor('success') + ->offColor('danger') + ->stateCast(new BooleanStateCast(false)), + Toggle::make('link_missing_users') + ->label(trans('admin/setting.oauth.link_missing_users')) + ->inline(false) + ->onIcon('tabler-check') + ->offIcon('tabler-x') + ->onColor('success') + ->offColor('danger') + ->stateCast(new BooleanStateCast(false)), + Toggle::make('verify_jwt') + ->label(trans('generic-oidc-providers::strings.verify_jwt')) + ->inline(false) + ->onIcon('tabler-check') + ->offIcon('tabler-x') + ->onColor('success') + ->offColor('danger') + ->stateCast(new BooleanStateCast(false)) + ->live(), + ]), + Textarea::make('jwt_public_key') + ->label(trans('generic-oidc-providers::strings.jwt_public_key')) + ->visible(fn (Get $get) => $get('verify_jwt')) + ->columnSpanFull() + ->rows(3) + ->autosize() + ->placeholder('-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA... +-----END PUBLIC KEY-----'), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->paginated(false) + ->columns([ + TextColumn::make('id') + ->label('ID') + ->sortable() + ->searchable() + ->badge(), + TextColumn::make('display_name') + ->label(trans('generic-oidc-providers::strings.display_name')) + ->sortable() + ->searchable() + ->badge() + ->icon(fn (GenericOIDCProvider $provider) => $provider->display_icon ?? 'tabler-brand-oauth') + ->color(fn (GenericOIDCProvider $provider) => $provider->display_color ? Color::hex($provider->display_color) : null), + TextColumn::make('base_url') + ->label(trans('generic-oidc-providers::strings.base_url')) + ->sortable() + ->searchable(), + IconColumn::make('verify_jwt') + ->label(trans('generic-oidc-providers::strings.verify_jwt')) + ->boolean(), + IconColumn::make('create_missing_users') + ->label(trans('admin/setting.oauth.create_missing_users')) + ->boolean(), + IconColumn::make('link_missing_users') + ->label(trans('admin/setting.oauth.link_missing_users')) + ->boolean(), + ]) + ->recordActions([ + EditAction::make(), + DeleteAction::make(), + ]) + ->toolbarActions([ + CreateAction::make(), + BulkActionGroup::make([ + DeleteBulkAction::make('exclude_bulk_delete'), + ]), + ]) + ->emptyStateIcon('tabler-brand-oauth') + ->emptyStateDescription('') + ->emptyStateHeading(trans('generic-oidc-providers::strings.no_generic_oidc_providers')); + } + + public static function getPages(): array + { + return [ + 'index' => ListGenericOIDCProviders::route('/'), + 'create' => CreateGenericOIDCProvider::route('/create'), + 'edit' => EditGenericOIDCProvider::route('/{record}/edit'), + ]; + } +} diff --git a/generic-oidc-providers/src/Filament/Admin/Resources/GenericOIDCProviders/Pages/CreateGenericOIDCProvider.php b/generic-oidc-providers/src/Filament/Admin/Resources/GenericOIDCProviders/Pages/CreateGenericOIDCProvider.php new file mode 100644 index 0000000..edbd6ff --- /dev/null +++ b/generic-oidc-providers/src/Filament/Admin/Resources/GenericOIDCProviders/Pages/CreateGenericOIDCProvider.php @@ -0,0 +1,37 @@ +getCreateFormAction()->formId('form') + ->tooltip(fn (Action $action) => $action->getLabel()) + ->hiddenLabel() + ->icon('tabler-plus'), + ]; + } + + protected function getFormActions(): array + { + return []; + } + + protected function mutateFormDataBeforeCreate(array $data): array + { + $data['id'] = Str::slug($data['id'], '_'); + + return $data; + } +} diff --git a/generic-oidc-providers/src/Filament/Admin/Resources/GenericOIDCProviders/Pages/EditGenericOIDCProvider.php b/generic-oidc-providers/src/Filament/Admin/Resources/GenericOIDCProviders/Pages/EditGenericOIDCProvider.php new file mode 100644 index 0000000..61b4d3f --- /dev/null +++ b/generic-oidc-providers/src/Filament/Admin/Resources/GenericOIDCProviders/Pages/EditGenericOIDCProvider.php @@ -0,0 +1,33 @@ +getCancelFormAction()->formId('form') + ->tooltip(fn (Action $action) => $action->getLabel()) + ->hiddenLabel() + ->icon('tabler-arrow-left'), + DeleteAction::make(), + $this->getSaveFormAction()->formId('form') + ->tooltip(fn (Action $action) => $action->getLabel()) + ->hiddenLabel() + ->icon('tabler-device-floppy'), + ]; + } +} diff --git a/generic-oidc-providers/src/Filament/Admin/Resources/GenericOIDCProviders/Pages/ListGenericOIDCProviders.php b/generic-oidc-providers/src/Filament/Admin/Resources/GenericOIDCProviders/Pages/ListGenericOIDCProviders.php new file mode 100644 index 0000000..ad0f654 --- /dev/null +++ b/generic-oidc-providers/src/Filament/Admin/Resources/GenericOIDCProviders/Pages/ListGenericOIDCProviders.php @@ -0,0 +1,11 @@ +getId())->title(); + + $panel->discoverResources(plugin_path($this->getId(), "src/Filament/$id/Resources"), "Boy132\\GenericOIDCProviders\\Filament\\$id\\Resources"); + } + + public function boot(Panel $panel): void {} +} diff --git a/generic-oidc-providers/src/Models/GenericOIDCProvider.php b/generic-oidc-providers/src/Models/GenericOIDCProvider.php new file mode 100644 index 0000000..cc622a0 --- /dev/null +++ b/generic-oidc-providers/src/Models/GenericOIDCProvider.php @@ -0,0 +1,50 @@ + 'bool', + 'link_missing_users' => 'bool', + 'client_id' => 'encrypted', + 'client_secret' => 'encrypted', + 'verify_jwt' => 'bool', + ]; + } +} diff --git a/generic-oidc-providers/src/Providers/GenericOIDCProvidersPluginProvider.php b/generic-oidc-providers/src/Providers/GenericOIDCProvidersPluginProvider.php new file mode 100644 index 0000000..bed2c4b --- /dev/null +++ b/generic-oidc-providers/src/Providers/GenericOIDCProvidersPluginProvider.php @@ -0,0 +1,21 @@ +app->make(OAuthService::class); + + $providers = GenericOIDCProvider::all(); + foreach ($providers as $provider) { + $service->register(new GenericOIDCProviderSchema($provider)); + } + } +} diff --git a/legal-pages/LICENSE b/legal-pages/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/legal-pages/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + 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 GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/legal-pages/README.md b/legal-pages/README.md new file mode 100644 index 0000000..96fec85 --- /dev/null +++ b/legal-pages/README.md @@ -0,0 +1,10 @@ +# Legal Pages (by Boy132) + +Adds essential legal pages (Imprint, Privacy Policy, Terms of Service) to the panel for compliance with legal requirements. + +## Features + +- Pre-configured legal page types (Imprint, Privacy Policy, Terms of Service) +- Admin interface for editing legal page content +- Accessible pages in the user-facing app panel +- Markdown support for page content diff --git a/legal-pages/lang/en/strings.php b/legal-pages/lang/en/strings.php new file mode 100644 index 0000000..ee28997 --- /dev/null +++ b/legal-pages/lang/en/strings.php @@ -0,0 +1,17 @@ + 'Legal Page|Legal Pages', + 'clear' => 'Clear', + + 'pages' => [ + 'imprint' => 'Imprint', + 'terms-of-service' => 'Terms of Service', + 'privacy-policy' => 'Privacy Policy', + ], + + 'notifications' => [ + 'saved' => 'Legal Pages saved', + 'saved_error' => 'Could not save Legal Pages', + ], +]; diff --git a/legal-pages/plugin.json b/legal-pages/plugin.json new file mode 100644 index 0000000..a4cb43f --- /dev/null +++ b/legal-pages/plugin.json @@ -0,0 +1,18 @@ +{ + "id": "legal-pages", + "name": "Legal Pages", + "author": "Boy132", + "version": "1.0.0", + "description": "Adds some legal pages (like an Imprint) to the panel", + "category": "plugin", + "url": "https://github.com/everestmcarthur/forged-plugs/tree/main/legal-pages", + "update_url": null, + "namespace": "Boy132\\LegalPages", + "class": "LegalPagesPlugin", + "panels": [ + "admin", + "app" + ], + "panel_version": null, + "composer_packages": null +} \ No newline at end of file diff --git a/legal-pages/resources/views/base-page.blade.php b/legal-pages/resources/views/base-page.blade.php new file mode 100644 index 0000000..6d969da --- /dev/null +++ b/legal-pages/resources/views/base-page.blade.php @@ -0,0 +1,3 @@ + + {{ $this->form }} + diff --git a/legal-pages/src/Enums/LegalPageType.php b/legal-pages/src/Enums/LegalPageType.php new file mode 100644 index 0000000..aa5f76c --- /dev/null +++ b/legal-pages/src/Enums/LegalPageType.php @@ -0,0 +1,37 @@ +name, '-'); + } + + public function getLabel(): string + { + return trans('legal-pages::strings.pages.' . $this->getId()); + } + + public function getUrl(): string + { + return '/' . Str::slug($this->getId()); + } + + /** @return class-string */ + public function getClass(): string + { + return $this->value; + } +} diff --git a/legal-pages/src/Filament/Admin/Pages/LegalPages.php b/legal-pages/src/Filament/Admin/Pages/LegalPages.php new file mode 100644 index 0000000..2256c80 --- /dev/null +++ b/legal-pages/src/Filament/Admin/Pages/LegalPages.php @@ -0,0 +1,135 @@ +|null */ + public ?array $data = []; + + public function getTitle(): string + { + return trans_choice('legal-pages::strings.legal_page', 2); + } + + public static function getNavigationLabel(): string + { + return trans_choice('legal-pages::strings.legal_page', 2); + } + + public static function getNavigationGroup(): ?string + { + return trans('admin/dashboard.advanced'); + } + + public static function canAccess(): bool + { + return user()?->can('view legalPage'); + } + + public function mount(): void + { + $data = []; + + foreach (LegalPageType::cases() as $legalPageType) { + $data[$legalPageType->getId()] = LegalPagesPlugin::Load($legalPageType); + } + + $this->form->fill($data); + } + + /** + * @return Component[] + * + * @throws Exception + */ + public function getFormSchema(): array + { + $schema = []; + + foreach (LegalPageType::cases() as $legalPageType) { + $schema[] = MarkdownEditor::make($legalPageType->getId()) + ->label($legalPageType->getLabel()) + ->disabled(fn () => !user()?->can('update legalPage')) + ->hintActions([ + Action::make('hint_view') + ->label(trans('filament-actions::view.single.label')) + ->icon('tabler-eye') + ->url($legalPageType->getUrl(), true) + ->visible(fn (Get $get) => $get($legalPageType->getId())), + Action::make('hint_clear') + ->label(trans('legal-pages::strings.clear')) + ->authorize(fn () => user()?->can('update legalPage')) + ->color('danger') + ->icon('tabler-trash') + ->action(fn (Set $set) => $set($legalPageType->getId(), null)), + ]); + } + + return $schema; + } + + protected function getFormStatePath(): ?string + { + return 'data'; + } + + protected function getHeaderActions(): array + { + return [ + Action::make('save') + ->authorize(fn () => user()?->can('update legalPage')) + ->hiddenLabel() + ->action('save') + ->keyBindings(['mod+s']) + ->tooltip(trans('filament-panels::resources/pages/edit-record.form.actions.save.label')) + ->icon('tabler-device-floppy'), + ]; + } + + public function save(): void + { + try { + $data = $this->form->getState(); + + foreach ($data as $legalPageType => $contents) { + LegalPagesPlugin::Save($legalPageType, $contents); + } + + Notification::make() + ->title(trans('legal-pages::strings.notifications.saved')) + ->success() + ->send(); + } catch (Exception $exception) { + Notification::make() + ->title(trans('legal-pages::strings.notifications.saved_error')) + ->body($exception->getMessage()) + ->danger() + ->send(); + } + } +} diff --git a/legal-pages/src/Filament/App/Pages/BaseLegalPage.php b/legal-pages/src/Filament/App/Pages/BaseLegalPage.php new file mode 100644 index 0000000..e821a36 --- /dev/null +++ b/legal-pages/src/Filament/App/Pages/BaseLegalPage.php @@ -0,0 +1,64 @@ + */ + public array $data = []; + + protected string $view = 'legal-pages::base-page'; + + protected ?string $content = null; + + public function getTitle(): string + { + return $this->getPageType()->getLabel(); + } + + public function getMaxContentWidth(): Width|string + { + return Width::SevenExtraLarge; + } + + public function mount(): void + { + $this->content = LegalPagesPlugin::Load($this->getPageType()); + + abort_if(!$this->content, 404); + } + + /** + * @return Component[] + * + * @throws Exception + */ + protected function getFormSchema(): array + { + return [ + TextEntry::make('content') + ->hiddenLabel() + ->markdown() + ->state(fn () => $this->content), + ]; + } + + protected function getFormStatePath(): ?string + { + return 'data'; + } + + abstract public function getPageType(): LegalPageType; +} diff --git a/legal-pages/src/Filament/App/Pages/Imprint.php b/legal-pages/src/Filament/App/Pages/Imprint.php new file mode 100644 index 0000000..5043cb3 --- /dev/null +++ b/legal-pages/src/Filament/App/Pages/Imprint.php @@ -0,0 +1,19 @@ +getId(); + } + + public function getPageType(): LegalPageType + { + return LegalPageType::Imprint; + } +} diff --git a/legal-pages/src/Filament/App/Pages/PrivacyPolicy.php b/legal-pages/src/Filament/App/Pages/PrivacyPolicy.php new file mode 100644 index 0000000..f6ba146 --- /dev/null +++ b/legal-pages/src/Filament/App/Pages/PrivacyPolicy.php @@ -0,0 +1,19 @@ +getId(); + } + + public function getPageType(): LegalPageType + { + return LegalPageType::PrivacyPolicy; + } +} diff --git a/legal-pages/src/Filament/App/Pages/TermsOfService.php b/legal-pages/src/Filament/App/Pages/TermsOfService.php new file mode 100644 index 0000000..d94ac7a --- /dev/null +++ b/legal-pages/src/Filament/App/Pages/TermsOfService.php @@ -0,0 +1,19 @@ +getId(); + } + + public function getPageType(): LegalPageType + { + return LegalPageType::TermsOfService; + } +} diff --git a/legal-pages/src/LegalPagesPlugin.php b/legal-pages/src/LegalPagesPlugin.php new file mode 100644 index 0000000..eb4a387 --- /dev/null +++ b/legal-pages/src/LegalPagesPlugin.php @@ -0,0 +1,49 @@ +getId())->title(); + + $panel->discoverPages(plugin_path($this->getId(), "src/Filament/$id/Pages"), "Boy132\\LegalPages\\Filament\\$id\\Pages"); + } + + public function boot(Panel $panel): void {} + + public static function Save(LegalPageType|string $type, ?string $contents): bool + { + if ($type instanceof LegalPageType) { + $type = $type->getId(); + } + + $path = $type . '.md'; + + if (!$contents) { + return Storage::delete($path); + } + + return Storage::put($path, $contents); + } + + public static function Load(LegalPageType|string $type): ?string + { + if ($type instanceof LegalPageType) { + $type = $type->getId(); + } + + return Storage::get($type . '.md'); + } +} diff --git a/legal-pages/src/Providers/LegalPagesPluginProvider.php b/legal-pages/src/Providers/LegalPagesPluginProvider.php new file mode 100644 index 0000000..81797d2 --- /dev/null +++ b/legal-pages/src/Providers/LegalPagesPluginProvider.php @@ -0,0 +1,46 @@ + [ + 'view', + 'update', + ], + ]); + Role::registerCustomModelIcon('legalPage', 'tabler-gavel'); + + $footer = null; + + foreach (LegalPageType::cases() as $legalPageType) { + $content = LegalPagesPlugin::Load($legalPageType); + + if ($content) { + $label = $legalPageType->getLabel(); + $url = $legalPageType->getUrl(); + + if (!$footer) { + $footer = "$label"; + } else { + $footer = "$footer | $label"; + } + } + } + + if ($footer) { + FilamentView::registerRenderHook(CustomRenderHooks::FooterEnd->value, fn () => Blade::render("
$footer
")); + } + } +} diff --git a/legal-pages/src/Providers/LegalPagesRouteProvider.php b/legal-pages/src/Providers/LegalPagesRouteProvider.php new file mode 100644 index 0000000..4a4946b --- /dev/null +++ b/legal-pages/src/Providers/LegalPagesRouteProvider.php @@ -0,0 +1,19 @@ +routes(function () { + foreach (LegalPageType::cases() as $legalPageType) { + Route::get($legalPageType->getId(), $legalPageType->getClass())->name('legal-pages.' . $legalPageType->getId())->withoutMiddleware(['auth']); + } + }); + } +} diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..4e35adb --- /dev/null +++ b/manifest.json @@ -0,0 +1,227 @@ +{ + "plugins": [ + { + "id": "announcements", + "name": "Announcements", + "author": "Boy132", + "version": "1.0.0", + "description": "Create panel wide announcements to inform your users about stuff", + "category": "plugin", + "download_url": "https://github.com/everestmcarthur/forged-plugs/archive/refs/heads/main.zip", + "plugin_download_url": "https://raw.githubusercontent.com/everestmcarthur/forged-plugs/main/announcements/", + "readme": "# Announcements (by Boy132)\n\nCreate panel-wide announcements to inform your users about important updates, maintenance schedules, or any other information.\n\n## Features\n\n- Create announcements with customizable titles and body text\n- Support for different announcement types (info, warning, danger, success)\n- Target specific panels (admin, app, server) or display on all panels\n- Schedule announcements with valid from/to dates\n- Announcements are displayed as alert banners across the panel\n", + "has_preview": false, + "preview_url": null + }, + { + "id": "billing", + "name": "Billing", + "author": "Boy132", + "version": "1.0.0", + "description": "A simple billing plugin which allows users to purchase servers.", + "category": "plugin", + "download_url": "https://github.com/everestmcarthur/forged-plugs/archive/refs/heads/main.zip", + "plugin_download_url": "https://raw.githubusercontent.com/everestmcarthur/forged-plugs/main/billing/", + "readme": "# Billing (by Boy132)\n\nA simple billing plugin that allows users to purchase servers using Stripe as the payment processor.\n\n**WARNING: This plugin is incomplete! Do NOT use this plugin in production!**\n\n## Features\n\n- Stripe integration for payment processing\n- Product management with customizable pricing intervals (monthly, yearly, etc.)\n- Coupon system with percentage and fixed amount discounts\n- Customer management linked to user accounts\n- Order tracking and management\n- Dashboard widget fo", + "has_preview": false, + "preview_url": null + }, + { + "id": "generic-oidc-providers", + "name": "Generic OIDC Providers", + "author": "Boy132", + "version": "1.0.0", + "description": "Allows to create generic OIDC providers.", + "category": "plugin", + "download_url": "https://github.com/everestmcarthur/forged-plugs/archive/refs/heads/main.zip", + "plugin_download_url": "https://raw.githubusercontent.com/everestmcarthur/forged-plugs/main/generic-oidc-providers/", + "readme": "# Generic OIDC Providers (by Boy132)\n\nAllows administrators to create and configure generic OpenID Connect (OIDC) providers for authentication.\n\n## Features\n\n- Create custom OIDC providers through the admin panel\n- Configure client ID, client secret, and authorization endpoints\n- Support for multiple OIDC providers simultaneously\n", + "has_preview": false, + "preview_url": null + }, + { + "id": "legal-pages", + "name": "Legal Pages", + "author": "Boy132", + "version": "1.0.0", + "description": "Adds some legal pages (like an Imprint) to the panel", + "category": "plugin", + "download_url": "https://github.com/everestmcarthur/forged-plugs/archive/refs/heads/main.zip", + "plugin_download_url": "https://raw.githubusercontent.com/everestmcarthur/forged-plugs/main/legal-pages/", + "readme": "# Legal Pages (by Boy132)\n\nAdds essential legal pages (Imprint, Privacy Policy, Terms of Service) to the panel for compliance with legal requirements.\n\n## Features\n\n- Pre-configured legal page types (Imprint, Privacy Policy, Terms of Service)\n- Admin interface for editing legal page content\n- Accessible pages in the user-facing app panel\n- Markdown support for page content\n", + "has_preview": false, + "preview_url": null + }, + { + "id": "mclogs-uploader", + "name": "Mclogs Uploader", + "author": "Boy132", + "version": "1.0.0", + "description": "Upload console logs to mclo.gs", + "category": "plugin", + "download_url": "https://github.com/everestmcarthur/forged-plugs/archive/refs/heads/main.zip", + "plugin_download_url": "https://raw.githubusercontent.com/everestmcarthur/forged-plugs/main/mclogs-uploader/", + "readme": "# MCLogs Uploader (by Boy132)\n\nUpload server console logs to mclo.gs for easy sharing and troubleshooting.\n\n## Features\n\n- One-click upload of console logs to mclo.gs\n- Integrated action button in the server console\n- Perfect for (but not limited to) Minecraft server\n", + "has_preview": false, + "preview_url": null + }, + { + "id": "minecraft-modrinth", + "name": "Minecraft Modrinth", + "author": "Boy132", + "version": "1.0.0", + "description": "Easily download minecraft mods & plugins from modrinth", + "category": "plugin", + "download_url": "https://github.com/everestmcarthur/forged-plugs/archive/refs/heads/main.zip", + "plugin_download_url": "https://raw.githubusercontent.com/everestmcarthur/forged-plugs/main/minecraft-modrinth/", + "readme": "# Minecraft Modrinth (by Boy132)\n\nEasily download and install Minecraft mods and plugins directly from Modrinth within the server panel.\n\n## Setup\n\nAdd `modrinth_mods` or `modrinth_plugins` to the _features_ of your egg to enable the mod/plugins page. \nAlso make sure your egg has the `minecraft` _tag_ and a _tag_ for the [mod loader](https://github.com/pelican-dev/plugins/blob/main/minecraft-modrinth/src/Enums/MinecraftLoader.php#L10-L16). (e.g. `paper` or `neoforge`)\n\n## Features\n\n- Browse and", + "has_preview": false, + "preview_url": null + }, + { + "id": "pirate-language", + "name": "Pirate Language", + "author": "Boy132", + "version": "1.0.0", + "description": "Turns yer site's lingo into pirate talk, matey!", + "category": "language", + "download_url": "https://github.com/everestmcarthur/forged-plugs/archive/refs/heads/main.zip", + "plugin_download_url": "https://raw.githubusercontent.com/everestmcarthur/forged-plugs/main/pirate-language/", + "readme": "# Pirate Language (by Boy132)\n\nTurns yer site's lingo into pirate talk, matey! A fun language pack that transforms the entire panel interface into pirate speak.\n\n_Not all sites are translated yet!_\n\n## Features\n\n- Complete translation of panel interface to pirate speak\n- Covers admin, server, and profile sections\n- Fun and thematic for gaming communities\n- Easy to enable through language settings\n", + "has_preview": false, + "preview_url": null + }, + { + "id": "player-counter", + "name": "Player Counter", + "author": "Boy132", + "version": "1.0.0", + "description": "Show the amount of connected players to the server", + "category": "plugin", + "download_url": "https://github.com/everestmcarthur/forged-plugs/archive/refs/heads/main.zip", + "plugin_download_url": "https://raw.githubusercontent.com/everestmcarthur/forged-plugs/main/player-counter/", + "readme": "# Player Counter (by Boy132)\n\nShow the amount of connected players to game servers with real-time querying capabilities.\n\n## Setup\n\nMake sure your server has an allocation with a public ip. Alternatively, if you use local ips you can put the public ip in the allocation alias and enable \"Use allocation alias?\" in the plugin settings.\n\nMinecraft servers will first try the query (which requires you to set `enable-query` to true and `query-port` to your server port in `server.properties`) and will f", + "has_preview": false, + "preview_url": null + }, + { + "id": "register", + "name": "Register", + "author": "Boy132", + "version": "1.0.0", + "description": "A simple way for users to register themselves", + "category": "plugin", + "download_url": "https://github.com/everestmcarthur/forged-plugs/archive/refs/heads/main.zip", + "plugin_download_url": "https://raw.githubusercontent.com/everestmcarthur/forged-plugs/main/register/", + "readme": "# Register (by Boy132)\n\nA simple way for users to register themselves on the panel without administrator intervention.\n\n## Features\n\n- Self-service user registration\n- Seamless integration with existing login flow\n", + "has_preview": false, + "preview_url": null + }, + { + "id": "robo-avatars", + "name": "Robo Avatars", + "author": "Boy132", + "version": "1.0.0", + "description": "Adds RoboHash as avatar provider", + "category": "plugin", + "download_url": "https://github.com/everestmcarthur/forged-plugs/archive/refs/heads/main.zip", + "plugin_download_url": "https://raw.githubusercontent.com/everestmcarthur/forged-plugs/main/robo-avatars/", + "readme": "# Robo Avatars (by Boy132)\n\nAdds [RoboHash](https://robohash.org/) as an avatar provider, generating unique robot avatars for users based on their email address.\n\n## Features\n\n- Automatic robot avatar generation for all users\n- Fun and distinctive visual identity for users\n- Unique avatars based on email hash\n", + "has_preview": false, + "preview_url": null + }, + { + "id": "rust-umod", + "name": "Rust uMod", + "author": "Boy132", + "version": "1.0.0", + "description": "Easily download rust plugins from uMod", + "category": "plugin", + "download_url": "https://github.com/everestmcarthur/forged-plugs/archive/refs/heads/main.zip", + "plugin_download_url": "https://raw.githubusercontent.com/everestmcarthur/forged-plugs/main/rust-umod/", + "readme": "# Rust uMod (by Boy132)\n\nEasily download and install Rust plugins directly from uMod (formerly Oxide) within the server panel.\n\n## Setup\n\nAdd `umod_plugins` to the _features_ of your egg to enable the mod page. \nAlso make sure you use `oxide` or `umod` as modding framework. (`FRAMEWORK` startup variable)\n\n## Features\n\n- Browse and search uMod's Rust plugin library\n- One-click installation to the correct directory\n- Search and filter plugins by name\n", + "has_preview": false, + "preview_url": null + }, + { + "id": "snowflakes", + "name": "Snowflakes", + "author": "Boy132 & notCharles", + "version": "1.0.0", + "description": "Let it snow, let it snow, let it snow", + "category": "plugin", + "download_url": "https://github.com/everestmcarthur/forged-plugs/archive/refs/heads/main.zip", + "plugin_download_url": "https://raw.githubusercontent.com/everestmcarthur/forged-plugs/main/snowflakes/", + "readme": "# Snowflakes (by Boy132 & notCharles)\n\nLet it snow, let it snow, let it snow! Adds a festive snowfall animation to the panel.\n\n## Features\n\n- Animated falling snowflakes across all panels\n- Non-intrusive - doesn't affect panel functionality\n- Perfect for holiday seasons or winter themes\n", + "has_preview": false, + "preview_url": null + }, + { + "id": "subdomains", + "name": "Subdomains", + "author": "Boy132 & HarlequinSin", + "version": "1.0.0", + "description": "Allows users to create subdomains for their servers", + "category": "plugin", + "download_url": "https://github.com/everestmcarthur/forged-plugs/archive/refs/heads/main.zip", + "plugin_download_url": "https://raw.githubusercontent.com/everestmcarthur/forged-plugs/main/subdomains/", + "readme": "# Subdomains (by Boy132 & HarlequinSin)\n\nAllows users to create and manage custom subdomains (A/AAAA or SRV) for their game servers using Cloudflare DNS.\n\n## Setup\n\n[Create a Cloudflare API token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/) and enter it via the plugin settings. \nThe token needs to have read permissions for `Zone.Zone` and write for `Zone.Dns`. For better security you can also set the `Zone Resources` to exclude certain domains and add the panel", + "has_preview": false, + "preview_url": null + }, + { + "id": "tawkto-widget", + "name": "Tawk.to Widget", + "author": "Boy132", + "version": "1.0.0", + "description": "Adds a Tawk.to widget to all panels", + "category": "plugin", + "download_url": "https://github.com/everestmcarthur/forged-plugs/archive/refs/heads/main.zip", + "plugin_download_url": "https://raw.githubusercontent.com/everestmcarthur/forged-plugs/main/tawkto-widget/", + "readme": "# Tawk.to Widget (by Boy132)\n\nAdds a Tawk.to live chat widget to all panels for real-time customer support.\n\n## Features\n\n- Tawk.to live chat integration\n- Configurable through plugin settings\n", + "has_preview": false, + "preview_url": null + }, + { + "id": "theme-customizer", + "name": "Theme Customizer", + "author": "Boy132", + "version": "1.0.0", + "description": "Allows to customize the panel font and colors", + "category": "plugin", + "download_url": "https://github.com/everestmcarthur/forged-plugs/archive/refs/heads/main.zip", + "plugin_download_url": "https://raw.githubusercontent.com/everestmcarthur/forged-plugs/main/theme-customizer/", + "readme": "# Theme Customizer (by Boy132)\n\nAllows administrators to customize the panel font and colors through an intuitive settings interface.\n\n## Features\n\n- Custom font support (upload TTF files)\n- Customizable color palette\n- Live preview of changes\n", + "has_preview": false, + "preview_url": null + }, + { + "id": "tickets", + "name": "Tickets", + "author": "Boy132", + "version": "1.0.0", + "description": "Simple ticket system", + "category": "plugin", + "download_url": "https://github.com/everestmcarthur/forged-plugs/archive/refs/heads/main.zip", + "plugin_download_url": "https://raw.githubusercontent.com/everestmcarthur/forged-plugs/main/tickets/", + "readme": "# Tickets (by Boy132)\n\nA simple ticket system for users to submit support requests and for administrators to manage them.\n\n## Features\n\n- User ticket submission from server panel\n- Ticket categories and priorities\n- Ticket assignment to administrators\n- Admin ticket management and responses\n", + "has_preview": false, + "preview_url": null + }, + { + "id": "user-creatable-servers", + "name": "User Creatable Servers", + "author": "Boy132", + "version": "1.0.0", + "description": "Allow users to create their own servers", + "category": "plugin", + "download_url": "https://github.com/everestmcarthur/forged-plugs/archive/refs/heads/main.zip", + "plugin_download_url": "https://raw.githubusercontent.com/everestmcarthur/forged-plugs/main/user-creatable-servers/", + "readme": "# User Creatable Servers (by Boy132)\n\nAllow users to create their own servers within defined resource limits set by administrators.\n\n## Setup\n\nAdd the deployment tag (`user_creatable_servers` by default) to the nodes that should be used for creating servers.\n\n## Features\n\n- Users can create servers without admin intervention\n- Configurable resource limits per user (CPU, RAM, disk, etc.)\n- Admin management of user resource allocations\n- Resource usage overview widget for users\n- Integration with ", + "has_preview": false, + "preview_url": null + } + ], + "version": "1.0.0", + "repo": "everestmcarthur/forged-plugs" +} \ No newline at end of file diff --git a/mclogs-uploader/LICENSE b/mclogs-uploader/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/mclogs-uploader/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + 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 GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/mclogs-uploader/README.md b/mclogs-uploader/README.md new file mode 100644 index 0000000..4ec9e92 --- /dev/null +++ b/mclogs-uploader/README.md @@ -0,0 +1,9 @@ +# MCLogs Uploader (by Boy132) + +Upload server console logs to mclo.gs for easy sharing and troubleshooting. + +## Features + +- One-click upload of console logs to mclo.gs +- Integrated action button in the server console +- Perfect for (but not limited to) Minecraft server diff --git a/mclogs-uploader/config/mclogs-uploader.php b/mclogs-uploader/config/mclogs-uploader.php new file mode 100644 index 0000000..525eabf --- /dev/null +++ b/mclogs-uploader/config/mclogs-uploader.php @@ -0,0 +1,5 @@ + env('MCLOGS_UPLOADER_ONLY_MINECRAFT_EGGS', false), +]; diff --git a/mclogs-uploader/lang/en/upload.php b/mclogs-uploader/lang/en/upload.php new file mode 100644 index 0000000..7060b9f --- /dev/null +++ b/mclogs-uploader/lang/en/upload.php @@ -0,0 +1,14 @@ + 'Upload logs', + 'uploaded' => 'Console logs uploaded', + 'upload_failed' => 'Could not upload logs', + + 'only_minecraft_eggs' => 'Only for Minecraft eggs?', + 'only_minecraft_eggs_hint' => 'If enabled the button to upload logs will only be displayed on eggs that have the "minecraft" tag.', + + 'notifications' => [ + 'settings_saved' => 'Settings saved', + ], +]; diff --git a/mclogs-uploader/plugin.json b/mclogs-uploader/plugin.json new file mode 100644 index 0000000..4e7b0ec --- /dev/null +++ b/mclogs-uploader/plugin.json @@ -0,0 +1,17 @@ +{ + "id": "mclogs-uploader", + "name": "Mclogs Uploader", + "author": "Boy132", + "version": "1.0.0", + "description": "Upload console logs to mclo.gs", + "category": "plugin", + "url": "https://github.com/everestmcarthur/forged-plugs/tree/main/mclogs-uploader", + "update_url": null, + "namespace": "Boy132\\MclogsUploader", + "class": "MclogsUploaderPlugin", + "panels": [ + "server" + ], + "panel_version": null, + "composer_packages": null +} \ No newline at end of file diff --git a/mclogs-uploader/src/Filament/Components/Actions/UploadLogsAction.php b/mclogs-uploader/src/Filament/Components/Actions/UploadLogsAction.php new file mode 100644 index 0000000..adfd2bd --- /dev/null +++ b/mclogs-uploader/src/Filament/Components/Actions/UploadLogsAction.php @@ -0,0 +1,93 @@ +hidden(function () { + /** @var Server $server */ + $server = Filament::getTenant(); + + if (config('mclogs-uploader.only_minecraft_eggs')) { + if (!in_array('minecraft', $server->egg->tags ?? [])) { + return true; + } + } + + return $server->retrieveStatus()->isOffline(); + }); + + $this->hiddenLabel(); + + $this->tooltip(fn () => trans('mclogs-uploader::upload.upload_logs')); + + $this->icon('tabler-upload'); + + $this->color('primary'); + + $this->size(Size::ExtraLarge); + + $this->action(function () { + /** @var Server $server */ + $server = Filament::getTenant(); + + try { + $logs = Http::daemon($server->node) + ->get("/api/servers/{$server->uuid}/logs") + ->throw() + ->json('data'); + + $logs = is_array($logs) ? implode(PHP_EOL, $logs) : $logs; + + $response = Http::asForm() + ->timeout(15) + ->connectTimeout(5) + ->throw() + ->post('https://api.mclo.gs/1/log', [ + 'content' => $logs, + ]) + ->json(); + + if ($response['success']) { + Notification::make() + ->title(trans('mclogs-uploader::upload.uploaded')) + ->body($response['url']) + ->persistent() + ->success() + ->send(); + } else { + Notification::make() + ->title(trans('mclogs-uploader::upload.upload_failed')) + ->body($response['error']) + ->danger() + ->send(); + } + } catch (Exception $exception) { + report($exception); + + Notification::make() + ->title(trans('mclogs-uploader::upload.upload_failed')) + ->body($exception->getMessage()) + ->danger() + ->send(); + } + }); + } +} diff --git a/mclogs-uploader/src/MclogsUploaderPlugin.php b/mclogs-uploader/src/MclogsUploaderPlugin.php new file mode 100644 index 0000000..a19de78 --- /dev/null +++ b/mclogs-uploader/src/MclogsUploaderPlugin.php @@ -0,0 +1,48 @@ +label(trans('mclogs-uploader::upload.only_minecraft_eggs')) + ->hintIcon('tabler-question-mark') + ->hintIconTooltip(trans('mclogs-uploader::upload.only_minecraft_eggs_hint')) + ->inline(false) + ->default(fn () => config('mclogs-uploader.only_minecraft_eggs')), + ]; + } + + public function saveSettings(array $data): void + { + $this->writeToEnvironment([ + 'MCLOGS_UPLOADER_ONLY_MINECRAFT_EGGS' => $data['only_minecraft_eggs'], + ]); + + Notification::make() + ->title(trans('mclogs-uploader::upload.notifications.settings_saved')) + ->success() + ->send(); + } +} diff --git a/mclogs-uploader/src/Providers/MclogsUploaderPluginProvider.php b/mclogs-uploader/src/Providers/MclogsUploaderPluginProvider.php new file mode 100644 index 0000000..32391a7 --- /dev/null +++ b/mclogs-uploader/src/Providers/MclogsUploaderPluginProvider.php @@ -0,0 +1,18 @@ + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + 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 GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/minecraft-modrinth/README.md b/minecraft-modrinth/README.md new file mode 100644 index 0000000..d72a274 --- /dev/null +++ b/minecraft-modrinth/README.md @@ -0,0 +1,15 @@ +# Minecraft Modrinth (by Boy132) + +Easily download and install Minecraft mods and plugins directly from Modrinth within the server panel. + +## Setup + +Add `modrinth_mods` or `modrinth_plugins` to the _features_ of your egg to enable the mod/plugins page. +Also make sure your egg has the `minecraft` _tag_ and a _tag_ for the [mod loader](https://github.com/pelican-dev/plugins/blob/main/minecraft-modrinth/src/Enums/MinecraftLoader.php#L10-L16). (e.g. `paper` or `neoforge`) + +## Features + +- Browse and search Modrinth's extensive mod library +- Download mods and plugins directly to your server +- Automatic version compatibility checking +- Seamless installation to the correct server directory diff --git a/minecraft-modrinth/config/minecraft-modrinth.php b/minecraft-modrinth/config/minecraft-modrinth.php new file mode 100644 index 0000000..c40a3eb --- /dev/null +++ b/minecraft-modrinth/config/minecraft-modrinth.php @@ -0,0 +1,5 @@ + env('LATEST_MINECRAFT_VERSION', '26.1.2'), +]; diff --git a/minecraft-modrinth/lang/de/strings.php b/minecraft-modrinth/lang/de/strings.php new file mode 100644 index 0000000..a6474b8 --- /dev/null +++ b/minecraft-modrinth/lang/de/strings.php @@ -0,0 +1,46 @@ + 'Modrinth', + 'minecraft_mods' => 'Minecraft Mods', + 'minecraft_plugins' => 'Minecraft Plugins', + + 'settings' => [ + 'latest_minecraft_version' => 'Neueste Minecraft-Version', + 'settings_saved' => 'Einstellungen gespeichert', + ], + + 'page' => [ + 'open_folder' => ':folder-Ordner öffnen', + 'minecraft_version' => 'Minecraft-Version', + 'loader' => 'Loader', + 'installed' => 'Installiert :type', + 'unknown' => 'Unbekannt', + ], + + 'table' => [ + 'columns' => [ + 'title' => 'Titel', + 'author' => 'Autor', + 'downloads' => 'Downloads', + 'date_modified' => 'Geändert', + ], + ], + + 'version' => [ + 'type' => 'Typ', + 'downloads' => 'Downloads', + 'published' => 'Veröffentlicht', + 'changelog' => 'Änderungsprotokoll', + 'no_file_found' => 'Keine Datei gefunden', + ], + + 'actions' => [ + 'download' => 'Herunterladen', + ], + + 'notifications' => [ + 'download_started' => 'Download gestartet', + 'download_failed' => 'Download konnte nicht gestartet werden', + ], +]; diff --git a/minecraft-modrinth/lang/en/strings.php b/minecraft-modrinth/lang/en/strings.php new file mode 100644 index 0000000..fc3b36e --- /dev/null +++ b/minecraft-modrinth/lang/en/strings.php @@ -0,0 +1,46 @@ + 'Modrinth', + 'minecraft_mods' => 'Minecraft Mods', + 'minecraft_plugins' => 'Minecraft Plugins', + + 'settings' => [ + 'latest_minecraft_version' => 'Latest Minecraft Version', + 'settings_saved' => 'Settings saved', + ], + + 'page' => [ + 'open_folder' => 'Open :folder folder', + 'minecraft_version' => 'Minecraft Version', + 'loader' => 'Loader', + 'installed' => 'Installed :type', + 'unknown' => 'Unknown', + ], + + 'table' => [ + 'columns' => [ + 'title' => 'Title', + 'author' => 'Author', + 'downloads' => 'Downloads', + 'date_modified' => 'Modified', + ], + ], + + 'version' => [ + 'type' => 'Type', + 'downloads' => 'Downloads', + 'published' => 'Published', + 'changelog' => 'Changelog', + 'no_file_found' => 'No file found', + ], + + 'actions' => [ + 'download' => 'Download', + ], + + 'notifications' => [ + 'download_started' => 'Download started', + 'download_failed' => 'Download could not be started', + ], +]; diff --git a/minecraft-modrinth/plugin.json b/minecraft-modrinth/plugin.json new file mode 100644 index 0000000..a988da1 --- /dev/null +++ b/minecraft-modrinth/plugin.json @@ -0,0 +1,17 @@ +{ + "id": "minecraft-modrinth", + "name": "Minecraft Modrinth", + "author": "Boy132", + "version": "1.0.0", + "description": "Easily download minecraft mods & plugins from modrinth", + "category": "plugin", + "url": "https://github.com/everestmcarthur/forged-plugs/tree/main/minecraft-modrinth", + "update_url": null, + "namespace": "Boy132\\MinecraftModrinth", + "class": "MinecraftModrinthPlugin", + "panels": [ + "server" + ], + "panel_version": null, + "composer_packages": null +} \ No newline at end of file diff --git a/minecraft-modrinth/src/Enums/ModrinthProjectType.php b/minecraft-modrinth/src/Enums/ModrinthProjectType.php new file mode 100644 index 0000000..e1f3575 --- /dev/null +++ b/minecraft-modrinth/src/Enums/ModrinthProjectType.php @@ -0,0 +1,46 @@ + trans('minecraft-modrinth::strings.minecraft_mods'), + self::Plugin => trans('minecraft-modrinth::strings.minecraft_plugins'), + }; + } + + public function getFolder(): string + { + return match ($this) { + self::Mod => 'mods', + self::Plugin => 'plugins', + }; + } + + public static function fromServer(Server $server): ?ModrinthProjectType + { + $server->loadMissing('egg'); + + $features = $server->egg->features ?? []; + $tags = $server->egg->tags ?? []; + + if (in_array('modrinth_plugins', $features) || (in_array('minecraft', $tags) && in_array('plugins', $features))) { + return self::Plugin; + } + + if (in_array('modrinth_mods', $features) || (in_array('minecraft', $tags) && in_array('mods', $features))) { + return self::Mod; + } + + return null; + } +} diff --git a/minecraft-modrinth/src/Facades/MinecraftModrinth.php b/minecraft-modrinth/src/Facades/MinecraftModrinth.php new file mode 100644 index 0000000..27b4c9f --- /dev/null +++ b/minecraft-modrinth/src/Facades/MinecraftModrinth.php @@ -0,0 +1,17 @@ +getLabel(); + } + + public static function getModelLabel(): string + { + return static::getNavigationLabel(); + } + + public static function getPluralModelLabel(): string + { + return static::getNavigationLabel(); + } + + public function getTitle(): string + { + return static::getNavigationLabel(); + } + + /** + * @throws Exception + */ + public function table(Table $table): Table + { + return $table + ->records(function (?string $search, int $page) { + /** @var Server $server */ + $server = Filament::getTenant(); + + $response = MinecraftModrinth::getProjects($server, $page, $search); + + return new LengthAwarePaginator($response['hits'], $response['total_hits'], 20, $page); + }) + ->paginated([20]) + ->columns([ + ImageColumn::make('icon_url') + ->label(''), + TextColumn::make('title') + ->searchable() + ->description(fn (array $record) => (strlen($record['description']) > 120) ? substr($record['description'], 0, 120).'...' : $record['description']), + TextColumn::make('author') + ->url(fn ($state) => "https://modrinth.com/user/$state", true) + ->toggleable(), + TextColumn::make('downloads') + ->icon('tabler-download') + ->numeric() + ->toggleable(), + TextColumn::make('date_modified') + ->icon('tabler-calendar') + ->formatStateUsing(fn ($state) => Carbon::parse($state, 'UTC')->diffForHumans()) + ->tooltip(fn ($state) => Carbon::parse($state, 'UTC')->timezone(user()->timezone ?? 'UTC')->format($table->getDefaultDateTimeDisplayFormat())) + ->toggleable(), + ]) + ->recordUrl(fn (array $record) => "https://modrinth.com/{$record['project_type']}/{$record['slug']}", true) + ->recordActions([ + Action::make('download') + ->tooltip(trans('minecraft-modrinth::strings.actions.download')) + ->icon('tabler-download') + ->modalSubmitAction(false) + ->schema(function (array $record) { + $schema = []; + + /** @var Server $server */ + $server = Filament::getTenant(); + + $versions = array_slice(MinecraftModrinth::getProjectVersions($record['project_id'], $server), 0, 10); + foreach ($versions as $versionData) { + $files = $versionData['files']; + $primaryFile = null; + + foreach ($files as $fileData) { + if ($fileData['primary']) { + $primaryFile = $fileData; + break; + } + } + + $schema[] = Section::make($versionData['name']) + ->description($versionData['version_number'] . ($primaryFile ? ' (' . convert_bytes_to_readable($primaryFile['size']) . ')' : ' (' . trans('minecraft-modrinth::strings.version.no_file_found') . ')')) + ->collapsed(!$versionData['featured']) + ->collapsible() + ->icon($versionData['version_type'] === 'alpha' ? 'tabler-circle-letter-a' : ($versionData['version_type'] === 'beta' ? 'tabler-circle-letter-b' : 'tabler-circle-letter-r')) + ->iconColor($versionData['version_type'] === 'alpha' ? 'danger' : ($versionData['version_type'] === 'beta' ? 'warning' : 'success')) + ->columns(3) + ->schema([ + TextEntry::make('type') + ->badge() + ->color($versionData['version_type'] === 'alpha' ? 'danger' : ($versionData['version_type'] === 'beta' ? 'warning' : 'success')) + ->state($versionData['version_type']), + TextEntry::make('downloads') + ->badge() + ->state($versionData['downloads']), + TextEntry::make('published') + ->badge() + ->state(Carbon::parse($versionData['date_published'], 'UTC')->diffForHumans()) + ->tooltip(Carbon::parse($versionData['date_published'], 'UTC')->timezone(user()->timezone ?? 'UTC')->format('M j, Y H:i:s')), + TextEntry::make('changelog') + ->columnSpanFull() + ->markdown() + ->state($versionData['changelog']), + ]) + ->headerActions([ + Action::make('exclude_download') + ->label(trans('minecraft-modrinth::strings.actions.download')) + ->visible(!is_null($primaryFile)) + ->action(function (DaemonFileRepository $fileRepository) use ($server, $versionData, $primaryFile) { + try { + $fileRepository->setServer($server)->pull($primaryFile['url'], ModrinthProjectType::fromServer($server)->getFolder()); + + Notification::make() + ->title(trans('minecraft-modrinth::strings.notifications.download_started')) + ->body($versionData['name']) + ->success() + ->send(); + } catch (Exception $exception) { + report($exception); + + Notification::make() + ->title(trans('minecraft-modrinth::strings.notifications.download_failed')) + ->body($exception->getMessage()) + ->danger() + ->send(); + } + }), + ]); + } + + return $schema; + }), + ]); + } + + protected function getHeaderActions(): array + { + /** @var Server $server */ + $server = Filament::getTenant(); + + $folder = ModrinthProjectType::fromServer($server)->getFolder(); + + return [ + Action::make('open_folder') + ->tooltip(fn () => trans('minecraft-modrinth::strings.page.open_folder', ['folder' => $folder])) + ->icon('tabler-folder-open') + ->url(fn () => ListFiles::getUrl(['path' => $folder]), true), + ]; + } + + public function content(Schema $schema): Schema + { + /** @var Server $server */ + $server = Filament::getTenant(); + + return $schema + ->components([ + Grid::make(3) + ->schema([ + TextEntry::make('Minecraft Version') + ->state(fn () => MinecraftModrinth::getMinecraftVersion($server) ?? trans('minecraft-modrinth::strings.page.unknown')) + ->badge(), + TextEntry::make('Loader') + ->state(fn () => MinecraftModrinth::getLoaderFromServer($server)['display_name'] ?? trans('minecraft-modrinth::strings.page.unknown')) + ->icon(fn () => new HtmlString(MinecraftModrinth::getLoaderFromServer($server)['icon'] ?? '')) + ->badge(), + TextEntry::make('installed') + ->label(fn () => trans('minecraft-modrinth::strings.page.installed', ['type' => ModrinthProjectType::fromServer($server)->getLabel()])) + ->state(function (DaemonFileRepository $fileRepository) use ($server) { + try { + $files = $fileRepository->setServer($server)->getDirectory(ModrinthProjectType::fromServer($server)->getFolder()); + + if (isset($files['error'])) { + throw new Exception($files['error']); + } + + return collect($files) + ->filter(fn ($file) => $file['mime'] === 'application/jar' || str($file['name'])->lower()->endsWith('.jar')) + ->count(); + } catch (Exception $exception) { + report($exception); + + return trans('minecraft-modrinth::strings.page.unknown'); + } + }) + ->badge(), + ]), + EmbeddedTable::make(), + ]); + } +} diff --git a/minecraft-modrinth/src/MinecraftModrinthPlugin.php b/minecraft-modrinth/src/MinecraftModrinthPlugin.php new file mode 100644 index 0000000..98e55f9 --- /dev/null +++ b/minecraft-modrinth/src/MinecraftModrinthPlugin.php @@ -0,0 +1,51 @@ +getId())->title(); + + $panel->discoverPages(plugin_path($this->getId(), "src/Filament/$id/Pages"), "Boy132\\MinecraftModrinth\\Filament\\$id\\Pages"); + } + + public function boot(Panel $panel): void {} + + public function getSettingsForm(): array + { + return [ + TextInput::make('latest_minecraft_version') + ->label(trans('minecraft-modrinth::strings.settings.latest_minecraft_version')) + ->required() + ->default(fn () => config('minecraft-modrinth.latest_minecraft_version', '26.1.2')), + ]; + } + + public function saveSettings(array $data): void + { + $this->writeToEnvironment([ + 'LATEST_MINECRAFT_VERSION' => $data['latest_minecraft_version'], + ]); + + Notification::make() + ->title(trans('minecraft-modrinth::strings.settings.settings_saved')) + ->success() + ->send(); + } +} diff --git a/minecraft-modrinth/src/Services/MinecraftModrinthService.php b/minecraft-modrinth/src/Services/MinecraftModrinthService.php new file mode 100644 index 0000000..fa1e853 --- /dev/null +++ b/minecraft-modrinth/src/Services/MinecraftModrinthService.php @@ -0,0 +1,153 @@ +variables()->where(fn ($builder) => $builder->where('env_variable', 'MINECRAFT_VERSION')->orWhere('env_variable', 'MC_VERSION'))->first()?->server_value; + + if (!$version || $version === 'latest') { + return config('minecraft-modrinth.latest_minecraft_version'); + } + + return $version; + } + + /** @return array{icon: string, name: string, supported_project_types: string[], display_name: string}|null */ + public function getLoaderFromServer(Server $server): ?array + { + $server->loadMissing('egg'); + + $tags = $server->egg->tags ?? []; + + if (!in_array('minecraft', $tags)) { + return null; + } + + $projectType = ModrinthProjectType::fromServer($server)?->value; + if (!$projectType) { + return null; + } + + $loaders = $this->getLoaders(); + foreach ($loaders as $loader) { + if (!in_array($projectType, $loader['supported_project_types'])) { + continue; + } + + if (in_array($loader['name'], $tags)) { + return array_merge($loader, ['display_name' => str($loader['name'])->title()->toString()]); + } + } + + return null; + } + + /** @return array */ + public function getLoaders(): array + { + return cache()->remember('modrinth_loaders', now()->addHour(), function () { + try { + return Http::asJson() + ->timeout(5) + ->connectTimeout(5) + ->throw() + ->get('https://api.modrinth.com/v2/tag/loader') + ->json(); + } catch (Exception $exception) { + report($exception); + + return []; + } + }); + } + + /** @return array{hits: array>, total_hits: int} */ + public function getProjects(Server $server, int $page = 1, ?string $search = null): array + { + $projectType = ModrinthProjectType::fromServer($server)?->value; + $minecraftLoader = $this->getLoaderFromServer($server); + + if (!$projectType || !$minecraftLoader) { + return [ + 'hits' => [], + 'total_hits' => 0, + ]; + } + + $minecraftVersion = $this->getMinecraftVersion($server); + $minecraftLoader = $minecraftLoader['name']; + + $data = [ + 'offset' => ($page - 1) * 20, + 'limit' => 20, + 'facets' => "[[\"categories:$minecraftLoader\"],[\"versions:$minecraftVersion\"],[\"project_type:{$projectType}\"]]", + ]; + + $key = "modrinth_projects:{$projectType}:$minecraftVersion:$minecraftLoader:$page"; + + if ($search) { + $data['query'] = $search; + + $key .= ":$search"; + } + + return cache()->remember($key, now()->addMinutes(30), function () use ($data) { + try { + return Http::asJson() + ->timeout(5) + ->connectTimeout(5) + ->throw() + ->get('https://api.modrinth.com/v2/search', $data) + ->json(); + } catch (Exception $exception) { + report($exception); + + return [ + 'hits' => [], + 'total_hits' => 0, + ]; + } + }); + } + + /** @return array, game_version: string[], version_type: string, loaders: string[], featured: bool, status: string, requested_status: ?string, id: string, project_id: string, author_id: string, date_published: string, downloads: int, changelog_url: ?string, files: array}> */ + public function getProjectVersions(string $projectId, Server $server): array + { + $minecraftLoader = $this->getLoaderFromServer($server); + + if (!$minecraftLoader) { + return []; + } + + $minecraftVersion = $this->getMinecraftVersion($server); + $minecraftLoader = $minecraftLoader['name']; + + $data = [ + 'game_versions' => "[\"$minecraftVersion\"]", + 'loaders' => "[\"$minecraftLoader\"]", + ]; + + return cache()->remember("modrinth_versions:$projectId:$minecraftVersion:$minecraftLoader", now()->addMinutes(30), function () use ($projectId, $data) { + try { + return Http::asJson() + ->timeout(5) + ->connectTimeout(5) + ->throw() + ->get("https://api.modrinth.com/v2/project/$projectId/version", $data) + ->json(); + } catch (Exception $exception) { + report($exception); + + return []; + } + }); + } +} diff --git a/pirate-language/LICENSE b/pirate-language/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/pirate-language/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + 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 GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/pirate-language/README.md b/pirate-language/README.md new file mode 100644 index 0000000..71a180d --- /dev/null +++ b/pirate-language/README.md @@ -0,0 +1,12 @@ +# Pirate Language (by Boy132) + +Turns yer site's lingo into pirate talk, matey! A fun language pack that transforms the entire panel interface into pirate speak. + +_Not all sites are translated yet!_ + +## Features + +- Complete translation of panel interface to pirate speak +- Covers admin, server, and profile sections +- Fun and thematic for gaming communities +- Easy to enable through language settings diff --git a/pirate-language/lang/pirate/admin/dashboard.php b/pirate-language/lang/pirate/admin/dashboard.php new file mode 100644 index 0000000..d9a33d2 --- /dev/null +++ b/pirate-language/lang/pirate/admin/dashboard.php @@ -0,0 +1,44 @@ + 'Welcome aboard the Pelican!', + 'version' => 'Version: :version', + 'advanced' => 'High Seas', + 'server' => 'Ship', + 'user' => 'Crewmate', + 'sections' => [ + 'intro-developers' => [ + 'heading' => 'Message in a Bottle fer Developers', + 'content' => 'Thanks fer testin\' the development ship, matey!', + 'extra_note' => 'If ye run aground, report it on the GitHub seas.', + 'button_issues' => 'Raise a Complaint', + 'button_features' => 'Parley Features', + ], + 'intro-update-available' => [ + 'heading' => 'New booty be available!', + 'content' => ':latestVersion be ready fer ye! Read the scrolls to upgrade yer Panel.', + ], + 'intro-no-update' => [ + 'heading' => 'Yer Panel be shipshape', + 'content' => 'Ye be sailin\' with :version. Yer panel be all up-to-date, savvy!', + ], + 'intro-first-node' => [ + 'heading' => 'No Nodes Spotted on the Horizon', + 'content' => "Looks like ye ain't got any Nodes charted yet, but fret not — just click the action button to craft yer first one, matey!", + 'extra_note' => 'If ye be runnin\' into troubles, send word to GitHub.', + 'button_label' => 'Forge yer First Node in Pelican', + ], + 'intro-support' => [ + 'heading' => 'Lend a Hand to Pelican', + 'content' => 'We be grateful fer yer help, mates! This ship sails thanks to ye, our crew, and all hands who support us!', + 'extra_note' => 'Any aid from landlubbers or seadogs is welcome!', + 'button_translate' => 'Help Translate the Tongue', + 'button_donate' => 'Send Some Booty', + ], + 'intro-help' => [ + 'heading' => 'Need a Hand, Matey?', + 'content' => 'Start with the scrolls! Still lost? Head over to our Discord port for aid!', + 'button_docs' => 'Read the Scrolls', + ], + ], +]; diff --git a/pirate-language/lang/pirate/admin/health.php b/pirate-language/lang/pirate/admin/health.php new file mode 100644 index 0000000..cfd257c --- /dev/null +++ b/pirate-language/lang/pirate/admin/health.php @@ -0,0 +1,60 @@ + 'Health', + 'results_refreshed' => 'Health check results be updated, aye!', + 'checked' => 'Checked results from :time, matey', + 'refresh' => 'Refresh the lookout', + 'results' => [ + 'cache' => [ + 'label' => 'Cache', + 'ok' => 'Arr, all be shipshape', + 'failed_retrieve' => "Couldn't set or fetch a cache value in the hold.", + 'failed' => 'A cursed error struck the cache: :error', + ], + 'database' => [ + 'label' => 'Database', + 'ok' => 'Arr, database be connected', + 'failed' => "Couldn't connect to the database port: :error", + ], + 'debugmode' => [ + 'label' => 'Debug Mode', + 'ok' => 'Debug mode be disabled, smooth sailin’', + 'failed' => 'Debug mode was expected to be :expected, but it be :actual instead!', + ], + 'environment' => [ + 'label' => 'Environment', + 'ok' => 'Aye, environment set to :actual', + 'failed' => 'Environment be set to :actual, but we expected :expected', + ], + 'nodeversions' => [ + 'label' => 'Node Versions', + 'ok' => 'All Nodes be up-to-date and seaworthy', + 'failed' => ':outdated out o’ :all Nodes be outdated, arr!', + 'no_nodes_created' => 'No Nodes created yet, matey', + 'no_nodes' => 'No Nodes in sight', + 'all_up_to_date' => 'All be shipshape and up-to-date', + 'outdated' => ':outdated out o’ :all be outdated', + ], + 'panelversion' => [ + 'label' => 'Panel Version', + 'ok' => 'Panel be shipshape and up-to-date', + 'failed' => 'Installed version be :currentVersion but latest be :latestVersion, matey!', + 'up_to_date' => 'All caught up', + 'outdated' => 'Old as a barnacle', + ], + 'schedule' => [ + 'label' => 'Schedule', + 'ok' => 'Aye, all good', + 'failed_last_ran' => 'The last time the schedule ran was over :time minutes ago, arr!', + 'failed_not_ran' => "The schedule hasn't set sail yet.", + ], + 'useddiskspace' => [ + 'label' => 'Disk Space', + ], + ], + 'checks' => [ + 'successful' => 'Fair winds', + 'failed' => 'Davy Jones’ locker', + ], +]; diff --git a/pirate-language/lang/pirate/admin/plugin.php b/pirate-language/lang/pirate/admin/plugin.php new file mode 100644 index 0000000..0d15acb --- /dev/null +++ b/pirate-language/lang/pirate/admin/plugin.php @@ -0,0 +1,47 @@ + 'Add-ons', + 'model_label' => 'Add-on', + 'model_label_plural' => 'Add-ons', + + 'name' => 'Name o\' the Treasure', + 'update_available' => 'Thar be an update fer this here add-on!', + 'author' => 'Scallywag Who Made It', + 'version' => 'Version o\' the Booty', + 'category' => 'Type o\' Loot', + 'status' => 'State o\' the Booty', + 'settings' => 'Ship Settin\'s', + 'install' => 'Hoist It Aboard', + 'update' => 'Refit', + 'enable' => 'Raise the Sails', + 'disable' => 'Drop Anchor', + 'import' => 'Smuggle In', + 'no_plugins' => 'Nay Add-ons in Sight', + 'from_file' => 'From the Captain\'s Log', + 'from_url' => 'From the Sea o\' URLs', + 'all' => 'All Hands', + + 'status_enum' => [ + 'not_installed' => 'Ain\'t Been Hoisted Yet', + 'disabled' => 'Anchor Be Dropped', + 'enabled' => 'Sails Be Raised', + 'errored' => 'Cursed with Errors', + 'incompatible' => 'Don\'t Belong on This Ship', + ], + + 'category_enum' => [ + 'plugin' => 'Trinket', + 'theme' => 'Colors o\' the Ship', + 'language' => 'Tongue o\' the Seas', + ], + + 'notifications' => [ + 'installed' => 'Add-on be hoisted aboard!', + 'updated' => 'Add-on\'s been given a fresh coat o\' paint!', + 'enabled' => 'Add-on be awake and ready, yarrr!', + 'disabled' => 'Add-on be sleepin\' in the brig.', + 'downloaded' => 'Add-on plundered from the net!', + 'download_failed' => 'Blast it! Couldn\'t snatch the add-on!', + ], +]; diff --git a/pirate-language/lang/pirate/exceptions.php b/pirate-language/lang/pirate/exceptions.php new file mode 100644 index 0000000..896d767 --- /dev/null +++ b/pirate-language/lang/pirate/exceptions.php @@ -0,0 +1,64 @@ + 'There be a storm brewin\' while tryin\' to parley with the daemon, resultin\' in a HTTP/:code response. This scallywag error has been logged in the captain\'s log.', + 'node' => [ + 'servers_attached' => 'A node can only be sent to Davy Jones\' Locker if no servers be chained to it.', + 'error_connecting' => 'Trouble makin\' contact with :node, arrr!', + 'daemon_off_config_updated' => 'The daemon\'s config has been updated, but there was a squall tryin\' to update the config file on the daemon itself. Ye\'ll need to update the config.yml file by hand to make the changes take hold.', + ], + 'allocations' => [ + 'server_using' => 'This allocation be already claimed by a server. Ye can only delete it if no server be assigned.', + 'too_many_ports' => 'Tryin\' to add over 1000 ports in one go ain\'t supported, matey.', + 'invalid_mapping' => 'The map given for port :port be as wrong as a drunk sailor\'s compass and can\'t be processed.', + 'cidr_out_of_range' => 'CIDR notation only allows masks from /25 to /32 — no more, no less!', + 'port_out_of_range' => 'Ports must be between 1024 and 65535 to sail these waters.', + ], + 'egg' => [ + 'delete_has_servers' => 'Ye can\'t toss an Egg overboard if there be active servers hatchin\' from it.', + 'invalid_copy_id' => 'The Egg ye picked to copy a script from either don\'t exist or be copyin\' from another script itself.', + 'has_children' => 'This Egg be a parent to other Eggs. Ye must send them to the deep before ye delete this one.', + ], + 'variables' => [ + 'env_not_unique' => 'The environment variable :name must be unique for this Egg\'s domain.', + 'reserved_name' => 'The environment variable :name be protected — no assignin\' allowed!', + 'bad_validation_rule' => 'The validation rule ":rule" be no good for this ship\'s application.', + ], + 'importer' => [ + 'json_error' => 'There was trouble parsing the JSON treasure map: :error.', + 'file_error' => 'The JSON file provided be nothin\' but bilge water.', + 'invalid_json_provided' => 'The JSON file be not in a form the ship can recognize.', + ], + 'subusers' => [ + 'editing_self' => 'Ye can\'t be editin\' yer own subuser account, savvy?', + 'user_is_owner' => 'Ye can\'t add the server\'s captain as a subuser, no matter how much grog ye offer.', + 'subuser_exists' => 'A matey with that email be already listed as a subuser for this server.', + ], + 'databases' => [ + 'delete_has_databases' => 'Ye can\'t scuttle a database host server while it still has active databases tied to it.', + ], + 'tasks' => [ + 'chain_interval_too_long' => 'The longest waitin\' time fer a chained task be 15 minutes, no more!', + ], + 'locations' => [ + 'has_nodes' => 'Ye can\'t delete a location if it\'s got active nodes anchored there.', + ], + 'users' => [ + 'is_self' => 'Ye can\'t send yerself to the briny deep by deletin\' yer own user account.', + 'has_servers' => 'Ye can\'t delete a user while they\'ve got servers sailin\' under their flag. Sink their servers first, then come back.', + 'node_revocation_failed' => 'Failed to revoke keys on Node #:node. :error', + ], + 'deployment' => [ + 'no_viable_nodes' => 'No nodes meetin\' the demands for automatic deployment could be found in these waters.', + 'no_viable_allocations' => 'No allocations fit fer automatic deployment were found, arr!', + ], + 'api' => [ + 'resource_not_found' => 'The treasure ye seek does not exist on this server.', + ], + 'mount' => [ + 'servers_attached' => 'A mount must be free of servers before it can be sent to the depths.', + ], + 'server' => [ + 'marked_as_failed' => 'This server\'s installation voyage ain\'t finished yet, try again later, matey.', + ], +]; diff --git a/pirate-language/lang/pirate/profile.php b/pirate-language/lang/pirate/profile.php new file mode 100644 index 0000000..7efce80 --- /dev/null +++ b/pirate-language/lang/pirate/profile.php @@ -0,0 +1,64 @@ + 'English (Pirate)', + + 'title' => 'Captain\'s Log', + 'tabs' => [ + 'account' => 'Account', + 'oauth' => 'OAuth', + 'activity' => 'Deck Happenings', + 'api_keys' => 'API Keys', + 'ssh_keys' => 'SSH Keys', + '2fa' => 'Two-Factor Challenge', + 'customization' => 'Riggin\'', + ], + 'username' => 'Pirate Name', + 'admin' => 'Captain', + 'exit_admin' => 'Leave Captain\'s Quarters', + 'email' => 'Message in a Bottle', + 'password' => 'Secret Code', + 'current_password' => 'Current Secret Code', + 'password_confirmation' => 'Confirm Secret Code', + 'timezone' => 'Time Zone o\' the Seas', + 'language' => 'Tongue', + 'language_help' => 'Yer tongue :state hasn\'t been translated to pirate talk yet!', + 'link' => 'Link \'em', + 'unlink' => 'Cut the Line', + 'unlinked' => ':name cut loose', + 'scan_qr' => 'Scan the Pirate\'s Mark (QR Code)', + 'code' => 'Code', + 'setup_key' => 'Set Up the Key', + 'invalid_code' => 'Wrong 2FA Code, ye scallywag!', + 'code_help' => 'Scan the Pirate\'s Mark above with yer two-step auth app, then enter the secret code it gives ye.', + '2fa_enabled' => 'Two-Factor Authentication be hoisted and ready!', + 'backup_help' => 'These treasure codes won\'t show again!', + 'backup_codes' => 'Backup Treasure Codes', + 'disable_2fa' => 'Lower the 2FA Flag', + 'disable_2fa_help' => 'Enter yer current 2FA code to lower the Two-Factor Authentication flag', + 'api_keys' => 'API Keys', + 'create_api_key' => 'Forge a New API Key', + 'api_key_created' => 'API Key Forged', + 'description' => 'Tale o\' the Key', + 'allowed_ips' => 'Allowed IPs o\' the Seas', + 'allowed_ips_help' => 'Press enter to add a new IP or leave blank to let any IP sail through', + 'ssh_keys' => 'SSH Keys', + 'create_ssh_key' => 'Forge a New SSH Key', + 'ssh_key_created' => 'SSH Key Forged', + 'name' => 'Name o\' the Key', + 'public_key' => 'Public Key', + 'could_not_create_ssh_key' => 'Failed to forge the SSH key, arrr!', + 'dashboard' => 'Captain\'s Helm', + 'dashboard_layout' => 'Captain\'s Helm Layout', + 'console' => 'Ship\'s Wheel', + 'grid' => 'Grid o\' the Deck', + 'table' => 'Table o\' Logs', + 'rows' => 'Rows o\' the Crew', + 'font_size' => 'Letter Size', + 'font' => 'Letterin\' Style', + 'font_preview' => 'Peek at the Letterin\'', + 'seconds' => 'Seconds o\' the Clock', + 'graph_period' => 'Chartin\' Time Span', + 'graph_period_helper' => 'How many data points, in seconds, be shown on the ship\'s console charts.', + +]; diff --git a/pirate-language/lang/pirate/server/activity.php b/pirate-language/lang/pirate/server/activity.php new file mode 100644 index 0000000..5f6d23e --- /dev/null +++ b/pirate-language/lang/pirate/server/activity.php @@ -0,0 +1,11 @@ + 'Cap\'n\'s Log', + 'event' => 'Happenin\'', + 'user' => 'Scallywag', + 'deleted_user' => 'Vanished Scallywag', + 'system' => 'The Ship', + 'timestamp' => 'Hourglass Sand', + 'metadata' => 'Hidden Booty', +]; diff --git a/pirate-language/lang/pirate/server/backup.php b/pirate-language/lang/pirate/server/backup.php new file mode 100644 index 0000000..1bbdc2f --- /dev/null +++ b/pirate-language/lang/pirate/server/backup.php @@ -0,0 +1,50 @@ + 'Booty Logs', + 'empty' => 'No Booty in the Hold', + 'size' => 'Cargo Weight', + 'created_at' => 'Stashed On', + 'status' => 'Condition o\' the Booty', + 'is_locked' => 'Be It Locked?', + 'backup_status' => [ + 'in_progress' => 'Still Bein\' Buried', + 'successful' => 'Buried Treasure Found', + 'failed' => 'The Buryin\' Failed', + ], + 'actions' => [ + 'create' => [ + 'title' => 'Stash New Booty', + 'limit' => 'Booty Hold Be Full', + 'created' => ':name be buried deep', + 'notification_success' => 'Booty Buried Successfully', + 'notification_fail' => 'Couldn\'t Bury the Booty', + 'name' => 'Name o\' the Booty', + 'ignored' => 'Files & Folders Left Behind', + 'locked' => 'Chained Down?', + 'lock_helper' => 'Stops this treasure from bein\' tossed until ye unchain it yerself.', + ], + 'lock' => [ + 'lock' => 'Chain It', + 'unlock' => 'Unchain It', + ], + 'download' => 'Snag It', + 'restore' => [ + 'title' => 'Raise the Booty', + 'helper' => 'Yer ship\'ll be stopped cold. No controls, no charts, no new stashin\' until the booty be back in place.', + 'delete_all' => 'Scuttle all files before raisin\' the treasure?', + 'notification_started' => 'Booty Be Comin\' Back', + 'notification_success' => 'Booty Raised from the Depths', + 'notification_fail' => 'Couldn\'t Raise the Booty', + 'notification_fail_body_1' => 'This vessel ain\'t ready to raise no treasure just yet.', + 'notification_fail_body_2' => 'This booty can\'t be raised now — it\'s either lost or unfinished.', + ], + 'delete' => [ + 'title' => 'Sink the Booty', + 'description' => 'Ye sure ye want to sink :backup to the deep?', + 'notification_success' => 'Booty Sunk to the Briny Deep', + 'notification_fail' => 'Couldn\'t Sink the Booty', + 'notification_fail_body' => 'Lost contact with the crow\'s nest. Try again later.', + ], + ], +]; diff --git a/pirate-language/lang/pirate/server/console.php b/pirate-language/lang/pirate/server/console.php new file mode 100644 index 0000000..b03045f --- /dev/null +++ b/pirate-language/lang/pirate/server/console.php @@ -0,0 +1,39 @@ + 'Speak\'n Tube', + 'command' => 'Type yer orders here...', + 'command_blocked' => 'Ship\'s Dead in the Water...', + 'command_blocked_title' => 'Can\'t shout orders when the ship be sinkin\'!', + 'open_in_admin' => 'Board as Cap\'n', + 'power_actions' => [ + 'start' => 'Hoist the Sails', + 'stop' => 'Drop Anchor', + 'restart' => 'Re-hoist the Colors', + 'kill' => 'Sink Her!', + 'kill_tooltip' => 'This might send yer data to Davy Jones\' locker!', + ], + 'labels' => [ + 'cpu' => 'Thinkin\' Box (CPU)', + 'memory' => 'Rum Storage', + 'network' => 'Spyglass (Network)', + 'disk' => 'Cargo Hold (Disk)', + 'name' => 'Ship\'s Name', + 'status' => 'Current State o\' the Ship', + 'address' => 'Where She Be Docked', + 'unavailable' => 'Nowhere to be Found', + ], + 'status' => [ + 'created' => 'Forged in the Shipwright\'s Forge', + 'starting' => 'Hoistin\' the Anchor', + 'running' => 'Sailin\' Full Speed', + 'restarting' => 'Turnin\' the Ship ‘Round', + 'exited' => 'Jumped Overboard', + 'paused' => 'Nappin\' in a Hammock', + 'dead' => 'Lost to the Deep', + 'removing' => 'Scuttlin\' the Wreck', + 'stopping' => 'Droppin\' Anchor', + 'offline' => 'Below the Waves', + 'missing' => 'Vanished in a Fog', + ], +]; diff --git a/pirate-language/lang/pirate/server/dashboard.php b/pirate-language/lang/pirate/server/dashboard.php new file mode 100644 index 0000000..f0b8727 --- /dev/null +++ b/pirate-language/lang/pirate/server/dashboard.php @@ -0,0 +1,25 @@ + 'Fleet o\' Ships', + 'list' => 'Manifest o\' Ships', + 'my_servers' => 'Me Own Vessels', + 'other_servers' => 'Ships of Other Scallywags', + 'all_servers' => 'The Whole Armada', + 'empty_own' => 'Ye own no ships, landlubber!', + 'empty_other' => 'Ye\'ve no rights to any other vessels!', + + 'status' => 'Where She Be Standin\'', + 'server' => 'The Ship', + 'resource' => 'Supplies', + 'usage_limit' => 'Limit o\' Usage: :resource', + + 'cpu' => 'Captain\'s Cogitator (CPU)', + 'memory' => 'Memory Chest', + 'disk' => 'Cargo Bay', + 'network' => 'Signal Ropes', + 'none' => 'Nay', + 'loading' => 'Hoistin\' the sails...', + + 'power_actions' => 'Ship Commands', +]; diff --git a/pirate-language/lang/pirate/server/database.php b/pirate-language/lang/pirate/server/database.php new file mode 100644 index 0000000..f3abd92 --- /dev/null +++ b/pirate-language/lang/pirate/server/database.php @@ -0,0 +1,21 @@ + 'Vaults o\' Knowledge', + 'create_database' => 'Forge a New Vault', + 'limit' => 'Vault Limit Reached, Ye Greedy Dog!', + 'viewing' => 'Peekin\' Inside: :database', + 'host' => 'Harbor Master (Host)', + 'database' => 'Treasure Vault', + 'username' => 'Scallywag Name', + 'password' => 'Secret Code', + 'remote' => 'Distant Lands', + 'created_at' => 'Buried On', + 'name' => 'Name o\' the Vault', + 'name_hint' => 'Leave blank an\' a name shall be summoned from the depths', + 'connections_from' => 'Boardin\' From', + 'max_connections' => 'Max Boarders', + 'database_host' => 'Vault Keeper', + 'database_host_select' => 'Pick Yer Vault Keeper', + 'jdbc' => 'JDBC Map to the Treasure', +]; diff --git a/pirate-language/lang/pirate/server/file.php b/pirate-language/lang/pirate/server/file.php new file mode 100644 index 0000000..25ac2ab --- /dev/null +++ b/pirate-language/lang/pirate/server/file.php @@ -0,0 +1,82 @@ + 'Ship\'s Logs', + 'name' => 'Name o\' the Scroll', + 'size' => 'Heft o\' the Loot', + 'modified_at' => 'Last Tampered', + 'actions' => [ + 'open' => 'Crack It Open', + 'download' => 'Snag It', + 'copy' => [ + 'title' => 'Make a Twin', + 'notification' => 'Scroll Be Duplicated', + ], + 'upload' => [ + 'title' => 'Stash Aboard', + 'from_files' => 'Bring Files Aboard', + 'from_url' => 'Fetch from Faraway Lands (URL)', + 'url' => 'Map to the Loot (URL)', + ], + 'rename' => [ + 'title' => 'Change the Name', + 'file_name' => 'New Scroll Title', + 'notification' => 'Scroll Be Renamed', + ], + 'move' => [ + 'title' => 'Stow Elsewhere', + 'directory' => 'Locker', + 'directory_hint' => 'Point the way to the new locker (relative to now)', + 'new_location' => 'New Dock', + 'new_location_hint' => 'Chart the new dock (relative)', + 'notification' => 'Scroll Moved', + 'bulk_notification' => ':count scrolls moved to :directory', + ], + 'permissions' => [ + 'title' => 'Who Can Touch It?', + 'read' => 'Spy It', + 'write' => 'Scratch on It', + 'execute' => 'Set It Sailin\'', + 'owner' => 'Cap\'n', + 'group' => 'The Crew', + 'public' => 'All Hands', + 'notification' => 'Rules be changed to :mode', + ], + 'archive' => [ + 'title' => 'Bottle It Up', + 'archive_name' => 'Name o\' the Barrel', + 'notification' => 'Barrel Sealed Tight', + ], + 'unarchive' => [ + 'title' => 'Crack Open the Barrel', + 'notification' => 'Booty Unpacked', + ], + 'new_file' => [ + 'title' => 'Scribe New Scroll', + 'file_name' => 'Name o\' the New Scroll', + 'syntax' => 'Scroll Style (Syntax)', + 'create' => 'Start Scribblin\'', + ], + 'new_folder' => [ + 'title' => 'Build New Locker', + 'folder_name' => 'Name o\' the New Locker', + ], + 'global_search' => [ + 'title' => 'Search the Seven Seas', + 'search_term' => 'What Be Ye Lookin\' For?', + 'search_term_placeholder' => 'Toss a word in, like *.txt', + 'search' => 'Start the Hunt', + ], + 'delete' => [ + 'notification' => 'Scroll Sent to the Depths', + 'bulk_notification' => ':count scrolls tossed overboard', + ], + 'edit' => [ + 'title' => 'Scribblin\' on: :file', + 'save_close' => 'Seal & Close', + 'save' => 'Seal the Changes', + 'cancel' => 'Abandon Ship', + 'notification' => 'Scroll Sealed Up', + ], + ], +]; diff --git a/pirate-language/lang/pirate/server/network.php b/pirate-language/lang/pirate/server/network.php new file mode 100644 index 0000000..18849a2 --- /dev/null +++ b/pirate-language/lang/pirate/server/network.php @@ -0,0 +1,15 @@ + 'Signal Ropes', + 'add' => 'Claim a New Channel', + 'limit' => 'Ye\'ve Reached the End o\' the Ropes!', + 'address' => 'Dockin\' Coordinates', + 'port' => 'Port o\' Call', + 'notes' => 'Captain\'s Scribbles', + 'no_notes' => 'No Scribbles Left Behind', + 'make_primary' => 'Fly as Main Flag', + 'primary' => 'Main Line', + 'make' => 'Hoist It!', + 'delete' => 'Cut the Line', +]; diff --git a/pirate-language/lang/pirate/server/schedule.php b/pirate-language/lang/pirate/server/schedule.php new file mode 100644 index 0000000..f567dc0 --- /dev/null +++ b/pirate-language/lang/pirate/server/schedule.php @@ -0,0 +1,107 @@ + 'Ship\'s Runnin\' Routines', + 'new' => 'Plot New Routine', + 'edit' => 'Tweak the Routine', + 'save' => 'Save the Routine', + 'delete' => 'Scuttle the Routine', + 'import' => 'Smuggle a Routine In', + 'export' => 'Send a Routine Out', + 'name' => 'Name o\' the Routine', + 'cron' => 'Bell Ringin\' (Cron)', + 'status' => 'Status o\' the Voyage', + 'inactive' => 'Sleepin\'', + 'processing' => 'Workin\' the Riggin\'', + 'active' => 'Full Sail Ahead', + 'no_tasks' => 'No Chores in the List', + 'run_now' => 'Fire It Up Now', + 'online_only' => 'Only When the Ship\'s Alive', + 'last_run' => 'Last Time She Sailed', + 'next_run' => 'Next Scheduled Voyage', + 'never' => 'Not Yet, Matey', + 'cancel' => 'Belay That!', + + 'only_online' => 'Only if the Ship\'s Breathin\'?', + 'only_online_hint' => 'Only set sail with this routine if the ship be runnin\'.', + 'enabled' => 'Hoist the Routine?', + 'enabled_hint' => 'The routine will sail on its own if ye give the word.', + + 'cron_body' => 'Keep yer eyes sharp — cron speak always goes by the UTC stars.', + 'cron_timezone' => 'Next voyage in yer timezone (:timezone): :next_run ', + + 'time' => [ + 'minute' => 'Minuteglass', + 'hour' => 'Hour o\' the Watch', + 'day' => 'Day at Sea', + 'week' => 'Seven-Day Stretch', + 'month' => 'Full Moon Cycle', + 'day_of_month' => 'Day o\' the Moon', + 'day_of_week' => 'Day o\' the Week', + + 'hourly' => 'Each Hour', + 'daily' => 'Every Tide', + 'weekly_mon' => 'Weekly (First Mate\'s Day)', + 'weekly_sun' => 'Weekly (Rest Day)', + 'monthly' => 'Each Full Moon', + 'every_min' => 'Every x Bells', + 'every_hour' => 'Every x Hours', + 'every_day' => 'Every x Sunrises', + 'every_week' => 'Every x Voyages', + 'every_month' => 'Every x Full Moons', + 'every_day_of_week' => 'Each x Weekday', + + 'every' => 'Every', + 'minutes' => 'Bells', + 'hours' => 'Watches', + 'days' => 'Days', + 'months' => 'Moons', + + 'monday' => 'First Mate\'s Day', + 'tuesday' => 'Two-Rum Tuesday', + 'wednesday' => 'Windsday', + 'thursday' => 'Thar\'sday', + 'friday' => 'Fish Fryday', + 'saturday' => 'Shipshape Saturday', + 'sunday' => 'Still Sunday', + ], + + 'tasks' => [ + 'title' => 'Chores', + 'create' => 'Add a Chore', + 'limit' => 'Ye\'ve Hit the Chore Limit', + 'action' => 'What Be Done', + 'payload' => 'The Cargo (Payload)', + 'time_offset' => 'Time Delay', + 'seconds' => 'Seconds on the Hourglass', + 'continue_on_failure' => 'Keep On Even if Things Go South', + + 'actions' => [ + 'title' => 'Action', + 'power' => [ + 'title' => 'Send Power Orders', + 'action' => 'Power Order', + 'start' => 'Hoist the Sails', + 'stop' => 'Drop Anchor', + 'restart' => 'Turn Her About', + 'kill' => 'Sink Her!', + ], + 'command' => [ + 'title' => 'Send a Command', + 'command' => 'Shouted Orders', + ], + 'backup' => [ + 'title' => 'Stash the Loot (Backup)', + 'files_to_ignore' => 'Files to Toss Overboard', + ], + 'delete' => [ + 'title' => 'Sink the Files', + 'files_to_delete' => 'Files to Send to Davy Jones', + + ], + ], + ], + + 'notification_invalid_cron' => 'Arrr! That cron gibberish don\'t make no sense, matey.', + +]; diff --git a/pirate-language/lang/pirate/server/setting.php b/pirate-language/lang/pirate/server/setting.php new file mode 100644 index 0000000..21074e2 --- /dev/null +++ b/pirate-language/lang/pirate/server/setting.php @@ -0,0 +1,54 @@ + 'Ship Settin\'s', + 'server_info' => [ + 'title' => 'Ship\'s Scrolls', + 'information' => 'The Details', + 'name' => 'Name o\' the Ship', + 'notification_name' => 'Ship\'s Name Hoisted High', + 'description' => 'What the Ship Be About', + 'notification_description' => 'New Tale for the Ship Written', + 'failed' => 'Aye, It Failed', + 'uuid' => 'Ship\'s Secret Mark (UUID)', + 'id' => 'Ship ID', + + 'limits' => [ + 'title' => 'What Ye Be Allowed', + 'unlimited' => 'No Shackles', + 'of' => 'of', + 'cpu' => 'Thinkin\' Power (CPU)', + 'memory' => 'Mindspace (Memory)', + 'disk' => 'Cargo Hold (Disk Space)', + 'backups' => 'Stashed Loot (Backups)', + 'databases' => 'Tomes o\' Knowledge (Databases)', + 'allocations' => 'Dockin\' Spots (Allocations)', + 'no_allocations' => 'No More Dockin\' Spots for This Vessel', + ], + ], + + 'node_info' => [ + 'title' => 'Dock Info', + 'name' => 'Name o\' the Dock', + 'sftp' => [ + 'title' => 'SFTP Ship Ropes', + 'connection' => 'Moorin\' Line (Connection)', + 'action' => 'Latch Onto SFTP', + 'username' => 'Deckhand\'s Name', + 'password' => 'Secret Code', + 'password_body' => 'Yer SFTP pass be the same one ye use to board this here panel.', + ], + ], + + 'reinstall' => [ + 'title' => 'Rig Her Again (Reinstall)', + 'body' => 'Riggin\' the ship anew will halt her sails and run the script that once gave her life.', + 'body2' => 'Mind ye, some maps or loot might be tossed o\'erboard. Back ‘em up first!', + 'action' => 'Rig Her Again', + 'modal' => 'Ye sure ye want to rig the ship anew?', + 'modal_description' => 'Beware! Some loot might be lost or changed. Best make a backup first.', + 'yes' => 'Aye, Rig Her Again!', + 'notification_start' => 'She Be Gettin\' Rigged', + 'notification_fail' => 'Re-Riggin\' Went Belly-Up', + ], +]; diff --git a/pirate-language/lang/pirate/server/startup.php b/pirate-language/lang/pirate/server/startup.php new file mode 100644 index 0000000..e9b4b1e --- /dev/null +++ b/pirate-language/lang/pirate/server/startup.php @@ -0,0 +1,14 @@ + 'Settin\' Sail', + 'command' => 'Captain\'s Orders', + 'preview' => 'Spyglass View', + 'docker_image' => 'Docker\'s Treasure Map', + 'notification_docker' => 'Docker\'s Treasure Updated', + 'notification_docker_body' => 'Hoist the sails an\' restart the ship to use the new map.', + 'variables' => 'Ship\'s Logs', + 'update' => 'Changed Course: :variable', + 'fail' => 'Ran Aground: :variable', + 'validation_fail' => 'Chart Error: :variable', +]; diff --git a/pirate-language/lang/pirate/server/user.php b/pirate-language/lang/pirate/server/user.php new file mode 100644 index 0000000..724806b --- /dev/null +++ b/pirate-language/lang/pirate/server/user.php @@ -0,0 +1,73 @@ + 'Crew', + 'username' => 'Pirate Name', + 'email' => 'Message in a Bottle', + 'assign_all' => 'Assign All Hands', + 'invite_user' => 'Send Invitation', + 'action' => 'Invite', + 'remove' => 'Send Overboard', + 'edit' => 'Chart a Course', + 'editing' => 'Chartin\' Course fer :user', + 'delete' => 'Walk the Plank', + 'notification_add' => 'Matey Invited!', + 'notification_edit' => 'Matey Updated!', + 'notification_delete' => 'Matey Sent Overboard!', + 'notification_failed' => 'Failed to Invite Matey!', + 'permissions' => [ + 'title' => 'Permissions', + 'activity_desc' => 'Permissions that govern a matey\'s access to the ship\'s log o\' activity.', + 'startup_desc' => 'Permissions that govern a matey\'s right to spy on this ship\'s sailin\' orders.', + 'settings_desc' => 'Permissions that let a matey fiddle with the ship\'s settings.', + 'control_desc' => 'Permissions that let a matey command the ship\'s power and send orders to the crew.', + 'user_desc' => 'Permissions that let a matey manage other deckhands aboard this ship. They can never change their own name or grant powers they don\'t hold.', + 'file_desc' => 'Permissions that let a matey alter the ship\'s hold and treasure maps (filesystem).', + 'allocation_desc' => 'Permissions that govern a matey\'s power to change port assignments for this ship.', + 'database_desc' => 'Permissions that govern a matey\'s access to the ship\'s ledger (database) management.', + 'backup_desc' => 'Permissions that let a matey make and manage backups of the ship\'s logs and treasures.', + 'schedule_desc' => 'Permissions that govern a matey\'s access to manage the ship\'s timetable.', + 'startup_read' => 'Lets a matey spy on the ship\'s sailin\' variables.', + 'startup_update' => 'Lets a matey change the sailin\' variables of the ship.', + 'startup_docker_image' => 'Lets a matey change the Docker image the ship runs on.', + 'settings_reinstall' => 'Lets a matey order a full refit of this ship.', + 'settings_rename' => 'Lets a matey rename the ship.', + 'settings_description' => 'Lets a matey change the ship\'s tale.', + 'activity_read' => 'Lets a matey read the logs of ship\'s deeds.', + 'websocket_*' => 'Lets a matey access the ship\'s magical websockets.', + 'control_console' => 'Lets a matey send commands to the ship\'s console.', + 'control_start' => 'Lets a matey hoist the sails and start the ship.', + 'control_stop' => 'Lets a matey drop anchor and stop the ship.', + 'control_restart' => 'Lets a matey restart the ship\'s engines.', + 'control_kill' => 'Lets a matey scuttle the ship immediately.', + 'user_create' => 'Lets a matey sign up new deckhands for the ship.', + 'user_read' => 'Lets a matey see who\'s aboard this ship.', + 'user_update' => 'Lets a matey change the details of other deckhands.', + 'user_delete' => 'Lets a matey send other deckhands overboard.', + 'file_create' => 'Lets a matey create new treasure maps and chests.', + 'file_read' => 'Lets a matey peek inside a hold but not open or plunder the chests.', + 'file_read_content' => 'Lets a matey open chests and take treasure (download files).', + 'file_update' => 'Lets a matey change the treasure maps and holds.', + 'file_delete' => 'Lets a matey destroy treasure maps and chests.', + 'file_archive' => 'Lets a matey stash treasure in chests or open chests of treasure.', + 'file_sftp' => 'Lets a matey use the secret SFTP route to do all the above.', + 'allocation_read' => 'Lets a matey spy on all port assignments for this ship. All hands can always see the main port.', + 'allocation_update' => 'Lets a matey change the main port and add notes to each port.', + 'allocation_delete' => 'Lets a matey erase a port assignment.', + 'allocation_create' => 'Lets a matey assign more ports to the ship.', + 'database_create' => 'Lets a matey create a new ledger for the ship.', + 'database_read' => 'Lets a matey view the ship\'s ledgers.', + 'database_update' => 'Lets a matey change the ledgers. Without the “View Password” power, they can\'t change passwords.', + 'database_delete' => 'Lets a matey erase a ledger.', + 'database_view_password' => 'Lets a matey see the secret passwords in the ledger.', + 'schedule_create' => 'Lets a matey make a new timetable for the ship.', + 'schedule_read' => 'Lets a matey spy on the ship\'s timetables.', + 'schedule_update' => 'Lets a matey change an existing timetable.', + 'schedule_delete' => 'Lets a matey erase a timetable.', + 'backup_create' => 'Lets a matey make new backups of the ship.', + 'backup_read' => 'Lets a matey view all the ship\'s backups.', + 'backup_delete' => 'Lets a matey toss backups overboard.', + 'backup_download' => 'Lets a matey plunder a backup. Beware! This grants access to all ship\'s secrets.', + 'backup_restore' => 'Lets a matey restore a backup. Beware! This can wipe all the ship\'s files clean.', + ], +]; diff --git a/pirate-language/plugin.json b/pirate-language/plugin.json new file mode 100644 index 0000000..63e376a --- /dev/null +++ b/pirate-language/plugin.json @@ -0,0 +1,15 @@ +{ + "id": "pirate-language", + "name": "Pirate Language", + "author": "Boy132", + "version": "1.0.0", + "description": "Turns yer site's lingo into pirate talk, matey!", + "category": "language", + "url": "https://github.com/everestmcarthur/forged-plugs/tree/main/pirate-language", + "update_url": null, + "namespace": "Boy132\\PirateLanguage", + "class": "PirateLanguagePlugin", + "panels": null, + "panel_version": null, + "composer_packages": null +} \ No newline at end of file diff --git a/pirate-language/src/PirateLanguagePlugin.php b/pirate-language/src/PirateLanguagePlugin.php new file mode 100644 index 0000000..cd7f9cb --- /dev/null +++ b/pirate-language/src/PirateLanguagePlugin.php @@ -0,0 +1,18 @@ + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + 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 GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/player-counter/README.md b/player-counter/README.md new file mode 100644 index 0000000..601b858 --- /dev/null +++ b/player-counter/README.md @@ -0,0 +1,19 @@ +# Player Counter (by Boy132) + +Show the amount of connected players to game servers with real-time querying capabilities. + +## Setup + +Make sure your server has an allocation with a public ip. Alternatively, if you use local ips you can put the public ip in the allocation alias and enable "Use allocation alias?" in the plugin settings. + +Minecraft servers will first try the query (which requires you to set `enable-query` to true and `query-port` to your server port in `server.properties`) and will fallback to ping. It is recommended to enable query. + +## Features + +- Real-time player count display for game servers +- Support for multiple game query protocols +- Link query protocols to specific eggs +- Dashboard widget showing connected players +- Dedicated players page for detailed information +- Configurable through the admin panel +- Advanced integration for Minecraft servers: Displays user helmet avatar and allows to manage whitelist & op list. diff --git a/player-counter/config/player-counter.php b/player-counter/config/player-counter.php new file mode 100644 index 0000000..b2c5da6 --- /dev/null +++ b/player-counter/config/player-counter.php @@ -0,0 +1,5 @@ + env('PLAYER_COUNTER_USE_ALIAS', false), +]; diff --git a/player-counter/database/Seeders/PlayerCounterSeeder.php b/player-counter/database/Seeders/PlayerCounterSeeder.php new file mode 100644 index 0000000..d17d9d2 --- /dev/null +++ b/player-counter/database/Seeders/PlayerCounterSeeder.php @@ -0,0 +1,124 @@ + 'Squad', + 'query_type' => 'source', + 'query_port_offset' => 19378, + 'query_port_variable' => null, + ], + [ + 'names' => 'Barotrauma', + 'query_type' => 'source', + 'query_port_offset' => 1, + 'query_port_variable' => null, + ], + [ + 'names' => 'Valheim', + 'query_type' => 'source', + 'query_port_offset' => 1, + 'query_port_variable' => null, + ], + [ + 'names' => ['V Rising', 'V-Rising', 'VRising'], + 'query_type' => 'source', + 'query_port_offset' => 1, + 'query_port_variable' => null, + ], + [ + 'names' => ['The Forrest', 'TheForrest'], + 'query_type' => 'source', + 'query_port_offset' => 1, + 'query_port_variable' => null, + ], + [ + 'names' => ['Arma 3', 'Arma3'], + 'query_type' => 'source', + 'query_port_offset' => 1, + 'query_port_variable' => null, + ], + [ + 'names' => ['Arma Reforger', 'ArmaReforger'], + 'query_type' => 'source', + 'query_port_offset' => 15776, + 'query_port_variable' => null, + ], + [ + 'names' => ['ARK: Survival Evolved', 'ARK: SurvivalEvolved', 'ARK Survival Evolved', 'ARK SurvivalEvolved', 'ARKSurvivalEvolved'], + 'query_type' => 'source', + 'query_port_offset' => 19238, + 'query_port_variable' => null, + ], + [ + 'names' => 'Unturned', + 'query_type' => 'source', + 'query_port_offset' => 1, + 'query_port_variable' => null, + ], + [ + 'names' => ['Insurgency: Sandstorm', 'Insurgency Sandstorm', 'InsurgencySandstorm'], + 'query_type' => 'source', + 'query_port_offset' => 29, + 'query_port_variable' => null, + ], + [ + 'tag' => 'bedrock', + 'query_type' => 'minecraft_bedrock', + 'query_port_offset' => null, + 'query_port_variable' => null, + ], + [ + 'tag' => 'minecraft', + 'query_type' => 'minecraft_java', + 'query_port_offset' => null, + 'query_port_variable' => null, + ], + [ + 'tag' => 'source', + 'query_type' => 'source', + 'query_port_offset' => null, + 'query_port_variable' => null, + ], + ]; + + public function run(): void + { + foreach (Egg::all() as $egg) { + $tags = $egg->tags ?? []; + + foreach (self::MAPPINGS as $mapping) { + if ((array_key_exists('names', $mapping) && in_array($egg->name, array_wrap($mapping['names']))) || (array_key_exists('tag', $mapping) && in_array($mapping['tag'], $tags))) { + try { + $query = GameQuery::firstOrCreate([ + 'query_type' => $mapping['query_type'], + 'query_port_offset' => $mapping['query_port_offset'], + 'query_port_variable' => $mapping['query_port_variable'], + ]); + + EggGameQuery::firstOrCreate([ + 'egg_id' => $egg->id, + ], [ + 'game_query_id' => $query->id, + ]); + } catch (Exception) { + } + } + } + } + + // @phpstan-ignore if.alwaysTrue + if ($this->command) { + $this->command->info('Created game query types for existing eggs'); + } + } +} diff --git a/player-counter/database/migrations/001_create_game_queries_table.php b/player-counter/database/migrations/001_create_game_queries_table.php new file mode 100644 index 0000000..8d6bb11 --- /dev/null +++ b/player-counter/database/migrations/001_create_game_queries_table.php @@ -0,0 +1,24 @@ +increments('id'); + $table->string('query_type'); + $table->integer('query_port_offset')->nullable(); + $table->string('query_port_variable')->nullable(); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('game_queries'); + } +}; diff --git a/player-counter/database/migrations/002_create_egg_game_query_table.php b/player-counter/database/migrations/002_create_egg_game_query_table.php new file mode 100644 index 0000000..f680b07 --- /dev/null +++ b/player-counter/database/migrations/002_create_egg_game_query_table.php @@ -0,0 +1,26 @@ +unsignedInteger('egg_id'); + $table->foreign('egg_id')->references('id')->on('eggs')->cascadeOnDelete(); + + $table->unsignedInteger('game_query_id'); + $table->foreign('game_query_id')->references('id')->on('game_queries')->cascadeOnDelete(); + + $table->unique('egg_id'); + }); + } + + public function down(): void + { + Schema::dropIfExists('egg_game_query'); + } +}; diff --git a/player-counter/lang/en/query.php b/player-counter/lang/en/query.php new file mode 100644 index 0000000..d590f9b --- /dev/null +++ b/player-counter/lang/en/query.php @@ -0,0 +1,57 @@ + 'No Game Queries', + 'query' => 'Game Query|Game Queries', + 'type' => 'Type', + 'port_offset' => 'Query Port Offset', + 'no_offset' => 'No Offset', + 'port_offset_hint' => 'The offset that will be added to the allocation port. Usually empty/0 or 1.', + 'port_variable' => 'Query Port Variable', + 'no_variable' => 'No Variable', + 'port_variable_hint' => 'The env name of the startup variable that will be used to get the query port, e.g. "QUERY_PORT". When a value is set the query port offset will be ignored! Leave empty to use the allocation port and offset.', + 'eggs' => 'Eggs', + 'no_eggs' => 'No Eggs', + 'hostname' => 'Hostname', + 'players' => 'Players', + 'map' => 'Map', + 'unknown' => 'Unknown', + + 'kick' => 'Kick', + 'ban' => 'Ban', + + 'whitelisted' => 'Whitelisted', + 'add_to_whitelist' => 'Add to whitelist', + 'remove_from_whitelist' => 'Remove from whitelist', + + 'op' => 'OP', + 'add_to_ops' => 'Add to OPs', + 'remove_from_ops' => 'Remove from OPs', + + 'use_alias' => 'Use allocation alias?', + 'use_alias_hint' => 'If checked, queries will use the allocation alias instead of the ip', + + 'table' => [ + 'no_players' => 'No players found', + 'no_players_description' => 'Either no players are online or query is disabled on this server', + 'server_offline' => 'Server is offline', + ], + + 'notifications' => [ + 'settings_saved' => 'Setting saved', + + 'player_kicked' => 'Player kicked from server', + 'player_kick_failed' => 'Could not kick player', + + 'player_banned' => 'Player banned from server', + 'player_ban_failed' => 'Could not ban player', + + 'player_whitelist_add' => 'Player added to whitelist', + 'player_whitelist_remove' => 'Player removed from whitelist', + 'player_whitelist_failed' => 'Could not change whitelist', + + 'player_op' => 'Player added to OPs', + 'player_deop' => 'Player removed from OPs', + 'player_op_failed' => 'Could not change OPs', + ], +]; diff --git a/player-counter/plugin.json b/player-counter/plugin.json new file mode 100644 index 0000000..4c83480 --- /dev/null +++ b/player-counter/plugin.json @@ -0,0 +1,21 @@ +{ + "id": "player-counter", + "name": "Player Counter", + "author": "Boy132", + "version": "1.0.0", + "description": "Show the amount of connected players to the server", + "category": "plugin", + "url": "https://github.com/everestmcarthur/forged-plugs/tree/main/player-counter", + "update_url": null, + "namespace": "Boy132\\PlayerCounter", + "class": "PlayerCounterPlugin", + "panels": [ + "admin", + "server" + ], + "panel_version": null, + "composer_packages": { + "xpaw/php-minecraft-query": "^5.0.0", + "xpaw/php-source-query-class": "^6.0.0" + } +} \ No newline at end of file diff --git a/player-counter/routes/api-client.php b/player-counter/routes/api-client.php new file mode 100644 index 0000000..937dffb --- /dev/null +++ b/player-counter/routes/api-client.php @@ -0,0 +1,16 @@ +middleware([ServerSubject::class, AuthenticateServerAccess::class, ResourceBelongsToServer::class])->group(function () { + Route::prefix('/query')->middleware(ThrottleRequests::using(PlayerCounterRoutesProvider::QUERY_THROTTLE_KEY))->group(function () { + Route::get('/', [PlayerCounterController::class, 'query']); + Route::get('/players', [PlayerCounterController::class, 'players']); + }); +}); diff --git a/player-counter/src/Extensions/Query/QueryTypeSchemaInterface.php b/player-counter/src/Extensions/Query/QueryTypeSchemaInterface.php new file mode 100644 index 0000000..041139e --- /dev/null +++ b/player-counter/src/Extensions/Query/QueryTypeSchemaInterface.php @@ -0,0 +1,15 @@ +} */ + public function process(Server $server, string $ip, int $port): ?array; +} diff --git a/player-counter/src/Extensions/Query/QueryTypeService.php b/player-counter/src/Extensions/Query/QueryTypeService.php new file mode 100644 index 0000000..c2c92bd --- /dev/null +++ b/player-counter/src/Extensions/Query/QueryTypeService.php @@ -0,0 +1,29 @@ +schemas, $id); + } + + public function register(QueryTypeSchemaInterface $schema): void + { + if (array_key_exists($schema->getId(), $this->schemas)) { + return; + } + + $this->schemas[$schema->getId()] = $schema; + } + + /** @return array */ + public function getMappings(): array + { + return collect($this->schemas)->mapWithKeys(fn ($schema) => [$schema->getId() => $schema->getName()])->all(); + } +} diff --git a/player-counter/src/Extensions/Query/Schemas/CitizenFXQueryTypeSchema.php b/player-counter/src/Extensions/Query/Schemas/CitizenFXQueryTypeSchema.php new file mode 100644 index 0000000..63828d5 --- /dev/null +++ b/player-counter/src/Extensions/Query/Schemas/CitizenFXQueryTypeSchema.php @@ -0,0 +1,74 @@ +} */ + public function process(Server $server, string $ip, int $port): ?array + { + try { + $this->resolveSRV($ip, $port); + + $http = Http::acceptJson() + ->timeout(5) + ->throw() + ->baseUrl("http://$ip:$port/"); + + $info = $http->get('dynamic.json')->json(); + $players = $http->get('players.json')->json(); + + if (!is_array($info) || !is_array($players)) { + return null; + } + + return [ + 'hostname' => $info['hostname'], + 'map' => $info['mapname'], + 'current_players' => $info['clients'], + 'max_players' => $info['sv_maxclients'], + 'players' => array_map(fn ($player) => ['id' => (string) $player['id'], 'name' => (string) $player['name']], $players), + ]; + } catch (Exception $exception) { + report($exception); + } + + return null; + } + + private function resolveSRV(string &$ip, int &$port): void + { + if (is_ip($ip)) { + return; + } + + $record = dns_get_record('_cfx._udp.' . $ip, DNS_SRV); + + if (!$record) { + return; + } + + if ($record[0]['target']) { + $ip = $record[0]['target']; + } + + if ($record[0]['port']) { + $port = (int) $record[0]['port']; + } + } +} diff --git a/player-counter/src/Extensions/Query/Schemas/GoldSourceQueryTypeSchema.php b/player-counter/src/Extensions/Query/Schemas/GoldSourceQueryTypeSchema.php new file mode 100644 index 0000000..59a5f62 --- /dev/null +++ b/player-counter/src/Extensions/Query/Schemas/GoldSourceQueryTypeSchema.php @@ -0,0 +1,25 @@ +} */ + public function process(Server $server, string $ip, int $port): ?array + { + return $this->run($ip, $port, SourceQuery::GOLDSOURCE); + } +} diff --git a/player-counter/src/Extensions/Query/Schemas/MinecraftBedrockQueryTypeSchema.php b/player-counter/src/Extensions/Query/Schemas/MinecraftBedrockQueryTypeSchema.php new file mode 100644 index 0000000..946dcdf --- /dev/null +++ b/player-counter/src/Extensions/Query/Schemas/MinecraftBedrockQueryTypeSchema.php @@ -0,0 +1,49 @@ +} */ + public function process(Server $server, string $ip, int $port): ?array + { + $query = new MinecraftQuery(); + + try { + $query->ConnectBedrock($ip, $port, 5, true); + + $info = $query->GetInfo(); + + if (!is_array($info)) { + return null; + } + + return [ + 'hostname' => $info['HostName'], + 'map' => $info['Map'], + 'current_players' => $info['Players'], + 'max_players' => $info['MaxPlayers'], + 'players' => null, // Bedrock has no player list + ]; + } catch (Exception $exception) { + report($exception); + } + + return null; + } +} diff --git a/player-counter/src/Extensions/Query/Schemas/MinecraftJavaQueryTypeSchema.php b/player-counter/src/Extensions/Query/Schemas/MinecraftJavaQueryTypeSchema.php new file mode 100644 index 0000000..ea4d685 --- /dev/null +++ b/player-counter/src/Extensions/Query/Schemas/MinecraftJavaQueryTypeSchema.php @@ -0,0 +1,97 @@ +} */ + public function process(Server $server, string $ip, int $port): ?array + { + $query = $this->tryQuery($ip, $port); + if ($query) { + return $query; + } + + $ping = $this->tryPing($ip, $port); + if ($ping) { + return $ping; + } + + return null; + } + + /** @return false|array{hostname: string, map: string, current_players: int, max_players: int, players: array} */ + protected function tryQuery(string $ip, int $port): false|array + { + $query = new MinecraftQuery(); + + try { + $query->Connect($ip, $port, 5, true); + + $info = $query->GetInfo(); + $players = $query->GetPlayers(); + + if (!is_array($info) || !is_array($players)) { + return false; + } + + return [ + 'hostname' => $info['HostName'], + 'map' => $info['Map'], + 'current_players' => $info['Players'], + 'max_players' => $info['MaxPlayers'], + 'players' => array_map(fn ($player) => ['id' => (string) $player, 'name' => (string) $player], $players), + ]; + } catch (Exception $exception) { + report($exception); + } + + return false; + } + + /** @return false|array{hostname: string, map: string, current_players: int, max_players: int, players: array} */ + protected function tryPing(string $ip, int $port): false|array + { + try { + $ping = new MinecraftPing($ip, $port, 5, true); + + $data = $ping->Query(); + + if (!$data) { + return false; + } + + return [ + 'hostname' => is_string($data['description']) ? $data['description'] : $data['description']['text'], + 'map' => 'world', // No map from MinecraftPing + 'current_players' => $data['players']['online'], + 'max_players' => $data['players']['max'], + 'players' => $data['players']['sample'] ?? [], + ]; + } catch (Exception $exception) { + report($exception); + } finally { + if (isset($ping)) { + $ping->Close(); + } + } + + return false; + } +} diff --git a/player-counter/src/Extensions/Query/Schemas/PalworldQueryTypeSchema.php b/player-counter/src/Extensions/Query/Schemas/PalworldQueryTypeSchema.php new file mode 100644 index 0000000..d8b5ba8 --- /dev/null +++ b/player-counter/src/Extensions/Query/Schemas/PalworldQueryTypeSchema.php @@ -0,0 +1,65 @@ +variables() + ->where('env_variable', 'ADMIN_PASSWORD') + ->first()?->server_value; + + if (!$adminPassword) { + return null; + } + + try { + $base = "http://{$ip}:{$port}"; + [$playersResp, $metricsResp] = Http::pool(fn ($pool) => [ + $pool->timeout(5)->withBasicAuth('admin', $adminPassword)->get("{$base}/v1/api/players"), + $pool->timeout(5)->withBasicAuth('admin', $adminPassword)->get("{$base}/v1/api/metrics"), + ]); + + if (!$playersResp->ok()) { + return null; + } + + $data = $playersResp->json(); + $players = array_map(fn ($p) => [ + 'id' => $p['playeruid'] ?? $p['steamid'] ?? '', + 'name' => $p['name'] ?? '', + ], $data['players'] ?? []); + + $maxPlayers = $metricsResp->ok() ? ($metricsResp->json()['maxplayernum'] ?? 32) : 32; + + return [ + 'hostname' => $server->name, + 'map' => 'Palpagos Islands', + 'current_players' => count($players), + 'max_players' => $maxPlayers, + 'players' => $players, + ]; + + } catch (Exception $exception) { + report($exception); + + return null; + } + } +} diff --git a/player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php b/player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php new file mode 100644 index 0000000..5d4902f --- /dev/null +++ b/player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php @@ -0,0 +1,54 @@ +} */ + public function process(Server $server, string $ip, int $port): ?array + { + return $this->run($ip, $port, SourceQuery::SOURCE); + } + + /** @return ?array{hostname: string, map: string, current_players: int, max_players: int, players: array} */ + protected function run(string $ip, int $port, int $engine): ?array + { + $query = new SourceQuery(); + + try { + $query->Connect($ip, $port, 5, $engine); + + $info = $query->GetInfo(); + $players = $query->GetPlayers(); + + return [ + 'hostname' => $info['HostName'], + 'map' => $info['Map'], + 'current_players' => $info['Players'], + 'max_players' => $info['MaxPlayers'], + 'players' => array_map(fn ($player) => ['id' => (string) $player['Id'], 'name' => (string) $player['Name']], $players), + ]; + } catch (Exception $exception) { + report($exception); + } finally { + $query->Disconnect(); + } + + return null; + } +} diff --git a/player-counter/src/Filament/Admin/Resources/GameQueries/GameQueryResource.php b/player-counter/src/Filament/Admin/Resources/GameQueries/GameQueryResource.php new file mode 100644 index 0000000..d1e2935 --- /dev/null +++ b/player-counter/src/Filament/Admin/Resources/GameQueries/GameQueryResource.php @@ -0,0 +1,143 @@ +count() ?: null; + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + TextColumn::make('query_type') + ->label(trans('player-counter::query.type')) + ->badge() + ->formatStateUsing(fn ($state, QueryTypeService $service) => $service->getMappings()[$state] ?? $state), + TextColumn::make('query_port_offset') + ->label(trans('player-counter::query.port_offset')) + ->placeholder(trans('player-counter::query.no_offset')), + TextColumn::make('query_port_variable') + ->label(trans('player-counter::query.port_variable')) + ->placeholder(trans('player-counter::query.no_variable')) + ->badge(), + TextColumn::make('eggs.name') + ->label(trans('player-counter::query.eggs')) + ->placeholder(trans('player-counter::query.no_eggs')) + ->icon('tabler-eggs') + ->badge(), + ]) + ->recordActions([ + ViewAction::make() + ->hidden(fn ($record) => static::getEditAuthorizationResponse($record)->allowed()), + EditAction::make(), + DeleteAction::make(), + ]) + ->toolbarActions([ + CreateAction::make() + ->createAnother(false), + ]) + ->emptyStateIcon('tabler-device-desktop-search') + ->emptyStateDescription('') + ->emptyStateHeading(trans('player-counter::query.no_queries')); + } + + public static function form(Schema $schema): Schema + { + return $schema + ->components([ + Select::make('query_type') + ->label(trans('player-counter::query.type')) + ->required() + ->options(fn (QueryTypeService $service) => $service->getMappings()) + ->selectablePlaceholder(false) + ->preload() + ->searchable() + ->columnSpanFull(), + TextInput::make('query_port_offset') + ->label(trans('player-counter::query.port_offset')) + ->placeholder(trans('player-counter::query.no_offset')) + ->numeric() + ->nullable() + ->minValue(1) + ->maxValue(65535 - 1024) + ->hintIcon('tabler-question-mark') + ->hintIconTooltip(trans('player-counter::query.port_offset_hint')), + TextInput::make('query_port_variable') + ->label(trans('player-counter::query.port_variable')) + ->placeholder(trans('player-counter::query.no_variable')) + ->nullable() + ->hintIcon('tabler-question-mark') + ->hintIconTooltip(trans('player-counter::query.port_variable_hint')), + Select::make('eggs') + ->label(trans('admin/mount.eggs')) + ->relationship('eggs', 'name') + ->multiple() + ->preload() + ->searchable() + ->columnSpanFull(), + ]); + } + + public static function infolist(Schema $schema): Schema + { + return $schema + ->components([ + TextEntry::make('query_type') + ->label(trans('player-counter::query.type')), + TextEntry::make('query_port_offset') + ->label(trans('player-counter::query.port_offset')) + ->placeholder(trans('player-counter::query.no_offset')) + ->numeric(), + TextEntry::make('eggs.name') + ->label(trans('admin/mount.eggs')) + ->placeholder(trans('player-counter::query.no_eggs')) + ->badge() + ->columnSpanFull(), + ]); + } + + public static function getPages(): array + { + return [ + 'index' => ManageGameQueries::route('/'), + ]; + } +} diff --git a/player-counter/src/Filament/Admin/Resources/GameQueries/Pages/ManageGameQueries.php b/player-counter/src/Filament/Admin/Resources/GameQueries/Pages/ManageGameQueries.php new file mode 100644 index 0000000..f908077 --- /dev/null +++ b/player-counter/src/Filament/Admin/Resources/GameQueries/Pages/ManageGameQueries.php @@ -0,0 +1,11 @@ +allocation)) { + return false; + } + + // @phpstan-ignore method.notFound + if (!$server->egg->gameQuery()->exists()) { + return false; + } + + return parent::canAccess(); + } + + public static function getNavigationLabel(): string + { + return trans('player-counter::query.players'); + } + + public static function getModelLabel(): string + { + return static::getNavigationLabel(); + } + + public static function getPluralModelLabel(): string + { + return static::getNavigationLabel(); + } + + public function getTitle(): string + { + return static::getNavigationLabel(); + } + + /** + * @throws Exception + */ + public function table(Table $table): Table + { + /** @var Server $server */ + $server = Filament::getTenant(); + + /** @var ?GameQuery $gameQuery */ + $gameQuery = $server->egg->gameQuery; // @phpstan-ignore property.notFound + + $isMinecraft = $gameQuery?->query_type === 'minecraft_java'; + + $whitelist = []; + $ops = []; + + if ($isMinecraft) { + $fileRepository = (new DaemonFileRepository())->setServer($server); + + try { + $whitelist = json_decode($fileRepository->getContent('whitelist.json'), true, 512, JSON_THROW_ON_ERROR); + $whitelist = array_unique(array_map(fn ($data) => $data['name'], $whitelist)); + } catch (Exception $exception) { + report($exception); + } + + try { + $ops = json_decode($fileRepository->getContent('ops.json'), true, 512, JSON_THROW_ON_ERROR); + $ops = array_unique(array_map(fn ($data) => $data['name'], $ops)); + } catch (Exception $exception) { + report($exception); + } + } + + return $table + ->records(function (?string $search, int $page, int $recordsPerPage) { + /** @var Server $server */ + $server = Filament::getTenant(); + + $players = []; + + /** @var ?GameQuery $gameQuery */ + $gameQuery = $server->egg->gameQuery; // @phpstan-ignore property.notFound + + if ($gameQuery) { + $data = $gameQuery->runQuery($server); + + if ($data) { + $players = $data['players'] ?? []; + } + } + + if ($search) { + $players = array_filter($players, fn ($player) => str($player['name'])->contains($search, true)); + } + + return new LengthAwarePaginator(array_slice($players, ($page - 1) * $recordsPerPage, $recordsPerPage), count($players), $recordsPerPage, $page); + }) + ->paginated([30, 60]) + ->contentGrid([ + 'default' => 1, + 'lg' => 2, + 'xl' => $isMinecraft ? 2 : 3, + ]) + ->columns([ + Split::make([ + ImageColumn::make('avatar') + ->visible(fn () => $isMinecraft) + ->state(fn (array $record) => 'https://cravatar.eu/helmhead/' . $record['id'] . '/256.png') + ->grow(false), + TextColumn::make('name') + ->label('Name') + ->tooltip(fn (array $record) => array_key_exists('id', $record) ? $record['id'] : null) + ->searchable(), + TextColumn::make('is_whitelisted') + ->visible(fn () => $isMinecraft) + ->badge() + ->grow(false) + ->state(fn (array $record) => in_array($record['name'], $whitelist) ? trans('player-counter::query.whitelisted') : null), + TextColumn::make('is_op') + ->visible(fn () => $isMinecraft) + ->badge() + ->grow(false) + ->state(fn (array $record) => in_array($record['name'], $ops) ? trans('player-counter::query.op') : null), + TextColumn::make('time') + ->hidden(fn () => $isMinecraft) + ->badge() + ->grow(false) + ->formatStateUsing(fn ($state) => $state ? CarbonInterval::seconds($state)->cascade()->forHumans() : null), + ]), + ]) + ->recordActions([ + Action::make('exclude_kick') + ->visible(fn () => $isMinecraft) + ->label(trans('player-counter::query.kick')) + ->icon('tabler-door-exit') + ->color('danger') + ->action(function (array $record) { + /** @var Server $server */ + $server = Filament::getTenant(); + + try { + $server->send('kick ' . $record['name']); + + Notification::make() + ->title(trans('player-counter::query.notifications.player_kicked')) + ->body($record['name']) + ->success() + ->send(); + + $this->refreshPage(); + } catch (Exception $exception) { + report($exception); + + Notification::make() + ->title(trans('player-counter::query.notifications.player_kick_failed')) + ->body($exception->getMessage()) + ->danger() + ->send(); + } + }), + Action::make('exclude_ban') + ->visible(fn () => $isMinecraft) + ->label(trans('player-counter::query.ban')) + ->icon('tabler-hammer') + ->color('danger') + ->requiresConfirmation() + ->action(function (array $record) { + /** @var Server $server */ + $server = Filament::getTenant(); + + try { + $server->send('ban ' . $record['name']); + + Notification::make() + ->title(trans('player-counter::query.notifications.player_banned')) + ->body($record['name']) + ->success() + ->send(); + + $this->refreshPage(); + } catch (Exception $exception) { + report($exception); + + Notification::make() + ->title(trans('player-counter::query.notifications.player_ban_failed')) + ->body($exception->getMessage()) + ->danger() + ->send(); + } + }), + Action::make('exclude_whitelist') + ->visible(fn () => $isMinecraft) + ->label(fn (array $record) => in_array($record['name'], $whitelist) ? trans('player-counter::query.remove_from_whitelist') : trans('player-counter::query.add_to_whitelist')) + ->icon(fn (array $record) => in_array($record['name'], $whitelist) ? 'tabler-playlist-x' : 'tabler-playlist-add') + ->color(fn (array $record) => in_array($record['name'], $whitelist) ? 'danger' : 'success') + ->action(function (array $record) use ($whitelist) { + /** @var Server $server */ + $server = Filament::getTenant(); + + try { + $action = in_array($record['name'], $whitelist) ? 'remove' : 'add'; + + $server->send('whitelist ' . $action . ' ' . $record['name']); + + Notification::make() + ->title(trans('player-counter::query.notifications.player_whitelist_' . $action)) + ->body($record['name']) + ->success() + ->send(); + + $this->refreshPage(); + } catch (Exception $exception) { + report($exception); + + Notification::make() + ->title(trans('player-counter::query.notifications.player_whitelist_failed')) + ->body($exception->getMessage()) + ->danger() + ->send(); + } + }), + Action::make('exclude_op') + ->visible(fn () => $isMinecraft) + ->label(fn (array $record) => in_array($record['name'], $ops) ? trans('player-counter::query.remove_from_ops') : trans('player-counter::query.add_to_ops')) + ->icon(fn (array $record) => in_array($record['name'], $ops) ? 'tabler-shield-minus' : 'tabler-shield-plus') + ->color(fn (array $record) => in_array($record['name'], $ops) ? 'warning' : 'success') + ->action(function (array $record) use ($ops) { + /** @var Server $server */ + $server = Filament::getTenant(); + + try { + $action = in_array($record['name'], $ops) ? 'deop' : 'op'; + + $server->send($action . ' ' . $record['name']); + + Notification::make() + ->title(trans('player-counter::query.notifications.player_' . $action)) + ->body($record['name']) + ->success() + ->send(); + + $this->refreshPage(); + } catch (Exception $exception) { + report($exception); + + Notification::make() + ->title(trans('player-counter::query.notifications.player_op_failed')) + ->body($exception->getMessage()) + ->danger() + ->send(); + } + }), + ]) + ->emptyStateHeading(function () { + /** @var Server $server */ + $server = Filament::getTenant(); + + if ($server->retrieveStatus()->isOffline()) { + return trans('player-counter::query.table.server_offline'); + } + + return trans('player-counter::query.table.no_players'); + }) + ->emptyStateDescription(function () { + /** @var Server $server */ + $server = Filament::getTenant(); + + if ($server->retrieveStatus()->isOffline()) { + return null; + } + + return trans('player-counter::query.table.no_players_description'); + }); + } + + public function content(Schema $schema): Schema + { + return $schema + ->components([ + EmbeddedTable::make(), + ]); + } + + protected function getHeaderWidgets(): array + { + return [ + ServerPlayerWidget::class, + ]; + } + + private function refreshPage(): void + { + $url = self::getUrl(); + $this->redirect($url, FilamentView::hasSpaMode($url)); + } +} diff --git a/player-counter/src/Filament/Server/Widgets/ServerPlayerWidget.php b/player-counter/src/Filament/Server/Widgets/ServerPlayerWidget.php new file mode 100644 index 0000000..4e3cfd5 --- /dev/null +++ b/player-counter/src/Filament/Server/Widgets/ServerPlayerWidget.php @@ -0,0 +1,56 @@ +isInConflictState()) { + return false; + } + + if (!GameQuery::canRunQuery($server->allocation)) { + return false; + } + + // @phpstan-ignore method.notFound + if (!$server->egg->gameQuery()->exists()) { + return false; + } + + return !$server->retrieveStatus()->isOffline(); + } + + protected function getStats(): array + { + /** @var Server $server */ + $server = Filament::getTenant(); + + /** @var ?GameQuery $gameQuery */ + $gameQuery = $server->egg->gameQuery; // @phpstan-ignore property.notFound + + if (!$gameQuery) { + return []; + } + + $data = $gameQuery->runQuery($server) ?? []; + + return [ + SmallStatBlock::make(trans('player-counter::query.hostname'), $data['hostname'] ?? trans('player-counter::query.unknown')), + SmallStatBlock::make(trans('player-counter::query.players'), ($data['current_players'] ?? '?') . ' / ' . ($data['max_players'] ?? '?')), + SmallStatBlock::make(trans('player-counter::query.map'), $data['map'] ?? trans('player-counter::query.unknown')), + ]; + } +} diff --git a/player-counter/src/Http/Controllers/Api/Client/Servers/PlayerCounterController.php b/player-counter/src/Http/Controllers/Api/Client/Servers/PlayerCounterController.php new file mode 100644 index 0000000..b9e86d4 --- /dev/null +++ b/player-counter/src/Http/Controllers/Api/Client/Servers/PlayerCounterController.php @@ -0,0 +1,71 @@ +runQuery($server); + + return response()->json(array_except($data, 'players')); + } + + /** + * Get players + * + * Returns the names of the current players. + * + * @throws HttpException + */ + public function players(Server $server): JsonResponse + { + $data = $this->runQuery($server); + + if (is_null($data['players'])) { + abort(Response::HTTP_NOT_ACCEPTABLE, 'Server query has no player list'); + } + + /** @var string[] $players */ + $players = array_map(fn ($player) => $player['name'], $data['players']); + + return response()->json($players); + } + + /** @return ?array{hostname: string, map: string, current_players: int, max_players: int, players: ?array} */ + private function runQuery(Server $server): ?array + { + if (!GameQuery::canRunQuery($server->allocation)) { + abort(Response::HTTP_NOT_ACCEPTABLE, 'Server has invalid allocation'); + } + + if ($server->retrieveStatus()->isOffline()) { + abort(Response::HTTP_NOT_ACCEPTABLE, 'Server is offline'); + } + + /** @var ?GameQuery $gameQuery */ + $gameQuery = $server->egg->gameQuery; // @phpstan-ignore property.notFound + + if (!$gameQuery) { + abort(Response::HTTP_NOT_ACCEPTABLE, 'Server has no query'); + } + + return $gameQuery->runQuery($server); + } +} diff --git a/player-counter/src/Models/EggGameQuery.php b/player-counter/src/Models/EggGameQuery.php new file mode 100644 index 0000000..07ef802 --- /dev/null +++ b/player-counter/src/Models/EggGameQuery.php @@ -0,0 +1,14 @@ + null, + 'query_port_variable' => null, + ]; + + public function eggs(): BelongsToMany + { + return $this->belongsToMany(Egg::class); + } + + /** @return ?array{hostname: string, map: string, current_players: int, max_players: int, players: ?array} */ + public function runQuery(Server $server): ?array + { + if (!static::canRunQuery($server->allocation)) { + return null; + } + + $ip = config('player-counter.use_alias') && is_ip($server->allocation->alias) ? $server->allocation->alias : $server->allocation->ip; + $ip = is_ipv6($ip) ? '[' . $ip . ']' : $ip; + + $port = $server->allocation->port + ($this->query_port_offset ?? 0); + + if ($this->query_port_variable) { + $variableValue = $server->variables()->where('env_variable', $this->query_port_variable)->first()?->server_value; + + if ($variableValue && is_numeric($variableValue)) { + $port = (int) $variableValue; + } + } + + /** @var QueryTypeService $service */ + $service = app(QueryTypeService::class); + + return $service->get($this->query_type)?->process($server, $ip, $port); + } + + public static function canRunQuery(?Allocation $allocation): bool + { + if (!$allocation) { + return false; + } + + $ip = config('player-counter.use_alias') && is_ip($allocation->alias) ? $allocation->alias : $allocation->ip; + + return !in_array($ip, ['0.0.0.0', '::']); + } +} diff --git a/player-counter/src/PlayerCounterPlugin.php b/player-counter/src/PlayerCounterPlugin.php new file mode 100644 index 0000000..30e4ff1 --- /dev/null +++ b/player-counter/src/PlayerCounterPlugin.php @@ -0,0 +1,55 @@ +getId())->title(); + + $panel->discoverResources(plugin_path($this->getId(), "src/Filament/$id/Resources"), "Boy132\\PlayerCounter\\Filament\\$id\\Resources"); + $panel->discoverPages(plugin_path($this->getId(), "src/Filament/$id/Pages"), "Boy132\\PlayerCounter\\Filament\\$id\\Pages"); + $panel->discoverWidgets(plugin_path($this->getId(), "src/Filament/$id/Widgets"), "Boy132\\PlayerCounter\\Filament\\$id\\Widgets"); + } + + public function boot(Panel $panel): void {} + + public function getSettingsForm(): array + { + return [ + Toggle::make('use_alias') + ->label(trans('player-counter::query.use_alias')) + ->hintIcon('tabler-question-mark') + ->hintIconTooltip(trans('player-counter::query.use_alias_hint')) + ->inline(false) + ->default(fn () => config('player-counter.use_alias')), + ]; + } + + public function saveSettings(array $data): void + { + $this->writeToEnvironment([ + 'PLAYER_COUNTER_USE_ALIAS' => $data['use_alias'], + ]); + + Notification::make() + ->title(trans('player-counter::query.notifications.settings_saved')) + ->success() + ->send(); + } +} diff --git a/player-counter/src/Policies/GameQueryPolicy.php b/player-counter/src/Policies/GameQueryPolicy.php new file mode 100644 index 0000000..63e619f --- /dev/null +++ b/player-counter/src/Policies/GameQueryPolicy.php @@ -0,0 +1,12 @@ +app->singleton(QueryTypeService::class, function () { + $service = new QueryTypeService(); + + // Default Query types + $service->register(new SourceQueryTypeSchema()); + $service->register(new GoldSourceQueryTypeSchema()); + $service->register(new MinecraftJavaQueryTypeSchema()); + $service->register(new MinecraftBedrockQueryTypeSchema()); + $service->register(new CitizenFXQueryTypeSchema()); + $service->register(new PalworldQueryTypeSchema()); + + return $service; + }); + } + + public function boot(): void + { + Egg::resolveRelationUsing('gameQuery', fn (Egg $egg) => $egg->hasOneThrough(GameQuery::class, EggGameQuery::class, 'egg_id', 'id', 'id', 'game_query_id')); + } +} diff --git a/player-counter/src/Providers/PlayerCounterRoutesProvider.php b/player-counter/src/Providers/PlayerCounterRoutesProvider.php new file mode 100644 index 0000000..5141133 --- /dev/null +++ b/player-counter/src/Providers/PlayerCounterRoutesProvider.php @@ -0,0 +1,32 @@ +routes(function () { + Route::middleware(['api', 'client-api', 'throttle:api.client']) + ->prefix('/api/client') + ->scopeBindings() + ->group(plugin_path('player-counter', 'routes/api-client.php')); + }); + + RateLimiter::for(self::QUERY_THROTTLE_KEY, function (Request $request) { + Assert::isInstanceOf($server = $request->route()->parameter('server'), Server::class); + + return Limit::perMinute(2)->by($server->uuid); + }); + } +} diff --git a/register/LICENSE b/register/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/register/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + 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 GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/register/README.md b/register/README.md new file mode 100644 index 0000000..7aff20c --- /dev/null +++ b/register/README.md @@ -0,0 +1,8 @@ +# Register (by Boy132) + +A simple way for users to register themselves on the panel without administrator intervention. + +## Features + +- Self-service user registration +- Seamless integration with existing login flow diff --git a/register/plugin.json b/register/plugin.json new file mode 100644 index 0000000..be8c92d --- /dev/null +++ b/register/plugin.json @@ -0,0 +1,15 @@ +{ + "id": "register", + "name": "Register", + "author": "Boy132", + "version": "1.0.0", + "description": "A simple way for users to register themselves", + "category": "plugin", + "url": "https://github.com/everestmcarthur/forged-plugs/tree/main/register", + "update_url": null, + "namespace": "Boy132\\Register", + "class": "RegisterPlugin", + "panels": null, + "panel_version": null, + "composer_packages": null +} \ No newline at end of file diff --git a/register/src/Filament/Pages/Auth/Register.php b/register/src/Filament/Pages/Auth/Register.php new file mode 100644 index 0000000..dd271ca --- /dev/null +++ b/register/src/Filament/Pages/Auth/Register.php @@ -0,0 +1,53 @@ +captchaService = $captchaService; + } + + public function form(Schema $schema): Schema + { + $components = [ + $this->getNameFormComponent(), + $this->getEmailFormComponent(), + $this->getPasswordFormComponent(), + $this->getPasswordConfirmationFormComponent(), + ]; + + if ($captchaComponent = $this->getCaptchaComponent()) { + $components[] = $captchaComponent; + } + + return $schema + ->components($components); + } + + private function getCaptchaComponent(): ?Component + { + return $this->captchaService->getActiveSchema()?->getFormComponent(); + } + + protected function getNameFormComponent(): Component + { + /** @var TextInput $parent */ + $parent = parent::getNameFormComponent(); + + return $parent + ->name('username') + ->statePath('username') + ->label(trans('profile.username')) + ->unique($this->getUserModel(), 'username'); + } +} diff --git a/register/src/RegisterPlugin.php b/register/src/RegisterPlugin.php new file mode 100644 index 0000000..f012f1c --- /dev/null +++ b/register/src/RegisterPlugin.php @@ -0,0 +1,22 @@ +registration(Register::class); + } + + public function boot(Panel $panel): void {} +} diff --git a/robo-avatars/LICENSE b/robo-avatars/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/robo-avatars/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + 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 GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/robo-avatars/README.md b/robo-avatars/README.md new file mode 100644 index 0000000..2459f89 --- /dev/null +++ b/robo-avatars/README.md @@ -0,0 +1,9 @@ +# Robo Avatars (by Boy132) + +Adds [RoboHash](https://robohash.org/) as an avatar provider, generating unique robot avatars for users based on their email address. + +## Features + +- Automatic robot avatar generation for all users +- Fun and distinctive visual identity for users +- Unique avatars based on email hash diff --git a/robo-avatars/plugin.json b/robo-avatars/plugin.json new file mode 100644 index 0000000..1321fd5 --- /dev/null +++ b/robo-avatars/plugin.json @@ -0,0 +1,15 @@ +{ + "id": "robo-avatars", + "name": "Robo Avatars", + "author": "Boy132", + "version": "1.0.0", + "description": "Adds RoboHash as avatar provider", + "category": "plugin", + "url": "https://github.com/everestmcarthur/forged-plugs/tree/main/robo-avatars", + "update_url": null, + "namespace": "Boy132\\RoboAvatars", + "class": "RoboAvatarsPlugin", + "panels": null, + "panel_version": null, + "composer_packages": null +} \ No newline at end of file diff --git a/robo-avatars/src/Providers/RoboAvatarsPluginProvider.php b/robo-avatars/src/Providers/RoboAvatarsPluginProvider.php new file mode 100644 index 0000000..5b758e8 --- /dev/null +++ b/robo-avatars/src/Providers/RoboAvatarsPluginProvider.php @@ -0,0 +1,17 @@ +app->make(AvatarService::class)->register(new RoboAvatarsSchema()); + } +} diff --git a/robo-avatars/src/RoboAvatarsPlugin.php b/robo-avatars/src/RoboAvatarsPlugin.php new file mode 100644 index 0000000..cc04e00 --- /dev/null +++ b/robo-avatars/src/RoboAvatarsPlugin.php @@ -0,0 +1,18 @@ +email); + } +} diff --git a/rust-umod/LICENSE b/rust-umod/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/rust-umod/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + 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 GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/rust-umod/README.md b/rust-umod/README.md new file mode 100644 index 0000000..39f7d86 --- /dev/null +++ b/rust-umod/README.md @@ -0,0 +1,14 @@ +# Rust uMod (by Boy132) + +Easily download and install Rust plugins directly from uMod (formerly Oxide) within the server panel. + +## Setup + +Add `umod_plugins` to the _features_ of your egg to enable the mod page. +Also make sure you use `oxide` or `umod` as modding framework. (`FRAMEWORK` startup variable) + +## Features + +- Browse and search uMod's Rust plugin library +- One-click installation to the correct directory +- Search and filter plugins by name diff --git a/rust-umod/plugin.json b/rust-umod/plugin.json new file mode 100644 index 0000000..202e5b0 --- /dev/null +++ b/rust-umod/plugin.json @@ -0,0 +1,17 @@ +{ + "id": "rust-umod", + "name": "Rust uMod", + "author": "Boy132", + "version": "1.0.0", + "description": "Easily download rust plugins from uMod", + "category": "plugin", + "url": "https://github.com/everestmcarthur/forged-plugs/tree/main/rust-umod", + "update_url": null, + "namespace": "Boy132\\RustUMod", + "class": "RustUModPlugin", + "panels": [ + "server" + ], + "panel_version": null, + "composer_packages": null +} \ No newline at end of file diff --git a/rust-umod/src/Facades/RustUMod.php b/rust-umod/src/Facades/RustUMod.php new file mode 100644 index 0000000..8018062 --- /dev/null +++ b/rust-umod/src/Facades/RustUMod.php @@ -0,0 +1,23 @@ +>, total: int} getUModPlugins(int $page = 1, string $search = '') + * @method static array getUModPlugin(string $pluginName) + * + * @see RustUModService + */ +class RustUMod extends Facade +{ + protected static function getFacadeAccessor(): string + { + return RustUModService::class; + } +} diff --git a/rust-umod/src/Filament/Server/Pages/RustUModPluginsPage.php b/rust-umod/src/Filament/Server/Pages/RustUModPluginsPage.php new file mode 100644 index 0000000..20ed3c4 --- /dev/null +++ b/rust-umod/src/Filament/Server/Pages/RustUModPluginsPage.php @@ -0,0 +1,174 @@ +records(function (?string $search, int $page) { + $response = RustUMod::getUModPlugins($page, $search ?? ''); + + return new LengthAwarePaginator($response['data'], $response['total'], 10, $page); + }) + ->paginated([10]) + ->columns([ + ImageColumn::make('icon_url') + ->label(''), + TextColumn::make('title') + ->searchable() + ->description(fn (array $record) => (strlen($record['description']) > 120) ? substr($record['description'], 0, 120).'...' : $record['description']), + TextColumn::make('author') + ->url(fn ($state) => "https://umod.org/user/$state", true) + ->toggleable(), + TextColumn::make('downloads_shortened') + ->label('Downloads') + ->icon('tabler-download') + ->toggleable(), + TextColumn::make('latest_release_at') + ->icon('tabler-calendar') + ->formatStateUsing(fn ($state) => Carbon::parse($state, 'UTC')->diffForHumans()) + ->tooltip(fn ($state) => Carbon::parse($state, 'UTC')->timezone(user()->timezone ?? 'UTC')->format($table->getDefaultDateTimeDisplayFormat())) + ->toggleable(), + ]) + ->recordUrl(fn (array $record) => $record['url'], true) + ->recordActions([ + Action::make('download') + ->tooltip('Download') + ->icon('tabler-download') + ->action(function (array $record, DaemonFileRepository $fileRepository) { + try { + /** @var Server $server */ + $server = Filament::getTenant(); + + $fileRepository->setServer($server)->pull($record['download_url'], 'oxide/plugins'); + + Notification::make() + ->title('Download started') + ->body($record['latest_release_version']) + ->success() + ->send(); + } catch (Exception $exception) { + report($exception); + + Notification::make() + ->title('Download could not be started') + ->body($exception->getMessage()) + ->danger() + ->send(); + } + }), + ]); + } + + protected function getHeaderActions(): array + { + return [ + Action::make('open_folder') + ->tooltip(fn () => 'Open plugins folder') + ->icon('tabler-folder-open') + ->url(fn () => ListFiles::getUrl(['path' => 'oxide/plugins']), true), + ]; + } + + public function content(Schema $schema): Schema + { + /** @var Server $server */ + $server = Filament::getTenant(); + + return $schema + ->components([ + Grid::make() + ->schema([ + TextEntry::make('framework') + ->label(fn () => 'Modding Framework') + ->state(fn () => RustUMod::getRustModdingFramework($server)) + ->badge(), + TextEntry::make('installed') + ->label(fn () => 'Installed plugins') + ->state(function (DaemonFileRepository $fileRepository) use ($server) { + try { + $files = $fileRepository->setServer($server)->getDirectory('oxide/plugins'); + + if (isset($files['error'])) { + throw new Exception($files['error']); + } + + return collect($files) + ->filter(fn ($file) => $file['mime'] === 'text/plain' && str($file['name'])->lower()->endsWith('.cs')) + ->count(); + } catch (Exception $exception) { + report($exception); + + return 'Unknown'; + } + }) + ->badge(), + ]), + EmbeddedTable::make(), + ]); + } +} diff --git a/rust-umod/src/RustUModPlugin.php b/rust-umod/src/RustUModPlugin.php new file mode 100644 index 0000000..da5f60f --- /dev/null +++ b/rust-umod/src/RustUModPlugin.php @@ -0,0 +1,23 @@ +getId())->title(); + + $panel->discoverPages(plugin_path($this->getId(), "src/Filament/$id/Pages"), "Boy132\\RustUMod\\Filament\\$id\\Pages"); + } + + public function boot(Panel $panel): void {} +} diff --git a/rust-umod/src/Services/RustUModService.php b/rust-umod/src/Services/RustUModService.php new file mode 100644 index 0000000..0a31e90 --- /dev/null +++ b/rust-umod/src/Services/RustUModService.php @@ -0,0 +1,72 @@ +variables()->where('env_variable', 'FRAMEWORK')->first()?->server_value; + } + + public function isRustServer(Server $server): bool + { + $framework = $this->getRustModdingFramework($server); + + if (!in_array($framework, ['oxide', 'umod'])) { + return false; + } + + $server->loadMissing('egg'); + + $features = $server->egg->features ?? []; + $tags = $server->egg->tags ?? []; + + return in_array('umod_plugins', $features) || in_array('rust', $tags); + } + + /** @return array{data: array>, total: int} */ + public function getUModPlugins(int $page = 1, string $search = ''): array + { + return cache()->remember("umod_plugins:$page:$search", now()->addMinutes(30), function () use ($search, $page) { + try { + return Http::asJson() + ->timeout(5) + ->connectTimeout(5) + ->throw() + ->get("https://umod.org/plugins/search.json?page=$page&query=$search&sort=downloads&sortdir=desc&categories=universal%2Crust") + ->json(); + } catch (Exception $exception) { + report($exception); + + return [ + 'data' => [], + 'total' => 0, + ]; + } + }); + } + + /** @return array */ + public function getUModPlugin(string $pluginName): array + { + return cache()->remember("umod_plugin:$pluginName", now()->addMinutes(30), function () use ($pluginName) { + try { + return Http::asJson() + ->timeout(5) + ->connectTimeout(5) + ->throw() + ->get("https://umod.org/plugins/$pluginName.json") + ->json(); + } catch (Exception $exception) { + report($exception); + + return []; + } + }); + } +} diff --git a/snowflakes/LICENSE b/snowflakes/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/snowflakes/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + 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 GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/snowflakes/README.md b/snowflakes/README.md new file mode 100644 index 0000000..397f044 --- /dev/null +++ b/snowflakes/README.md @@ -0,0 +1,9 @@ +# Snowflakes (by Boy132 & notCharles) + +Let it snow, let it snow, let it snow! Adds a festive snowfall animation to the panel. + +## Features + +- Animated falling snowflakes across all panels +- Non-intrusive - doesn't affect panel functionality +- Perfect for holiday seasons or winter themes diff --git a/snowflakes/config/snowflakes.php b/snowflakes/config/snowflakes.php new file mode 100644 index 0000000..2144120 --- /dev/null +++ b/snowflakes/config/snowflakes.php @@ -0,0 +1,9 @@ + env('SNOWFLAKES_SIZE', 0.8), + 'speed' => env('SNOWFLAKES_SPEED', 1), + 'opacity' => env('SNOWFLAKES_OPACITY', 0.5), + 'density' => env('SNOWFLAKES_DENSITY', 1), + 'quality' => env('SNOWFLAKES_QUALITY', 1), +]; diff --git a/snowflakes/lang/en/strings.php b/snowflakes/lang/en/strings.php new file mode 100644 index 0000000..8bd13fc --- /dev/null +++ b/snowflakes/lang/en/strings.php @@ -0,0 +1,14 @@ + 'Size', + 'size_help' => 'Size of the snowflakes.', + 'speed' => 'Speed', + 'speed_help' => 'Speed of the snowflakes falling.', + 'opacity' => 'Opacity', + 'opacity_help' => 'How well can you see through the snowflakes.', + 'density' => 'Density', + 'density_help' => 'Page density of the snowflakes. More density, more snowflakes.', + 'quality' => 'Quality', + 'quality_help' => 'Higher quality may impact performance on some devices.', +]; diff --git a/snowflakes/plugin.json b/snowflakes/plugin.json new file mode 100644 index 0000000..00d02e9 --- /dev/null +++ b/snowflakes/plugin.json @@ -0,0 +1,15 @@ +{ + "id": "snowflakes", + "name": "Snowflakes", + "author": "Boy132 & notCharles", + "version": "1.0.0", + "description": "Let it snow, let it snow, let it snow", + "category": "plugin", + "url": "https://github.com/everestmcarthur/forged-plugs/tree/main/snowflakes", + "update_url": null, + "namespace": "Boy132\\Snowflakes", + "class": "SnowflakesPlugin", + "panels": null, + "panel_version": null, + "composer_packages": null +} \ No newline at end of file diff --git a/snowflakes/src/Providers/SnowflakesPluginProvider.php b/snowflakes/src/Providers/SnowflakesPluginProvider.php new file mode 100644 index 0000000..d3d851f --- /dev/null +++ b/snowflakes/src/Providers/SnowflakesPluginProvider.php @@ -0,0 +1,32 @@ + Blade::render(<<<'HTML' + + + HTML, config('snowflakes')) + ); + } +} diff --git a/snowflakes/src/SnowflakesPlugin.php b/snowflakes/src/SnowflakesPlugin.php new file mode 100644 index 0000000..0d21f80 --- /dev/null +++ b/snowflakes/src/SnowflakesPlugin.php @@ -0,0 +1,92 @@ +label(trans('snowflakes::strings.size')) + ->range(minValue: 0.5, maxValue: 4) + ->decimalPlaces(1) + ->step(0.1) + ->tooltips() + ->hintIcon('tabler-question-mark') + ->hintIconTooltip(trans('snowflakes::strings.size_help')) + ->default(fn () => config('snowflakes.size')), + Slider::make('SNOWFLAKES_SPEED') + ->label(trans('snowflakes::strings.speed')) + ->range(minValue: 0.5, maxValue: 3) + ->decimalPlaces(1) + ->step(0.1) + ->tooltips() + ->hintIcon('tabler-question-mark') + ->hintIconTooltip(trans('snowflakes::strings.speed_help')) + ->default(fn () => config('snowflakes.speed')), + Slider::make('SNOWFLAKES_OPACITY') + ->label(trans('snowflakes::strings.opacity')) + ->range(minValue: 0.1, maxValue: 1) + ->decimalPlaces(1) + ->step(0.1) + ->tooltips() + ->hintIcon('tabler-question-mark') + ->hintIconTooltip(trans('snowflakes::strings.opacity_help')) + ->default(fn () => config('snowflakes.opacity')), + Slider::make('SNOWFLAKES_DENSITY') + ->label(trans('snowflakes::strings.density')) + ->range(minValue: 0.5, maxValue: 10) + ->decimalPlaces(1) + ->step(0.1) + ->tooltips() + ->hintIcon('tabler-question-mark') + ->hintIconTooltip(trans('snowflakes::strings.density_help')) + ->default(fn () => config('snowflakes.density')), + Slider::make('SNOWFLAKES_QUALITY') + ->label(trans('snowflakes::strings.quality')) + ->range(minValue: 0.1, maxValue: 1) + ->decimalPlaces(1) + ->step(0.1) + ->tooltips() + ->hintIcon('tabler-question-mark') + ->hintIconTooltip(trans('snowflakes::strings.quality_help')) + ->default(fn () => config('snowflakes.quality')), + ]; + + return [ + Group::make() + ->schema($schema) + ->columns(), + ]; + } + + public function saveSettings(array $data): void + { + $this->writeToEnvironment($data); + + Notification::make() + ->title(trans('admin/setting.save_success')) + ->success() + ->send(); + } +} diff --git a/subdomains/LICENSE b/subdomains/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/subdomains/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + 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 GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/subdomains/README.md b/subdomains/README.md new file mode 100644 index 0000000..f2aa321 --- /dev/null +++ b/subdomains/README.md @@ -0,0 +1,19 @@ +# Subdomains (by Boy132 & HarlequinSin) + +Allows users to create and manage custom subdomains (A/AAAA or SRV) for their game servers using Cloudflare DNS. + +## Setup + +[Create a Cloudflare API token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/) and enter it via the plugin settings. +The token needs to have read permissions for `Zone.Zone` and write for `Zone.Dns`. For better security you can also set the `Zone Resources` to exclude certain domains and add the panel ip to the `Client IP Address Filtering`. + +By default every server has a subdomain limit of 0. You can change this limit by editing the server in the admin area. + +Note: You can't create subdomains for servers with `0.0.0.0` or `::` as allocation! + +## SRV Records + +In order to create SRV records instead of A/AAAA you need to do the following: + +1. Set a `SRV target` for the node +2. Add a [SRV service type](https://github.com/pelican-dev/plugins/blob/main/subdomains/src/Enums/SRVServiceType.php#L10-L15) to the features of the egg. The format is `srv-` and then the service name, e.g. `srv-minecraft` or `srv-rust`. diff --git a/subdomains/config/subdomains.php b/subdomains/config/subdomains.php new file mode 100644 index 0000000..5cdb6b5 --- /dev/null +++ b/subdomains/config/subdomains.php @@ -0,0 +1,5 @@ + env('CLOUDFLARE_TOKEN'), +]; diff --git a/subdomains/database/migrations/001_create_cloudflare_domains_table.php b/subdomains/database/migrations/001_create_cloudflare_domains_table.php new file mode 100644 index 0000000..4ba3ca8 --- /dev/null +++ b/subdomains/database/migrations/001_create_cloudflare_domains_table.php @@ -0,0 +1,23 @@ +increments('id'); + $table->string('name')->unique(); + $table->string('cloudflare_id')->nullable(); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('cloudflare_domains'); + } +}; diff --git a/subdomains/database/migrations/002_create_subdomains_table.php b/subdomains/database/migrations/002_create_subdomains_table.php new file mode 100644 index 0000000..3d08971 --- /dev/null +++ b/subdomains/database/migrations/002_create_subdomains_table.php @@ -0,0 +1,41 @@ +increments('id'); + $table->string('name'); + $table->string('record_type')->default('A'); + $table->string('cloudflare_id')->nullable(); + + $table->unsignedInteger('domain_id'); + $table->foreign('domain_id')->references('id')->on('cloudflare_domains')->cascadeOnDelete(); + + $table->unsignedInteger('server_id'); + $table->foreign('server_id')->references('id')->on('servers')->cascadeOnDelete(); + + $table->timestamps(); + + $table->unique(['name', 'domain_id']); + }); + } + + public function down(): void + { + Subdomain::all()->each(function (Subdomain $subdomain) { + try { + $subdomain->delete(); + } catch (Exception) { + } + }); + + Schema::dropIfExists('subdomains'); + } +}; diff --git a/subdomains/database/migrations/003_add_subdomain_limit_to_servers.php b/subdomains/database/migrations/003_add_subdomain_limit_to_servers.php new file mode 100644 index 0000000..5fcd693 --- /dev/null +++ b/subdomains/database/migrations/003_add_subdomain_limit_to_servers.php @@ -0,0 +1,22 @@ +unsignedInteger('subdomain_limit')->default(0)->after('backup_limit'); + }); + } + + public function down(): void + { + Schema::table('servers', function (Blueprint $table) { + $table->dropColumn('subdomain_limit'); + }); + } +}; diff --git a/subdomains/database/migrations/004_add_srv_target_to_nodes.php b/subdomains/database/migrations/004_add_srv_target_to_nodes.php new file mode 100644 index 0000000..b038059 --- /dev/null +++ b/subdomains/database/migrations/004_add_srv_target_to_nodes.php @@ -0,0 +1,22 @@ +string('srv_target')->nullable()->after('fqdn'); + }); + } + + public function down(): void + { + Schema::table('nodes', function (Blueprint $table) { + $table->dropColumn('srv_target'); + }); + } +}; diff --git a/subdomains/lang/de/strings.php b/subdomains/lang/de/strings.php new file mode 100644 index 0000000..9e98575 --- /dev/null +++ b/subdomains/lang/de/strings.php @@ -0,0 +1,30 @@ + 'Keine Domains', + 'domain' => 'Domain|Domains', + + 'no_subdomains' => 'Keine Subdomains', + 'subdomain' => 'Subdomain|Subdomains', + 'limit' => 'Limit', + 'change_limit' => 'Limit anpassen', + 'limit_changed' => 'Limit angepasst', + 'limit_reached' => 'Subdomain Limit erreicht', + 'create_subdomain' => 'Subdomain erstellen', + + 'name' => 'Name', + 'record_type' => 'Record Typ', + 'is_synced' => 'Ist synchronisiert?', + 'srv_target' => 'SRV Ziel', + 'no_srv_target' => 'Kein SRV Ziel', + + 'sync' => 'Synchronisieren', + + 'api_token' => 'Cloudflare API Token', + 'api_token_help' => 'Der Token benötigt Leseberechtigung für Zone.Zone und Schreibberechtigung für Zone.Dns. Für eine verbesserte Sicherheit können mit "Zone Resources" bestimmte Domains ausgeschlossen werden und die Panel-IP zum "Client IP Adress Filtering" hinzugefügt werden.', + + 'notifications' => [ + 'synced' => 'Domain wurde erfolgreich mit Cloudflare synchronisiert', + 'not_synced' => 'Domain konnte nicht mit Cloudflare synchronisiert werden', + ], +]; diff --git a/subdomains/lang/en/strings.php b/subdomains/lang/en/strings.php new file mode 100644 index 0000000..869110a --- /dev/null +++ b/subdomains/lang/en/strings.php @@ -0,0 +1,30 @@ + 'No Domains', + 'domain' => 'Domain|Domains', + + 'no_subdomains' => 'No Subdomains', + 'subdomain' => 'Subdomain|Subdomains', + 'limit' => 'Limit', + 'change_limit' => 'Change limit', + 'limit_changed' => 'Limit changed', + 'limit_reached' => 'Subdomain limit reached', + 'create_subdomain' => 'Create Subdomain', + + 'name' => 'Name', + 'record_type' => 'Record type', + 'is_synced' => 'Is Synced?', + 'srv_target' => 'SRV target', + 'no_srv_target' => 'No SRV target', + + 'sync' => 'Sync', + + 'api_token' => 'Cloudflare API Token', + 'api_token_help' => 'The token needs to have read permissions for Zone.Zone and write for Zone.Dns. For better security you can also set the "Zone Resources" to exclude certain domains and add the panel ip to the "Client IP Address Filtering".', + + 'notifications' => [ + 'synced' => 'Domain synced with cloudflare', + 'not_synced' => 'Could not sync domain with cloudflare', + ], +]; diff --git a/subdomains/plugin.json b/subdomains/plugin.json new file mode 100644 index 0000000..c4063eb --- /dev/null +++ b/subdomains/plugin.json @@ -0,0 +1,18 @@ +{ + "id": "subdomains", + "name": "Subdomains", + "author": "Boy132 & HarlequinSin", + "version": "1.0.0", + "description": "Allows users to create subdomains for their servers", + "category": "plugin", + "url": "https://github.com/everestmcarthur/forged-plugs/tree/main/subdomains", + "update_url": null, + "namespace": "Boy132\\Subdomains", + "class": "SubdomainsPlugin", + "panels": [ + "admin", + "server" + ], + "panel_version": null, + "composer_packages": null +} \ No newline at end of file diff --git a/subdomains/src/Enums/SRVServiceType.php b/subdomains/src/Enums/SRVServiceType.php new file mode 100644 index 0000000..d2428bb --- /dev/null +++ b/subdomains/src/Enums/SRVServiceType.php @@ -0,0 +1,36 @@ +name)->title(); + } + + public static function fromServer(Server $server): ?self + { + $features = $server->egg->features ?? []; + + foreach (self::cases() as $type) { + $name = str($type->name)->lower()->prepend('srv-'); + + if (in_array($name, $features)) { + return $type; + } + } + + return null; + } +} diff --git a/subdomains/src/Filament/Admin/Resources/CloudflareDomains/CloudflareDomainResource.php b/subdomains/src/Filament/Admin/Resources/CloudflareDomains/CloudflareDomainResource.php new file mode 100644 index 0000000..592a245 --- /dev/null +++ b/subdomains/src/Filament/Admin/Resources/CloudflareDomains/CloudflareDomainResource.php @@ -0,0 +1,143 @@ +count() ?: null; + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + TextColumn::make('name') + ->label(trans('subdomains::strings.name')), + TextColumn::make('subdomains_count') + ->label(trans_choice('subdomains::strings.subdomain', 2)) + ->counts('subdomains'), + IconColumn::make('is_synced') + ->label(trans('subdomains::strings.is_synced')) + ->state(fn (CloudflareDomain $domain) => !is_null($domain->cloudflare_id)) + ->boolean() + ->trueIcon('tabler-refresh') + ->falseIcon('tabler-refresh-off') + ->tooltip(fn (CloudflareDomain $domain) => $domain->cloudflare_id), + ]) + ->recordActions([ + Action::make('sync') + ->tooltip(trans('subdomains::strings.sync')) + ->icon('tabler-refresh') + ->visible(fn (CloudflareDomain $domain) => is_null($domain->cloudflare_id)) + ->action(function (CloudflareDomain $domain) { + try { + $domain->fetchCloudflareId(); + + Notification::make() + ->title(trans('subdomains::strings.notifications.synced')) + ->success() + ->send(); + } catch (Exception $exception) { + Notification::make() + ->title(trans('subdomains::strings.notifications.not_synced')) + ->body($exception->getMessage()) + ->danger() + ->persistent() + ->send(); + } + }), + DeleteAction::make(), + ]) + ->toolbarActions([ + CreateAction::make() + ->createAnother(false) + //->hidden(fn () => is_null(config('subdomains.token'))) + ->using(function (array $data) { + try { + return CloudflareDomain::create($data); + } catch (Exception $exception) { + Notification::make() + ->title(trans('subdomains::strings.notifications.not_synced')) + ->body($exception->getMessage()) + ->warning() + ->persistent() + ->send(); + } + }), + ]) + ->emptyStateIcon('tabler-world-www') + ->emptyStateDescription('') + ->emptyStateHeading(trans('subdomains::strings.no_domains')); + } + + public static function form(Schema $schema): Schema + { + return $schema + ->columns(1) + ->components([ + TextInput::make('name') + ->label(trans('subdomains::strings.name')) + ->required() + ->unique(), + ]); + } + + public static function infolist(Schema $schema): Schema + { + return $schema + ->components([ + TextEntry::make('name') + ->label(trans('subdomains::strings.name')), + ]); + } + + public static function getPages(): array + { + return [ + 'index' => ManageCloudflareDomains::route('/'), + ]; + } +} diff --git a/subdomains/src/Filament/Admin/Resources/CloudflareDomains/Pages/ManageCloudflareDomains.php b/subdomains/src/Filament/Admin/Resources/CloudflareDomains/Pages/ManageCloudflareDomains.php new file mode 100644 index 0000000..ef27128 --- /dev/null +++ b/subdomains/src/Filament/Admin/Resources/CloudflareDomains/Pages/ManageCloudflareDomains.php @@ -0,0 +1,11 @@ +heading(fn () => trans_choice('subdomains::strings.subdomain', 2) . ' (' . trans('subdomains::strings.limit') .': ' . ($this->getOwnerRecord()->subdomain_limit ?? 0) . ')') + ->columns([ + TextColumn::make('label') + ->label(trans('subdomains::strings.name')) + ->state(fn (Subdomain $subdomain) => $subdomain->getLabel()), + TextColumn::make('record_type') + ->label(trans('subdomains::strings.record_type')), + ]) + ->recordActions([ + EditAction::make() + ->action(function (array $data, Subdomain $subdomain, SubdomainService $service) { + try { + return $service->handle($data, $subdomain); + } catch (Exception $exception) { + Notification::make() + ->title(trans('subdomains::strings.notifications.not_synced')) + ->body($exception->getMessage()) + ->danger() + ->persistent() + ->send(); + + throw new Halt(); + } + }), + DeleteAction::make(), + ]) + ->headerActions([ + Action::make('change_limit') + ->tooltip(trans('subdomains::strings.change_limit')) + ->icon('tabler-filter-2-edit') + ->schema([ + TextInput::make('limit') + ->label(trans('subdomains::strings.limit')) + ->numeric() + ->required() + ->default($this->getOwnerRecord()->subdomain_limit ?? 0) + ->minValue(0), + ]) + ->action(function ($data) { + $oldLimit = $this->getOwnerRecord()->subdomain_limit ?? 0; + $newLimit = $data['limit']; + + $this->getOwnerRecord()->update(['subdomain_limit' => $newLimit]); + + Notification::make() + ->title(trans('subdomains::strings.limit_changed')) + ->body($oldLimit . ' -> ' . $newLimit) + ->success() + ->send(); + }), + CreateAction::make() + ->visible(fn () => CloudflareDomain::count() > 0) + ->disabled(fn () => !$this->getOwnerRecord()->allocation || $this->getOwnerRecord()->allocation->ip === '0.0.0.0' || $this->getOwnerRecord()->allocation->ip === '::') + ->createAnother(false) + ->action(function (array $data, SubdomainService $service) { + try { + $data['server_id'] = $this->getOwnerRecord()->id; + + return $service->handle($data); + } catch (Exception $exception) { + Notification::make() + ->title(trans('subdomains::strings.notifications.not_synced')) + ->body($exception->getMessage()) + ->danger() + ->persistent() + ->send(); + + throw new Halt(); + } + }), + ]); + } + + public function form(Schema $schema): Schema + { + return $schema + ->components([ + TextInput::make('name') + ->label(trans('subdomains::strings.name')) + ->required() + ->unique() + ->alphaNum() + ->columnSpanFull() + ->suffix(fn (Get $get) => '.' . CloudflareDomain::find($get('domain_id'))?->name), + Select::make('domain_id') + ->label(trans_choice('subdomains::strings.domain', 1)) + ->disabledOn('edit') + ->hidden(fn () => CloudflareDomain::count() <= 1) + ->dehydratedWhenHidden() + ->required() + ->selectablePlaceholder(false) + ->default(fn () => CloudflareDomain::first()?->id) + ->relationship('domain', 'name') + ->preload() + ->searchable() + ->live(), + Select::make('record_type') + ->label(trans('subdomains::strings.record_type')) + ->disabledOn('edit') + ->hidden(fn () => is_null($this->getOwnerRecord()->node->srv_target)) // @phpstan-ignore property.notFound + ->dehydratedWhenHidden() + ->required() + ->selectablePlaceholder(false) + ->options(function () { + $types = is_ipv6($this->getOwnerRecord()->allocation->ip) ? ['AAAA' => 'AAAA'] : ['A' => 'A']; + + // @phpstan-ignore property.notFound + if (!is_null($this->getOwnerRecord()->node->srv_target)) { + $types['SRV'] = 'SRV'; + } + + return $types; + }) + ->default(fn () => is_ipv6($this->getOwnerRecord()->allocation->ip) ? 'AAAA' : 'A'), + ]); + } +} diff --git a/subdomains/src/Filament/Admin/Resources/SrvTargets/Pages/ManageSrvTargets.php b/subdomains/src/Filament/Admin/Resources/SrvTargets/Pages/ManageSrvTargets.php new file mode 100644 index 0000000..5699c79 --- /dev/null +++ b/subdomains/src/Filament/Admin/Resources/SrvTargets/Pages/ManageSrvTargets.php @@ -0,0 +1,11 @@ +columns([ + TextColumn::make('name') + ->label(trans('admin/node.table.name')) + ->url(fn (Node $node) => user()?->can('update', $node) ? EditNode::getUrl(['record' => $node]) : null), + TextColumn::make('fqdn') + ->label(trans('admin/node.table.address')), + TextInputColumn::make('srv_target') + ->label(trans('subdomains::strings.srv_target')) + ->placeholder(trans('subdomains::strings.no_srv_target')) + ->updateStateUsing(function (Node $node, $state) { + $node->forceFill([ + 'srv_target' => $state, + ])->save(); + }), + ]) + ->emptyStateIcon('tabler-world-www') + ->emptyStateDescription('') + ->emptyStateHeading(trans('admin/node.no_nodes')); + } + + public static function getPages(): array + { + return [ + 'index' => ManageSrvTargets::route('/'), + ]; + } +} diff --git a/subdomains/src/Filament/Server/Resources/Subdomains/Pages/ListSubdomains.php b/subdomains/src/Filament/Server/Resources/Subdomains/Pages/ListSubdomains.php new file mode 100644 index 0000000..6596336 --- /dev/null +++ b/subdomains/src/Filament/Server/Resources/Subdomains/Pages/ListSubdomains.php @@ -0,0 +1,16 @@ +allocation && $server->allocation->ip !== '0.0.0.0' && $server->allocation->ip !== '::' && CloudflareDomain::count() > 0; + } + + public static function getNavigationLabel(): string + { + return trans_choice('subdomains::strings.subdomain', 2); + } + + public static function getModelLabel(): string + { + return trans_choice('subdomains::strings.subdomain', 1); + } + + public static function getPluralModelLabel(): string + { + return trans_choice('subdomains::strings.subdomain', 2); + } + + protected static function getBadgeCount(): int + { + /** @var Server $server */ + $server = Filament::getTenant(); + + return $server->subdomains->count(); // @phpstan-ignore property.notFound + } + + protected static function getBadgeLimit(): int + { + /** @var Server $server */ + $server = Filament::getTenant(); + + return $server->subdomain_limit ?? 0; + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + TextColumn::make('label') + ->label(trans('subdomains::strings.name')) + ->state(fn (Subdomain $subdomain) => $subdomain->getLabel()), + TextColumn::make('record_type') + ->label(trans('subdomains::strings.record_type')), + ]) + ->recordActions([ + EditAction::make() + ->action(function (array $data, Subdomain $subdomain, SubdomainService $service) { + try { + return $service->handle($data, $subdomain); + } catch (Exception $exception) { + Notification::make() + ->title(trans('subdomains::strings.notifications.not_synced')) + ->body($exception->getMessage()) + ->danger() + ->persistent() + ->send(); + + throw new Halt(); + } + }), + DeleteAction::make(), + ]) + ->toolbarActions([ + CreateAction::make() + ->icon('tabler-world-plus') + ->tooltip(fn () => static::getBadgeCount() >= static::getBadgeLimit() ? trans('subdomains::strings.limit_reached') : trans('subdomains::strings.create_subdomain')) + ->disabled(fn () => static::getBadgeCount() >= static::getBadgeLimit()) + ->color(fn () => static::getBadgeCount() >= static::getBadgeLimit() ? 'danger' : 'primary') + ->createAnother(false) + ->hiddenLabel() + ->iconButton() + ->iconSize(IconSize::ExtraLarge) + ->action(function (array $data, SubdomainService $service) { + try { + /** @var Server $server */ + $server = Filament::getTenant(); + + $data['server_id'] = $server->id; + + return $service->handle($data); + } catch (Exception $exception) { + Notification::make() + ->title(trans('subdomains::strings.notifications.not_synced')) + ->body($exception->getMessage()) + ->danger() + ->persistent() + ->send(); + + throw new Halt(); + } + }), + ]); + } + + public static function form(Schema $schema): Schema + { + return $schema + ->components([ + TextInput::make('name') + ->label(trans('subdomains::strings.name')) + ->required() + ->unique() + ->alphaNum() + ->columnSpanFull() + ->suffix(fn (Get $get) => '.' . CloudflareDomain::find($get('domain_id'))?->name), + Select::make('domain_id') + ->label(trans_choice('subdomains::strings.domain', 1)) + ->disabledOn('edit') + ->hidden(fn () => CloudflareDomain::count() <= 1) + ->dehydratedWhenHidden() + ->required() + ->selectablePlaceholder(false) + ->default(fn () => CloudflareDomain::first()?->id) + ->relationship('domain', 'name') + ->preload() + ->searchable() + ->live(), + Select::make('record_type') + ->label(trans('subdomains::strings.record_type')) + ->disabledOn('edit') + ->hidden(function () { + /** @var Server $server */ + $server = Filament::getTenant(); + + // @phpstan-ignore property.notFound + return is_null($server->node->srv_target); + }) + ->dehydratedWhenHidden() + ->required() + ->selectablePlaceholder(false) + ->options(function () { + /** @var Server $server */ + $server = Filament::getTenant(); + + $types = is_ipv6($server->allocation->ip) ? ['AAAA' => 'AAAA'] : ['A' => 'A']; + + // @phpstan-ignore property.notFound + if (!is_null($server->node->srv_target)) { + $types['SRV'] = 'SRV'; + } + + return $types; + }) + ->default(function () { + /** @var Server $server */ + $server = Filament::getTenant(); + + return is_ipv6($server->allocation->ip) ? 'AAAA' : 'A'; + }), + ]); + } + + public static function getPages(): array + { + return [ + 'index' => ListSubdomains::route('/'), + ]; + } +} diff --git a/subdomains/src/Models/CloudflareDomain.php b/subdomains/src/Models/CloudflareDomain.php new file mode 100644 index 0000000..4d8e3ce --- /dev/null +++ b/subdomains/src/Models/CloudflareDomain.php @@ -0,0 +1,60 @@ +fetchCloudflareId(); + }); + } + + public function subdomains(): HasMany + { + return $this->hasMany(Subdomain::class, 'domain_id'); + } + + /** @throws Exception */ + public function fetchCloudflareId(): void + { + // @phpstan-ignore staticMethod.notFound + $response = Http::cloudflare()->get('zones', [ + 'name' => $this->name, + ])->json(); + + if ($response['success']) { + $zones = $response['result']; + + if (count($zones) > 0) { + $this->update([ + 'cloudflare_id' => $zones[0]['id'], + ]); + } else { + throw new Exception("No zone with name $this->name found."); + } + } else { + if ($response['errors'] && count($response['errors']) > 0) { + throw new Exception($response['errors'][0]['message']); + } + } + } +} diff --git a/subdomains/src/Models/Subdomain.php b/subdomains/src/Models/Subdomain.php new file mode 100644 index 0000000..e501bc0 --- /dev/null +++ b/subdomains/src/Models/Subdomain.php @@ -0,0 +1,158 @@ +deleteOnCloudflare(); + }); + } + + public function domain(): BelongsTo + { + return $this->belongsTo(CloudflareDomain::class, 'domain_id'); + } + + public function server(): BelongsTo + { + return $this->belongsTo(Server::class); + } + + public function getLabel(): string|Htmlable|null + { + return $this->name . '.' . $this->domain->name; + } + + /** @throws Exception */ + public function upsertOnCloudflare(): void + { + if (!$this->server->allocation) { + throw new Exception('Server has no allocation'); + } + + if ($this->record_type === 'SRV') { + $srvTarget = $this->server->node->srv_target; // @phpstan-ignore property.notFound + + if (!$srvTarget) { + throw new Exception('Node has no SRV target'); + } + + $srvServiceType = SRVServiceType::fromServer($this->server); + + if (!$srvServiceType) { + throw new Exception('Server has no SRV type'); + } + + $searchName = "$srvServiceType->value.$this->name"; + + $payload = [ + 'name' => $searchName, + 'type' => $this->record_type, + 'comment' => 'Created by Pelican Subdomains plugin', + 'data' => [ + 'port' => $this->server->allocation->port, + 'priority' => 0, + 'target' => $srvTarget, + 'weight' => 0, + ], + 'proxied' => false, + ]; + } else { + if ($this->server->allocation->ip === '0.0.0.0' || $this->server->allocation->ip === '::') { + throw new Exception('Server has invalid allocation ip (0.0.0.0 or ::)'); + } + + $searchName = $this->name; + + $payload = [ + 'name' => $searchName, + 'type' => $this->record_type, + 'comment' => 'Created by Pelican Subdomains plugin', + 'content' => $this->server->allocation->ip, + 'proxied' => false, + ]; + } + + // @phpstan-ignore staticMethod.notFound + $searchResponse = Http::cloudflare()->get("zones/{$this->domain->cloudflare_id}/dns_records", [ + 'name' => $searchName, + 'type' => $this->record_type, + ])->json(); + + if ($searchResponse['success']) { + $results = $searchResponse['result'] ?? []; + + foreach ($results as $record) { + if ($record['id'] !== $this->cloudflare_id) { + throw new Exception('A subdomain with that name already exists'); + } + } + } else { + if ($searchResponse['errors'] && count($searchResponse['errors']) > 0) { + throw new Exception($searchResponse['errors'][0]['message']); + } + } + + if ($this->cloudflare_id) { + // @phpstan-ignore staticMethod.notFound + $response = Http::cloudflare()->patch("zones/{$this->domain->cloudflare_id}/dns_records/$this->cloudflare_id", $payload)->json(); + } else { + // @phpstan-ignore staticMethod.notFound + $response = Http::cloudflare()->post("zones/{$this->domain->cloudflare_id}/dns_records", $payload)->json(); + + if ($response['success']) { + $dnsRecord = $response['result']; + + $this->updateQuietly([ + 'cloudflare_id' => $dnsRecord['id'], + ]); + } + } + + if (!$response['success']) { + if ($response['errors'] && count($response['errors']) > 0) { + throw new Exception($response['errors'][0]['message']); + } + } + } + + protected function deleteOnCloudflare(): void + { + if ($this->cloudflare_id) { + // @phpstan-ignore staticMethod.notFound + Http::cloudflare()->delete("zones/{$this->domain->cloudflare_id}/dns_records/$this->cloudflare_id"); + } + } +} diff --git a/subdomains/src/Policies/CloudflareDomainPolicy.php b/subdomains/src/Policies/CloudflareDomainPolicy.php new file mode 100644 index 0000000..b2c748e --- /dev/null +++ b/subdomains/src/Policies/CloudflareDomainPolicy.php @@ -0,0 +1,12 @@ + Http::acceptJson() + ->withToken(config('subdomains.token')) + ->timeout(5) + ->connectTimeout(1) + ->baseUrl('https://api.cloudflare.com/client/v4/') + ); + + Server::resolveRelationUsing('subdomains', fn (Server $server) => $server->hasMany(Subdomain::class, 'server_id', 'id')); + + Server::deleting(function (Server $server) { + /** @phpstan-ignore property.notFound */ + foreach ($server->subdomains as $subdomain) { + try { + $subdomain->delete(); + } catch (Exception $exception) { + report($exception); + } + } + }); + } +} diff --git a/subdomains/src/Services/SubdomainService.php b/subdomains/src/Services/SubdomainService.php new file mode 100644 index 0000000..3592993 --- /dev/null +++ b/subdomains/src/Services/SubdomainService.php @@ -0,0 +1,40 @@ + $data + * + * @throws Exception + */ + public function handle(array $data, ?Subdomain $subdomain = null): Subdomain + { + $newSubdomain = true; + + if (is_null($subdomain)) { + $subdomain = Subdomain::create($data); + } else { + $subdomain->update($data); + $newSubdomain = false; + } + + $subdomain->refresh(); + + try { + $subdomain->upsertOnCloudflare(); + } catch (Exception $exception) { + if ($newSubdomain) { + $subdomain->delete(); + } + + throw $exception; + } + + return $subdomain; + } +} diff --git a/subdomains/src/SubdomainsPlugin.php b/subdomains/src/SubdomainsPlugin.php new file mode 100644 index 0000000..17e7164 --- /dev/null +++ b/subdomains/src/SubdomainsPlugin.php @@ -0,0 +1,54 @@ +getId())->title(); + + $panel->discoverResources(plugin_path($this->getId(), "src/Filament/$id/Resources"), "Boy132\\Subdomains\\Filament\\$id\\Resources"); + $panel->discoverPages(plugin_path($this->getId(), "src/Filament/$id/Pages"), "Boy132\\Subdomains\\Filament\\$id\\Pages"); + } + + public function boot(Panel $panel): void {} + + public function getSettingsForm(): array + { + return [ + TextInput::make('token') + ->label(trans('subdomains::strings.api_token')) + ->required() + ->hintIcon('tabler-question-mark') + ->hintIconTooltip(trans('subdomains::strings.api_token_help')) + ->default(fn () => config('subdomains.token')), + ]; + } + + public function saveSettings(array $data): void + { + $this->writeToEnvironment([ + 'CLOUDFLARE_TOKEN' => $data['token'], + ]); + + Notification::make() + ->title('Settings saved') + ->success() + ->send(); + } +} diff --git a/tawkto-widget/LICENSE b/tawkto-widget/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/tawkto-widget/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + 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 GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/tawkto-widget/README.md b/tawkto-widget/README.md new file mode 100644 index 0000000..73d24aa --- /dev/null +++ b/tawkto-widget/README.md @@ -0,0 +1,8 @@ +# Tawk.to Widget (by Boy132) + +Adds a Tawk.to live chat widget to all panels for real-time customer support. + +## Features + +- Tawk.to live chat integration +- Configurable through plugin settings diff --git a/tawkto-widget/config/tawkto-widget.php b/tawkto-widget/config/tawkto-widget.php new file mode 100644 index 0000000..72fb062 --- /dev/null +++ b/tawkto-widget/config/tawkto-widget.php @@ -0,0 +1,6 @@ + env('TAWKTO_PROVIDER_ID'), + 'widget_id' => env('TAWKTO_WIDGET_ID'), +]; diff --git a/tawkto-widget/plugin.json b/tawkto-widget/plugin.json new file mode 100644 index 0000000..21707d5 --- /dev/null +++ b/tawkto-widget/plugin.json @@ -0,0 +1,15 @@ +{ + "id": "tawkto-widget", + "name": "Tawk.to Widget", + "author": "Boy132", + "version": "1.0.0", + "description": "Adds a Tawk.to widget to all panels", + "category": "plugin", + "url": "https://github.com/everestmcarthur/forged-plugs/tree/main/tawkto-widget", + "update_url": null, + "namespace": "Boy132\\TawktoWidget", + "class": "TawktoWidgetPlugin", + "panels": null, + "panel_version": null, + "composer_packages": null +} \ No newline at end of file diff --git a/tawkto-widget/src/Providers/TawktoWidgetPluginProvider.php b/tawkto-widget/src/Providers/TawktoWidgetPluginProvider.php new file mode 100644 index 0000000..ab80a2b --- /dev/null +++ b/tawkto-widget/src/Providers/TawktoWidgetPluginProvider.php @@ -0,0 +1,41 @@ + Blade::render(<<<'HTML' + + + + HTML, [ + 'providerId' => $providerId, + 'widgetId' => $widgetId, + ]) + ); + } + } +} diff --git a/tawkto-widget/src/TawktoWidgetPlugin.php b/tawkto-widget/src/TawktoWidgetPlugin.php new file mode 100644 index 0000000..73bbc38 --- /dev/null +++ b/tawkto-widget/src/TawktoWidgetPlugin.php @@ -0,0 +1,51 @@ +label('Provider ID') + ->required() + ->default(fn () => config('tawkto-widget.provider_id')), + TextInput::make('widget_id') + ->label('Widget ID') + ->required() + ->default(fn () => config('tawkto-widget.widget_id')), + ]; + } + + public function saveSettings(array $data): void + { + $this->writeToEnvironment([ + 'TAWKTO_PROVIDER_ID' => $data['provider_id'], + 'TAWKTO_WIDGET_ID' => $data['widget_id'], + ]); + + Notification::make() + ->title('Settings saved') + ->success() + ->send(); + } +} diff --git a/theme-customizer/LICENSE b/theme-customizer/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/theme-customizer/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + 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 GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/theme-customizer/README.md b/theme-customizer/README.md new file mode 100644 index 0000000..d71d5e7 --- /dev/null +++ b/theme-customizer/README.md @@ -0,0 +1,9 @@ +# Theme Customizer (by Boy132) + +Allows administrators to customize the panel font and colors through an intuitive settings interface. + +## Features + +- Custom font support (upload TTF files) +- Customizable color palette +- Live preview of changes diff --git a/theme-customizer/config/theme-customizer.php b/theme-customizer/config/theme-customizer.php new file mode 100644 index 0000000..7d468a0 --- /dev/null +++ b/theme-customizer/config/theme-customizer.php @@ -0,0 +1,16 @@ + env('THEME_CUSTOMIZER_FONT'), + + 'colors' => [ + 'gray' => env('THEME_CUSTOMIZER_COLORS_GRAY'), + 'primary' => env('THEME_CUSTOMIZER_COLORS_PRIMARY'), + 'info' => env('THEME_CUSTOMIZER_COLORS_INFO'), + 'success' => env('THEME_CUSTOMIZER_COLORS_SUCCESS'), + 'warning' => env('THEME_CUSTOMIZER_COLORS_WARNING'), + 'danger' => env('THEME_CUSTOMIZER_COLORS_DANGER'), + ], + + 'default_theme_mode' => env('THEME_CUSTOMIZER_DEFAULT_THEME_MODE', 'system'), +]; diff --git a/theme-customizer/plugin.json b/theme-customizer/plugin.json new file mode 100644 index 0000000..afa3fea --- /dev/null +++ b/theme-customizer/plugin.json @@ -0,0 +1,15 @@ +{ + "id": "theme-customizer", + "name": "Theme Customizer", + "author": "Boy132", + "version": "1.0.0", + "description": "Allows to customize the panel font and colors", + "category": "plugin", + "url": "https://github.com/everestmcarthur/forged-plugs/tree/main/theme-customizer", + "update_url": null, + "namespace": "Boy132\\ThemeCustomizer", + "class": "ThemeCustomizerPlugin", + "panels": null, + "panel_version": null, + "composer_packages": null +} \ No newline at end of file diff --git a/theme-customizer/src/Filament/Admin/Pages/Theme.php b/theme-customizer/src/Filament/Admin/Pages/Theme.php new file mode 100644 index 0000000..b04b4e6 --- /dev/null +++ b/theme-customizer/src/Filament/Admin/Pages/Theme.php @@ -0,0 +1,208 @@ +|null */ + public ?array $data = []; + + public function getTitle(): string + { + return 'Theme Customizer'; + } + + public static function getNavigationLabel(): string + { + return 'Theme Customizer'; + } + + public static function canAccess(): bool + { + return user()?->can('view themeCustomizer'); + } + + public function mount(): void + { + $this->form->fill(config('theme-customizer')); + } + + /** + * @return Component[] + * + * @throws Exception + */ + public function getFormSchema(): array + { + $schema = [ + Section::make('Font') + ->columns() + ->columnSpanFull() + ->schema([ + Select::make('font') + ->live() + ->selectablePlaceholder() + ->placeholder('Default Font') + ->options(function () { + $fonts = []; + + foreach (Storage::disk('public')->allFiles('fonts') as $file) { + $fileInfo = pathinfo($file); + + if ($fileInfo['extension'] === 'ttf') { + $fonts[$fileInfo['filename']] = $fileInfo['filename']; + } + } + + return $fonts; + }), + TextEntry::make('font_preview') + ->label('Preview') + ->state(function (Get $get) { + $fontName = $get('font'); + + if (!$fontName) { + return 'The quick brown fox jumps over the lazy dog'; + } + + $fontUrl = asset("storage/fonts/$fontName.ttf"); + $style = << + {$style} + + The quick brown fox jumps over the lazy dog + HTML); + }), + ]), + ]; + + $colorsSchema = []; + foreach (ThemeCustomizerPlugin::COLOR_NAMES as $color) { + $colorsSchema[] = ColorPicker::make('colors.' . $color) + ->live() + ->rgb() + ->placeholder('Default color') + ->columnSpan(3); + + $colorsSchema[] = TextEntry::make($color . '_text_preview') + ->hiddenLabel() + ->state($color) + ->badge() + ->color(fn (Get $get) => $get('colors.' . $color) ? Color::rgb($get('colors.' . $color)) : $color); + + $colorsSchema[] = Action::make('exclude_' . $color . '_button_preview') + ->label($color) + ->color(fn (Get $get) => $get('colors.' . $color) ? Color::rgb($get('colors.' . $color)) : $color); + + $colorsSchema[] = Action::make('exclude_' . $color . '_icon_button_preview') + ->tooltip($color) + ->iconButton() + ->icon('tabler-palette') + ->color(fn (Get $get) => $get('colors.' . $color) ? Color::rgb($get('colors.' . $color)) : $color); + } + $schema[] = Section::make('Colors') + ->columns(6) + ->columnSpanFull() + ->schema($colorsSchema); + + $schema[] = Section::make('Theme Mode') + ->columns() + ->columnSpanFull() + ->schema([ + ToggleButtons::make('default_theme_mode') + ->label('Default Theme Mode') + ->inline() + ->options(ThemeMode::class) + ->columnSpanFull(), + ]); + + return $schema; + } + + protected function getFormStatePath(): ?string + { + return 'data'; + } + + protected function getHeaderActions(): array + { + return [ + Action::make('save') + ->authorize(fn () => user()?->can('update themeCustomizer')) + ->hiddenLabel() + ->action('save') + ->keyBindings(['mod+s']) + ->tooltip(trans('filament-panels::resources/pages/edit-record.form.actions.save.label')) + ->icon('tabler-device-floppy'), + ]; + } + + public function save(): void + { + $formData = $this->form->getState(); + + $envData = [ + 'THEME_CUSTOMIZER_FONT' => $formData['font'], + 'THEME_CUSTOMIZER_DEFAULT_THEME_MODE' => $formData['default_theme_mode']?->value, + ]; + + foreach (ThemeCustomizerPlugin::COLOR_NAMES as $color) { + $envData['THEME_CUSTOMIZER_COLORS_' . strtoupper($color)] = Arr::get($formData, 'colors.' . $color); + } + + $this->writeToEnvironment($envData); + + Notification::make() + ->title('Theme saved') + ->success() + ->send(); + + $this->redirect(static::getUrl()); + } +} diff --git a/theme-customizer/src/Providers/ThemeCustomizerPluginProvider.php b/theme-customizer/src/Providers/ThemeCustomizerPluginProvider.php new file mode 100644 index 0000000..feeb3d2 --- /dev/null +++ b/theme-customizer/src/Providers/ThemeCustomizerPluginProvider.php @@ -0,0 +1,20 @@ + [ + 'view', + 'update', + ], + ]); + Role::registerCustomModelIcon('themeCustomizer', 'tabler-palette'); + } +} diff --git a/theme-customizer/src/ThemeCustomizerPlugin.php b/theme-customizer/src/ThemeCustomizerPlugin.php new file mode 100644 index 0000000..9faae1d --- /dev/null +++ b/theme-customizer/src/ThemeCustomizerPlugin.php @@ -0,0 +1,68 @@ +getId())->title(); + + $panel->discoverPages(plugin_path($this->getId(), "src/Filament/$id/Pages"), "Boy132\\ThemeCustomizer\\Filament\\$id\\Pages"); + + $this->applyTheme($panel); + } + + public function boot(Panel $panel): void {} + + private function applyTheme(Panel $panel): void + { + $font = config('theme-customizer.font'); + if ($font) { + $panel->font($font, provider: LocalFontProvider::class); + + $fontUrl = asset("storage/fonts/$font.ttf"); + $panel->renderHook( + PanelsRenderHook::STYLES_BEFORE, + fn () => Blade::render("") + ); + } + + $colors = []; + + foreach (static::COLOR_NAMES as $color) { + $value = config('theme-customizer.colors.' . $color); + if ($value) { + $colors[$color] = $value; + } + } + + $panel->colors($colors); + + $defaultThemeMode = config('theme-customizer.default_theme_mode'); + if ($defaultThemeMode) { + $panel->defaultThemeMode(ThemeMode::tryFrom($defaultThemeMode) ?? ThemeMode::System); + } + } +} diff --git a/tickets/LICENSE b/tickets/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/tickets/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + 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 GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/tickets/README.md b/tickets/README.md new file mode 100644 index 0000000..675466f --- /dev/null +++ b/tickets/README.md @@ -0,0 +1,10 @@ +# Tickets (by Boy132) + +A simple ticket system for users to submit support requests and for administrators to manage them. + +## Features + +- User ticket submission from server panel +- Ticket categories and priorities +- Ticket assignment to administrators +- Admin ticket management and responses diff --git a/tickets/database/migrations/001_create_tickets_table.php b/tickets/database/migrations/001_create_tickets_table.php new file mode 100644 index 0000000..2914db1 --- /dev/null +++ b/tickets/database/migrations/001_create_tickets_table.php @@ -0,0 +1,37 @@ +increments('id'); + + $table->string('title'); + $table->string('category'); + $table->string('priority'); + $table->string('status'); + $table->text('description')->nullable(); + + $table->unsignedInteger('server_id'); + $table->foreign('server_id')->references('id')->on('servers')->cascadeOnDelete(); + + $table->unsignedInteger('author_id')->nullable(); + $table->foreign('author_id')->references('id')->on('users')->nullOnDelete(); + + $table->unsignedInteger('assigned_user_id')->nullable(); + $table->foreign('assigned_user_id')->references('id')->on('users')->nullOnDelete(); + + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('tickets'); + } +}; diff --git a/tickets/database/migrations/002_create_ticket_messages_table.php b/tickets/database/migrations/002_create_ticket_messages_table.php new file mode 100644 index 0000000..c1c1d49 --- /dev/null +++ b/tickets/database/migrations/002_create_ticket_messages_table.php @@ -0,0 +1,31 @@ +increments('id'); + + $table->text('message')->nullable(); + $table->boolean('hidden')->default(false); + + $table->unsignedInteger('ticket_id'); + $table->foreign('ticket_id')->references('id')->on('tickets')->cascadeOnDelete(); + + $table->unsignedInteger('author_id')->nullable(); + $table->foreign('author_id')->references('id')->on('users')->nullOnDelete(); + + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('ticket_messages'); + } +}; diff --git a/tickets/lang/de/tickets.php b/tickets/lang/de/tickets.php new file mode 100644 index 0000000..c35b7be --- /dev/null +++ b/tickets/lang/de/tickets.php @@ -0,0 +1,35 @@ + 'Keine Tickets', + 'ticket' => 'Ticket|Tickets', + 'message' => 'Nachricht|Nachrichten', + 'title' => 'Titel', + 'category' => 'Kategorie', + 'priority' => 'Priorität', + 'status' => 'Status', + 'description' => 'Beschreibung', + 'no_description' => 'Keine Beschreibung', + 'open' => 'Offen', + 'closed' => 'Geschlossen', + 'all' => 'Alle', + 'answer_verb' => 'Antworten', + 'answer_noun' => 'Antwort', + 'server' => 'Server', + 'owner' => 'Server Besitzer', + 'created_at' => 'Erstellt am', + 'created_by' => 'Erstellt von', + 'author' => 'Author', + 'admin' => 'Admin', + 'hidden' => 'Versteckt', + 'unknown' => 'Unbekannt', + 'assigned_to' => 'Zugewiesen an', + 'noone' => 'Niemand', + 'assign_to_me' => 'Mir zuweisen', + 'assigned_to_me' => 'Mir zugewiesene', + + 'notifications' => [ + 'closed' => 'Ticket wurde geschlossen', + 'assigned_to_you' => 'Ticket wurde dir zugewiesen', + ], +]; diff --git a/tickets/lang/en/tickets.php b/tickets/lang/en/tickets.php new file mode 100644 index 0000000..9dde020 --- /dev/null +++ b/tickets/lang/en/tickets.php @@ -0,0 +1,35 @@ + 'No tickets', + 'ticket' => 'Ticket|Tickets', + 'message' => 'Message|Messages', + 'title' => 'Title', + 'category' => 'Category', + 'priority' => 'Priority', + 'status' => 'Status', + 'description' => 'Description', + 'no_description' => 'No description', + 'open' => 'Open', + 'closed' => 'Closed', + 'all' => 'All', + 'answer_verb' => 'Answer', + 'answer_noun' => 'Answer', + 'server' => 'Server', + 'owner' => 'Server Owner', + 'created_at' => 'Created at', + 'created_by' => 'Created by', + 'author' => 'Author', + 'admin' => 'Admin', + 'hidden' => 'Hidden', + 'unknown' => 'Unknown', + 'assigned_to' => 'Assigned to', + 'noone' => 'No one', + 'assign_to_me' => 'Assign to me', + 'assigned_to_me' => 'Assigned to me', + + 'notifications' => [ + 'closed' => 'Ticket closed', + 'assigned_to_you' => 'Ticket assigned to you', + ], +]; diff --git a/tickets/plugin.json b/tickets/plugin.json new file mode 100644 index 0000000..db6bab5 --- /dev/null +++ b/tickets/plugin.json @@ -0,0 +1,18 @@ +{ + "id": "tickets", + "name": "Tickets", + "author": "Boy132", + "version": "1.0.0", + "description": "Simple ticket system", + "category": "plugin", + "url": "https://github.com/everestmcarthur/forged-plugs/tree/main/tickets", + "update_url": null, + "namespace": "Boy132\\Tickets", + "class": "TicketsPlugin", + "panels": [ + "admin", + "server" + ], + "panel_version": null, + "composer_packages": null +} \ No newline at end of file diff --git a/tickets/src/Enums/TicketCategory.php b/tickets/src/Enums/TicketCategory.php new file mode 100644 index 0000000..bd46197 --- /dev/null +++ b/tickets/src/Enums/TicketCategory.php @@ -0,0 +1,37 @@ + 'tabler-help-circle', + self::Issue => 'tabler-exclamation-circle', + self::Feedback => 'tabler-user-circle', + }; + } + + public function getColor(): string + { + return match ($this) { + self::Question => 'primary', + self::Issue => 'danger', + self::Feedback => 'success', + }; + } + + public function getLabel(): string + { + return str($this->value)->headline(); + } +} diff --git a/tickets/src/Enums/TicketPriority.php b/tickets/src/Enums/TicketPriority.php new file mode 100644 index 0000000..9084ebe --- /dev/null +++ b/tickets/src/Enums/TicketPriority.php @@ -0,0 +1,40 @@ + 'tabler-chevron-down', + self::Normal => 'tabler-menu', + self::High => 'tabler-chevron-up', + self::VeryHigh => 'tabler-chevrons-up', + }; + } + + public function getColor(): string + { + return match ($this) { + self::Low => 'success', + self::Normal => 'primary', + self::High => 'warning', + self::VeryHigh => 'danger', + }; + } + + public function getLabel(): string + { + return str($this->value)->headline(); + } +} diff --git a/tickets/src/Enums/TicketStatus.php b/tickets/src/Enums/TicketStatus.php new file mode 100644 index 0000000..9932590 --- /dev/null +++ b/tickets/src/Enums/TicketStatus.php @@ -0,0 +1,37 @@ + 'tabler-circle-dashed', + self::InProgress => 'tabler-progress', + self::Closed => 'tabler-circle-check', + }; + } + + public function getColor(): string + { + return match ($this) { + self::Open => 'primary', + self::InProgress => 'success', + self::Closed => 'danger', + }; + } + + public function getLabel(): string + { + return str($this->value)->headline(); + } +} diff --git a/tickets/src/Filament/Admin/Resources/Tickets/Pages/CreateTicket.php b/tickets/src/Filament/Admin/Resources/Tickets/Pages/CreateTicket.php new file mode 100644 index 0000000..12382ce --- /dev/null +++ b/tickets/src/Filament/Admin/Resources/Tickets/Pages/CreateTicket.php @@ -0,0 +1,29 @@ +getCreateFormAction()->formId('form') + ->tooltip(fn (Action $action) => $action->getLabel()) + ->hiddenLabel() + ->icon('tabler-plus'), + ]; + } + + protected function getFormActions(): array + { + return []; + } +} diff --git a/tickets/src/Filament/Admin/Resources/Tickets/Pages/EditTicket.php b/tickets/src/Filament/Admin/Resources/Tickets/Pages/EditTicket.php new file mode 100644 index 0000000..c5fcbd5 --- /dev/null +++ b/tickets/src/Filament/Admin/Resources/Tickets/Pages/EditTicket.php @@ -0,0 +1,35 @@ +getCancelFormAction()->formId('form') + ->tooltip(fn (Action $action) => $action->getLabel()) + ->hiddenLabel() + ->icon('tabler-arrow-left'), + AnswerAction::make(), + AssignToMeAction::make(), + $this->getSaveFormAction()->formId('form') + ->tooltip(fn (Action $action) => $action->getLabel()) + ->hiddenLabel() + ->icon('tabler-device-floppy'), + ]; + } + + protected function getFormActions(): array + { + return []; + } +} diff --git a/tickets/src/Filament/Admin/Resources/Tickets/Pages/ListTickets.php b/tickets/src/Filament/Admin/Resources/Tickets/Pages/ListTickets.php new file mode 100644 index 0000000..cbd9dee --- /dev/null +++ b/tickets/src/Filament/Admin/Resources/Tickets/Pages/ListTickets.php @@ -0,0 +1,35 @@ + Tab::make(trans('tickets::tickets.assigned_to_me')) + ->modifyQueryUsing(fn (Builder $query) => $query->whereNot('status', TicketStatus::Closed->value)->where('assigned_user_id', auth()->user()->id)) + ->badge(fn () => Ticket::whereNot('status', TicketStatus::Closed->value)->where('assigned_user_id', auth()->user()->id)->count()), + + 'open' => Tab::make(trans('tickets::tickets.open')) + ->modifyQueryUsing(fn (Builder $query) => $query->whereNot('status', TicketStatus::Closed->value)) + ->badge(fn () => Ticket::whereNot('status', TicketStatus::Closed->value)->count()), + + 'closed' => Tab::make(trans('tickets::tickets.closed')) + ->modifyQueryUsing(fn (Builder $query) => $query->where('status', TicketStatus::Closed->value)) + ->badge(fn () => Ticket::where('status', TicketStatus::Closed->value)->count()), + + 'all' => Tab::make(trans('tickets::tickets.all')) + ->badge(fn () => Ticket::count()), + ]; + } +} diff --git a/tickets/src/Filament/Admin/Resources/Tickets/Pages/ViewTicket.php b/tickets/src/Filament/Admin/Resources/Tickets/Pages/ViewTicket.php new file mode 100644 index 0000000..b807b17 --- /dev/null +++ b/tickets/src/Filament/Admin/Resources/Tickets/Pages/ViewTicket.php @@ -0,0 +1,19 @@ +modelLabel(trans_choice('tickets::tickets.message', 1)) + ->pluralModelLabel(trans_choice('tickets::tickets.message', 2)) + ->paginated(false) + ->defaultSort('created_at', 'desc') + ->columns([ + Stack::make([ + TextColumn::make('message') + ->markdown(), + Split::make([ + TextColumn::make('author.username') + ->grow(false) + ->placeholder(trans('tickets::tickets.unknown')) + ->icon('tabler-user') + ->url(fn (TicketMessage $ticketMessage) => $ticketMessage->author && auth()->user()->can('edit user', $ticketMessage->author) ? EditUser::getUrl(['record' => $ticketMessage->author], panel: 'admin') : null), + DateTimeColumn::make('created_at') + ->grow(false) + ->since(), + TextColumn::make('is_hidden') + ->grow(false) + ->badge() + ->color('warning') + ->state(fn (TicketMessage $ticketMessage) => $ticketMessage->hidden ? trans('tickets::tickets.hidden') : null), + TextColumn::make('is_author') + ->grow(false) + ->badge() + ->color('success') + ->state(fn (TicketMessage $ticketMessage) => $ticketMessage->author_id === $this->getOwnerRecord()->author_id ? trans('tickets::tickets.author') : null), + TextColumn::make('is_assigned') + ->grow(false) + ->badge() + ->state(fn (TicketMessage $ticketMessage) => $ticketMessage->author_id === $this->getOwnerRecord()->assigned_user_id ? trans('tickets::tickets.admin') : null), + ]), + ])->space(3), + ]) + ->headerActions([ + CreateAction::make() + ->createAnother(false) + ->hiddenLabel() + ->icon('tabler-plus') + ->schema([ + MarkdownEditor::make('message') + ->label(trans_choice('tickets::tickets.message', 1)) + ->required(), + Toggle::make('hidden') + ->label(trans('tickets::tickets.hidden') . '?'), + ]), + ]); + } +} diff --git a/tickets/src/Filament/Admin/Resources/Tickets/TicketResource.php b/tickets/src/Filament/Admin/Resources/Tickets/TicketResource.php new file mode 100644 index 0000000..8fca688 --- /dev/null +++ b/tickets/src/Filament/Admin/Resources/Tickets/TicketResource.php @@ -0,0 +1,246 @@ +value)->count(); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + TextColumn::make('id') + ->label('#') + ->sortable() + ->searchable(), + TextColumn::make('title') + ->label(trans_choice('tickets::tickets.title', 1)) + ->description(fn (Ticket $ticket) => Markdown::inline($ticket->description ?? '')) + ->sortable() + ->searchable() + ->grow(), + TextColumn::make('category') + ->label(trans('tickets::tickets.category')) + ->badge() + ->toggleable(), + TextColumn::make('priority') + ->label(trans('tickets::tickets.priority')) + ->badge() + ->toggleable(), + TextColumn::make('status') + ->label(trans('tickets::tickets.status')) + ->badge() + ->toggleable(), + TextColumn::make('assignedUser.username') + ->label(trans('tickets::tickets.assigned_to')) + ->icon('tabler-user') + ->placeholder(trans('tickets::tickets.noone')) + ->url(fn (Ticket $ticket) => $ticket->assignedUser && auth()->user()->can('update user', $ticket->assignedUser) ? EditUser::getUrl(['record' => $ticket->assignedUser]) : null) + ->toggleable(), + TextColumn::make('server.name') + ->label(trans('tickets::tickets.server')) + ->icon('tabler-brand-docker') + ->url(fn (Ticket $ticket) => auth()->user()->can('update server', $ticket->server) ? EditServer::getUrl(['record' => $ticket->server]) : null) + ->toggleable(), + TextColumn::make('author.username') + ->label(trans('tickets::tickets.created_by')) + ->icon('tabler-user') + ->placeholder(trans('tickets::tickets.unknown')) + ->url(fn (Ticket $ticket) => $ticket->author && auth()->user()->can('update user', $ticket->author) ? EditUser::getUrl(['record' => $ticket->author]) : null) + ->toggleable(), + DateTimeColumn::make('created_at') + ->label(trans('tickets::tickets.created_at')) + ->since() + ->sortable() + ->toggleable(), + ]) + ->recordActions([ + ViewAction::make() + ->hidden(fn ($record) => static::getEditAuthorizationResponse($record)->allowed()), + EditAction::make(), + AnswerAction::make(), + AssignToMeAction::make(), + DeleteAction::make(), + ]) + ->toolbarActions([ + CreateAction::make(), + ]) + ->groups([ + Group::make('category') + ->label(trans('tickets::tickets.category')), + Group::make('priority') + ->label(trans('tickets::tickets.priority')), + Group::make('status') + ->label(trans('tickets::tickets.status')), + Group::make('server.name') + ->label(trans('tickets::tickets.server')), + Group::make('author.username') + ->label(trans('tickets::tickets.created_by')), + ]) + ->emptyStateIcon('tabler-ticket') + ->emptyStateDescription('') + ->emptyStateHeading(trans('tickets::tickets.no_tickets')); + } + + public static function form(Schema $schema): Schema + { + return $schema + ->schema([ + TextInput::make('title') + ->label(trans_choice('tickets::tickets.title', 1)) + ->required() + ->columnSpanFull(), + Select::make('category') + ->label(trans('tickets::tickets.category')) + ->required() + ->selectablePlaceholder(false) + ->options(TicketCategory::class), + Select::make('priority') + ->label(trans('tickets::tickets.priority')) + ->required() + ->selectablePlaceholder(false) + ->options(TicketPriority::class) + ->default(TicketPriority::Normal), + Select::make('status') + ->label(trans('tickets::tickets.status')) + ->required() + ->selectablePlaceholder(false) + ->options(TicketStatus::class) + ->default(TicketStatus::Open), + Select::make('server_id') + ->label(trans('tickets::tickets.server')) + ->required() + ->selectablePlaceholder(false) + ->relationship('server', 'name'), + MarkdownEditor::make('description') + ->label(trans('tickets::tickets.description')) + ->columnSpanFull(), + ]); + } + + public static function infolist(Schema $schema): Schema + { + return $schema + ->components([ + Section::make() + ->columnSpanFull() + ->columns(['default' => 1, 'md' => 2, 'lg' => 4]) + ->schema([ + TextEntry::make('title') + ->label(trans_choice('tickets::tickets.title', 1)) + ->columnSpanFull(), + TextEntry::make('category') + ->label(trans('tickets::tickets.category')) + ->badge(), + TextEntry::make('priority') + ->label(trans('tickets::tickets.priority')) + ->badge(), + TextEntry::make('status') + ->label(trans('tickets::tickets.status')) + ->badge(), + TextEntry::make('assignedUser.username') + ->label(trans('tickets::tickets.assigned_to')) + ->icon('tabler-user') + ->placeholder(trans('tickets::tickets.noone')) + ->url(fn (Ticket $ticket) => $ticket->assignedUser && auth()->user()->can('update user', $ticket->assignedUser) ? EditUser::getUrl(['record' => $ticket->assignedUser]) : null), + TextEntry::make('server.name') + ->label(trans('tickets::tickets.server')) + ->icon('tabler-brand-docker') + ->url(fn (Ticket $ticket) => auth()->user()->can('update server', $ticket->server) ? EditServer::getUrl(['record' => $ticket->server]) : null), + TextEntry::make('server.user.username') + ->label(trans('tickets::tickets.owner')) + ->icon('tabler-user') + ->url(fn (Ticket $ticket) => auth()->user()->can('update user', $ticket->server->user) ? EditUser::getUrl(['record' => $ticket->server->user]) : null), + TextEntry::make('author.username') + ->label(trans('tickets::tickets.created_by')) + ->icon('tabler-user') + ->placeholder(trans('tickets::tickets.unknown')) + ->url(fn (Ticket $ticket) => $ticket->author && auth()->user()->can('update user', $ticket->author) ? EditUser::getUrl(['record' => $ticket->author]) : null), + TextEntry::make('created_at') + ->label(trans('tickets::tickets.created_at')) + ->since(timezone: auth()->user()->timezone ?? config('app.timezone', 'UTC')) + ->dateTimeTooltip(timezone: auth()->user()->timezone ?? config('app.timezone', 'UTC')), + ]), + Section::make(trans('tickets::tickets.description')) + ->columnSpanFull() + ->schema([ + TextEntry::make('description') + ->hiddenLabel() + ->markdown() + ->placeholder(trans('tickets::tickets.no_description')), + ]), + ]); + } + + public static function getPages(): array + { + return [ + 'index' => ListTickets::route('/'), + 'create' => CreateTicket::route('/create'), + 'view' => ViewTicket::route('/{record}'), + 'edit' => EditTicket::route('/{record}/edit'), + ]; + } + + public static function getRelations(): array + { + return [ + MessagesRelationManager::class, + ]; + } +} diff --git a/tickets/src/Filament/Components/Actions/AnswerAction.php b/tickets/src/Filament/Components/Actions/AnswerAction.php new file mode 100644 index 0000000..01b3545 --- /dev/null +++ b/tickets/src/Filament/Components/Actions/AnswerAction.php @@ -0,0 +1,47 @@ +authorize(fn (Ticket $ticket) => auth()->user()->can('update ticket', $ticket)); + + $this->hidden(fn (Ticket $ticket) => $ticket->status === TicketStatus::Closed || $ticket->assigned_user_id !== auth()->user()->id); + + $this->tooltip(trans('tickets::tickets.answer_verb')); + + $this->icon('tabler-edit'); + + $this->color('primary'); + + $this->schema([ + MarkdownEditor::make('answer') + ->nullable() + ->hiddenLabel(), + ]); + + $this->action(function (Ticket $ticket, array $data) { + $ticket->close($data['answer']); + + Notification::make() + ->title(trans('tickets::tickets.notifications.closed')) + ->success() + ->send(); + }); + } +} diff --git a/tickets/src/Filament/Components/Actions/AssignToMeAction.php b/tickets/src/Filament/Components/Actions/AssignToMeAction.php new file mode 100644 index 0000000..60fd453 --- /dev/null +++ b/tickets/src/Filament/Components/Actions/AssignToMeAction.php @@ -0,0 +1,39 @@ +authorize(fn (Ticket $ticket) => auth()->user()->can('update ticket', $ticket)); + + $this->hidden(fn (Ticket $ticket) => $ticket->assignedUser); + + $this->tooltip(trans('tickets::tickets.assign_to_me')); + + $this->icon('tabler-user-share'); + + $this->color('primary'); + + $this->action(function (Ticket $ticket) { + $ticket->assignTo(auth()->user()); + + Notification::make() + ->title(trans('tickets::tickets.notifications.assigned_to_you')) + ->success() + ->send(); + }); + } +} diff --git a/tickets/src/Filament/Server/Resources/Tickets/Pages/CreateTicket.php b/tickets/src/Filament/Server/Resources/Tickets/Pages/CreateTicket.php new file mode 100644 index 0000000..b8f9d37 --- /dev/null +++ b/tickets/src/Filament/Server/Resources/Tickets/Pages/CreateTicket.php @@ -0,0 +1,29 @@ +getCreateFormAction()->formId('form') + ->tooltip(fn (Action $action) => $action->getLabel()) + ->hiddenLabel() + ->icon('tabler-plus'), + ]; + } + + public function getBreadcrumbs(): array + { + return []; + } +} diff --git a/tickets/src/Filament/Server/Resources/Tickets/Pages/ListTickets.php b/tickets/src/Filament/Server/Resources/Tickets/Pages/ListTickets.php new file mode 100644 index 0000000..896f94e --- /dev/null +++ b/tickets/src/Filament/Server/Resources/Tickets/Pages/ListTickets.php @@ -0,0 +1,37 @@ + Tab::make(trans('tickets::tickets.open')) + ->modifyQueryUsing(fn (Builder $query) => $query->whereNot('status', TicketStatus::Closed->value)) + ->badge(fn () => Ticket::where('server_id', Filament::getTenant()->getKey())->whereNot('status', TicketStatus::Closed->value)->count()), + + 'closed' => Tab::make(trans('tickets::tickets.closed')) + ->modifyQueryUsing(fn (Builder $query) => $query->where('status', TicketStatus::Closed->value)) + ->badge(fn () => Ticket::where('server_id', Filament::getTenant()->getKey())->where('status', TicketStatus::Closed->value)->count()), + + 'all' => Tab::make(trans('tickets::tickets.all')) + ->badge(fn () => Ticket::count()), + ]; + } +} diff --git a/tickets/src/Filament/Server/Resources/Tickets/Pages/ViewTicket.php b/tickets/src/Filament/Server/Resources/Tickets/Pages/ViewTicket.php new file mode 100644 index 0000000..516617e --- /dev/null +++ b/tickets/src/Filament/Server/Resources/Tickets/Pages/ViewTicket.php @@ -0,0 +1,16 @@ +modifyQueryUsing(fn (Builder $query) => $query->where('hidden', false)) + ->modelLabel(trans_choice('tickets::tickets.message', 1)) + ->pluralModelLabel(trans_choice('tickets::tickets.message', 2)) + ->paginated(false) + ->defaultSort('created_at', 'desc') + ->columns([ + Stack::make([ + TextColumn::make('message') + ->markdown(), + Split::make([ + TextColumn::make('author.username') + ->grow(false) + ->placeholder(trans('tickets::tickets.unknown')) + ->icon('tabler-user') + ->url(fn (TicketMessage $ticketMessage) => $ticketMessage->author && auth()->user()->can('edit user', $ticketMessage->author) ? EditUser::getUrl(['record' => $ticketMessage->author], panel: 'admin') : null), + DateTimeColumn::make('created_at') + ->grow(false) + ->since(), + TextColumn::make('is_author') + ->grow(false) + ->badge() + ->color('success') + ->state(fn (TicketMessage $ticketMessage) => $ticketMessage->author_id === $this->getOwnerRecord()->author_id ? trans('tickets::tickets.author') : null), + TextColumn::make('is_assigned') + ->grow(false) + ->badge() + ->state(fn (TicketMessage $ticketMessage) => $ticketMessage->author_id === $this->getOwnerRecord()->assigned_user_id ? trans('tickets::tickets.admin') : null), + ]), + ])->space(3), + ]) + ->headerActions([ + CreateAction::make() + ->hidden(fn () => $this->getOwnerRecord()->status === TicketStatus::Closed) + ->createAnother(false) + ->schema([ + MarkdownEditor::make('message') + ->label(trans_choice('tickets::tickets.message', 1)) + ->required(), + ]), + ]); + } + + public function isReadOnly(): bool + { + return false; + } +} diff --git a/tickets/src/Filament/Server/Resources/Tickets/TicketResource.php b/tickets/src/Filament/Server/Resources/Tickets/TicketResource.php new file mode 100644 index 0000000..8d0db28 --- /dev/null +++ b/tickets/src/Filament/Server/Resources/Tickets/TicketResource.php @@ -0,0 +1,240 @@ +value)->count(); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + TextColumn::make('id') + ->label('#') + ->sortable() + ->searchable(), + TextColumn::make('title') + ->label(trans_choice('tickets::tickets.title', 1)) + ->description(fn (Ticket $ticket) => Markdown::inline($ticket->description ?? '')) + ->sortable() + ->searchable() + ->grow(), + TextColumn::make('category') + ->label(trans('tickets::tickets.category')) + ->badge() + ->toggleable(), + TextColumn::make('priority') + ->label(trans('tickets::tickets.priority')) + ->badge() + ->toggleable(), + TextColumn::make('status') + ->label(trans('tickets::tickets.status')) + ->badge() + ->toggleable(), + TextColumn::make('assignedUser.username') + ->label(trans('tickets::tickets.assigned_to')) + ->icon('tabler-user') + ->placeholder(trans('tickets::tickets.noone')) + ->url(fn (Ticket $ticket) => $ticket->assignedUser && auth()->user()->can('update user', $ticket->assignedUser) ? EditUser::getUrl(['record' => $ticket->assignedUser], panel: 'admin') : null) + ->toggleable(), + TextColumn::make('author.username') + ->label(trans('tickets::tickets.created_by')) + ->icon('tabler-user') + ->placeholder(trans('tickets::tickets.unknown')) + ->url(fn (Ticket $ticket) => $ticket->author && auth()->user()->can('update user', $ticket->author) ? EditUser::getUrl(['record' => $ticket->author], panel: 'admin') : null) + ->toggleable(), + DateTimeColumn::make('created_at') + ->label(trans('tickets::tickets.created_at')) + ->since() + ->sortable() + ->toggleable(), + ]) + ->recordActions([ + ViewAction::make(), + ]) + ->toolbarActions([ + CreateAction::make(), + ]) + ->groups([ + Group::make('category') + ->label(trans('tickets::tickets.category')), + Group::make('priority') + ->label(trans('tickets::tickets.priority')), + Group::make('status') + ->label(trans('tickets::tickets.status')), + Group::make('author.username') + ->label(trans('tickets::tickets.created_by')), + ]) + ->emptyStateIcon('tabler-ticket') + ->emptyStateDescription('') + ->emptyStateHeading(trans('tickets::tickets.no_tickets')); + } + + public static function form(Schema $schema): Schema + { + return $schema + ->components([ + TextInput::make('title') + ->label(trans_choice('tickets::tickets.title', 1)) + ->required() + ->columnSpanFull(), + Select::make('category') + ->label(trans('tickets::tickets.category')) + ->required() + ->options(TicketCategory::class), + Select::make('priority') + ->label(trans('tickets::tickets.priority')) + ->required() + ->options(TicketPriority::class) + ->default(TicketPriority::Normal), + MarkdownEditor::make('description') + ->label(trans('tickets::tickets.description')) + ->columnSpanFull(), + ]); + } + + public static function infolist(Schema $schema): Schema + { + return $schema + ->components([ + Section::make() + ->columnSpanFull() + ->columns(['default' => 1, 'md' => 2, 'lg' => 3]) + ->schema([ + TextEntry::make('title') + ->label(trans_choice('tickets::tickets.title', 1)) + ->columnSpanFull(), + TextEntry::make('category') + ->label(trans('tickets::tickets.category')) + ->badge(), + TextEntry::make('priority') + ->label(trans('tickets::tickets.priority')) + ->badge(), + TextEntry::make('status') + ->label(trans('tickets::tickets.status')) + ->badge(), + TextEntry::make('assignedUser.username') + ->label(trans('tickets::tickets.assigned_to')) + ->icon('tabler-user') + ->placeholder(trans('tickets::tickets.noone')) + ->url(fn (Ticket $ticket) => $ticket->assignedUser && auth()->user()->can('update user', $ticket->assignedUser) ? EditUser::getUrl(['record' => $ticket->assignedUser], panel: 'admin') : null), + TextEntry::make('author.username') + ->label(trans('tickets::tickets.created_by')) + ->icon('tabler-user') + ->placeholder(trans('tickets::tickets.unknown')) + ->url(fn (Ticket $ticket) => $ticket->author && auth()->user()->can('update user', $ticket->author) ? EditUser::getUrl(['record' => $ticket->author], panel: 'admin') : null), + TextEntry::make('created_at') + ->label(trans('tickets::tickets.created_at')) + ->since(timezone: auth()->user()->timezone ?? config('app.timezone', 'UTC')) + ->dateTimeTooltip(timezone: auth()->user()->timezone ?? config('app.timezone', 'UTC')), + ]), + Section::make(trans('tickets::tickets.description')) + ->columnSpanFull() + ->schema([ + TextEntry::make('description') + ->hiddenLabel() + ->markdown() + ->placeholder(trans('tickets::tickets.no_description')), + ]), + ]); + } + + public static function getPages(): array + { + return [ + 'index' => ListTickets::route('/'), + 'create' => CreateTicket::route('/create'), + 'view' => ViewTicket::route('/{record}'), + ]; + } + + public static function getRelations(): array + { + return [ + MessagesRelationManager::class, + ]; + } + + public static function canViewAny(): bool + { + return true; + } + + public static function getViewAnyAuthorizationResponse(): Response + { + return Response::allow(); + } + + public static function canView(Model $record): bool + { + return true; + } + + public static function getViewAuthorizationResponse(Model $record): Response + { + return Response::allow(); + } + + public static function canCreate(): bool + { + return true; + } + + public static function getCreateAuthorizationResponse(): Response + { + return Response::allow(); + } +} diff --git a/tickets/src/Models/Ticket.php b/tickets/src/Models/Ticket.php new file mode 100644 index 0000000..cf54a77 --- /dev/null +++ b/tickets/src/Models/Ticket.php @@ -0,0 +1,133 @@ +status = TicketStatus::Open; + + $model->server_id ??= Filament::getTenant()?->getKey(); + $model->author_id ??= auth()->user()?->id; + }); + } + + protected function casts(): array + { + return [ + 'category' => TicketCategory::class, + 'priority' => TicketPriority::class, + 'status' => TicketStatus::class, + ]; + } + + public function server(): BelongsTo + { + return $this->belongsTo(Server::class, 'server_id'); + } + + public function author(): BelongsTo + { + return $this->belongsTo(User::class, 'author_id'); + } + + public function assignedUser(): BelongsTo + { + return $this->belongsTo(User::class, 'assigned_user_id'); + } + + public function messages(): HasMany + { + return $this->hasMany(TicketMessage::class); + } + + public function close(?string $answer = null): void + { + if ($answer) { + $this->messages()->create([ + 'message' => $answer, + 'author_id' => auth()->user()?->id, + ]); + } + + $this->status = TicketStatus::Closed; + + $this->save(); + + // Send notification to author if existing and is the owner or a subuser of the server + if ($this->author && collect($this->author->directAccessibleServers()->pluck('id')->all())->contains($this->server->id)) { + Notification::make() + ->title(trans('tickets::tickets.notifications.closed')) + ->body($answer ? Markdown::inline($answer) : null) + ->actions([ + Action::make('view') + ->label(trans(('filament-actions::view.single.label'))) + ->button() + ->markAsRead() + ->url(fn () => ListTickets::getUrl([ + 'tab' => 'closed', + 'tableAction' => 'view', + 'tableActionRecord' => $this->id, + ], panel: 'server', tenant: $this->server)), + ]) + ->sendToDatabase($this->author); + } + } + + public function assignTo(User $user, bool $setStatus = true): void + { + $this->assigned_user_id = $user->id; + + if ($setStatus) { + $this->status = TicketStatus::InProgress; + } + + $this->save(); + } +} diff --git a/tickets/src/Models/TicketMessage.php b/tickets/src/Models/TicketMessage.php new file mode 100644 index 0000000..bf0eeca --- /dev/null +++ b/tickets/src/Models/TicketMessage.php @@ -0,0 +1,48 @@ +author_id ??= auth()->user()?->id; + }); + } + + public function ticket(): BelongsTo + { + return $this->belongsTo(Ticket::class, 'ticket_id'); + } + + public function author(): BelongsTo + { + return $this->belongsTo(User::class, 'author_id'); + } +} diff --git a/tickets/src/Policies/TicketPolicy.php b/tickets/src/Policies/TicketPolicy.php new file mode 100644 index 0000000..2eb3f9d --- /dev/null +++ b/tickets/src/Policies/TicketPolicy.php @@ -0,0 +1,12 @@ + $server->hasMany(Ticket::class, 'server_id', 'id')); + } +} diff --git a/tickets/src/TicketsPlugin.php b/tickets/src/TicketsPlugin.php new file mode 100644 index 0000000..96adfdd --- /dev/null +++ b/tickets/src/TicketsPlugin.php @@ -0,0 +1,23 @@ +getId())->title(); + + $panel->discoverResources(plugin_path($this->getId(), "src/Filament/$id/Resources"), "Boy132\\Tickets\\Filament\\$id\\Resources"); + } + + public function boot(Panel $panel): void {} +} diff --git a/user-creatable-servers/LICENSE b/user-creatable-servers/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/user-creatable-servers/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + 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 GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/user-creatable-servers/README.md b/user-creatable-servers/README.md new file mode 100644 index 0000000..becda7d --- /dev/null +++ b/user-creatable-servers/README.md @@ -0,0 +1,15 @@ +# User Creatable Servers (by Boy132) + +Allow users to create their own servers within defined resource limits set by administrators. + +## Setup + +Add the deployment tag (`user_creatable_servers` by default) to the nodes that should be used for creating servers. + +## Features + +- Users can create servers without admin intervention +- Configurable resource limits per user (CPU, RAM, disk, etc.) +- Admin management of user resource allocations +- Resource usage overview widget for users +- Integration with existing server management diff --git a/user-creatable-servers/config/user-creatable-servers.php b/user-creatable-servers/config/user-creatable-servers.php new file mode 100644 index 0000000..7545bf0 --- /dev/null +++ b/user-creatable-servers/config/user-creatable-servers.php @@ -0,0 +1,13 @@ + env('UCS_DEFAULT_DATABASE_LIMIT', 0), + 'allocation_limit' => env('UCS_DEFAULT_ALLOCATION_LIMIT', 0), + 'backup_limit' => env('UCS_DEFAULT_BACKUP_LIMIT', 0), + + 'can_users_update_servers' => env('UCS_CAN_USERS_UPDATE_SERVERS', true), + 'can_users_delete_servers' => env('UCS_CAN_USERS_DELETE_SERVERS', false), + + 'deployment_tags' => env('UCS_DEPLOYMENT_TAGS', 'user_creatable_servers'), + 'deployment_ports' => env('UCS_DEPLOYMENT_PORTS', ''), +]; diff --git a/user-creatable-servers/database/migrations/001_create_user_resource_limits_table.php b/user-creatable-servers/database/migrations/001_create_user_resource_limits_table.php new file mode 100644 index 0000000..c5353d5 --- /dev/null +++ b/user-creatable-servers/database/migrations/001_create_user_resource_limits_table.php @@ -0,0 +1,27 @@ +increments('id'); + $table->unsignedInteger('user_id')->unique(); + $table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete(); + $table->unsignedInteger('cpu'); + $table->unsignedInteger('memory'); + $table->unsignedInteger('disk'); + $table->unsignedInteger('server_limit')->nullable(); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('user_resource_limits'); + } +}; diff --git a/user-creatable-servers/lang/en/strings.php b/user-creatable-servers/lang/en/strings.php new file mode 100644 index 0000000..4df4865 --- /dev/null +++ b/user-creatable-servers/lang/en/strings.php @@ -0,0 +1,40 @@ + 'User Resource Limit|User Resource Limits', + 'user' => 'User|Users', + 'cpu' => 'CPU', + 'memory' => 'Memory', + 'disk' => 'Disk Space', + 'server_limit' => 'Server Limit', + 'no_limit' => 'No Limit', + 'unlimited' => 'Unlimited', + 'hint_unlimited' => '0 means unlimited', + 'name' => 'Server Name', + 'egg' => 'Egg', + 'left' => 'left', + 'variables' => 'Startup variables', + + 'create_server' => 'Create server', + + 'modals' => [ + 'delete_server_confirm' => 'Are you sure you want to delete this server?', + 'delete_server_warning' => 'This action cannot be undone and all data will be permanently lost.', + 'delete_server' => 'Delete Server', + ], + + 'notifications' => [ + 'server_resources_updated' => 'Server Resource Limits updated', + 'might_need_restart' => 'To fully use the new resource limits a server restart might be required.', + 'manual_restart_needed' => 'Please manually restart your server to apply the new resource limits.', + + 'server_deleted' => 'Server Deleted', + 'server_deleted_success' => 'The server has been deleted successfully.', + 'server_delete_error' => 'Could not delete server', + + 'server_creation_failed' => 'Could not create server', + 'no_viable_node_found' => 'No viable node was found. Please contact the panel admin.', + 'no_viable_allocation_found' => 'No viable allocation was found. Please contact the panel admin.', + 'unknown_server_creation_error' => 'Unknown error. Please contact the panel admin.', + ], +]; diff --git a/user-creatable-servers/plugin.json b/user-creatable-servers/plugin.json new file mode 100644 index 0000000..c1c97f2 --- /dev/null +++ b/user-creatable-servers/plugin.json @@ -0,0 +1,15 @@ +{ + "id": "user-creatable-servers", + "name": "User Creatable Servers", + "author": "Boy132", + "version": "1.0.0", + "description": "Allow users to create their own servers", + "category": "plugin", + "url": "https://github.com/everestmcarthur/forged-plugs/tree/main/user-creatable-servers", + "update_url": null, + "namespace": "Boy132\\UserCreatableServers", + "class": "UserCreatableServersPlugin", + "panels": null, + "panel_version": null, + "composer_packages": null +} \ No newline at end of file diff --git a/user-creatable-servers/src/Filament/Admin/Resources/UserResourceLimits/Pages/ManageUserResourceLimits.php b/user-creatable-servers/src/Filament/Admin/Resources/UserResourceLimits/Pages/ManageUserResourceLimits.php new file mode 100644 index 0000000..d7c24c1 --- /dev/null +++ b/user-creatable-servers/src/Filament/Admin/Resources/UserResourceLimits/Pages/ManageUserResourceLimits.php @@ -0,0 +1,11 @@ +getCustomization(CustomizationKey::TopNavigation) ? false : trans('admin/dashboard.user'); + } + + public static function getNavigationBadge(): ?string + { + return (string) static::getEloquentQuery()->count() ?: null; + } + + public static function table(Table $table): Table + { + $suffix = config('panel.use_binary_prefix') ? ' MiB' : ' MB'; + + return $table + ->columns([ + TextColumn::make('user.username') + ->label(trans_choice('user-creatable-servers::strings.user', 1)) + ->icon('tabler-user') + ->url(fn (UserResourceLimits $userResourceLimits) => auth()->user()->can('update', $userResourceLimits->user) ? EditUser::getUrl(['record' => $userResourceLimits->user]) : null), + TextColumn::make('cpu') + ->label(trans('user-creatable-servers::strings.cpu')) + ->badge() + ->formatStateUsing(fn ($state) => $state > 0 ? $state . '%' : trans('user-creatable-servers::strings.unlimited')), + TextColumn::make('memory') + ->label(trans('user-creatable-servers::strings.memory')) + ->badge() + ->formatStateUsing(fn ($state) => $state > 0 ? $state . $suffix : trans('user-creatable-servers::strings.unlimited')), + TextColumn::make('disk') + ->label(trans('user-creatable-servers::strings.disk')) + ->badge() + ->formatStateUsing(fn ($state) => $state > 0 ? $state . $suffix : trans('user-creatable-servers::strings.unlimited')), + ]) + ->recordActions([ + ViewAction::make() + ->hidden(fn ($record) => static::getEditAuthorizationResponse($record)->allowed()), + EditAction::make(), + DeleteAction::make(), + ]) + ->toolbarActions([ + CreateAction::make() + ->createAnother(false), + ]) + ->emptyStateIcon('tabler-cube-plus') + ->emptyStateDescription(''); + } + + public static function form(Schema $schema): Schema + { + return $schema + ->components([ + Select::make('user_id') + ->label(trans_choice('user-creatable-servers::strings.user', 1)) + ->required() + ->prefixIcon('tabler-user') + ->unique() + ->relationship('user', 'username') + ->searchable(['username', 'email']) + ->getOptionLabelFromRecordUsing(fn (User $user) => "$user->username ($user->email)") + ->selectablePlaceholder(false) + ->hiddenOn('edit') + ->columnSpanFull(), + TextInput::make('cpu') + ->label(trans('user-creatable-servers::strings.cpu')) + ->required() + ->numeric() + ->minValue(0) + ->default(0) + ->suffix('%') + ->hint(trans('user-creatable-servers::strings.hint_unlimited')), + TextInput::make('memory') + ->label(trans('user-creatable-servers::strings.memory')) + ->required() + ->numeric() + ->minValue(0) + ->default(0) + ->suffix(config('panel.use_binary_prefix') ? 'MiB' : 'MB') + ->hint(trans('user-creatable-servers::strings.hint_unlimited')), + TextInput::make('disk') + ->label(trans('user-creatable-servers::strings.disk')) + ->required() + ->numeric() + ->minValue(0) + ->default(0) + ->suffix(config('panel.use_binary_prefix') ? 'MiB' : 'MB') + ->hint(trans('user-creatable-servers::strings.hint_unlimited')), + TextInput::make('server_limit') + ->label(trans('user-creatable-servers::strings.server_limit')) + ->numeric() + ->nullable() + ->placeholder(trans('user-creatable-servers::strings.no_limit')), + ]); + } + + public static function infolist(Schema $schema): Schema + { + return $schema + ->components([ + TextEntry::make('user.username') + ->label(trans_choice('user-creatable-servers::strings.user', 1)) + ->columnSpanFull(), + TextEntry::make('cpu') + ->label(trans('user-creatable-servers::strings.cpu')) + ->badge(), + TextEntry::make('memory') + ->label(trans('user-creatable-servers::strings.memory')) + ->badge(), + TextEntry::make('disk') + ->label(trans('user-creatable-servers::strings.disk')) + ->badge(), + TextEntry::make('server_limit') + ->label(trans('user-creatable-servers::strings.server_limit')) + ->badge() + ->placeholder(trans('user-creatable-servers::strings.no_limit')), + ]); + } + + public static function getPages(): array + { + return [ + 'index' => ManageUserResourceLimits::route('/'), + ]; + } +} diff --git a/user-creatable-servers/src/Filament/Admin/Resources/Users/RelationManagers/UserResourceLimitRelationManager.php b/user-creatable-servers/src/Filament/Admin/Resources/Users/RelationManagers/UserResourceLimitRelationManager.php new file mode 100644 index 0000000..5d47a38 --- /dev/null +++ b/user-creatable-servers/src/Filament/Admin/Resources/Users/RelationManagers/UserResourceLimitRelationManager.php @@ -0,0 +1,94 @@ +heading(trans_choice('user-creatable-servers::strings.user_resource_limits', 2)) + ->columns([ + TextColumn::make('cpu') + ->label(trans('user-creatable-servers::strings.cpu')) + ->badge() + ->formatStateUsing(fn ($state) => $state > 0 ? $state . '%' : trans('user-creatable-servers::strings.unlimited')), + TextColumn::make('memory') + ->label(trans('user-creatable-servers::strings.memory')) + ->badge() + ->formatStateUsing(fn ($state) => $state > 0 ? $state . $suffix : trans('user-creatable-servers::strings.unlimited')), + TextColumn::make('disk') + ->label(trans('user-creatable-servers::strings.disk')) + ->badge() + ->formatStateUsing(fn ($state) => $state > 0 ? $state . $suffix : trans('user-creatable-servers::strings.unlimited')), + ]) + ->recordActions([ + ViewAction::make() + ->hidden(fn ($record) => static::getEditAuthorizationResponse($record)->allowed()), + EditAction::make(), + DeleteAction::make(), + ]) + ->emptyStateIcon('tabler-cube-plus') + ->emptyStateDescription(''); + } + + public function form(Schema $schema): Schema + { + return $schema + ->components([ + TextInput::make('cpu') + ->label(trans('user-creatable-servers::strings.cpu')) + ->required() + ->numeric() + ->minValue(0) + ->default(0) + ->suffix('%') + ->hint(trans('user-creatable-servers::strings.hint_unlimited')), + TextInput::make('memory') + ->label(trans('user-creatable-servers::strings.memory')) + ->required() + ->numeric() + ->minValue(0) + ->default(0) + ->suffix(config('panel.use_binary_prefix') ? 'MiB' : 'MB') + ->hint(trans('user-creatable-servers::strings.hint_unlimited')), + TextInput::make('disk') + ->label(trans('user-creatable-servers::strings.disk')) + ->required() + ->numeric() + ->minValue(0) + ->default(0) + ->suffix(config('panel.use_binary_prefix') ? 'MiB' : 'MB') + ->hint(trans('user-creatable-servers::strings.hint_unlimited')), + TextInput::make('server_limit') + ->label(trans('user-creatable-servers::strings.server_limit')) + ->numeric() + ->nullable() + ->placeholder(trans('user-creatable-servers::strings.no_limit')), + ]); + } +} diff --git a/user-creatable-servers/src/Filament/App/Pages/CreateServerPage.php b/user-creatable-servers/src/Filament/App/Pages/CreateServerPage.php new file mode 100644 index 0000000..9f539ba --- /dev/null +++ b/user-creatable-servers/src/Filament/App/Pages/CreateServerPage.php @@ -0,0 +1,198 @@ +|null */ + public ?array $data = []; + + public function getTitle(): string + { + return trans('user-creatable-servers::strings.create_server'); + } + + public static function getNavigationLabel(): string + { + return trans('user-creatable-servers::strings.create_server'); + } + + public static function canAccess(): bool + { + return UserResourceLimits::where('user_id', auth()->user()->id)->exists(); + } + + public function mount(): void + { + $this->form->fill(); + } + + public function form(Schema $schema): Schema + { + /** @var UserResourceLimits $userResourceLimits */ + $userResourceLimits = UserResourceLimits::where('user_id', auth()->user()->id)->firstOrFail(); + + return $schema + ->statePath('data') + ->columns(3) + ->schema([ + TextInput::make('name') + ->label(trans('user-creatable-servers::strings.name')) + ->required() + ->default(fn () => (new RandomWordService())->word()) + ->columnSpanFull(), + Select::make('egg_id') + ->label(trans('user-creatable-servers::strings.egg')) + ->prefixIcon('tabler-egg') + ->options(fn () => Egg::all()->mapWithKeys(fn (Egg $egg) => [$egg->id => $egg->name])) + ->required() + ->searchable() + ->preload() + ->live() + ->afterStateUpdated(function ($state, Set $set) { + $egg = Egg::find($state); + + $variables = $egg->variables ?? []; + $serverVariables = collect(); + foreach ($variables as $variable) { + $serverVariables->add($variable->toArray()); + } + + $set('variables', $serverVariables->sortBy(['sort'])->all()); + for ($i = 0; $i < $serverVariables->count(); $i++) { + $set("variables.$i.variable_value", $serverVariables[$i]['default_value']); + $set("variables.$i.variable_id", $serverVariables[$i]['id']); + } + }) + ->columnSpanFull(), + TextInput::make('cpu') + ->label(trans('user-creatable-servers::strings.cpu')) + ->required() + ->numeric() + ->minValue($userResourceLimits->cpu > 0 ? 1 : 0) + ->maxValue($userResourceLimits->getCpuLeft()) + ->suffix('%'), + TextInput::make('memory') + ->label(trans('user-creatable-servers::strings.memory')) + ->required() + ->numeric() + ->minValue($userResourceLimits->memory > 0 ? 1 : 0) + ->maxValue($userResourceLimits->getMemoryLeft()) + ->suffix(config('panel.use_binary_prefix') ? 'MiB' : 'MB'), + TextInput::make('disk') + ->label(trans('user-creatable-servers::strings.disk')) + ->required() + ->numeric() + ->minValue($userResourceLimits->disk > 0 ? 1 : 0) + ->maxValue($userResourceLimits->getDiskLeft()) + ->suffix(config('panel.use_binary_prefix') ? 'MiB' : 'MB'), + Repeater::make('variables') + ->label(trans('user-creatable-servers::strings.variables')) + ->hidden(fn (Get $get) => !$get('egg_id')) + ->grid(2) + ->columnSpanFull() + ->reorderable(false) + ->addable(false) + ->deletable(false) + ->default([]) + ->hidden(fn ($state) => empty($state)) + ->schema([ + StartupVariable::make('variable_value') + ->fromForm() + ->disabled(false), + ]), + ]); + } + + protected function getHeaderActions(): array + { + return [ + Action::make('save') + ->hiddenLabel() + ->action('save') + ->keyBindings(['mod+s']) + ->tooltip(trans('filament-panels::resources/pages/edit-record.form.actions.save.label')) + ->icon('tabler-device-floppy'), + ]; + } + + protected function getHeaderWidgets(): array + { + return [ + UserResourceLimitsOverview::class, + ]; + } + + public function save(): void + { + $data = $this->form->getState(); + + try { + /** @var UserResourceLimits $userResourceLimits */ + $userResourceLimits = UserResourceLimits::where('user_id', auth()->user()->id)->firstOrFail(); + + if ($server = $userResourceLimits->createServer($data['name'], $data['egg_id'], $data['cpu'], $data['memory'], $data['disk'], Arr::mapWithKeys($data['variables'], fn ($value) => [$value['env_variable'] => $value['variable_value']]))) { + $redirectUrl = Console::getUrl(panel: 'server', tenant: $server); + $this->redirect($redirectUrl, navigate: FilamentView::hasSpaMode($redirectUrl)); + } + } catch (Exception $exception) { + report($exception); + + if ($exception instanceof NoViableNodeException) { + Notification::make() + ->title(trans('user-creatable-servers::strings.notifications.server_creation_failed')) + ->body(trans('user-creatable-servers::strings.notifications.no_viable_node_found')) + ->danger() + ->send(); + } elseif ($exception instanceof NoViableAllocationException) { + Notification::make() + ->title(trans('user-creatable-servers::strings.notifications.server_creation_failed')) + ->body(trans('user-creatable-servers::strings.notifications.no_viable_allocation_found')) + ->danger() + ->send(); + } else { + Notification::make() + ->title(trans('user-creatable-servers::strings.notifications.server_creation_failed')) + ->body(trans('user-creatable-servers::strings.notifications.unknown_server_creation_error')) + ->danger() + ->send(); + } + } + } +} diff --git a/user-creatable-servers/src/Filament/App/Widgets/UserResourceLimitsOverview.php b/user-creatable-servers/src/Filament/App/Widgets/UserResourceLimitsOverview.php new file mode 100644 index 0000000..9a8ff84 --- /dev/null +++ b/user-creatable-servers/src/Filament/App/Widgets/UserResourceLimitsOverview.php @@ -0,0 +1,35 @@ +user()->id)->first(); + $userServers = auth()->user()->servers; + + $suffix = config('panel.use_binary_prefix') ? ' MiB' : ' MB'; + + $cpu = $userServers->sum('cpu') . '% / ' . ($userResourceLimits->cpu > 0 ? "{$userResourceLimits->cpu}%" : '∞'); + $memory = $userServers->sum('memory') . "{$suffix} / " . ($userResourceLimits->memory > 0 ? "{$userResourceLimits->memory}{$suffix}" : '∞'); + $disk = $userServers->sum('disk') . "{$suffix} / " . ($userResourceLimits->disk > 0 ? "{$userResourceLimits->disk}{$suffix}" : '∞'); + + return [ + Stat::make(trans('user-creatable-servers::strings.cpu'), $cpu), + Stat::make(trans('user-creatable-servers::strings.memory'), $memory), + Stat::make(trans('user-creatable-servers::strings.disk'), $disk), + ]; + } + + public static function canView(): bool + { + return UserResourceLimits::where('user_id', auth()->user()->id)->exists(); + } +} diff --git a/user-creatable-servers/src/Filament/Components/Actions/CreateServerAction.php b/user-creatable-servers/src/Filament/Components/Actions/CreateServerAction.php new file mode 100644 index 0000000..7a2d0e6 --- /dev/null +++ b/user-creatable-servers/src/Filament/Components/Actions/CreateServerAction.php @@ -0,0 +1,37 @@ +label(fn () => trans('user-creatable-servers::strings.create_server')); + + $this->visible(fn () => UserResourceLimits::where('user_id', auth()->user()->id)->exists()); + + $this->disabled(function () { + /** @var ?UserResourceLimits $userResourceLimits */ + $userResourceLimits = UserResourceLimits::where('user_id', auth()->user()->id)->first(); + + if (!$userResourceLimits) { + return true; + } + + return !$userResourceLimits->canCreateServer(1, 1, 1); + }); + + $this->url(fn () => CreateServerPage::getUrl()); + } +} diff --git a/user-creatable-servers/src/Filament/Server/Pages/ServerResourcePage.php b/user-creatable-servers/src/Filament/Server/Pages/ServerResourcePage.php new file mode 100644 index 0000000..f188de2 --- /dev/null +++ b/user-creatable-servers/src/Filament/Server/Pages/ServerResourcePage.php @@ -0,0 +1,188 @@ +owner_id)->exists()) { + return false; + } + + return parent::canAccess(); + } + + public function form(Schema $schema): Schema + { + /** @var Server $server */ + $server = Filament::getTenant(); + + $userResourceLimits = UserResourceLimits::where('user_id', $server->owner_id)->firstOrFail(); + + $maxCpu = $server->cpu + $userResourceLimits->getCpuLeft(); + $maxMemory = $server->memory + $userResourceLimits->getMemoryLeft(); + $maxDisk = $server->disk + $userResourceLimits->getDiskLeft(); + + $suffix = config('panel.use_binary_prefix') ? 'MiB' : 'MB'; + + return parent::form($schema) + ->columns([ + 'default' => 1, + 'lg' => 3, + ]) + ->schema([ + TextInput::make('cpu') + ->label(trans('user-creatable-servers::strings.cpu')) + ->required() + ->live(onBlur: true) + ->hint(fn ($state) => $userResourceLimits->cpu > 0 ? ($maxCpu - $state . '% ' . trans('user-creatable-servers::strings.left')) : trans('user-creatable-servers::strings.unlimited')) + ->hintColor(fn ($state) => $userResourceLimits->cpu > 0 && $maxCpu - $state < 0 ? 'danger' : null) + ->numeric() + ->minValue($userResourceLimits->cpu > 0 ? 1 : 0) + ->maxValue($userResourceLimits->cpu > 0 ? $maxCpu : null) + ->suffix('%'), + TextInput::make('memory') + ->label(trans('user-creatable-servers::strings.memory')) + ->required() + ->live(onBlur: true) + ->hint(fn ($state) => $userResourceLimits->memory > 0 ? ($maxMemory - $state . $suffix . ' ' . trans('user-creatable-servers::strings.left')) : trans('user-creatable-servers::strings.unlimited')) + ->hintColor(fn ($state) => $userResourceLimits->memory > 0 && $maxMemory - $state < 0 ? 'danger' : null) + ->numeric() + ->minValue($userResourceLimits->memory > 0 ? 1 : 0) + ->maxValue($userResourceLimits->memory > 0 ? $maxMemory : null) + ->suffix($suffix), + TextInput::make('disk') + ->label(trans('user-creatable-servers::strings.disk')) + ->required() + ->live(onBlur: true) + ->hint(fn ($state) => $userResourceLimits->disk > 0 ? ($maxDisk - $state . $suffix . ' ' . trans('user-creatable-servers::strings.left')) : trans('user-creatable-servers::strings.unlimited')) + ->hintColor(fn ($state) => $userResourceLimits->disk > 0 && $maxDisk - $state < 0 ? 'danger' : null) + ->numeric() + ->minValue($userResourceLimits->disk > 0 ? 1 : 0) + ->maxValue($userResourceLimits->disk > 0 ? $maxDisk : null) + ->suffix($suffix), + ]); + } + + protected function getHeaderWidgets(): array + { + return [ + UserResourceLimitsOverview::class, + ]; + } + + protected function getHeaderActions(): array + { + /** @var Server $server */ + $server = Filament::getTenant(); + + return [ + Action::make('save') + ->hiddenLabel() + ->action('save') + ->keyBindings(['mod+s']) + ->tooltip(trans('filament-panels::resources/pages/edit-record.form.actions.save.label')) + ->icon('tabler-device-floppy'), + Action::make('delete_server') + ->visible(fn () => config('user-creatable-servers.can_users_delete_servers')) + ->authorize(fn () => $server->owner_id === auth()->user()->id || auth()->user()->can('delete server', $server)) + ->tooltip(trans('user-creatable-servers::strings.modals.delete_server')) + ->color('danger') + ->icon('tabler-trash') + ->requiresConfirmation() + ->modalHeading(trans('user-creatable-servers::strings.modals.delete_server_confirm')) + ->modalDescription(trans('user-creatable-servers::strings.modals.delete_server_warning')) + ->modalSubmitActionLabel(trans('user-creatable-servers::strings.modals.delete_server')) + ->action(function (ServerDeletionService $service) use ($server) { + try { + $service->handle($server); + + Notification::make() + ->title(trans('user-creatable-servers::strings.notifications.server_deleted')) + ->body(trans('user-creatable-servers::strings.notifications.server_deleted_success')) + ->success() + ->send(); + + redirect(Filament::getDefaultPanel()->getUrl()); + } catch (Exception $exception) { + report($exception); + + Notification::make() + ->title(trans('user-creatable-servers::strings.notifications.server_delete_error')) + ->body($exception->getMessage()) + ->danger() + ->send(); + } + }), + ]; + } + + public function save(): void + { + $data = $this->form->getState(); + + /** @var Server $server */ + $server = Filament::getTenant(); + + $server->update([ + 'cpu' => $data['cpu'], + 'memory' => $data['memory'], + 'disk' => $data['disk'], + ]); + + try { + /** @var DaemonServerRepository $repository */ + $repository = app(DaemonServerRepository::class); + + $repository->setServer($server)->sync(); + + Notification::make() + ->title(trans('user-creatable-servers::strings.notifications.server_resources_updated')) + ->body(trans('user-creatable-servers::strings.notifications.might_need_restart')) + ->success() + ->persistent() + ->send(); + } catch (ConnectionException) { + Notification::make() + ->title(trans('user-creatable-servers::strings.notifications.server_resources_updated')) + ->body(trans('user-creatable-servers::strings.notifications.manual_restart_needed')) + ->warning() + ->persistent() + ->send(); + } + + $redirectUrl = self::getUrl(); + $this->redirect($redirectUrl, navigate: FilamentView::hasSpaMode($redirectUrl)); + } +} diff --git a/user-creatable-servers/src/Models/UserResourceLimits.php b/user-creatable-servers/src/Models/UserResourceLimits.php new file mode 100644 index 0000000..3c083c5 --- /dev/null +++ b/user-creatable-servers/src/Models/UserResourceLimits.php @@ -0,0 +1,159 @@ +belongsTo(User::class); + } + + public function getCpuLeft(): ?int + { + if ($this->cpu > 0) { + $sum_cpu = $this->user->servers->sum('cpu'); + + return max(0, $this->cpu - $sum_cpu); + } + + return null; + } + + public function getMemoryLeft(): ?int + { + if ($this->memory > 0) { + $sum_memory = $this->user->servers->sum('memory'); + + return max(0, $this->memory - $sum_memory); + } + + return null; + } + + public function getDiskLeft(): ?int + { + if ($this->disk > 0) { + $sum_disk = $this->user->servers->sum('disk'); + + return max(0, $this->disk - $sum_disk); + } + + return null; + } + + public function canCreateServer(int $cpu, int $memory, int $disk): bool + { + if ($this->server_limit && $this->user->servers->count() >= $this->server_limit) { + return false; + } + + if ($this->cpu > 0) { + if ($cpu <= 0) { + return false; + } + + $sum_cpu = $this->user->servers->sum('cpu'); + if ($sum_cpu + $cpu > $this->cpu) { + return false; + } + } + + if ($this->memory > 0) { + if ($memory <= 0) { + return false; + } + + $sum_memory = $this->user->servers->sum('memory'); + if ($sum_memory + $memory > $this->memory) { + return false; + } + } + + if ($this->disk > 0) { + if ($disk <= 0) { + return false; + } + + $sum_disk = $this->user->servers->sum('disk'); + if ($sum_disk + $disk > $this->disk) { + return false; + } + } + + return true; + } + + /** @param array $variables */ + public function createServer(string $name, int|Egg $egg, int $cpu, int $memory, int $disk, array $variables = []): Server|bool + { + if ($this->canCreateServer($cpu, $memory, $disk)) { + if (!$egg instanceof Egg) { + $egg = Egg::findOrFail($egg); + } + + $environment = []; + foreach ($egg->variables as $variable) { + $environment[$variable->env_variable] = $variables[$variable->env_variable] ?? $variable->default_value; + } + + $data = [ + 'name' => $name, + 'owner_id' => $this->user_id, + 'egg_id' => $egg->id, + 'cpu' => $cpu, + 'memory' => $memory, + 'disk' => $disk, + 'swap' => 0, + 'io' => 500, + 'environment' => $environment, + 'skip_scripts' => false, + 'start_on_completion' => true, + 'oom_killer' => false, + 'database_limit' => config('user-creatable-servers.database_limit'), + 'allocation_limit' => config('user-creatable-servers.allocation_limit'), + 'backup_limit' => config('user-creatable-servers.backup_limit'), + ]; + + $object = new DeploymentObject(); + $object->setDedicated(false); + $object->setTags(array_filter(explode(',', config('user-creatable-servers.deployment_tags')))); + $object->setPorts(array_filter(explode(',', config('user-creatable-servers.deployment_ports')))); + + /** @var ServerCreationService $service */ + $service = app(ServerCreationService::class); + + return $service->handle($data, $object); + } + + return false; + } +} diff --git a/user-creatable-servers/src/Policies/UserResourceLimitsPolicy.php b/user-creatable-servers/src/Policies/UserResourceLimitsPolicy.php new file mode 100644 index 0000000..986ffc6 --- /dev/null +++ b/user-creatable-servers/src/Policies/UserResourceLimitsPolicy.php @@ -0,0 +1,12 @@ + $user->belongsTo(UserResourceLimits::class, 'id', 'user_id')); + } +} diff --git a/user-creatable-servers/src/UserCreatableServersPlugin.php b/user-creatable-servers/src/UserCreatableServersPlugin.php new file mode 100644 index 0000000..2fdc16a --- /dev/null +++ b/user-creatable-servers/src/UserCreatableServersPlugin.php @@ -0,0 +1,111 @@ +getId())->title(); + + $panel->discoverPages(plugin_path($this->getId(), "src/Filament/$id/Pages"), "Boy132\\UserCreatableServers\\Filament\\$id\\Pages"); + $panel->discoverResources(plugin_path($this->getId(), "src/Filament/$id/Resources"), "Boy132\\UserCreatableServers\\Filament\\$id\\Resources"); + $panel->discoverWidgets(plugin_path($this->getId(), "src/Filament/$id/Widgets"), "Boy132\\UserCreatableServers\\Filament\\$id\\Widgets"); + } + + public function boot(Panel $panel): void {} + + public function getSettingsForm(): array + { + return [ + Section::make('Limits') + ->columns(3) + ->schema([ + TextInput::make('database_limit') + ->label('Default database limit') + ->required() + ->numeric() + ->minValue(0) + ->default(fn () => config('user-creatable-servers.database_limit')), + TextInput::make('allocation_limit') + ->label('Default allocation limit') + ->required() + ->numeric() + ->minValue(0) + ->default(fn () => config('user-creatable-servers.allocation_limit')), + TextInput::make('backup_limit') + ->label('Default backup limit') + ->required() + ->numeric() + ->minValue(0) + ->default(fn () => config('user-creatable-servers.backup_limit')), + ]), + Section::make('User Settings') + ->columns() + ->schema([ + Toggle::make('can_users_update_servers') + ->label('Can users update servers?') + ->hintIcon('tabler-question-mark') + ->hintIconTooltip('If checked users can update the resource limits of their servers after creation.') + ->inline(false) + ->default(fn () => config('user-creatable-servers.can_users_update_servers')), + Toggle::make('can_users_delete_servers') + ->label('Can users delete servers?') + ->hintIcon('tabler-question-mark') + ->hintIconTooltip('If checked users can delete their own servers.') + ->inline(false) + ->default(fn () => config('user-creatable-servers.can_users_delete_servers')), + ]), + Section::make('Deployment Settings') + ->columns() + ->schema([ + TagsInput::make('deployment_tags') + ->label('Node tags') + ->hintIcon('tabler-question-mark') + ->hintIconTooltip('Only nodes with these tags will be used for deployment. Leave empty to allow all nodes.') + ->default(fn () => array_filter(explode(',', config('user-creatable-servers.deployment_tags')))), + TagsInput::make('deployment_ports') + ->label('Ports') + ->placeholder('New port or port range') + ->hintIcon('tabler-question-mark') + ->hintIconTooltip('These ports will be used for deployment. You can enter individual ports or port ranges. (e.g. 8000-8100) Leave empty to create servers with any allocations.') + ->default(fn () => array_filter(explode(',', config('user-creatable-servers.deployment_ports')))), + ]), + ]; + } + + public function saveSettings(array $data): void + { + $this->writeToEnvironment([ + 'UCS_DEFAULT_DATABASE_LIMIT' => $data['database_limit'], + 'UCS_DEFAULT_ALLOCATION_LIMIT' => $data['allocation_limit'], + 'UCS_DEFAULT_BACKUP_LIMIT' => $data['backup_limit'], + 'UCS_CAN_USERS_UPDATE_SERVERS' => $data['can_users_update_servers'] ? 'true' : 'false', + 'UCS_CAN_USERS_DELETE_SERVERS' => $data['can_users_delete_servers'] ? 'true' : 'false', + 'UCS_DEPLOYMENT_TAGS' => implode(',', $data['deployment_tags']), + 'UCS_DEPLOYMENT_PORTS' => implode(',', $data['deployment_ports']), + ]); + + Notification::make() + ->title('Settings saved') + ->success() + ->send(); + } +}