diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..49239b7 Binary files /dev/null and b/.DS_Store differ diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index f35e258..0000000 --- a/.dockerignore +++ /dev/null @@ -1,7 +0,0 @@ -**/atri.dad -**/.env -**/airbin -**/tmp -**/*.rdb -fly.toml -tailwind.config.*.js \ No newline at end of file diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 755df8a..0000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -*.css linguist-vendored -*.js linguist-vendored \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index eee8a2d..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Docker Deploy -on: - push: - branches: [main] - pull_request: - branches: [main] -jobs: - build-and-push: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Container Registry - uses: docker/login-action@v2 - with: - registry: ${{ secrets.REPO_HOST }} - username: ${{ github.repository_owner }} - password: ${{ secrets.DEPLOY_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v4 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - tags: | - ${{ secrets.REPO_HOST }}/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }} - ${{ secrets.REPO_HOST }}/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest diff --git a/.gitignore b/.gitignore index 1ceae6f..5b4bdef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,11 @@ -atri.dad -main +# dotenv environment variable files .env -airbin -tmp/ -*.rdb -.DS_Store -tailwind.config.js -lib/stylegen/tw +.env.development.local +.env.test.local +.env.production.local +.env.local + +# Fresh build directory +_fresh/ +# npm dependencies +node_modules/ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b943dbc --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "deno.enable": true +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 896f3d8..0000000 --- a/Dockerfile +++ /dev/null @@ -1,43 +0,0 @@ -FROM --platform=$BUILDPLATFORM golang:1.24.0-alpine AS builder - -WORKDIR /app - -# Download dependencies and install required tools -COPY go.mod go.sum ./ -RUN go mod download && \ - go install github.com/swaggo/swag/cmd/swag@latest - -# Copy source code and Makefile -COPY . . - -# Install required tools and make scripts executable -RUN apk add --no-cache upx make bash - -# Create necessary directories -RUN mkdir -p /app/public/css - -# Generate assets and build with optimizations -SHELL ["/bin/bash", "-c"] - -# Platform-specific builds -ARG TARGETPLATFORM -RUN cd /app && make generate && \ - case "${TARGETPLATFORM}" in \ - "linux/amd64") GOARCH=amd64 ;; \ - "linux/arm64") GOARCH=arm64 ;; \ - *) GOARCH=amd64 ;; \ - esac && \ - CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} go build \ - -ldflags='-s -w -extldflags "-static"' \ - -tags netgo,osusergo \ - -o /go/bin/app - -# Final stage -FROM --platform=$TARGETPLATFORM scratch - -# Copy static files and assets -COPY --from=builder /app/public/css/styles.css /public/css/styles.css -COPY --from=builder /app/docs /docs -COPY --from=builder /go/bin/app /app - -ENTRYPOINT ["/app"] diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 84e0755..0000000 --- a/LICENSE +++ /dev/null @@ -1,232 +0,0 @@ -GNU GENERAL PUBLIC LICENSE -Version 3, 29 June 2007 - -Copyright © 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. - - gpl - Copyright (C) 2025 atridad - - 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: - - gpl Copyright (C) 2025 atridad - 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/Makefile b/Makefile deleted file mode 100644 index 68c3ff6..0000000 --- a/Makefile +++ /dev/null @@ -1,105 +0,0 @@ -# Emoji -CHECK := ✅ -BUILD := 🔨 -CLEAN := 🧹 -RUN := 🚀 -TEST := 🧪 -DOCKER := 🐳 -WARN := ⚠️ -DOCS := 📚 - -# Variables -BINARY_NAME := atri.dad -DOCKER_IMAGE := atri-dot-dad -GO_FILES := $(wildcard *.go) - -# Docker detection -DOCKER_ENV := $(shell if [ -f /.dockerenv ]; then echo true; else echo false; fi) -ifeq ($(DOCKER_ENV),true) - BASE_PATH := /app -else - BASE_PATH := $(CURDIR) -endif - -.PHONY: all build clean run dev docker-dev docker-build docker-run test help reset ensure-swag - -help: - @echo "Available commands:" - @echo "make reset - Clean and reset the project to initial state" - @echo "make build - Generate docs and build Go binary" - @echo "make run - Build and run the binary" - @echo "make dev - Run in development mode" - @echo "make docker-dev - Run development environment in Docker" - @echo "make docker-run - Run production container" - @echo "make test - Run tests" - @echo "make prod - Full production build" - -# Check if swag is installed -ensure-swag: - @command -v swag >/dev/null 2>&1 || { \ - echo "$(WARN) Swagger CLI (swag) is not installed. Installing..."; \ - go install github.com/swaggo/swag/cmd/swag@latest; \ - } - -clean: - @echo "$(CLEAN) Cleaning project..." - @rm -f $(BINARY_NAME) - @rm -rf docs/docs.go docs/swagger.json docs/swagger.yaml - @go clean -cache -testcache -modcache - @echo "$(CHECK) Project clean complete" - -swaggergen: ensure-swag - @echo "$(DOCS) Generating Swagger documentation..." - @swag init - @echo "$(CHECK) Swagger docs generated" - -# Combined generation target -generate: swaggergen - -build: generate - @echo "$(BUILD) Building binary..." - @go build -o $(BINARY_NAME) - @echo "$(CHECK) Build complete: $(BINARY_NAME)" - -test: - @echo "$(TEST) Running tests..." - @go test ./... - @echo "$(CHECK) Tests complete" - -dev: generate - @echo "$(RUN) Starting development server..." - @go run main.go - -run: build - @echo "$(RUN) Running server..." - @./$(BINARY_NAME) - -docker-dev: - @echo "$(DOCKER) Starting development container..." - @docker-compose -f docker-compose.dev.yml up --build - -docker-build: generate - @echo "$(DOCKER) Building production Docker image..." - @docker build -t $(DOCKER_IMAGE) . - @echo "$(CHECK) Docker image build complete" - -docker-run: docker-build - @echo "$(DOCKER) Running production container..." - @docker-compose up - -deps: - @echo "$(BUILD) Installing dependencies..." - @go mod download - @go install github.com/swaggo/swag/cmd/swag@latest - @echo "$(CHECK) Dependencies installed" - -fmt: - @echo "$(BUILD) Formatting code..." - @go fmt ./... - @echo "$(CHECK) Code formatting complete" - -# Full production build -prod: clean generate build - @echo "$(CHECK) Production build complete" - -.DEFAULT_GOAL := help diff --git a/README.md b/README.md index 7802398..ec0e33e 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,16 @@ -# atri.dad -This is my personal website! +# Fresh project -## Stack: -- Backend: Golang + Echo -- Rendering: Golang templates -- Style: TailwindCSS + DaisyUI -- Content format: Markdown +Your new Fresh project is ready to go. You can follow the Fresh "Getting +Started" guide here: https://fresh.deno.dev/docs/getting-started -## Requirements: -- Golang 1.23.1 +### Usage -## Getting Started -1. Clone this repository -2. Copy `.env.example` to `.env` -3. Run `go mod download` -4. Start the server: `go run main.go` +Make sure to install Deno: https://deno.land/manual/getting_started/installation -## API Documentation -1. Install swag by running ```go install github.com/swaggo/swag/cmd/swag@latest``` -2. Visit `/api/swagger/index.html` after starting the server +Then start the project: + +``` +deno task start +``` + +This will watch the project directory and restart as necessary. diff --git a/api/ping.go b/api/ping.go deleted file mode 100644 index bbdea29..0000000 --- a/api/ping.go +++ /dev/null @@ -1,19 +0,0 @@ -package api - -import ( - "net/http" - - "github.com/labstack/echo/v4" -) - -// Ping godoc -// @Summary Ping the server -// @Description Get a pong response -// @Tags ping -// @Accept json -// @Produce json -// @Success 200 {string} string "Pong!" -// @Router /ping [get] -func Ping(c echo.Context) error { - return c.String(http.StatusOK, "Pong!") -} diff --git a/api/post.copy.go b/api/post.copy.go deleted file mode 100644 index a41ca39..0000000 --- a/api/post.copy.go +++ /dev/null @@ -1,19 +0,0 @@ -package api - -import ( - "net/http" - - "github.com/labstack/echo/v4" -) - -// PostCopy godoc -// @Summary Get copy icon SVG -// @Description Returns an SVG of a copy icon -// @Tags post -// @Accept json -// @Produce html -// @Success 200 {string} string "SVG content" -// @Router /post/copy [get] -func PostCopy(c echo.Context) error { - return c.String(http.StatusOK, ``) -} diff --git a/api/rss.go b/api/rss.go deleted file mode 100644 index 22f5f80..0000000 --- a/api/rss.go +++ /dev/null @@ -1,63 +0,0 @@ -package api - -// RSSFeedHandler godoc -// @Summary Get RSS feed -// @Description Returns an RSS feed of blog posts -// @Tags rss -// @Accept json -// @Produce xml -// @Success 200 {string} string "RSS feed content" -// @Failure 500 {string} string "Internal Server Error" -// @Router /rss [get] -import ( - "io/fs" - "net/http" - "strings" - "time" - - contentfs "atri.dad/content" - "atri.dad/lib" - "github.com/gorilla/feeds" - "github.com/labstack/echo/v4" -) - -func RSSFeedHandler(c echo.Context) error { - files, err := fs.ReadDir(contentfs.FS, ".") - - protocol := "http" - if c.Request().TLS != nil { - protocol = "https" - } - - feed := &feeds.Feed{ - Title: "Atridad Lahiji's Blog", - Link: &feeds.Link{Href: protocol + "://" + c.Request().Host + "/api/rss"}, - } - - if err != nil { - http.Error(c.Response().Writer, "There was an issue finding posts!", http.StatusInternalServerError) - return nil - } - - for _, file := range files { - if !file.IsDir() && strings.HasSuffix(file.Name(), ".md") { - - frontMatter, err := lib.ExtractFrontMatter(file, contentfs.FS) - if err != nil { - http.Error(c.Response().Writer, "There was an issue rendering the posts!", http.StatusInternalServerError) - return nil - } - - date, _ := time.Parse("January 2 2006", frontMatter.Date) - - feed.Add(&feeds.Item{ - Title: frontMatter.Name, - Link: &feeds.Link{Href: protocol + "://" + c.Request().Host + "/post/" + strings.TrimSuffix(file.Name(), ".md")}, - Created: date, - }) - } - } - - rss, _ := feed.ToRss() - return c.Blob(http.StatusOK, "application/rss+xml", []byte(rss)) -} diff --git a/api/sse.go b/api/sse.go deleted file mode 100644 index c9b0048..0000000 --- a/api/sse.go +++ /dev/null @@ -1,83 +0,0 @@ -package api - -import ( - "fmt" - "net/http" - "time" - - "atri.dad/lib" - "github.com/labstack/echo/v4" -) - -// SSE godoc -// @Summary Server-Sent Events endpoint -// @Description Establishes a Server-Sent Events connection -// @Tags sse -// @Accept json -// @Produce text/event-stream -// @Param channel query string false "Channel name" -// @Success 200 {string} string "Event stream" -// @Router /sse [get] -func SSE(c echo.Context) error { - channel := c.QueryParam("channel") - if channel == "" { - channel = "default" - } - - // Use the request context, which is cancelled when the client disconnects - ctx := c.Request().Context() - - // Standard SSE headers - c.Response().Header().Set("Content-Type", "text/event-stream") - c.Response().Header().Set("Cache-Control", "no-cache") - c.Response().Header().Set("Connection", "keep-alive") - c.Response().Header().Set("X-Accel-Buffering", "no") - - // CORS headers - origin := c.Request().Header.Get("Origin") - if origin == "https://atri.dad" || origin == "http://localhost:3000" { - c.Response().Header().Set("Access-Control-Allow-Origin", origin) - } else { - c.Response().Header().Set("Access-Control-Allow-Origin", "*") - } - - // Prepare the response - c.Response().WriteHeader(http.StatusOK) - c.Response().Flush() - - // Client channel for SSE messages - clientChan := make(chan string) - lib.SSEServer.AddClient(channel, clientChan) - defer lib.SSEServer.RemoveClient(channel, clientChan) - - // Write initial message - if _, err := c.Response().Write([]byte("data: Connected to SSE server\n\n")); err != nil { - return err - } - c.Response().Flush() - - // Keep-alive ticker - ticker := time.NewTicker(15 * time.Second) - defer ticker.Stop() - - // Event loop - for { - select { - case <-ctx.Done(): - return nil - case <-ticker.C: - // Send keep-alive comment - if _, err := c.Response().Write([]byte(": ping\n\n")); err != nil { - return err - } - c.Response().Flush() - case msg := <-clientChan: - // Format as standard SSE message - data := fmt.Sprintf("data: %s\n\n", msg) - if _, err := c.Response().Write([]byte(data)); err != nil { - return err - } - c.Response().Flush() - } - } -} diff --git a/api/tools.resize.go b/api/tools.resize.go deleted file mode 100644 index f193e9f..0000000 --- a/api/tools.resize.go +++ /dev/null @@ -1,58 +0,0 @@ -package api - -import ( - "fmt" - "net/http" - "strconv" - - "atri.dad/lib" - "github.com/labstack/echo/v4" -) - -// ResizeHandler godoc -// @Summary Resize an image -// @Description Resizes an uploaded image to specified dimensions -// @Tags tools -// @Accept mpfd -// @Produce png -// @Param image formData file true "Image file to resize" -// @Param width formData int true "Target width" -// @Param height formData int true "Target height" -// @Success 200 {file} binary "Resized image" -// @Failure 400 {string} string "Bad request" -// @Failure 500 {string} string "Internal server error" -// @Router /tools/resize [post] -func ResizeHandler(c echo.Context) error { - - // Extract file from request - file, _, err := c.Request().FormFile("image") - if err != nil { - return c.String(http.StatusBadRequest, "Error getting image file") - } - defer file.Close() - - // Get dimensions from form data parameters - widthStr := c.FormValue("width") - heightStr := c.FormValue("height") - - // Validate and convert dimensions to integers - width, err := strconv.Atoi(widthStr) - if err != nil { - return c.String(http.StatusBadRequest, "Invalid width parameter") - } - - height, err := strconv.Atoi(heightStr) - if err != nil { - return c.String(http.StatusBadRequest, "Invalid height parameter") - } - - fileBlob, err := lib.ResizeImg(file, width, height) - - if err != nil { - return c.String(http.StatusInternalServerError, err.Error()) - } - - c.Response().Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", "resized.png")) - - return c.Blob(http.StatusOK, "image/png", fileBlob) -} diff --git a/api/tools.sendsse.go b/api/tools.sendsse.go deleted file mode 100644 index 5d32dd5..0000000 --- a/api/tools.sendsse.go +++ /dev/null @@ -1,48 +0,0 @@ -package api - -import ( - "net/http" - - "atri.dad/lib" - "github.com/labstack/echo/v4" -) - -// SSEDemoSend godoc -// @Summary Send SSE message -// @Description Sends a message to a specified SSE channel -// @Tags sse,tools -// @Accept json -// @Produce json -// @Param channel query string false "Channel name" -// @Param message query string false "Message to send" -// @Success 200 {object} map[string]string -// @Failure 400 {object} map[string]string -// @Router /tools/sendsse [post] -func SSEDemoSend(c echo.Context) error { - channel := c.QueryParam("channel") - if channel == "" { - channel = "default" - } - - // Get message from query parameters, form value, or request body - message := c.QueryParam("message") - if message == "" { - message = c.FormValue("message") - if message == "" { - var body map[string]string - if err := c.Bind(&body); err != nil { - return err - } - message = body["message"] - } - } - - if message == "" { - return c.JSON(http.StatusBadRequest, map[string]string{"error": "message parameter is required"}) - } - - // Send message - lib.SSEServer.SendSSE(channel, message) - - return c.JSON(http.StatusOK, map[string]string{"status": "message sent"}) -} diff --git a/components/SocialLinks.tsx b/components/SocialLinks.tsx new file mode 100644 index 0000000..b076f62 --- /dev/null +++ b/components/SocialLinks.tsx @@ -0,0 +1,13 @@ +import { LuMail } from "@preact-icons/lu"; +import { SiBluesky, SiForgejo, SiRss } from "@preact-icons/si"; + +export default function SocialLinks() { + return ( +
+ + + + +
+ ); +} diff --git a/components/TechLinks.tsx b/components/TechLinks.tsx new file mode 100644 index 0000000..514df1d --- /dev/null +++ b/components/TechLinks.tsx @@ -0,0 +1,13 @@ +import { LuMail } from "@preact-icons/lu"; +import { SiBluesky, SiForgejo, SiRss } from "@preact-icons/si"; + +export default function TechLinks() { + return ( +
+ + + + +
+ ); +} diff --git a/content/contentfs.go b/content/contentfs.go deleted file mode 100644 index a306e28..0000000 --- a/content/contentfs.go +++ /dev/null @@ -1,6 +0,0 @@ -package contentfs - -import "embed" - -//go:embed * -var FS embed.FS diff --git a/content/favourite_tools_list.md b/content/favourite_tools_list.md deleted file mode 100644 index 3bd9a28..0000000 --- a/content/favourite_tools_list.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -name: "Current List of Favourite Tools" -description: "A periodically updated list of tools I use day-to-day." -date: "January 28 2025" -tags: ["tools","list"] ---- -I change what I use _constantly_ in order to find something that feels just right. I wanted to share them here and update them here so when someone asks, I can just point them to this article. - -1. Sublime Text - Currently my favourite text editor. Fast, simple, and extensible. Just a joy to use! -2. Sublime Merge - Honestly one of the fastest and best looking git GUIs around! Awesome for visualizing changes when you have larger code changes. -3. Ghostty - A Zig based terminal emulator by one of the founders of Hashicorp. Runs great on MacOS and Linux. No windows for those who are into that. -4. OrbStack - A faster alternative to Docker Desktop that also runs VMs! -5. Bitwarden - An open-source password manager. Easy to self host with Vaultwarden and with the recent updates, it has SSH Agent support! -6. iA Writer - A minimalist Markdown editor. For MacOS and Windows only, but really the MacOS version is the most mature. Awesome for focus. -7. Dataflare - A simple but powerful cross-platform database client. Supports most common databases, including LibSQL which is rare! -8. Bruno - A simple and powerful API client, similar to Postman. An critical tool to debug API endpoints. - -I hope you found this helpful! This will be periodically updated to avoid outdated recommendations. \ No newline at end of file diff --git a/content/welcome.md b/content/welcome.md deleted file mode 100644 index f8b46e9..0000000 --- a/content/welcome.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -name: "Welcome!" -description: "Welcome to my website!" -date: "October 20 2024" -tags: ["welcome"] ---- - -Welcome to my site! This is a place for me to share my thoughts and updates on my projects. I hope you find something interesting here. - -Feel free to reach out if you have any questions or comments. I'd love to hear from you! I can be reached by email at [me@atri.dad](mailto:me@atri.dad). diff --git a/deno.json b/deno.json new file mode 100644 index 0000000..f866593 --- /dev/null +++ b/deno.json @@ -0,0 +1,42 @@ +{ + "nodeModulesDir": "auto", + "lock": false, + "tasks": { + "check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx", + "cli": "echo \"import '\\$fresh/src/dev/cli.ts'\" | deno run --unstable -A -", + "manifest": "deno task cli manifest $(pwd)", + "start": "deno run -A --watch=static/,routes/ dev.ts", + "build": "deno run -A dev.ts build", + "preview": "deno run -A main.ts", + "update": "deno run -A -r https://fresh.deno.dev/update ." + }, + "lint": { + "rules": { + "tags": [ + "fresh", + "recommended" + ] + } + }, + "exclude": [ + "**/_fresh/*" + ], + "imports": { + "$fresh/": "https://deno.land/x/fresh@1.7.3/", + "@pakornv/fresh-plugin-tailwindcss": "jsr:@pakornv/fresh-plugin-tailwindcss@^1.0.2", + "@preact-icons/lu": "jsr:@preact-icons/lu@^1.0.13", + "@preact-icons/si": "jsr:@preact-icons/si@^1.0.13", + "daisyui": "npm:daisyui@^5.0.27", + "preact": "npm:preact@10.22.1", + "preact/jsx-runtime": "npm:preact@10.22.1/jsx-runtime", + "preact/hooks": "npm:preact@10.22.1/hooks", + "@preact/signals": "https://esm.sh/*@preact/signals@1.2.2", + "@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.1", + "$std/": "https://deno.land/std@0.216.0/", + "tailwindcss": "npm:tailwindcss@^4.1.4" + }, + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "preact" + } +} diff --git a/dev.ts b/dev.ts new file mode 100755 index 0000000..ae73946 --- /dev/null +++ b/dev.ts @@ -0,0 +1,8 @@ +#!/usr/bin/env -S deno run -A --watch=static/,routes/ + +import dev from "$fresh/dev.ts"; +import config from "./fresh.config.ts"; + +import "$std/dotenv/load.ts"; + +await dev(import.meta.url, "./main.ts", config); diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml deleted file mode 100644 index 2a07efa..0000000 --- a/docker-compose.dev.yml +++ /dev/null @@ -1,10 +0,0 @@ -services: - app: - build: - context: . - dockerfile: Dockerfile - image: atridad:latest - command: ["/app"] - pull_policy: build - ports: - - "3000:3000" diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index b2f2553..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,6 +0,0 @@ -services: - app: - image: ${IMAGE} - command: ["/app"] - ports: - - "3000:3000" diff --git a/docs/docs.go b/docs/docs.go deleted file mode 100644 index 42d6560..0000000 --- a/docs/docs.go +++ /dev/null @@ -1,222 +0,0 @@ -// Package docs Code generated by swaggo/swag. DO NOT EDIT -package docs - -import "github.com/swaggo/swag" - -const docTemplate = `{ - "schemes": {{ marshal .Schemes }}, - "swagger": "2.0", - "info": { - "description": "{{escape .Description}}", - "title": "{{.Title}}", - "contact": {}, - "version": "{{.Version}}" - }, - "host": "{{.Host}}", - "basePath": "{{.BasePath}}", - "paths": { - "/ping": { - "get": { - "description": "Get a pong response", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "ping" - ], - "summary": "Ping the server", - "responses": { - "200": { - "description": "Pong!", - "schema": { - "type": "string" - } - } - } - } - }, - "/post/copy": { - "get": { - "description": "Returns an SVG of a copy icon", - "consumes": [ - "application/json" - ], - "produces": [ - "text/html" - ], - "tags": [ - "post" - ], - "summary": "Get copy icon SVG", - "responses": { - "200": { - "description": "SVG content", - "schema": { - "type": "string" - } - } - } - } - }, - "/sse": { - "get": { - "description": "Establishes a Server-Sent Events connection", - "consumes": [ - "application/json" - ], - "produces": [ - "text/event-stream" - ], - "tags": [ - "sse" - ], - "summary": "Server-Sent Events endpoint", - "parameters": [ - { - "type": "string", - "description": "Channel name", - "name": "channel", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Event stream", - "schema": { - "type": "string" - } - } - } - } - }, - "/tools/resize": { - "post": { - "description": "Resizes an uploaded image to specified dimensions", - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "image/png" - ], - "tags": [ - "tools" - ], - "summary": "Resize an image", - "parameters": [ - { - "type": "file", - "description": "Image file to resize", - "name": "image", - "in": "formData", - "required": true - }, - { - "type": "integer", - "description": "Target width", - "name": "width", - "in": "formData", - "required": true - }, - { - "type": "integer", - "description": "Target height", - "name": "height", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "Resized image", - "schema": { - "type": "file" - } - }, - "400": { - "description": "Bad request", - "schema": { - "type": "string" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "type": "string" - } - } - } - } - }, - "/tools/sendsse": { - "post": { - "description": "Sends a message to a specified SSE channel", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "sse", - "tools" - ], - "summary": "Send SSE message", - "parameters": [ - { - "type": "string", - "description": "Channel name", - "name": "channel", - "in": "query" - }, - { - "type": "string", - "description": "Message to send", - "name": "message", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "400": { - "description": "Bad Request", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - } - } - } - } - } -}` - -// SwaggerInfo holds exported Swagger Info so clients can modify it -var SwaggerInfo = &swag.Spec{ - Version: "1.0", - Host: "localhost:3000", - BasePath: "/api", - Schemes: []string{}, - Title: "Atri.dad API", - Description: "This is the API for atri.dad", - InfoInstanceName: "swagger", - SwaggerTemplate: docTemplate, - LeftDelim: "{{", - RightDelim: "}}", -} - -func init() { - swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) -} diff --git a/docs/swagger.json b/docs/swagger.json deleted file mode 100644 index 54c014b..0000000 --- a/docs/swagger.json +++ /dev/null @@ -1,198 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "description": "This is the API for atri.dad", - "title": "Atri.dad API", - "contact": {}, - "version": "1.0" - }, - "host": "localhost:3000", - "basePath": "/api", - "paths": { - "/ping": { - "get": { - "description": "Get a pong response", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "ping" - ], - "summary": "Ping the server", - "responses": { - "200": { - "description": "Pong!", - "schema": { - "type": "string" - } - } - } - } - }, - "/post/copy": { - "get": { - "description": "Returns an SVG of a copy icon", - "consumes": [ - "application/json" - ], - "produces": [ - "text/html" - ], - "tags": [ - "post" - ], - "summary": "Get copy icon SVG", - "responses": { - "200": { - "description": "SVG content", - "schema": { - "type": "string" - } - } - } - } - }, - "/sse": { - "get": { - "description": "Establishes a Server-Sent Events connection", - "consumes": [ - "application/json" - ], - "produces": [ - "text/event-stream" - ], - "tags": [ - "sse" - ], - "summary": "Server-Sent Events endpoint", - "parameters": [ - { - "type": "string", - "description": "Channel name", - "name": "channel", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Event stream", - "schema": { - "type": "string" - } - } - } - } - }, - "/tools/resize": { - "post": { - "description": "Resizes an uploaded image to specified dimensions", - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "image/png" - ], - "tags": [ - "tools" - ], - "summary": "Resize an image", - "parameters": [ - { - "type": "file", - "description": "Image file to resize", - "name": "image", - "in": "formData", - "required": true - }, - { - "type": "integer", - "description": "Target width", - "name": "width", - "in": "formData", - "required": true - }, - { - "type": "integer", - "description": "Target height", - "name": "height", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "Resized image", - "schema": { - "type": "file" - } - }, - "400": { - "description": "Bad request", - "schema": { - "type": "string" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "type": "string" - } - } - } - } - }, - "/tools/sendsse": { - "post": { - "description": "Sends a message to a specified SSE channel", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "sse", - "tools" - ], - "summary": "Send SSE message", - "parameters": [ - { - "type": "string", - "description": "Channel name", - "name": "channel", - "in": "query" - }, - { - "type": "string", - "description": "Message to send", - "name": "message", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "400": { - "description": "Bad Request", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - } - } - } - } - } -} \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml deleted file mode 100644 index 12d3e8f..0000000 --- a/docs/swagger.yaml +++ /dev/null @@ -1,131 +0,0 @@ -basePath: /api -host: localhost:3000 -info: - contact: {} - description: This is the API for atri.dad - title: Atri.dad API - version: "1.0" -paths: - /ping: - get: - consumes: - - application/json - description: Get a pong response - produces: - - application/json - responses: - "200": - description: Pong! - schema: - type: string - summary: Ping the server - tags: - - ping - /post/copy: - get: - consumes: - - application/json - description: Returns an SVG of a copy icon - produces: - - text/html - responses: - "200": - description: SVG content - schema: - type: string - summary: Get copy icon SVG - tags: - - post - /sse: - get: - consumes: - - application/json - description: Establishes a Server-Sent Events connection - parameters: - - description: Channel name - in: query - name: channel - type: string - produces: - - text/event-stream - responses: - "200": - description: Event stream - schema: - type: string - summary: Server-Sent Events endpoint - tags: - - sse - /tools/resize: - post: - consumes: - - multipart/form-data - description: Resizes an uploaded image to specified dimensions - parameters: - - description: Image file to resize - in: formData - name: image - required: true - type: file - - description: Target width - in: formData - name: width - required: true - type: integer - - description: Target height - in: formData - name: height - required: true - type: integer - produces: - - image/png - responses: - "200": - description: Resized image - schema: - type: file - "400": - description: Bad request - schema: - type: string - "500": - description: Internal server error - schema: - type: string - summary: Resize an image - tags: - - tools - /tools/sendsse: - post: - consumes: - - application/json - description: Sends a message to a specified SSE channel - parameters: - - description: Channel name - in: query - name: channel - type: string - - description: Message to send - in: query - name: message - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - additionalProperties: - type: string - type: object - "400": - description: Bad Request - schema: - additionalProperties: - type: string - type: object - summary: Send SSE message - tags: - - sse - - tools -swagger: "2.0" diff --git a/fresh.config.ts b/fresh.config.ts new file mode 100644 index 0000000..dcd30a9 --- /dev/null +++ b/fresh.config.ts @@ -0,0 +1,6 @@ +import { defineConfig } from "$fresh/server.ts"; +import tailwind from "@pakornv/fresh-plugin-tailwindcss"; + +export default defineConfig({ + plugins: [tailwind()], +}); diff --git a/fresh.gen.ts b/fresh.gen.ts new file mode 100644 index 0000000..1fa99b1 --- /dev/null +++ b/fresh.gen.ts @@ -0,0 +1,29 @@ +// DO NOT EDIT. This file is generated by Fresh. +// This file SHOULD be checked into source version control. +// This file is automatically updated during development when running `dev.ts`. + +import * as $_404 from "./routes/_404.tsx"; +import * as $_app from "./routes/_app.tsx"; +import * as $_layout from "./routes/_layout.tsx"; +import * as $api_joke from "./routes/api/joke.ts"; +import * as $index from "./routes/index.tsx"; +import * as $posts from "./routes/posts.tsx"; +import * as $projects from "./routes/projects.tsx"; + +import type { Manifest } from "$fresh/server.ts"; + +const manifest = { + routes: { + "./routes/_404.tsx": $_404, + "./routes/_app.tsx": $_app, + "./routes/_layout.tsx": $_layout, + "./routes/api/joke.ts": $api_joke, + "./routes/index.tsx": $index, + "./routes/posts.tsx": $posts, + "./routes/projects.tsx": $projects, + }, + islands: {}, + baseUrl: import.meta.url, +} satisfies Manifest; + +export default manifest; diff --git a/go.mod b/go.mod deleted file mode 100644 index 9daa2f3..0000000 --- a/go.mod +++ /dev/null @@ -1,47 +0,0 @@ -module atri.dad - -go 1.24 - -require ( - github.com/alecthomas/chroma/v2 v2.15.0 - github.com/swaggo/echo-swagger v1.4.1 - github.com/swaggo/swag v1.16.4 - golang.org/x/image v0.25.0 -) - -require ( - github.com/KyleBanks/depth v1.2.1 // indirect - github.com/dlclark/regexp2 v1.11.5 // indirect - github.com/ghodss/yaml v1.0.0 // indirect - github.com/go-openapi/jsonpointer v0.21.1 // indirect - github.com/go-openapi/jsonreference v0.21.0 // indirect - github.com/go-openapi/spec v0.21.0 // indirect - github.com/go-openapi/swag v0.23.1 // indirect - github.com/josharian/intern v1.0.0 // indirect - github.com/labstack/gommon v0.4.2 // indirect - github.com/mailru/easyjson v0.9.0 // indirect - github.com/rogpeppe/go-internal v1.12.0 // indirect - github.com/swaggo/files/v2 v2.0.2 // indirect - github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasttemplate v1.2.2 // indirect - github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect - golang.org/x/net v0.37.0 // indirect - golang.org/x/text v0.23.0 // indirect - golang.org/x/time v0.11.0 // indirect - golang.org/x/tools v0.31.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) - -require ( - github.com/gookit/color v1.5.4 - github.com/gorilla/feeds v1.2.0 - github.com/joho/godotenv v1.5.1 - github.com/labstack/echo/v4 v4.13.3 - github.com/mattn/go-colorable v0.1.14 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/yuin/goldmark v1.7.8 - github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc - golang.org/x/crypto v0.36.0 // indirect - golang.org/x/sys v0.31.0 // indirect - gopkg.in/yaml.v2 v2.4.0 -) diff --git a/go.sum b/go.sum deleted file mode 100644 index 26f0998..0000000 --- a/go.sum +++ /dev/null @@ -1,105 +0,0 @@ -github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= -github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= -github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= -github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/chroma/v2 v2.2.0/go.mod h1:vf4zrexSH54oEjJ7EdB65tGNHmH3pGZmVkgTP5RHvAs= -github.com/alecthomas/chroma/v2 v2.15.0 h1:LxXTQHFoYrstG2nnV9y2X5O94sOBzf0CIUpSTbpxvMc= -github.com/alecthomas/chroma/v2 v2.15.0/go.mod h1:gUhVLrPDXPtp/f+L1jo9xepo9gL4eLwRuGAunSZMkio= -github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8= -github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= -github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= -github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ= -github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-openapi/jsonpointer v0.21.1 h1:whnzv/pNXtK2FbX/W9yJfRmE2gsmkfahjMKB0fZvcic= -github.com/go-openapi/jsonpointer v0.21.1/go.mod h1:50I1STOfbY1ycR8jGz8DaMeLCdXiI6aDteEdRNNzpdk= -github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ= -github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4= -github.com/go-openapi/spec v0.21.0 h1:LTVzPc3p/RzRnkQqLRndbAzjY0d0BCL72A6j3CdL9ZY= -github.com/go-openapi/spec v0.21.0/go.mod h1:78u6VdPw81XU44qEWGhtr982gJ5BWg2c0I5XwVMotYk= -github.com/go-openapi/swag v0.23.1 h1:lpsStH0n2ittzTnbaSloVZLuB5+fvSY/+hnagBjSNZU= -github.com/go-openapi/swag v0.23.1/go.mod h1:STZs8TbRvEQQKUA+JZNAm3EWlgaOBGpyFDqQnDHMef0= -github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0= -github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w= -github.com/gorilla/feeds v1.2.0 h1:O6pBiXJ5JHhPvqy53NsjKOThq+dNFm8+DFrxBEdzSCc= -github.com/gorilla/feeds v1.2.0/go.mod h1:WMib8uJP3BbY+X8Szd1rA5Pzhdfh+HCCAYT2z7Fza6Y= -github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= -github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= -github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= -github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= -github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= -github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/labstack/echo/v4 v4.13.3 h1:pwhpCPrTl5qry5HRdM5FwdXnhXSLSY+WE+YQSeCaafY= -github.com/labstack/echo/v4 v4.13.3/go.mod h1:o90YNEeQWjDozo584l7AwhJMHN0bOC4tAfg+Xox9q5g= -github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= -github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU= -github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4= -github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= -github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= -github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/swaggo/echo-swagger v1.4.1 h1:Yf0uPaJWp1uRtDloZALyLnvdBeoEL5Kc7DtnjzO/TUk= -github.com/swaggo/echo-swagger v1.4.1/go.mod h1:C8bSi+9yH2FLZsnhqMZLIZddpUxZdBYuNHbtaS1Hljc= -github.com/swaggo/files/v2 v2.0.2 h1:Bq4tgS/yxLB/3nwOMcul5oLEUKa877Ykgz3CJMVbQKU= -github.com/swaggo/files/v2 v2.0.2/go.mod h1:TVqetIzZsO9OhHX1Am9sRf9LdrFZqoK49N37KON/jr0= -github.com/swaggo/swag v1.16.4 h1:clWJtd9LStiG3VeijiCfOVODP6VpHtKdQy9ELFG3s1A= -github.com/swaggo/swag v1.16.4/go.mod h1:VBsHJRsDvfYvqoiMKnsdwhNV9LEMHgEDZcyVYX0sxPg= -github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= -github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= -github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= -github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= -github.com/yuin/goldmark v1.4.15/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic= -github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= -github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc h1:+IAOyRda+RLrxa1WC7umKOZRsGq4QrFFMYApOeHzQwQ= -github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc/go.mod h1:ovIvrum6DQJA4QsJSovrkC4saKHQVs7TvcaeO8AIl5I= -golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= -golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E= -golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= -golang.org/x/image v0.25.0 h1:Y6uW6rH1y5y/LK1J8BPWZtr6yZ7hrsy6hFrXjgsc2fQ= -golang.org/x/image v0.25.0/go.mod h1:tCAmOEGthTtkalusGp1g3xa2gke8J6c2N565dTyl9Rs= -golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= -golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= -golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= -golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= -golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= -golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= -golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= -golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0= -golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= -golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU= -golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/lib/email.go b/lib/email.go deleted file mode 100644 index 306375c..0000000 --- a/lib/email.go +++ /dev/null @@ -1,101 +0,0 @@ -package lib - -import ( - "crypto/tls" - "net/smtp" - "os" -) - -func SendEmail(to_email string, from_email string, from_name string, html string, subject string) { - LogInfo.Println("Starting email sending process") - - // Set up authentication information. - auth := smtp.PlainAuth( - "", - os.Getenv("SMTP_USERNAME"), - os.Getenv("SMTP_PASSWORD"), - os.Getenv("SMTP_HOST"), - ) - - LogSuccess.Println("Authentication set up") - - // Connect to the server, authenticate, set the sender and recipient, - // and send the email all in one step. - msg := []byte("From: " + from_name + " <" + from_email + ">\r\n" + - "To: " + to_email + "\r\n" + - "Subject: " + subject + "\r\n" + - "Content-Type: text/html; charset=UTF-8" + "\r\n" + - "\r\n" + - html + "\r\n") - - tlsconfig := &tls.Config{ - InsecureSkipVerify: false, - ServerName: os.Getenv("SMTP_HOST"), - } - - LogSuccess.Println("TLS configuration set up") - - c, err := smtp.Dial(os.Getenv("SMTP_HOST") + ":587") - if err != nil { - LogError.Println("Error dialing SMTP server:", err) - return - } - - LogSuccess.Println("Connected to SMTP server") - - if err = c.StartTLS(tlsconfig); err != nil { - LogError.Println("Error starting TLS:", err) - return - } - - LogInfo.Println("TLS started") - - if err = c.Auth(auth); err != nil { - LogError.Println("Error authenticating with SMTP server:", err) - return - } - - LogSuccess.Println("Authenticated with SMTP server") - - if err = c.Mail(from_email); err != nil { - LogError.Println("Error setting sender address:", err) - return - } - - LogSuccess.Println("Sender address set") - - if err = c.Rcpt(to_email); err != nil { - LogError.Println("Error setting recipient address:", err) - return - } - - LogSuccess.Println("Recipient address set") - - w, err := c.Data() - if err != nil { - LogError.Println("Error getting write closer:", err) - return - } - - LogSuccess.Println("Got write closer") - - _, err = w.Write(msg) - if err != nil { - LogError.Println("Error writing message:", err) - return - } - - LogSuccess.Println("Message written") - - err = w.Close() - if err != nil { - LogError.Println("Error closing write closer:", err) - return - } - - LogSuccess.Println("Write closer closed") - - c.Quit() - - LogSuccess.Println("Email sent successfully") -} diff --git a/lib/files.go b/lib/files.go deleted file mode 100644 index 47d3a41..0000000 --- a/lib/files.go +++ /dev/null @@ -1,33 +0,0 @@ -package lib - -import ( - "os" - "path/filepath" -) - -// ListFiles returns a slice of file paths in the given directory -func ListFiles(dir string) ([]string, error) { - var filePaths []string - - entries, err := os.ReadDir(dir) - if err != nil { - return nil, err - } - - for _, entry := range entries { - if entry.IsDir() { - // Recursively list files in subdirectories - subDir := filepath.Join(dir, entry.Name()) - subFiles, err := ListFiles(subDir) - if err != nil { - return nil, err - } - filePaths = append(filePaths, subFiles...) - } else { - // Add file path to the slice - filePath := filepath.Join(dir, entry.Name()) - filePaths = append(filePaths, filePath) - } - } - return filePaths, nil -} diff --git a/lib/img.go b/lib/img.go deleted file mode 100644 index cdd8806..0000000 --- a/lib/img.go +++ /dev/null @@ -1,33 +0,0 @@ -package lib - -import ( - "bytes" - "fmt" - "image" - "image/png" - "mime/multipart" - - "golang.org/x/image/draw" -) - -func ResizeImg(file multipart.File, width int, height int) ([]byte, error) { - // Read and decode image - img, _, err := image.Decode(file) - if err != nil { - return nil, fmt.Errorf("decode error: %w", err) - } - - // Create new RGBA image - dst := image.NewRGBA(image.Rect(0, 0, width, height)) - - // Resize using high-quality interpolation - draw.CatmullRom.Scale(dst, dst.Bounds(), img, img.Bounds(), draw.Over, nil) - - // Encode to PNG - buf := new(bytes.Buffer) - if err := png.Encode(buf, dst); err != nil { - return nil, fmt.Errorf("encode error: %w", err) - } - - return buf.Bytes(), nil -} diff --git a/lib/links.go b/lib/links.go deleted file mode 100644 index f1f6efa..0000000 --- a/lib/links.go +++ /dev/null @@ -1,26 +0,0 @@ -package lib - -import ( - "html/template" -) - -type IconLink struct { - Name string - Href string - Icon template.HTML -} - -type CardLink struct { - Name string - Href string - Description string - Date string - Tags []string - Internal bool -} - -type ButtonLink struct { - Name string - Href string - Internal bool -} diff --git a/lib/logging.go b/lib/logging.go deleted file mode 100644 index 8a1c6c6..0000000 --- a/lib/logging.go +++ /dev/null @@ -1,41 +0,0 @@ -package lib - -import ( - "github.com/gookit/color" -) - -// Error logging -var LogError = color.Style{ - color.FgRed, - color.OpBold, -} - -// Info logging -var LogInfo = color.Style{ - color.FgCyan, - color.OpBold, -} - -// Success logging -var LogSuccess = color.Style{ - color.FgGreen, - color.OpBold, -} - -// Warning logging -var LogWarning = color.Style{ - color.FgYellow, - color.OpBold, -} - -// Debug logging -var LogDebug = color.Style{ - color.FgMagenta, - color.OpBold, -} - -// Custom logging -var LogCustom = color.Style{ - color.FgWhite, - color.OpBold, -} diff --git a/lib/markdown.go b/lib/markdown.go deleted file mode 100644 index a700125..0000000 --- a/lib/markdown.go +++ /dev/null @@ -1,66 +0,0 @@ -package lib - -import ( - "bufio" - "bytes" - "errors" - "fmt" - "io/fs" - "strings" - - "github.com/yuin/goldmark" - "gopkg.in/yaml.v2" -) - -type FrontMatter struct { - Name string - Description string - Date string - Tags []string -} - -func ExtractFrontMatter(file fs.DirEntry, contentFS fs.FS) (CardLink, error) { - f, err := contentFS.Open(file.Name()) - if err != nil { - return CardLink{}, fmt.Errorf("failed to open file: %w", err) - } - defer f.Close() - - scanner := bufio.NewScanner(f) - var lines []string - for scanner.Scan() { - lines = append(lines, scanner.Text()) - } - if err := scanner.Err(); err != nil { - return CardLink{}, fmt.Errorf("failed to read file: %w", err) - } - - content := strings.Join(lines, "\n") - splitContent := strings.SplitN(content, "---", 3) - if len(splitContent) < 3 { - return CardLink{}, fmt.Errorf("invalid file format: %s", file.Name()) - } - - frontMatter := CardLink{} - if err := yaml.Unmarshal([]byte(splitContent[1]), &frontMatter); err != nil { - return CardLink{}, fmt.Errorf("failed to unmarshal frontmatter: %w", err) - } - - md := goldmark.New(goldmark.WithExtensions()) - var buf bytes.Buffer - if err := md.Convert([]byte(splitContent[2]), &buf); err != nil { - return CardLink{}, fmt.Errorf("failed to convert markdown: %w", err) - } - - return frontMatter, nil -} - -func SplitFrontmatter(md []byte) (frontmatter []byte, content []byte, err error) { - parts := bytes.SplitN(md, []byte("---"), 3) - - if len(parts) < 3 { - return nil, nil, errors.New("invalid or missing frontmatter") - } - - return parts[1], parts[2], nil -} diff --git a/lib/sse.go b/lib/sse.go deleted file mode 100644 index 0702aa8..0000000 --- a/lib/sse.go +++ /dev/null @@ -1,66 +0,0 @@ -package lib - -import "sync" - -type SSEServerType struct { - clients map[string]map[chan string]bool - mu sync.Mutex -} - -var SSEServer *SSEServerType - -func init() { - SSEServer = &SSEServerType{ - clients: make(map[string]map[chan string]bool), - } -} - -func NewSSEServer() *SSEServerType { - return &SSEServerType{ - clients: make(map[string]map[chan string]bool), - } -} - -func (s *SSEServerType) AddClient(channel string, client chan string) { - s.mu.Lock() - defer s.mu.Unlock() - - if _, ok := s.clients[channel]; !ok { - s.clients[channel] = make(map[chan string]bool) - } - s.clients[channel][client] = true - - LogInfo.Printf("\nClient connected to channel %s\n", channel) -} - -func (s *SSEServerType) RemoveClient(channel string, client chan string) { - s.mu.Lock() - defer s.mu.Unlock() - - delete(s.clients[channel], client) - if len(s.clients[channel]) == 0 { - delete(s.clients, channel) - } - - LogInfo.Printf("\nClient disconnected from channel %s\n", channel) -} - -func (s *SSEServerType) ClientCount(channel string) int { - s.mu.Lock() - defer s.mu.Unlock() - - return len(s.clients[channel]) -} - -func (s *SSEServerType) SendSSE(channel string, message string) { - s.mu.Lock() - defer s.mu.Unlock() - - go func() { - for client := range s.clients[channel] { - client <- message - } - }() - - LogDebug.Printf("\nMessage broadcast on channel %s: %s\n", channel, message) -} diff --git a/lib/templates.go b/lib/templates.go deleted file mode 100644 index e650567..0000000 --- a/lib/templates.go +++ /dev/null @@ -1,42 +0,0 @@ -package lib - -import ( - "html/template" - "net/http" - "path/filepath" - "runtime" - - templatefs "atri.dad/pages/templates" -) - -func RenderTemplate(w http.ResponseWriter, layout string, partials []string, props interface{}) error { - // Get the name of the current file - _, filename, _, _ := runtime.Caller(1) - page := filepath.Base(filename) - page = page[:len(page)-len(filepath.Ext(page))] // remove the file extension - - // Build the list of templates - templates := []string{ - "layouts/" + layout + ".html", - page + ".html", - } - for _, partial := range partials { - templates = append(templates, "partials/"+partial+".html") - } - - // Parse the templates - ts, err := template.ParseFS(templatefs.FS, templates...) - if err != nil { - LogError.Print(err.Error()) - return err - } - - // Execute the layout template - err = ts.ExecuteTemplate(w, layout, props) - if err != nil { - LogError.Print(err.Error()) - return err - } - - return nil -} diff --git a/main.go b/main.go deleted file mode 100755 index a4c55a3..0000000 --- a/main.go +++ /dev/null @@ -1,102 +0,0 @@ -package main - -import ( - "embed" - "flag" - "fmt" - "net/http" - - "atri.dad/api" - "atri.dad/lib" - "atri.dad/pages" - - _ "atri.dad/docs" - "github.com/joho/godotenv" - "github.com/labstack/echo/v4" - "github.com/labstack/echo/v4/middleware" - echoSwagger "github.com/swaggo/echo-swagger" -) - -//go:embed public/* -var PublicFS embed.FS - -// @title Atri.dad API -// @version 1.0 -// @description This is the API for atri.dad -// @host localhost:3000 -// @BasePath /api -func main() { - // Load environment variables - godotenv.Load(".env") - - // Initialize Echo router - e := echo.New() - - // Middleware - e.Use(middleware.Logger()) - e.Use(middleware.Recover()) - e.Pre(middleware.RemoveTrailingSlash()) - e.Use(middleware.RequestID()) - e.Use(middleware.Secure()) - e.Use(middleware.GzipWithConfig(middleware.GzipConfig{ - Level: 5, - })) - e.Use(middleware.RateLimiter(middleware.NewRateLimiterMemoryStore(50))) - - // Add CORS middleware - e.Use(middleware.CORSWithConfig(middleware.CORSConfig{ - AllowOrigins: []string{"https://atri.dad", "http://localhost:3000"}, - AllowMethods: []string{http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete}, - AllowHeaders: []string{echo.HeaderOrigin, echo.HeaderContentType, echo.HeaderAccept}, - ExposeHeaders: []string{echo.HeaderContentType}, - AllowCredentials: true, - MaxAge: 86400, - })) - - // Static server - fs := http.FS(PublicFS) - e.GET("/public/*", echo.WrapHandler(http.FileServer(fs))) - - // Page routes - e.GET("/", pages.Home) - e.GET("/projects", pages.Projects) - e.GET("/talks", pages.Talks) - e.GET("/papers", pages.Papers) - e.GET("/posts", pages.Posts) - e.GET("/posts/:post", pages.Post) - e.GET("/tools", pages.Tools) - e.GET("/tools/resize", pages.Resize) - e.GET("/tools/ssedemo", pages.SSEDemo) - - // API Routes: - apiGroup := e.Group("/api") - apiGroup.GET("/ping", api.Ping) - apiGroup.GET("/rss", api.RSSFeedHandler) - apiGroup.GET("/post/copy", api.PostCopy) - - // Swagger endpoint - apiGroup.GET("/swagger/*", echoSwagger.WrapHandler) - - apiGroup.GET("/sse", func(c echo.Context) error { - return api.SSE(c) - }) - - apiGroup.POST("/tools/sendsse", func(c echo.Context) error { - return api.SSEDemoSend(c) - }) - - apiGroup.POST("/tools/resize", api.ResizeHandler) - - // Parse command-line arguments for IP and port - ip := flag.String("ip", "", "IP address to bind the server to") - port := flag.String("port", "3000", "Port to bind the server to") - flag.Parse() - - // Start server with HTTP/2 support - s := &http.Server{ - Addr: fmt.Sprintf("%s:%s", *ip, *port), - Handler: e, - } - e.Logger.Fatal(e.StartServer(s)) - lib.LogSuccess.Println("Server started on port", *port) -} diff --git a/main.ts b/main.ts new file mode 100644 index 0000000..675f529 --- /dev/null +++ b/main.ts @@ -0,0 +1,13 @@ +/// +/// +/// +/// +/// + +import "$std/dotenv/load.ts"; + +import { start } from "$fresh/server.ts"; +import manifest from "./fresh.gen.ts"; +import config from "./fresh.config.ts"; + +await start(manifest, config); diff --git a/pages/example.go b/pages/example.go deleted file mode 100644 index 37d75c0..0000000 --- a/pages/example.go +++ /dev/null @@ -1,22 +0,0 @@ -package pages - -import ( - "atri.dad/lib" - "github.com/labstack/echo/v4" -) - -type ExampleProps struct { - ExamplePropText string -} - -func Example(c echo.Context) error { - props := ExampleProps{ - ExamplePropText: "EXAMPLE TEXT HERE", - } - - // Specify the partials used by this page - partials := []string{"header", "navitems"} - - // Render the template - return lib.RenderTemplate(c.Response().Writer, "base", partials, props) -} diff --git a/pages/home.go b/pages/home.go deleted file mode 100644 index 98a745e..0000000 --- a/pages/home.go +++ /dev/null @@ -1,106 +0,0 @@ -package pages - -import ( - "html/template" - - "atri.dad/lib" - "github.com/labstack/echo/v4" -) - -type HomeProps struct { - Title template.HTML - Subtitle template.HTML - Socials []lib.IconLink - Tech []lib.IconLink - ButtonsLinks []lib.ButtonLink -} - -func Home(c echo.Context) error { - socials := []lib.IconLink{ - { - Name: "Email", - Href: "mailto:me@atri.dad", - Icon: template.HTML(``), - }, - { - Name: "RSS", - Href: "/api/rss", - Icon: template.HTML(`RSS`), - }, - { - Name: "Git", - Href: "https://git.atri.dad/atridad", - Icon: template.HTML(`Forgejo`), - }, - { - Name: "Bluesky", - Href: "https://bsky.app/profile/atri.dad", - Icon: template.HTML(`Bluesky`), - }, - } - - tech := []lib.IconLink{ - { - Name: "React", - Href: "https://react.dev", - Icon: template.HTML(`React`), - }, - { - Name: "TypeScript", - Href: "https://typescriptlang.org", - Icon: template.HTML(`TypeScript`), - }, - { - Name: "Node.js", - Href: "https://nodejs.org", - Icon: template.HTML(`Node.js`), - }, - { - Name: "Go", - Href: "https://golang.org", - Icon: template.HTML(`Go`), - }, - { - Name: "PostgreSQL", - Href: "https://postgresql.org", - Icon: template.HTML(`PostgreSQL`), - }, - { - Name: "Redis", - Href: "https://redis.io", - Icon: template.HTML(`Redis`), - }, - { - Name: "Docker", - Href: "https://docker.com", - Icon: template.HTML(`Docker`), - }, - } - - buttons := []lib.ButtonLink{ - { - Name: "Resumé", - Href: "/public/files/Atridad_Lahiji_Resume.pdf", - Internal: false, - }, - { - Name: "Posts", - Href: "/posts", - Internal: true, - }, - } - - props := HomeProps{ - Title: "Hi, I'm Atridad", - Subtitle: "Researcher, Full-Stack Developer, and IT Professional.", - Socials: socials, - Tech: tech, - ButtonsLinks: buttons, - } - - // Specify the partials used by this page - partials := []string{"header", "navitems", "iconlinks", "buttonlinks"} - - // Render the template - return lib.RenderTemplate(c.Response().Writer, "base", partials, props) -} diff --git a/pages/papers.go b/pages/papers.go deleted file mode 100644 index 8a9b0a1..0000000 --- a/pages/papers.go +++ /dev/null @@ -1,32 +0,0 @@ -package pages - -import ( - "atri.dad/lib" - "github.com/labstack/echo/v4" -) - -type PapersProps struct { - Papers []lib.CardLink -} - -func Papers(c echo.Context) error { - papers := []lib.CardLink{ - { - Name: "Bridging the Gap Between Social Networks and Healthcare", - Description: "An Assessment of the Need for Improved Patient-Patient, Patient-Provider, and Provider-Provider Sharing", - Href: "/public/files/bridging_the_gap_between_social_networks_and_healthcare.pdf", - Tags: []string{"masters", "coursework", "sna"}, - Date: "January 03, 2025", - }, - } - - props := PapersProps{ - Papers: papers, - } - - // Specify the partials used by this page - partials := []string{"header", "navitems", "cardlinks"} - - // Render the template - return lib.RenderTemplate(c.Response().Writer, "base", partials, props) -} diff --git a/pages/post.go b/pages/post.go deleted file mode 100644 index 151804e..0000000 --- a/pages/post.go +++ /dev/null @@ -1,80 +0,0 @@ -package pages - -import ( - "bytes" - "html/template" - "io/fs" - "net/http" - - contentfs "atri.dad/content" - "atri.dad/lib" - chromahtml "github.com/alecthomas/chroma/v2/formatters/html" - "github.com/labstack/echo/v4" - "github.com/yuin/goldmark" - highlighting "github.com/yuin/goldmark-highlighting/v2" - "gopkg.in/yaml.v2" -) - -type PostProps struct { - Content template.HTML - Name string - Description string - Date string - Tags []string -} - -func Post(c echo.Context) error { - postName := c.Param("post") - - filePath := postName + ".md" - - md, err := fs.ReadFile(contentfs.FS, filePath) - if err != nil { - println(err.Error()) - http.Error(c.Response().Writer, "This post does not exist!", http.StatusNotFound) - return nil - } - - frontmatterBytes, content, err := lib.SplitFrontmatter(md) - if err != nil { - http.Error(c.Response().Writer, "There was an issue rendering this post!", http.StatusInternalServerError) - return nil - } - - var frontmatter lib.FrontMatter - if err := yaml.Unmarshal(frontmatterBytes, &frontmatter); err != nil { - http.Error(c.Response().Writer, "There was an issue rendering this post!", http.StatusInternalServerError) - return nil - } - - var buf bytes.Buffer - markdown := goldmark.New( - goldmark.WithExtensions( - highlighting.NewHighlighting( - highlighting.WithStyle("fruity"), - highlighting.WithFormatOptions( - chromahtml.WithLineNumbers(true), - ), - ), - ), - ) - - if err := markdown.Convert(content, &buf); err != nil { - http.Error(c.Response().Writer, "There was an issue rendering this post!", http.StatusInternalServerError) - return nil - } - - props := PostProps{ - Content: template.HTML(buf.String()), - Name: frontmatter.Name, - Description: frontmatter.Description, - Date: frontmatter.Date, - Tags: frontmatter.Tags, - } - - // Specify the partials used by this page - partials := []string{"header", "navitems"} - - // Render the template - return lib.RenderTemplate(c.Response().Writer, "post", partials, props) -} diff --git a/pages/posts.go b/pages/posts.go deleted file mode 100644 index 7a6d195..0000000 --- a/pages/posts.go +++ /dev/null @@ -1,71 +0,0 @@ -package pages - -import ( - "io/fs" - "log" - "net/http" - "sort" - "strings" - "time" - - contentfs "atri.dad/content" - "atri.dad/lib" - "github.com/labstack/echo/v4" -) - -type PostsProps struct { - Posts []lib.CardLink -} - -func Posts(c echo.Context) error { - var posts []lib.CardLink - - files, err := fs.ReadDir(contentfs.FS, ".") - if err != nil { - lib.LogError.Println(err) - http.Error(c.Response().Writer, "There was an issue finding posts!", http.StatusInternalServerError) - return nil - } - - for _, file := range files { - if !file.IsDir() && strings.HasSuffix(file.Name(), ".md") { - frontMatter, err := lib.ExtractFrontMatter(file, contentfs.FS) - if err != nil { - lib.LogError.Println(err) - http.Error(c.Response().Writer, "There was an issue rendering the posts!", http.StatusInternalServerError) - return nil - } - - frontMatter.Href = "posts/" + strings.TrimSuffix(file.Name(), ".md") - frontMatter.Internal = true - - posts = append(posts, frontMatter) - } - } - - const layout = "January 2 2006" - - sort.Slice(posts, func(i, j int) bool { - iDate, err := time.Parse(layout, posts[i].Date) - if err != nil { - log.Fatal(err) - } - - jDate, err := time.Parse(layout, posts[j].Date) - if err != nil { - log.Fatal(err) - } - - return iDate.Before(jDate) - }) - - props := PostsProps{ - Posts: posts, - } - - // Specify the partials used by this page - partials := []string{"header", "navitems", "cardlinks"} - - // Render the template - return lib.RenderTemplate(c.Response().Writer, "base", partials, props) -} diff --git a/pages/projects.go b/pages/projects.go deleted file mode 100644 index 81af9f7..0000000 --- a/pages/projects.go +++ /dev/null @@ -1,55 +0,0 @@ -package pages - -import ( - "atri.dad/lib" - "github.com/labstack/echo/v4" -) - -type ProjectProps struct { - Projects []lib.CardLink -} - -func Projects(c echo.Context) error { - projects := []lib.CardLink{ - { - Name: "BlueSky PDS Manager", - Description: "A web-based BlueSky PDS Manager. Manage your invite codes and users with a simple web UI.", - Tags: []string{"astro", "atproto"}, - Href: "https://pdsman.atri.dad", - }, - { - Name: "Pollo", - Description: "A dead-simple real-time voting tool.", - Tags: []string{"golang", "htmx", "product"}, - Href: "https://git.atri.dad/atridad/pollo", - }, - { - Name: "GOTH Stack", - Description: "🚀 A Web Application Template Powered by HTMX + Go + Tailwind 🚀", - Tags: []string{"golang", "htmx", "template"}, - Href: "https://git.atri.dad/atridad/goth.stack", - }, - { - Name: "Himbot", - Description: "A discord bot written in Go. Loosly named after my username online (HimbothySwaggins).", - Tags: []string{"golang", "bot"}, - Href: "https://git.atri.dad/atridad/himbot", - }, - { - Name: "loadr", - Description: "A lightweight REST load testing tool with robust support for different verbs, token auth, and performance reports.", - Tags: []string{"golang", "cli"}, - Href: "https://git.atri.dad/atridad/loadr", - }, - } - - props := ProjectProps{ - Projects: projects, - } - - // Specify the partials used by this page - partials := []string{"header", "navitems", "cardlinks"} - - // Render the template - return lib.RenderTemplate(c.Response().Writer, "base", partials, props) -} diff --git a/pages/talks.go b/pages/talks.go deleted file mode 100644 index 9bfc596..0000000 --- a/pages/talks.go +++ /dev/null @@ -1,39 +0,0 @@ -package pages - -import ( - "atri.dad/lib" - "github.com/labstack/echo/v4" -) - -type TalkProps struct { - Talks []lib.CardLink -} - -func Talks(c echo.Context) error { - talks := []lib.CardLink{ - { - Name: "Hypermedia as the engine of application state - an Introduction", - Description: "A talk on building reactive websites using tools like HTMX instead of JSON + JS. Will be presented at the Dev Edmonton Fabruary 2024 JS/Ruby/Python Meetup", - Href: "/public/files/hypermedia_talk_atridad.pdf", - Tags: []string{"golang", "htmx", "ssr"}, - Date: "February 01, 2024", - }, - { - Name: "Introduction to Social Network Analysis (SNA)", - Description: "Understanding Relationships in Social Structures", - Href: "/public/files/Understanding_Relationships_in_Social_Structures.pdf", - Tags: []string{"graphs", "social", "lecture"}, - Date: "October 08, 2024", - }, - } - - props := TalkProps{ - Talks: talks, - } - - // Specify the partials used by this page - partials := []string{"header", "navitems", "cardlinks"} - - // Render the template - return lib.RenderTemplate(c.Response().Writer, "base", partials, props) -} diff --git a/pages/templates/home.html b/pages/templates/home.html deleted file mode 100644 index 4637a9a..0000000 --- a/pages/templates/home.html +++ /dev/null @@ -1,54 +0,0 @@ -{{define "title"}} -Atridad Lahiji // Root -{{end}} - -{{define "description"}} -Researcher, Full-Stack Developer, and IT Professional. -{{end}} - -{{define "navcontent"}} -Atridad Lahiji // Root -{{end}} - -{{define "head"}} -{{end}} - -{{define "main"}} -
-

- {{.Title}} -

- -

- {{.Subtitle}} -

- - -

Places I exist:

-
- {{range .Socials}} - {{template "iconlinks" .}} - {{end}} -
-
- - -

Stuff I Use:

- -
- {{range .Tech}} - {{template "iconlinks" .}} - {{end}} -
-
- -
- {{range .ButtonsLinks}} - {{template "buttonlinks" .}} - {{end}} -
-
-{{end}} - -{{define "foot"}} -{{end}} diff --git a/pages/templates/layouts/base.html b/pages/templates/layouts/base.html deleted file mode 100644 index 207da35..0000000 --- a/pages/templates/layouts/base.html +++ /dev/null @@ -1,26 +0,0 @@ -{{define "base"}} - - - - - - - {{template "title" .}} - - - - {{template "head" .}} - - - - {{template "header" .}} - -
- {{template "main" .}} -
- - - {{template "foot" .}} - - -{{end}} diff --git a/pages/templates/layouts/post.html b/pages/templates/layouts/post.html deleted file mode 100644 index c22c3cd..0000000 --- a/pages/templates/layouts/post.html +++ /dev/null @@ -1,90 +0,0 @@ -{{define "post"}} - - - - - - - - {{template "title" .}} - - - - {{template "head" .}} - - - - {{template "header" .}} - -
-
-

{{.Name}}

- -
- {{if .Date}} -
- - - - - {{.Date}} -
- {{end}} - - {{if .Tags}} -
- {{range .Tags}} - #{{.}} - {{end}} -
- {{end}} - - - -
- - - - - - - - Back - -
-
- -
-
- {{template "main" .}} -
-
-
- - - {{template "foot" .}} - - - -{{end}} \ No newline at end of file diff --git a/pages/templates/papers.html b/pages/templates/papers.html deleted file mode 100644 index 6f8c84c..0000000 --- a/pages/templates/papers.html +++ /dev/null @@ -1,41 +0,0 @@ -{{define "title"}} -Atridad Lahiji // Papers -{{end}} - -{{define "description"}} -Papers I've Written -{{end}} - -{{define "navcontent"}} -Atridad Lahiji // Papers -{{end}} - -{{define "head"}} -{{end}} - -{{define "main"}} - -{{if .Papers}} -
-
- {{range .Papers}} - {{template "cardlinks" .}} - {{end}} -
-
-{{end}} - -{{if not .Papers}} -
-
-

- Nothing to see here (yet)! -

-
-
-{{end}} - -{{end}} - -{{define "foot"}} -{{end}} diff --git a/pages/templates/partials/buttonlinks.html b/pages/templates/partials/buttonlinks.html deleted file mode 100644 index 9afcafd..0000000 --- a/pages/templates/partials/buttonlinks.html +++ /dev/null @@ -1,15 +0,0 @@ -{{define "buttonlinks"}} -{{if eq true .Internal}} - - - {{.Name}} - - -{{else}} - - - {{.Name}} - - -{{end}} -{{end}} diff --git a/pages/templates/partials/cardlinks.html b/pages/templates/partials/cardlinks.html deleted file mode 100644 index 22a96b2..0000000 --- a/pages/templates/partials/cardlinks.html +++ /dev/null @@ -1,55 +0,0 @@ -{{define "cardlinks"}} -
-
-

{{.Name}}

- - {{if .Description}} -

{{.Description}}

- {{end}} - - {{if .Date}} -

-

- - {{.Date}} -
-

- {{end}} - - {{if .Tags}} -
- {{range .Tags}} - #{{.}} - {{end}} -
- {{end}} - - {{if .Href}} - - {{end}} -
-
-{{end}} diff --git a/pages/templates/partials/global.html b/pages/templates/partials/global.html deleted file mode 100644 index 2d49ac7..0000000 --- a/pages/templates/partials/global.html +++ /dev/null @@ -1,4 +0,0 @@ - -{{define "header"}} -
-{{end}} diff --git a/pages/templates/partials/header.html b/pages/templates/partials/header.html deleted file mode 100644 index 9629f01..0000000 --- a/pages/templates/partials/header.html +++ /dev/null @@ -1,49 +0,0 @@ -{{define "header"}} - - - -{{end}} diff --git a/pages/templates/partials/iconlinks.html b/pages/templates/partials/iconlinks.html deleted file mode 100644 index 8a4bb5b..0000000 --- a/pages/templates/partials/iconlinks.html +++ /dev/null @@ -1,5 +0,0 @@ -{{define "iconlinks"}} - - {{.Icon}} - -{{end}} \ No newline at end of file diff --git a/pages/templates/partials/navitems.html b/pages/templates/partials/navitems.html deleted file mode 100644 index 8b75ccf..0000000 --- a/pages/templates/partials/navitems.html +++ /dev/null @@ -1,8 +0,0 @@ -{{define "navitems"}} -
  • Home
  • -
  • Projects
  • -
  • Papers
  • -
  • Talks
  • -
  • Posts
  • -
  • Tools
  • -{{end}} diff --git a/pages/templates/post.html b/pages/templates/post.html deleted file mode 100644 index 8c59900..0000000 --- a/pages/templates/post.html +++ /dev/null @@ -1,22 +0,0 @@ -{{define "title"}} -Atridad Lahiji // Post // {{.Name}} -{{end}} - -{{define "description"}} -{{.Description}} -{{end}} - -{{define "navcontent"}} -Atridad Lahiji // Post // {{.Name}} -{{end}} - -{{define "head"}} -{{end}} - -{{define "main"}} -{{.Content}} -{{end}} - -{{define "foot"}} - -{{end}} diff --git a/pages/templates/posts.html b/pages/templates/posts.html deleted file mode 100644 index 5945676..0000000 --- a/pages/templates/posts.html +++ /dev/null @@ -1,41 +0,0 @@ -{{define "title"}} -Atridad Lahiji // Posts -{{end}} - -{{define "description"}} -Posts I've Written -{{end}} - -{{define "navcontent"}} -Atridad Lahiji // Posts -{{end}} - -{{define "head"}} -{{end}} - -{{define "main"}} - -{{if .Posts}} -
    -
    - {{range .Posts}} - {{template "cardlinks" .}} - {{end}} -
    -
    -{{end}} - -{{if not .Posts}} -
    -
    -

    - Nothing to see here (yet)! -

    -
    -
    -{{end}} - -{{end}} - -{{define "foot"}} -{{end}} diff --git a/pages/templates/projects.html b/pages/templates/projects.html deleted file mode 100644 index fd4d573..0000000 --- a/pages/templates/projects.html +++ /dev/null @@ -1,41 +0,0 @@ -{{define "title"}} -Atridad Lahiji // Projects -{{end}} - -{{define "description"}} -Projects I've Done -{{end}} - -{{define "navcontent"}} -Atridad Lahiji // Projects -{{end}} - -{{define "head"}} -{{end}} - -{{define "main"}} - -{{if .Projects}} -
    -
    - {{range .Projects}} - {{template "cardlinks" .}} - {{end}} -
    -
    -{{end}} - -{{if not .Projects}} -
    -
    -

    - Nothing to see here (yet)! -

    -
    -
    -{{end}} - -{{end}} - -{{define "foot"}} -{{end}} diff --git a/pages/templates/talks.html b/pages/templates/talks.html deleted file mode 100644 index feb5fbd..0000000 --- a/pages/templates/talks.html +++ /dev/null @@ -1,41 +0,0 @@ -{{define "title"}} -Atridad Lahiji // Talks -{{end}} - -{{define "description"}} -Talks I've Given -{{end}} - -{{define "navcontent"}} -Atridad Lahiji // Talks -{{end}} - -{{define "head"}} -{{end}} - -{{define "main"}} - -{{if .Talks}} -
    -
    - {{range .Talks}} - {{template "cardlinks" .}} - {{end}} -
    -
    -{{end}} - -{{if not .Talks}} -
    -
    -

    - Nothing to see here (yet)! -

    -
    -
    -{{end}} - -{{end}} - -{{define "foot"}} -{{end}} diff --git a/pages/templates/templatesfs.go b/pages/templates/templatesfs.go deleted file mode 100644 index 59353f0..0000000 --- a/pages/templates/templatesfs.go +++ /dev/null @@ -1,6 +0,0 @@ -package templatefs - -import "embed" - -//go:embed * -var FS embed.FS diff --git a/pages/templates/tools.html b/pages/templates/tools.html deleted file mode 100644 index b30f5c3..0000000 --- a/pages/templates/tools.html +++ /dev/null @@ -1,43 +0,0 @@ -{{define "title"}} -Atridad Lahiji // Tools -{{end}} - -{{define "description"}} -Tools I've Built -{{end}} - -{{define "navcontent"}} -Atridad Lahiji // Tools -{{end}} - -{{define "head"}} -{{end}} - -{{define "main"}} - -
    - {{if .Tools}} -
    -
    - {{range .Tools}} - {{template "cardlinks" .}} - {{end}} -
    -
    - {{end}} - - {{if not .Tools}} -
    -
    -

    - Nothing to see here (yet)! -

    -
    -
    - {{end}} -
    - -{{end}} - -{{define "foot"}} -{{end}} diff --git a/pages/templates/tools.resize.html b/pages/templates/tools.resize.html deleted file mode 100644 index a8ee776..0000000 --- a/pages/templates/tools.resize.html +++ /dev/null @@ -1,44 +0,0 @@ -{{define "title"}} -Atridad Lahiji // Tools // Resizer -{{end}} - -{{define "description"}} -A tool to re-size images. -{{end}} - -{{define "navcontent"}} -Atridad Lahiji // Tools // Resizer -{{end}} - -{{define "head"}} -{{end}} - -{{define "main"}} -
    -

    Image Resizer

    - -

    Upload and resize your images quickly and easily. Select an image file, specify dimensions, and get a resized version instantly.

    - -
    -
    - - -
    - -
    - - -
    - -
    - - -
    - - -
    -
    -{{end}} - -{{define "foot"}} -{{end}} diff --git a/pages/templates/tools.ssedemo.html b/pages/templates/tools.ssedemo.html deleted file mode 100644 index 5a98783..0000000 --- a/pages/templates/tools.ssedemo.html +++ /dev/null @@ -1,41 +0,0 @@ -{{define "title"}} -Atridad Lahiji // Tools // SSE Demo -{{end}} - -{{define "navcontent"}} -Atridad Lahiji // Tools // SSE Demo -{{end}} - -{{define "description"}} -A demo of my SSE implementation. -{{end}} - -{{define "head"}} -{{end}} - -{{define "main"}} -
    -

    Server Sent Events Demo

    - -

    This page demonstrates the use of the HTMX SSE - Extension to receive Server Sent Events on the "default" channel.

    -

    Any events received on the "default" channel will appear below:

    -
    - Waiting for SSE Message... -
    - -

    Here you can send messages on the default channel:

    -
    -
    - - -
    - - -
    -
    -{{end}} - -{{define "foot"}} - -{{end}} diff --git a/pages/tools.go b/pages/tools.go deleted file mode 100644 index 0ffa9d1..0000000 --- a/pages/tools.go +++ /dev/null @@ -1,37 +0,0 @@ -package pages - -import ( - "atri.dad/lib" - "github.com/labstack/echo/v4" -) - -type ToolsProps struct { - Tools []lib.CardLink -} - -func Tools(c echo.Context) error { - tools := []lib.CardLink{ - { - Name: "Server Sent Events Demo", - Description: "Server Sent Events Demo", - Href: "/tools/ssedemo", - Internal: true, - }, - { - Name: "Image Resizer", - Description: "Image Resizer Tool", - Href: "/tools/resize", - Internal: true, - }, - } - - props := ToolsProps{ - Tools: tools, - } - - // Specify the partials used by this page - partials := []string{"header", "navitems", "cardlinks"} - - // Render the template - return lib.RenderTemplate(c.Response().Writer, "base", partials, props) -} diff --git a/pages/tools.resize.go b/pages/tools.resize.go deleted file mode 100644 index 9d244fa..0000000 --- a/pages/tools.resize.go +++ /dev/null @@ -1,39 +0,0 @@ -package pages - -import ( - "atri.dad/lib" - "github.com/labstack/echo/v4" -) - -type ResizeProps struct { - Talks []lib.CardLink -} - -func Resize(c echo.Context) error { - talks := []lib.CardLink{ - { - Name: "How to ship less JavaScript", - Description: "A talk on building websites while being mindful of the JavaScript we ship. Presented at the Dev Edmonton July 2023 JS/Ruby/Python Meetup", - Href: "https://github.com/atridadl/devedmonton-july-2023", - Tags: []string{"astro", "ssr"}, - Date: "July 06, 2023", - }, - { - Name: "Hypermedia as the engine of application state - an Introduction", - Description: "A talk on building reactive websites using tools like HTMX instead of JSON + JS. Will be presented at the Dev Edmonton Fabruary 2024 JS/Ruby/Python Meetup", - // Href: lib.GeneratePublicURL("hypermedia_talk_atridad.pdf"), - Tags: []string{"golang", "htmx", "ssr"}, - Date: "February 01, 2024", - }, - } - - props := TalkProps{ - Talks: talks, - } - - // Specify the partials used by this page - partials := []string{"header", "navitems", "cardlinks"} - - // Render the template - return lib.RenderTemplate(c.Response().Writer, "base", partials, props) -} diff --git a/pages/tools.ssedemo.go b/pages/tools.ssedemo.go deleted file mode 100644 index d085fa1..0000000 --- a/pages/tools.ssedemo.go +++ /dev/null @@ -1,14 +0,0 @@ -package pages - -import ( - "atri.dad/lib" - "github.com/labstack/echo/v4" -) - -func SSEDemo(c echo.Context) error { - // Specify the partials used by this page - partials := []string{"header", "navitems"} - - // Render the template - return lib.RenderTemplate(c.Response().Writer, "base", partials, nil) -} diff --git a/public/css/styles.css b/public/css/styles.css deleted file mode 100644 index e521eef..0000000 --- a/public/css/styles.css +++ /dev/null @@ -1,1325 +0,0 @@ -/*======================================== -This stylesheet is organized into: - 1. Theme variables - Color schemes and design variables - 2. Base elements - Core HTML element styling - 3. Typography & Links - Text and link styling - 4. Navigation - Navbar and menu styling - 5. Buttons - Button styling and variants - 6. Home page - Homepage specific styles - 7. Projects page - Project listing and cards - 8. Post page - Blog post styling - 9. Markdown - Content styling for markdown - 10. Cards & Components - Reusable UI components - 11. Utility classes - Helper styles - 12. Tools & Utility - Styles for tools and utility pages -========================================*/ - -/*======================================== - 1. THEME VARIABLES -========================================*/ - -:root { - --color-base-100: oklch(15% 0.09 281.288); - --color-base-200: oklch(20% 0.09 281.288); - --color-base-300: oklch(25% 0.09 281.288); - --color-base-content: oklch(78% 0.115 274.713); - --color-primary: oklch(71% 0.202 349.761); - --color-primary-content: oklch(28% 0.109 3.907); - --color-secondary: oklch(82% 0.111 230.318); - --color-secondary-content: oklch(29% 0.066 243.157); - --color-accent: oklch(75% 0.183 55.934); - --color-accent-content: oklch(26% 0.079 36.259); - --color-neutral: oklch(45% 0.24 277.023); - --color-neutral-content: oklch(87% 0.065 274.039); - --color-info: oklch(74% 0.16 232.661); - --color-info-content: oklch(29% 0.066 243.157); - --color-success: oklch(77% 0.152 181.912); - --color-success-content: oklch(27% 0.046 192.524); - --color-warning: oklch(90% 0.182 98.111); - --color-warning-content: oklch(42% 0.095 57.708); - --color-error: oklch(73.7% 0.121 32.639); - --color-error-content: oklch(23.501% 0.096 290.329); - --radius-selector: 1rem; - --radius-field: 0.5rem; - --radius-box: 1rem; - --size-selector: 0.25rem; - --size-field: 0.25rem; - - /* Border styles */ - --border: 1px; - --border-radius-sm: 0.25rem; - --border-radius-md: 0.5rem; - --border-radius-lg: 1rem; - --border-radius-full: 9999px; - - /* Effects */ - --depth: 0; - --noise: 0; - - /* Shadows */ - --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1); - --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.2); - --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.3); - - /* Typography */ - --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; - --font-size-xs: 0.75rem; - --font-size-sm: 0.875rem; - --font-size-md: 1rem; - --font-size-lg: 1.25rem; - --font-size-xl: 1.5rem; - --font-size-2xl: 2rem; - --font-size-3xl: 3rem; - --font-size-4xl: 3.75rem; - --font-weight-normal: 400; - --font-weight-medium: 500; - --font-weight-bold: 700; - --line-height-tight: 1.1; - --line-height-normal: 1.5; - --line-height-loose: 1.8; - - /* Spacing */ - --spacing-xs: 0.25rem; - --spacing-sm: 0.5rem; - --spacing-md: 1rem; - --spacing-lg: 1.5rem; - --spacing-xl: 2rem; - --spacing-2xl: 3rem; - - /* Animations */ - --animation-fast: 0.2s; - --animation-normal: 0.3s; - --animation-slow: 0.5s; - --easing-default: ease-in-out; - - /* Layout */ - --navbar-height: 64px; - --container-max-width: 1200px; - --content-max-width: 768px; - - /* Z-index layers */ - --z-dropdown: 100; - --z-sticky: 200; - --z-overlay: 300; - --z-modal: 400; -} - -/*======================================== - 2. BASE ELEMENTS -========================================*/ - -/* Reset and foundation styles */ -html, body { - background-color: var(--color-base-200); - color: var(--color-base-content); - height: 100%; - margin: 0; - padding: 0; - overflow-x: hidden; /* Prevent horizontal scrolling */ -} - -body { - display: flex; - flex-direction: column; /* Stack elements vertically */ - font-family: var(--font-family); - font-size: var(--font-size-md); - line-height: var(--line-height-normal); -} - -/*======================================== - 4. NAVIGATION -========================================*/ - -/* Main navigation bar - complete redesign for mobile stability */ -.navbar { - display: flex; - justify-content: space-between; - align-items: center; - height: var(--navbar-height); - padding: 0 var(--spacing-lg); - background-color: var(--color-base-200); - position: sticky; - top: 0; - z-index: var(--z-sticky); - font-weight: var(--font-weight-medium); - box-sizing: border-box; - width: 100%; -} - -/* Left side of navbar - title container */ -.navbar .navbar-start { - display: inline-block; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - max-width: calc(100% - 60px); - padding-right: 10px; -} - -/* Right side of navbar - hamburger container */ -.navbar .navbar-end { - display: flex; - justify-content: center; - align-items: center; - width: 44px; - min-width: 44px; - position: relative; -} - -/* Ghost buttons in navbar */ -.navbar a.btn-ghost { - color: var(--color-base-content); - font-weight: 500; -} - -.navbar a.btn-ghost:hover { - background-color: transparent; - color: var(--color-primary); /* Pink on hover */ -} - -/* Dropdown menu in navbar */ -.dropdown .dropdown-content { - display: none; /* Hidden by default */ - position: absolute; - right: 0; - background-color: var(--color-base-200); - min-width: 200px; - box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4); - border-radius: var(--radius-box); -} - -/* Show dropdown and nav menu when toggled */ -.dropdown-content.show, -.nav-menu.show { - display: block; -} - -/* Main content area */ -main { - flex: 1; /* Take up all available space */ - display: flex; - flex-direction: column; - align-items: center; /* Center content horizontally */ - width: 100%; - padding: 1rem 1rem 2rem; - margin: 0 auto; - gap: 1.75rem; /* Space between child elements */ - max-width: 800px; /* Maximum width for better readability */ - box-sizing: border-box; /* Include padding in width calculation */ -} - -/*======================================== - 6. HOME PAGE -========================================*/ - -/* Center homepage content vertically */ -body:has(.home-page) main { - justify-content: center; -} - -/* Homepage layout */ -.home-page { - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - gap: 2.5rem; /* Generous spacing between sections */ - width: 100%; - text-align: center; -} - -/* Homepage buttons container */ -.home-buttons-container { - display: flex; - flex-wrap: wrap; /* Allow buttons to wrap on small screens */ - gap: 1rem; - justify-content: center; - margin: 1rem auto; - max-width: 600px; -} - -/* Icon styling for social links, etc */ -.icon-link svg { - width: 32px; - height: 32px; - color: var(--color-base-content); - fill: var(--color-base-content); -} - -.icon-link:hover svg { - color: var(--color-primary); /* Pink on hover */ - fill: var(--color-primary); -} - -/* Standard container - centers content with max width */ -.container { - width: 100%; - max-width: 1200px; - margin: 0 auto; /* Center horizontally */ - padding: 0 1rem; /* Side padding */ -} - -/*======================================== - 3. TYPOGRAPHY & LINKS -========================================*/ - -/* Basic link styling */ -a { - color: var(--color-primary); /* Pink links */ - text-decoration: none; - transition: all 0.2s ease-in-out; /* Smooth hover effect */ -} - -a:hover { - color: var(--color-secondary); /* Blue on hover */ -} - -/*======================================== - 5. BUTTONS -========================================*/ - -/* Base button styles */ -.btn { - text-transform: none; - font-weight: 500; - transition: all 0.2s ease-in-out; /* Smooth hover effect */ - height: auto; - min-height: 2.25rem; - padding: 0.375rem 1.25rem; - border-radius: var(--radius-field); - font-size: 0.9375rem; - display: flex; - align-items: center; - justify-content: center; - text-align: center; - margin: 0 0.375rem; -} - -/* Primary button - outline style with hover fill */ -.btn-primary { - background-color: transparent; - border: 1px solid var(--color-primary); /* Pink border */ - color: var(--color-primary); /* Pink text */ - width: auto; - min-width: 5rem; - padding: 0.5rem 1.5rem; - font-size: 0.9375rem; -} - -.btn-primary:hover { - background-color: var(--color-primary); /* Pink fill on hover */ - color: var(--color-primary-content); /* Dark text on hover */ - border-color: var(--color-primary); -} - -/* Outline style button */ -.btn-outline { - border-width: 1px; -} - -/* Link styled as button */ -a.btn { - display: inline-flex; - justify-content: center; - align-items: center; - text-align: center; - white-space: nowrap; - margin: 0.25rem; - min-width: 120px; /* Ensure minimum clickable area */ -} - -/*======================================== - 10. CARDS & COMPONENTS -========================================*/ - -/* List styling for navbar dropdown */ -ul.menu { - padding: 1rem 0; - margin: 0; - list-style: none; - display: none; -} - -ul.menu.show { - display: block; -} - -ul.menu li { - margin: 0; - padding: 0; - display: block; -} - -ul.menu li a { - color: var(--color-base-content); - font-weight: 400; - padding: 0.75rem 1.5rem; - display: flex; - align-items: center; - text-decoration: none; - white-space: nowrap; - transition: background-color 0.2s ease; -} - -ul.menu li a:hover { - background-color: rgba(255, 255, 255, 0.05); -} - -ul.menu li a::before { - content: ""; - margin-right: 0; -} - -/* Hamburger menu icon styling */ -.menu-icon { - color: var(--color-base-content); -} - -.dropdown { - position: relative; - display: inline-block; -} - -.nav-menu { - position: absolute; - right: 0; - top: 100%; - background-color: var(--color-base-200); - min-width: 200px; - z-index: 100; -} - -/* Button styling for navbar toggle */ -.navbar .btn-ghost { - background: transparent; - border: none; - padding: 0.5rem; - display: flex; - align-items: center; - justify-content: center; - cursor: pointer; - transition: opacity 0.2s ease; -} - -.navbar .btn-ghost:hover { - opacity: 0.8; - background-color: transparent; -} - -/*======================================== - 3. TYPOGRAPHY & HEADINGS -========================================*/ - -/* Basic heading styles */ -h1, h2, h3, h4, h5, h6 { - margin-bottom: 0.5rem; - font-weight: 700; - line-height: 1.1; -} - -/* Main heading */ -h1 { - font-size: 3.75rem; - margin-bottom: 0.5rem; - letter-spacing: -0.025em; -} - -/* Subheading style */ -h2 { - font-size: 1.25rem; - margin-top: 0; - margin-bottom: 0.5rem; - letter-spacing: -0.025em; - font-weight: 600; -} - -/*======================================== - 11. UTILITY CLASSES -========================================*/ - -/* Gradient text - eye-catching pink to blue gradient for headings */ -.gradient-text { - background-image: linear-gradient(to right, oklch(71% 0.202 349.761), oklch(82% 0.111 230.318)); - background-clip: text; - -webkit-background-clip: text; - color: transparent; - display: inline-block; - font-weight: 800; -} - -/* Section spacing - consistent spacing between main content blocks */ -main > * { - margin-bottom: 2rem; - width: 100%; -} - -/*======================================== - 12. RESPONSIVE DESIGN -========================================*/ - -/* Tablet and desktop adjustments */ -@media (min-width: 640px) { - /* Larger headings on bigger screens */ - h1 { - font-size: 4.5rem; - } - - h2 { - font-size: 1.5rem; - } - - /* Adjust spacing on larger screens */ - main { - gap: 2rem; - padding: 1.5rem 1.5rem 4rem; - } -} - -/* Icon styling for social links and tech stack */ -.fill-white { - fill: var(--color-base-content); /* Match text color */ - width: 22px; - height: 22px; -} - -.fill-white:hover { - fill: var(--color-primary); /* Pink on hover */ - transition: fill 0.2s ease-in-out; -} - -/* Flex layout utility classes - FIXED to actually use flex, not grid */ -.flex { - display: flex; -} - -.flex-row { - display: flex; - flex-direction: row; -} - -.flex-col { - display: flex; - flex-direction: column; -} - -.flex-wrap { - flex-wrap: wrap; -} - -/* Spacing utilities */ -.gap-1 { - gap: var(--spacing-xs); -} - -.gap-2 { - gap: var(--spacing-sm); -} - -.gap-3 { - gap: var(--spacing-md); -} - -.gap-4 { - gap: var(--spacing-lg); -} - -.gap-6 { - gap: var(--spacing-xl); -} - -/* Padding utilities */ -.p-4 { - padding: var(--spacing-md); -} - -/* Alignment utilities */ -.justify-center { - justify-content: center; -} - -.items-center { - align-items: center; -} - -.text-center { - text-align: center; -} - -/* Specific styling for sections */ -/* General section styling except for post content */ -main:not(.container) > span, -main:not(.container) > section { - display: flex; - flex-direction: row; - flex-wrap: wrap; - align-items: center; - gap: var(--spacing-sm); - margin-bottom: var(--spacing-sm); - width: 100%; - max-width: 100%; /* Allow content to use full width */ - margin-left: auto; - margin-right: auto; -} - -/* Button size adjustments */ -.btn-md { - height: 2.25rem; - min-height: 2.25rem; - font-size: var(--font-size-sm); - border: var(--border) solid var(--color-primary); - transition: all var(--animation-fast) var(--easing-default); -} - -.lg\:btn-lg { - height: 2.25rem; - min-height: 2.25rem; - font-size: var(--font-size-sm); - border: var(--border) solid var(--color-primary); - transition: all var(--animation-fast) var(--easing-default); -} - -@media (min-width: 1024px) { - .lg\:btn-lg { - height: 2.5rem; - min-height: 2.5rem; - font-size: var(--font-size-md); - } -} - -/*======================================== - 10. CARD SYSTEM - Unified card grid and component styles -========================================*/ - -/* Card grid container and layout styles */ -.card-grid-container { - width: 100%; - max-width: 80vw; /* Use 80% of viewport width */ - display: flex; - flex-direction: row; - justify-content: center; - align-items: center; - padding: 0 var(--spacing-md); - min-height: 70vh; -} - -/* Override with !important for flex direction to ensure it takes precedence */ -.card-grid { - display: flex !important; - flex-direction: row !important; - flex-wrap: wrap; - justify-content: center; - align-items: center; - gap: var(--spacing-lg); - width: 100%; - max-width: 100%; /* Use full width of container */ - margin: 0 auto; -} - -/* Project cards layout - proper flex row with wrapping */ -section.flex.flex-row, -section.card-grid { - display: flex; - flex-direction: row; /* Ensure horizontal layout */ - flex-wrap: wrap; - gap: 1.5rem; - width: 100%; - max-width: 100%; /* Use full width of container */ - padding: 1.5rem; - align-items: center; - justify-content: center; - margin: 0 auto; -} - -/* Unified card styling - used for projects, posts, papers, and talks */ -.project-card { - max-width: 100%; - width: 340px; /* Wider cards by default */ - min-height: 240px; - height: auto; - background-color: var(--color-secondary); - border-radius: var(--border-radius-lg); - overflow: hidden; - display: flex; - flex-direction: column; - transition: transform var(--animation-fast) var(--easing-default), box-shadow var(--animation-fast) var(--easing-default); - box-shadow: var(--shadow-md); - margin: 0.75rem; /* Consistent margin all around */ - flex: 0 0 auto; /* Prevent flex items from growing or shrinking */ -} - -.project-card:hover { - transform: translateY(-5px); - box-shadow: var(--shadow-lg); -} - -.project-card-content { - padding: var(--spacing-lg); - display: flex; - flex-direction: column; - flex: 1; - height: 100%; - color: var(--color-primary-content); - position: relative; - padding-bottom: 3.5rem; -} - -.project-card-title { - font-size: var(--font-size-lg); - font-weight: var(--font-weight-bold); - margin-bottom: var(--spacing-sm); - color: var(--color-base-100); -} - -.project-card-description { - font-size: var(--font-size-sm); - margin-bottom: var(--spacing-md); - flex-grow: 1; - line-height: var(--line-height-normal); -} - -.project-card-tags { - display: flex; - flex-wrap: wrap; - gap: var(--spacing-xs); - margin-bottom: var(--spacing-sm); -} - -.project-tag { - font-size: var(--font-size-xs); - padding: var(--spacing-xs) var(--spacing-sm); - border-radius: var(--border-radius-sm); - background-color: var(--color-primary); - color: var(--color-primary-content); - transition: transform var(--animation-fast) var(--easing-default); -} - -.project-tag:nth-child(2n) { - background-color: var(--color-accent); - color: var(--color-accent-content); -} - -.project-tag:nth-child(3n) { - background-color: var(--color-info); - color: var(--color-info-content); -} - -.project-tag:nth-child(4n) { - background-color: var(--color-warning); - color: var(--color-warning-content); -} - -.project-card-link { - display: flex; - justify-content: flex-end; - position: absolute; - bottom: 1rem; - right: 1.25rem; -} - -.project-link-button { - width: 2.25rem; - height: 2.25rem; - display: flex; - align-items: center; - justify-content: center; - border-radius: 50%; - background-color: var(--color-base-100); - color: var(--color-base-content); - border: 1px solid var(--color-base-content); - transition: all 0.2s ease-in-out; -} - -.project-link-button:hover { - background-color: var(--color-primary); - color: var(--color-primary-content); - border-color: var(--color-primary); -} - -/*======================================== - 7. PROJECTS PAGE -========================================*/ - -/* Project cards layout - proper flex row with wrapping */ -section.flex.flex-row, -section.card-grid { - display: flex; - flex-direction: row; /* Ensure horizontal layout */ - flex-wrap: wrap; - gap: 1.5rem; - width: 100%; - max-width: 1200px; - padding: 1.5rem; - align-items: center; - justify-content: center; - margin: 0 auto; -} - -/* Remove the min-height from the section and put it on the container */ -.card-grid-container { - min-height: 70vh; - display: flex; - flex-direction: row; /* Ensure container is also row */ - align-items: center; - justify-content: center; -} - -/* Improved empty state */ -.card-grid:empty, -.card-grid:has(h2:only-child) { - display: flex; - align-items: center; - justify-content: center; - width: 100%; - height: 100%; -} - -/* Responsive adjustments */ -@media (max-width: 767px) { - .project-card { - width: 300px; /* Slightly smaller on mobile */ - margin: 0.5rem; /* Smaller margin on mobile */ - } - - /* Even on mobile, ensure cards are in a row */ - .card-grid, - section.card-grid, - section.flex.flex-row { - flex-direction: row; - justify-content: center; - } -} - -@media (min-width: 768px) and (max-width: 1023px) { - .project-card { - width: 320px; /* Medium size on tablets */ - } -} - -@media (min-width: 1024px) { - .card-grid { - gap: 2rem; /* More spacing on larger screens */ - } -} - -/*======================================== - 8. POST PAGE -========================================*/ - -main.container article { - display: block; - width: 100%; - max-width: 700px; /* Limit width for post content */ - margin-left: auto; /* Center the article */ - margin-right: auto; /* Center the article */ - line-height: 1.6; - text-align: left; -} - -main.container h1 { - margin-bottom: 0.5rem; -} - -/* Post metadata layout */ -main.container article hr { - margin-top: 0.5rem; - margin-bottom: 1.5rem; - opacity: 0.15; - border-color: var(--color-base-content); -} - -/* Post content layout */ -main.container .markdown { - max-width: 100%; -} - -/* Icon buttons on post page */ -.post-icon-button { - background: transparent; - border: none; - color: var(--color-base-content); - width: 2rem; - height: 2rem; - display: inline-flex; - align-items: center; - justify-content: center; - transition: color 0.2s ease-in-out, transform 0.2s ease-in-out; - cursor: pointer; - padding: 0; -} - -.post-icon-button:hover { - color: var(--color-primary); /* Pink on hover */ - transform: scale(1.1); /* Slight grow effect */ -} - -/* Back button for post navigation */ -.post-back-button { - background-color: transparent; - color: var(--color-primary); - border: 1px solid var(--color-primary); - border-radius: var(--radius-field); - padding: 0.375rem 0.75rem; - font-size: 0.75rem; - display: inline-flex; - align-items: center; - gap: 0.375rem; - height: 28px; - transition: all 0.2s ease-in-out; -} - -.post-back-button:hover { - background-color: var(--color-primary); - color: var(--color-primary-content); -} - -/*======================================== - 9. MARKDOWN CONTENT STYLING -========================================*/ - -/* Base markdown content */ -.markdown { - line-height: 1.7; /* Better readability */ - font-size: 1rem; - margin-top: 1rem; -} - -/* Paragraph spacing */ -.markdown p { - margin-bottom: 1.25rem; -} - -/* Headings within markdown */ -.markdown h1, -.markdown h2, -.markdown h3, -.markdown h4, -.markdown h5, -.markdown h6 { - margin-top: 2rem; - margin-bottom: 1rem; -} - -/* Post title */ -main article h1 { - font-size: 2.25rem; - margin-top: 2rem; - margin-bottom: 1.5rem; - color: var(--color-secondary); /* Blue color */ -} - -/* Tailwind-style text utilities */ -.text-md { - font-size: var(--font-size-md); -} - -.text-lg { - font-size: var(--font-size-lg); -} - -.text-xl { - font-size: var(--font-size-xl); -} - -.text-2xl { - font-size: var(--font-size-2xl); -} - -.text-4xl { - font-size: var(--font-size-4xl); -} - -.text-white { - color: white; -} - -/* Font weight utilities */ -.font-extrabold { - font-weight: 800; -} - -/* Tracking/letter-spacing utilities */ -.tracking-tight { - letter-spacing: -0.025em; -} - -/* Media query screen size utilities */ -@media (min-width: 640px) { - .sm\:text-8xl { - font-size: 6rem; /* Approximate 8xl size */ - } - - .sm\:text-\[1\.5rem\] { - font-size: 1.5rem; - } - - .sm\:text-\[2rem\] { - font-size: 2rem; - } - - .sm\:gap-6 { - gap: var(--spacing-xl); - } -} - -/* Additional margin utilities */ -.mb-2 { - margin-bottom: 0.5rem; -} - -/*======================================== - 13. TOOLS & UTILITY PAGES -========================================*/ - -/* General tool page styling */ -.tool-page { - display: flex; - flex-direction: column; - align-items: center; - justify-content: flex-start; - width: 100%; - max-width: 800px; - margin: 0 auto; - padding: 2rem 1rem; -} - -.tool-page h1 { - font-size: 2.5rem; - margin-bottom: 1.5rem; - color: var(--color-secondary); -} - -.tool-page p { - margin-bottom: 1.5rem; - text-align: center; - max-width: 700px; - line-height: 1.6; -} - -/* Form elements styling */ -input[type="text"], -input[type="number"], -input[type="file"], -textarea { - width: 100%; - padding: 0.75rem 1rem; - margin-bottom: 1.5rem; - background-color: var(--color-base-300); - border: 1px solid var(--color-secondary); - border-radius: var(--border-radius-md); - color: var(--color-base-content); - font-size: 1rem; - transition: all 0.2s ease; -} - -input[type="text"]:focus, -input[type="number"]:focus, -textarea:focus { - border-color: var(--color-primary); - outline: none; - box-shadow: 0 0 0 2px rgba(var(--color-primary), 0.25); -} - -button[type="submit"], -.tool-button { - display: inline-flex; - align-items: center; - justify-content: center; - padding: 0.75rem 1.5rem; - background-color: transparent; - color: var(--color-primary); - border: 1px solid var(--color-primary); - border-radius: var(--border-radius-md); - font-size: 1rem; - font-weight: 500; - cursor: pointer; - transition: all 0.2s ease; - margin-top: 1rem; - width: 100%; - max-width: 400px; -} - -button[type="submit"]:hover, -.tool-button:hover { - background-color: var(--color-primary); - color: var(--color-primary-content); -} - -/* File input customization */ -input[type="file"] { - padding: 0.5rem; -} - -input[type="file"]::-webkit-file-upload-button { - padding: 0.5rem 1rem; - margin-right: 1rem; - background-color: var(--color-secondary); - color: var(--color-primary-content); - border: none; - border-radius: var(--border-radius-sm); - cursor: pointer; - transition: all 0.2s ease; -} - -input[type="file"]::-webkit-file-upload-button:hover { - background-color: var(--color-primary); -} - -/* Form group styling */ -.form-group { - width: 100%; - max-width: 700px; - margin-bottom: 1.5rem; -} - -.form-group label { - display: block; - margin-bottom: 0.5rem; - font-size: 1rem; - color: var(--color-base-content); -} - -/* SSE specific styling */ -.sse-message-container { - width: 100%; - max-width: 700px; - min-height: 100px; - padding: 1.5rem; - margin: 1.5rem 0; - background-color: var(--color-base-300); - border-radius: var(--border-radius-lg); - border: 1px dashed var(--color-secondary); -} - -.sse-message { - margin-bottom: 0.5rem; - padding: 0.5rem; - border-radius: var(--border-radius-sm); - background-color: var(--color-base-200); -} - -/* Tool links styling */ -.tool-link { - color: var(--color-primary); - text-decoration: underline; - transition: all 0.2s ease; -} - -.tool-link:hover { - color: var(--color-secondary); - text-decoration: none; -} - -/* Standard container for pages */ -main.container { - max-width: 90vw; - padding: 2rem 1rem; - width: 100%; -} - -/* Error message styling */ -.error-message { - color: var(--color-error); - margin-top: 0.5rem; - font-size: 0.875rem; -} - -/* Tool cards specific styling */ -.tools-page .card-grid-container { - display: flex; - align-items: center; - justify-content: center; - min-height: 70vh; -} - -.tools-page .project-card, -.tool-card { - position: relative; - max-width: 100%; - width: 340px; - min-height: 200px; - background-color: var(--color-secondary); - border-radius: var(--border-radius-lg); - display: flex; - flex-direction: column; - transition: transform var(--animation-fast) var(--easing-default), box-shadow var(--animation-fast) var(--easing-default); - box-shadow: var(--shadow-md); - margin: 0.75rem; - overflow: hidden; -} - -.tools-page .project-card-content { - padding: var(--spacing-lg); - position: relative; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - text-align: center; - min-height: 180px; -} - -/* Base elements for better mobile experience */ -@media (max-width: 480px) { - html, body { - font-size: 15px; - } - - h1 { - font-size: 2.5rem; - } - - h2 { - font-size: 1.25rem; - } - - main { - padding: 1rem 0.75rem 2rem; - } -} - -/* Card grid container and layout styles - mobile improvements */ -.card-grid-container { - width: 100%; - max-width: 80vw; /* Use 80% of viewport width */ - display: flex; - flex-direction: row; - justify-content: center; - align-items: center; - padding: 0 var(--spacing-md); - min-height: 70vh; -} - -@media (max-width: 480px) { - .card-grid-container { - max-width: 95vw; /* Use more screen width on mobile */ - padding: 0 0.5rem; - } - - .card-grid { - gap: 1rem; /* Tighter spacing on mobile */ - } -} - -/* Mobile improvements for tool pages */ -@media (max-width: 480px) { - .tool-page { - padding: 1.5rem 0.75rem; - } - - .tool-page h1 { - font-size: 2rem; - margin-bottom: 1rem; - } - - .form-group { - max-width: 100%; - } - - input[type="text"], - input[type="number"], - input[type="file"], - textarea { - padding: 0.5rem 0.75rem; - } - - .sse-message-container { - padding: 1rem; - margin: 1rem 0; - } -} - -/* Responsive adjustments for cards */ -@media (max-width: 480px) { - .project-card { - width: 100%; /* Full width on very small screens */ - max-width: 300px; - min-height: 220px; - margin: 0.5rem 0; - } - - .project-card-content { - padding: var(--spacing-md); - padding-bottom: 3rem; - } - - .project-card-title { - font-size: 1.15rem; - } - - .project-card-description { - font-size: 0.875rem; - } - - .tools-page .project-card, - .tool-card { - width: 100%; - max-width: 300px; - min-height: 180px; - margin: 0.5rem 0; - } - - .tools-page .project-card-content { - min-height: 150px; - padding: var(--spacing-md); - } -} - -/* Improved mobile styles for home page */ -@media (max-width: 480px) { - .home-page { - gap: 1.75rem; - } - - .home-buttons-container { - gap: 0.75rem; - } - - .btn { - padding: 0.325rem 1rem; - min-width: 100px; - } -} - -/* Button size adjustments for mobile */ -@media (max-width: 480px) { - .btn-md { - height: 2rem; - min-height: 2rem; - font-size: var(--font-size-xs); - padding: 0.25rem 1rem; - } - - .tool-button { - padding: 0.5rem 1.25rem; - } -} - -/* Improve mobile menu usability */ -@media (max-width: 480px) { - ul.menu li a { - padding: 0.875rem 1.25rem; - } - - .dropdown .dropdown-content { - min-width: 180px; - } -} - -/* Fix margin and width for post and markdown content on mobile */ -@media (max-width: 480px) { - main.container { - padding: 1rem 0.75rem; - } - - .markdown { - font-size: 0.9375rem; - } - - .markdown h1 { - font-size: 1.75rem; - } - - .markdown h2 { - font-size: 1.5rem; - } -} diff --git a/public/files/Atridad_Lahiji_Resume.pdf b/public/files/Atridad_Lahiji_Resume.pdf deleted file mode 100644 index 41fc052..0000000 Binary files a/public/files/Atridad_Lahiji_Resume.pdf and /dev/null differ diff --git a/public/files/Understanding_Relationships_in_Social_Structures.pdf b/public/files/Understanding_Relationships_in_Social_Structures.pdf deleted file mode 100644 index 7a545dc..0000000 Binary files a/public/files/Understanding_Relationships_in_Social_Structures.pdf and /dev/null differ diff --git a/public/files/bridging_the_gap_between_social_networks_and_healthcare.pdf b/public/files/bridging_the_gap_between_social_networks_and_healthcare.pdf deleted file mode 100644 index 126cb11..0000000 Binary files a/public/files/bridging_the_gap_between_social_networks_and_healthcare.pdf and /dev/null differ diff --git a/public/files/hypermedia_talk_atridad.pdf b/public/files/hypermedia_talk_atridad.pdf deleted file mode 100644 index 9d07c17..0000000 Binary files a/public/files/hypermedia_talk_atridad.pdf and /dev/null differ diff --git a/public/img/articles/scalability.png b/public/img/articles/scalability.png deleted file mode 100644 index 306115f..0000000 Binary files a/public/img/articles/scalability.png and /dev/null differ diff --git a/public/js/htmx.base.js b/public/js/htmx.base.js deleted file mode 100644 index 59937d7..0000000 --- a/public/js/htmx.base.js +++ /dev/null @@ -1 +0,0 @@ -var htmx=function(){"use strict";const Q={onLoad:null,process:null,on:null,off:null,trigger:null,ajax:null,find:null,findAll:null,closest:null,values:function(e,t){const n=cn(e,t||"post");return n.values},remove:null,addClass:null,removeClass:null,toggleClass:null,takeClass:null,swap:null,defineExtension:null,removeExtension:null,logAll:null,logNone:null,logger:null,config:{historyEnabled:true,historyCacheSize:10,refreshOnHistoryMiss:false,defaultSwapStyle:"innerHTML",defaultSwapDelay:0,defaultSettleDelay:20,includeIndicatorStyles:true,indicatorClass:"htmx-indicator",requestClass:"htmx-request",addedClass:"htmx-added",settlingClass:"htmx-settling",swappingClass:"htmx-swapping",allowEval:true,allowScriptTags:true,inlineScriptNonce:"",inlineStyleNonce:"",attributesToSettle:["class","style","width","height"],withCredentials:false,timeout:0,wsReconnectDelay:"full-jitter",wsBinaryType:"blob",disableSelector:"[hx-disable], [data-hx-disable]",scrollBehavior:"instant",defaultFocusScroll:false,getCacheBusterParam:false,globalViewTransitions:false,methodsThatUseUrlParams:["get","delete"],selfRequestsOnly:true,ignoreTitle:false,scrollIntoViewOnBoost:true,triggerSpecsCache:null,disableInheritance:false,responseHandling:[{code:"204",swap:false},{code:"[23]..",swap:true},{code:"[45]..",swap:false,error:true}],allowNestedOobSwaps:true},parseInterval:null,_:null,version:"2.0.4"};Q.onLoad=j;Q.process=kt;Q.on=ye;Q.off=be;Q.trigger=he;Q.ajax=Rn;Q.find=u;Q.findAll=x;Q.closest=g;Q.remove=z;Q.addClass=K;Q.removeClass=G;Q.toggleClass=W;Q.takeClass=Z;Q.swap=$e;Q.defineExtension=Fn;Q.removeExtension=Bn;Q.logAll=V;Q.logNone=_;Q.parseInterval=d;Q._=e;const n={addTriggerHandler:St,bodyContains:le,canAccessLocalStorage:B,findThisElement:Se,filterValues:hn,swap:$e,hasAttribute:s,getAttributeValue:te,getClosestAttributeValue:re,getClosestMatch:o,getExpressionVars:En,getHeaders:fn,getInputValues:cn,getInternalData:ie,getSwapSpecification:gn,getTriggerSpecs:st,getTarget:Ee,makeFragment:P,mergeObjects:ce,makeSettleInfo:xn,oobSwap:He,querySelectorExt:ae,settleImmediately:Kt,shouldCancel:ht,triggerEvent:he,triggerErrorEvent:fe,withExtensions:Ft};const r=["get","post","put","delete","patch"];const H=r.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");function d(e){if(e==undefined){return undefined}let t=NaN;if(e.slice(-2)=="ms"){t=parseFloat(e.slice(0,-2))}else if(e.slice(-1)=="s"){t=parseFloat(e.slice(0,-1))*1e3}else if(e.slice(-1)=="m"){t=parseFloat(e.slice(0,-1))*1e3*60}else{t=parseFloat(e)}return isNaN(t)?undefined:t}function ee(e,t){return e instanceof Element&&e.getAttribute(t)}function s(e,t){return!!e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute("data-"+t))}function te(e,t){return ee(e,t)||ee(e,"data-"+t)}function c(e){const t=e.parentElement;if(!t&&e.parentNode instanceof ShadowRoot)return e.parentNode;return t}function ne(){return document}function m(e,t){return e.getRootNode?e.getRootNode({composed:t}):ne()}function o(e,t){while(e&&!t(e)){e=c(e)}return e||null}function i(e,t,n){const r=te(t,n);const o=te(t,"hx-disinherit");var i=te(t,"hx-inherit");if(e!==t){if(Q.config.disableInheritance){if(i&&(i==="*"||i.split(" ").indexOf(n)>=0)){return r}else{return null}}if(o&&(o==="*"||o.split(" ").indexOf(n)>=0)){return"unset"}}return r}function re(t,n){let r=null;o(t,function(e){return!!(r=i(t,ue(e),n))});if(r!=="unset"){return r}}function h(e,t){const n=e instanceof Element&&(e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector);return!!n&&n.call(e,t)}function T(e){const t=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i;const n=t.exec(e);if(n){return n[1].toLowerCase()}else{return""}}function q(e){const t=new DOMParser;return t.parseFromString(e,"text/html")}function L(e,t){while(t.childNodes.length>0){e.append(t.childNodes[0])}}function A(e){const t=ne().createElement("script");se(e.attributes,function(e){t.setAttribute(e.name,e.value)});t.textContent=e.textContent;t.async=false;if(Q.config.inlineScriptNonce){t.nonce=Q.config.inlineScriptNonce}return t}function N(e){return e.matches("script")&&(e.type==="text/javascript"||e.type==="module"||e.type==="")}function I(e){Array.from(e.querySelectorAll("script")).forEach(e=>{if(N(e)){const t=A(e);const n=e.parentNode;try{n.insertBefore(t,e)}catch(e){O(e)}finally{e.remove()}}})}function P(e){const t=e.replace(/]*)?>[\s\S]*?<\/head>/i,"");const n=T(t);let r;if(n==="html"){r=new DocumentFragment;const i=q(e);L(r,i.body);r.title=i.title}else if(n==="body"){r=new DocumentFragment;const i=q(t);L(r,i.body);r.title=i.title}else{const i=q('");r=i.querySelector("template").content;r.title=i.title;var o=r.querySelector("title");if(o&&o.parentNode===r){o.remove();r.title=o.innerText}}if(r){if(Q.config.allowScriptTags){I(r)}else{r.querySelectorAll("script").forEach(e=>e.remove())}}return r}function oe(e){if(e){e()}}function t(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function k(e){return typeof e==="function"}function D(e){return t(e,"Object")}function ie(e){const t="htmx-internal-data";let n=e[t];if(!n){n=e[t]={}}return n}function M(t){const n=[];if(t){for(let e=0;e=0}function le(e){return e.getRootNode({composed:true})===document}function F(e){return e.trim().split(/\s+/)}function ce(e,t){for(const n in t){if(t.hasOwnProperty(n)){e[n]=t[n]}}return e}function S(e){try{return JSON.parse(e)}catch(e){O(e);return null}}function B(){const e="htmx:localStorageTest";try{localStorage.setItem(e,e);localStorage.removeItem(e);return true}catch(e){return false}}function U(t){try{const e=new URL(t);if(e){t=e.pathname+e.search}if(!/^\/$/.test(t)){t=t.replace(/\/+$/,"")}return t}catch(e){return t}}function e(e){return vn(ne().body,function(){return eval(e)})}function j(t){const e=Q.on("htmx:load",function(e){t(e.detail.elt)});return e}function V(){Q.logger=function(e,t,n){if(console){console.log(t,e,n)}}}function _(){Q.logger=null}function u(e,t){if(typeof e!=="string"){return e.querySelector(t)}else{return u(ne(),e)}}function x(e,t){if(typeof e!=="string"){return e.querySelectorAll(t)}else{return x(ne(),e)}}function E(){return window}function z(e,t){e=y(e);if(t){E().setTimeout(function(){z(e);e=null},t)}else{c(e).removeChild(e)}}function ue(e){return e instanceof Element?e:null}function $(e){return e instanceof HTMLElement?e:null}function J(e){return typeof e==="string"?e:null}function f(e){return e instanceof Element||e instanceof Document||e instanceof DocumentFragment?e:null}function K(e,t,n){e=ue(y(e));if(!e){return}if(n){E().setTimeout(function(){K(e,t);e=null},n)}else{e.classList&&e.classList.add(t)}}function G(e,t,n){let r=ue(y(e));if(!r){return}if(n){E().setTimeout(function(){G(r,t);r=null},n)}else{if(r.classList){r.classList.remove(t);if(r.classList.length===0){r.removeAttribute("class")}}}}function W(e,t){e=y(e);e.classList.toggle(t)}function Z(e,t){e=y(e);se(e.parentElement.children,function(e){G(e,t)});K(ue(e),t)}function g(e,t){e=ue(y(e));if(e&&e.closest){return e.closest(t)}else{do{if(e==null||h(e,t)){return e}}while(e=e&&ue(c(e)));return null}}function l(e,t){return e.substring(0,t.length)===t}function Y(e,t){return e.substring(e.length-t.length)===t}function ge(e){const t=e.trim();if(l(t,"<")&&Y(t,"/>")){return t.substring(1,t.length-2)}else{return t}}function p(t,r,n){if(r.indexOf("global ")===0){return p(t,r.slice(7),true)}t=y(t);const o=[];{let t=0;let n=0;for(let e=0;e"){t--}}if(n0){const r=ge(o.shift());let e;if(r.indexOf("closest ")===0){e=g(ue(t),ge(r.substr(8)))}else if(r.indexOf("find ")===0){e=u(f(t),ge(r.substr(5)))}else if(r==="next"||r==="nextElementSibling"){e=ue(t).nextElementSibling}else if(r.indexOf("next ")===0){e=pe(t,ge(r.substr(5)),!!n)}else if(r==="previous"||r==="previousElementSibling"){e=ue(t).previousElementSibling}else if(r.indexOf("previous ")===0){e=me(t,ge(r.substr(9)),!!n)}else if(r==="document"){e=document}else if(r==="window"){e=window}else if(r==="body"){e=document.body}else if(r==="root"){e=m(t,!!n)}else if(r==="host"){e=t.getRootNode().host}else{s.push(r)}if(e){i.push(e)}}if(s.length>0){const e=s.join(",");const c=f(m(t,!!n));i.push(...M(c.querySelectorAll(e)))}return i}var pe=function(t,e,n){const r=f(m(t,n)).querySelectorAll(e);for(let e=0;e=0;e--){const o=r[e];if(o.compareDocumentPosition(t)===Node.DOCUMENT_POSITION_FOLLOWING){return o}}};function ae(e,t){if(typeof e!=="string"){return p(e,t)[0]}else{return p(ne().body,e)[0]}}function y(e,t){if(typeof e==="string"){return u(f(t)||document,e)}else{return e}}function xe(e,t,n,r){if(k(t)){return{target:ne().body,event:J(e),listener:t,options:n}}else{return{target:y(e),event:J(t),listener:n,options:r}}}function ye(t,n,r,o){Vn(function(){const e=xe(t,n,r,o);e.target.addEventListener(e.event,e.listener,e.options)});const e=k(n);return e?n:r}function be(t,n,r){Vn(function(){const e=xe(t,n,r);e.target.removeEventListener(e.event,e.listener)});return k(n)?n:r}const ve=ne().createElement("output");function we(e,t){const n=re(e,t);if(n){if(n==="this"){return[Se(e,t)]}else{const r=p(e,n);if(r.length===0){O('The selector "'+n+'" on '+t+" returned no matches!");return[ve]}else{return r}}}}function Se(e,t){return ue(o(e,function(e){return te(ue(e),t)!=null}))}function Ee(e){const t=re(e,"hx-target");if(t){if(t==="this"){return Se(e,"hx-target")}else{return ae(e,t)}}else{const n=ie(e);if(n.boosted){return ne().body}else{return e}}}function Ce(t){const n=Q.config.attributesToSettle;for(let e=0;e0){s=e.substring(0,e.indexOf(":"));n=e.substring(e.indexOf(":")+1)}else{s=e}o.removeAttribute("hx-swap-oob");o.removeAttribute("data-hx-swap-oob");const r=p(t,n,false);if(r){se(r,function(e){let t;const n=o.cloneNode(true);t=ne().createDocumentFragment();t.appendChild(n);if(!Re(s,e)){t=f(n)}const r={shouldSwap:true,target:e,fragment:t};if(!he(e,"htmx:oobBeforeSwap",r))return;e=r.target;if(r.shouldSwap){qe(t);_e(s,e,e,t,i);Te()}se(i.elts,function(e){he(e,"htmx:oobAfterSwap",r)})});o.parentNode.removeChild(o)}else{o.parentNode.removeChild(o);fe(ne().body,"htmx:oobErrorNoTarget",{content:o})}return e}function Te(){const e=u("#--htmx-preserve-pantry--");if(e){for(const t of[...e.children]){const n=u("#"+t.id);n.parentNode.moveBefore(t,n);n.remove()}e.remove()}}function qe(e){se(x(e,"[hx-preserve], [data-hx-preserve]"),function(e){const t=te(e,"id");const n=ne().getElementById(t);if(n!=null){if(e.moveBefore){let e=u("#--htmx-preserve-pantry--");if(e==null){ne().body.insertAdjacentHTML("afterend","
    ");e=u("#--htmx-preserve-pantry--")}e.moveBefore(n,null)}else{e.parentNode.replaceChild(n,e)}}})}function Le(l,e,c){se(e.querySelectorAll("[id]"),function(t){const n=ee(t,"id");if(n&&n.length>0){const r=n.replace("'","\\'");const o=t.tagName.replace(":","\\:");const e=f(l);const i=e&&e.querySelector(o+"[id='"+r+"']");if(i&&i!==e){const s=t.cloneNode();Oe(t,i);c.tasks.push(function(){Oe(t,s)})}}})}function Ae(e){return function(){G(e,Q.config.addedClass);kt(ue(e));Ne(f(e));he(e,"htmx:load")}}function Ne(e){const t="[autofocus]";const n=$(h(e,t)?e:e.querySelector(t));if(n!=null){n.focus()}}function a(e,t,n,r){Le(e,n,r);while(n.childNodes.length>0){const o=n.firstChild;K(ue(o),Q.config.addedClass);e.insertBefore(o,t);if(o.nodeType!==Node.TEXT_NODE&&o.nodeType!==Node.COMMENT_NODE){r.tasks.push(Ae(o))}}}function Ie(e,t){let n=0;while(n0}function $e(e,t,r,o){if(!o){o={}}e=y(e);const i=o.contextElement?m(o.contextElement,false):ne();const n=document.activeElement;let s={};try{s={elt:n,start:n?n.selectionStart:null,end:n?n.selectionEnd:null}}catch(e){}const l=xn(e);if(r.swapStyle==="textContent"){e.textContent=t}else{let n=P(t);l.title=n.title;if(o.selectOOB){const u=o.selectOOB.split(",");for(let t=0;t0){E().setTimeout(c,r.settleDelay)}else{c()}}function Je(e,t,n){const r=e.getResponseHeader(t);if(r.indexOf("{")===0){const o=S(r);for(const i in o){if(o.hasOwnProperty(i)){let e=o[i];if(D(e)){n=e.target!==undefined?e.target:n}else{e={value:e}}he(n,i,e)}}}else{const s=r.split(",");for(let e=0;e0){const s=o[0];if(s==="]"){e--;if(e===0){if(n===null){t=t+"true"}o.shift();t+=")})";try{const l=vn(r,function(){return Function(t)()},function(){return true});l.source=t;return l}catch(e){fe(ne().body,"htmx:syntax:error",{error:e,source:t});return null}}}else if(s==="["){e++}if(tt(s,n,i)){t+="(("+i+"."+s+") ? ("+i+"."+s+") : (window."+s+"))"}else{t=t+s}n=o.shift()}}}function C(e,t){let n="";while(e.length>0&&!t.test(e[0])){n+=e.shift()}return n}function rt(e){let t;if(e.length>0&&Ye.test(e[0])){e.shift();t=C(e,Qe).trim();e.shift()}else{t=C(e,v)}return t}const ot="input, textarea, select";function it(e,t,n){const r=[];const o=et(t);do{C(o,w);const l=o.length;const c=C(o,/[,\[\s]/);if(c!==""){if(c==="every"){const u={trigger:"every"};C(o,w);u.pollInterval=d(C(o,/[,\[\s]/));C(o,w);var i=nt(e,o,"event");if(i){u.eventFilter=i}r.push(u)}else{const a={trigger:c};var i=nt(e,o,"event");if(i){a.eventFilter=i}C(o,w);while(o.length>0&&o[0]!==","){const f=o.shift();if(f==="changed"){a.changed=true}else if(f==="once"){a.once=true}else if(f==="consume"){a.consume=true}else if(f==="delay"&&o[0]===":"){o.shift();a.delay=d(C(o,v))}else if(f==="from"&&o[0]===":"){o.shift();if(Ye.test(o[0])){var s=rt(o)}else{var s=C(o,v);if(s==="closest"||s==="find"||s==="next"||s==="previous"){o.shift();const h=rt(o);if(h.length>0){s+=" "+h}}}a.from=s}else if(f==="target"&&o[0]===":"){o.shift();a.target=rt(o)}else if(f==="throttle"&&o[0]===":"){o.shift();a.throttle=d(C(o,v))}else if(f==="queue"&&o[0]===":"){o.shift();a.queue=C(o,v)}else if(f==="root"&&o[0]===":"){o.shift();a[f]=rt(o)}else if(f==="threshold"&&o[0]===":"){o.shift();a[f]=C(o,v)}else{fe(e,"htmx:syntax:error",{token:o.shift()})}C(o,w)}r.push(a)}}if(o.length===l){fe(e,"htmx:syntax:error",{token:o.shift()})}C(o,w)}while(o[0]===","&&o.shift());if(n){n[t]=r}return r}function st(e){const t=te(e,"hx-trigger");let n=[];if(t){const r=Q.config.triggerSpecsCache;n=r&&r[t]||it(e,t,r)}if(n.length>0){return n}else if(h(e,"form")){return[{trigger:"submit"}]}else if(h(e,'input[type="button"], input[type="submit"]')){return[{trigger:"click"}]}else if(h(e,ot)){return[{trigger:"change"}]}else{return[{trigger:"click"}]}}function lt(e){ie(e).cancelled=true}function ct(e,t,n){const r=ie(e);r.timeout=E().setTimeout(function(){if(le(e)&&r.cancelled!==true){if(!gt(n,e,Mt("hx:poll:trigger",{triggerSpec:n,target:e}))){t(e)}ct(e,t,n)}},n.pollInterval)}function ut(e){return location.hostname===e.hostname&&ee(e,"href")&&ee(e,"href").indexOf("#")!==0}function at(e){return g(e,Q.config.disableSelector)}function ft(t,n,e){if(t instanceof HTMLAnchorElement&&ut(t)&&(t.target===""||t.target==="_self")||t.tagName==="FORM"&&String(ee(t,"method")).toLowerCase()!=="dialog"){n.boosted=true;let r,o;if(t.tagName==="A"){r="get";o=ee(t,"href")}else{const i=ee(t,"method");r=i?i.toLowerCase():"get";o=ee(t,"action");if(o==null||o===""){o=ne().location.href}if(r==="get"&&o.includes("?")){o=o.replace(/\?[^#]+/,"")}}e.forEach(function(e){pt(t,function(e,t){const n=ue(e);if(at(n)){b(n);return}de(r,o,n,t)},n,e,true)})}}function ht(e,t){const n=ue(t);if(!n){return false}if(e.type==="submit"||e.type==="click"){if(n.tagName==="FORM"){return true}if(h(n,'input[type="submit"], button')&&(h(n,"[form]")||g(n,"form")!==null)){return true}if(n instanceof HTMLAnchorElement&&n.href&&(n.getAttribute("href")==="#"||n.getAttribute("href").indexOf("#")!==0)){return true}}return false}function dt(e,t){return ie(e).boosted&&e instanceof HTMLAnchorElement&&t.type==="click"&&(t.ctrlKey||t.metaKey)}function gt(e,t,n){const r=e.eventFilter;if(r){try{return r.call(t,n)!==true}catch(e){const o=r.source;fe(ne().body,"htmx:eventFilter:error",{error:e,source:o});return true}}return false}function pt(l,c,e,u,a){const f=ie(l);let t;if(u.from){t=p(l,u.from)}else{t=[l]}if(u.changed){if(!("lastValue"in f)){f.lastValue=new WeakMap}t.forEach(function(e){if(!f.lastValue.has(u)){f.lastValue.set(u,new WeakMap)}f.lastValue.get(u).set(e,e.value)})}se(t,function(i){const s=function(e){if(!le(l)){i.removeEventListener(u.trigger,s);return}if(dt(l,e)){return}if(a||ht(e,l)){e.preventDefault()}if(gt(u,l,e)){return}const t=ie(e);t.triggerSpec=u;if(t.handledFor==null){t.handledFor=[]}if(t.handledFor.indexOf(l)<0){t.handledFor.push(l);if(u.consume){e.stopPropagation()}if(u.target&&e.target){if(!h(ue(e.target),u.target)){return}}if(u.once){if(f.triggeredOnce){return}else{f.triggeredOnce=true}}if(u.changed){const n=event.target;const r=n.value;const o=f.lastValue.get(u);if(o.has(n)&&o.get(n)===r){return}o.set(n,r)}if(f.delayed){clearTimeout(f.delayed)}if(f.throttle){return}if(u.throttle>0){if(!f.throttle){he(l,"htmx:trigger");c(l,e);f.throttle=E().setTimeout(function(){f.throttle=null},u.throttle)}}else if(u.delay>0){f.delayed=E().setTimeout(function(){he(l,"htmx:trigger");c(l,e)},u.delay)}else{he(l,"htmx:trigger");c(l,e)}}};if(e.listenerInfos==null){e.listenerInfos=[]}e.listenerInfos.push({trigger:u.trigger,listener:s,on:i});i.addEventListener(u.trigger,s)})}let mt=false;let xt=null;function yt(){if(!xt){xt=function(){mt=true};window.addEventListener("scroll",xt);window.addEventListener("resize",xt);setInterval(function(){if(mt){mt=false;se(ne().querySelectorAll("[hx-trigger*='revealed'],[data-hx-trigger*='revealed']"),function(e){bt(e)})}},200)}}function bt(e){if(!s(e,"data-hx-revealed")&&X(e)){e.setAttribute("data-hx-revealed","true");const t=ie(e);if(t.initHash){he(e,"revealed")}else{e.addEventListener("htmx:afterProcessNode",function(){he(e,"revealed")},{once:true})}}}function vt(e,t,n,r){const o=function(){if(!n.loaded){n.loaded=true;he(e,"htmx:trigger");t(e)}};if(r>0){E().setTimeout(o,r)}else{o()}}function wt(t,n,e){let i=false;se(r,function(r){if(s(t,"hx-"+r)){const o=te(t,"hx-"+r);i=true;n.path=o;n.verb=r;e.forEach(function(e){St(t,e,n,function(e,t){const n=ue(e);if(g(n,Q.config.disableSelector)){b(n);return}de(r,o,n,t)})})}});return i}function St(r,e,t,n){if(e.trigger==="revealed"){yt();pt(r,n,t,e);bt(ue(r))}else if(e.trigger==="intersect"){const o={};if(e.root){o.root=ae(r,e.root)}if(e.threshold){o.threshold=parseFloat(e.threshold)}const i=new IntersectionObserver(function(t){for(let e=0;e0){t.polling=true;ct(ue(r),n,e)}else{pt(r,n,t,e)}}function Et(e){const t=ue(e);if(!t){return false}const n=t.attributes;for(let e=0;e", "+e).join(""));return o}else{return[]}}function Tt(e){const t=g(ue(e.target),"button, input[type='submit']");const n=Lt(e);if(n){n.lastButtonClicked=t}}function qt(e){const t=Lt(e);if(t){t.lastButtonClicked=null}}function Lt(e){const t=g(ue(e.target),"button, input[type='submit']");if(!t){return}const n=y("#"+ee(t,"form"),t.getRootNode())||g(t,"form");if(!n){return}return ie(n)}function At(e){e.addEventListener("click",Tt);e.addEventListener("focusin",Tt);e.addEventListener("focusout",qt)}function Nt(t,e,n){const r=ie(t);if(!Array.isArray(r.onHandlers)){r.onHandlers=[]}let o;const i=function(e){vn(t,function(){if(at(t)){return}if(!o){o=new Function("event",n)}o.call(t,e)})};t.addEventListener(e,i);r.onHandlers.push({event:e,listener:i})}function It(t){ke(t);for(let e=0;eQ.config.historyCacheSize){i.shift()}while(i.length>0){try{localStorage.setItem("htmx-history-cache",JSON.stringify(i));break}catch(e){fe(ne().body,"htmx:historyCacheError",{cause:e,cache:i});i.shift()}}}function Vt(t){if(!B()){return null}t=U(t);const n=S(localStorage.getItem("htmx-history-cache"))||[];for(let e=0;e=200&&this.status<400){he(ne().body,"htmx:historyCacheMissLoad",i);const e=P(this.response);const t=e.querySelector("[hx-history-elt],[data-hx-history-elt]")||e;const n=Ut();const r=xn(n);kn(e.title);qe(e);Ve(n,t,r);Te();Kt(r.tasks);Bt=o;he(ne().body,"htmx:historyRestore",{path:o,cacheMiss:true,serverResponse:this.response})}else{fe(ne().body,"htmx:historyCacheMissLoadError",i)}};e.send()}function Wt(e){zt();e=e||location.pathname+location.search;const t=Vt(e);if(t){const n=P(t.content);const r=Ut();const o=xn(r);kn(t.title);qe(n);Ve(r,n,o);Te();Kt(o.tasks);E().setTimeout(function(){window.scrollTo(0,t.scroll)},0);Bt=e;he(ne().body,"htmx:historyRestore",{path:e,item:t})}else{if(Q.config.refreshOnHistoryMiss){window.location.reload(true)}else{Gt(e)}}}function Zt(e){let t=we(e,"hx-indicator");if(t==null){t=[e]}se(t,function(e){const t=ie(e);t.requestCount=(t.requestCount||0)+1;e.classList.add.call(e.classList,Q.config.requestClass)});return t}function Yt(e){let t=we(e,"hx-disabled-elt");if(t==null){t=[]}se(t,function(e){const t=ie(e);t.requestCount=(t.requestCount||0)+1;e.setAttribute("disabled","");e.setAttribute("data-disabled-by-htmx","")});return t}function Qt(e,t){se(e.concat(t),function(e){const t=ie(e);t.requestCount=(t.requestCount||1)-1});se(e,function(e){const t=ie(e);if(t.requestCount===0){e.classList.remove.call(e.classList,Q.config.requestClass)}});se(t,function(e){const t=ie(e);if(t.requestCount===0){e.removeAttribute("disabled");e.removeAttribute("data-disabled-by-htmx")}})}function en(t,n){for(let e=0;en.indexOf(e)<0)}else{e=e.filter(e=>e!==n)}r.delete(t);se(e,e=>r.append(t,e))}}function on(t,n,r,o,i){if(o==null||en(t,o)){return}else{t.push(o)}if(tn(o)){const s=ee(o,"name");let e=o.value;if(o instanceof HTMLSelectElement&&o.multiple){e=M(o.querySelectorAll("option:checked")).map(function(e){return e.value})}if(o instanceof HTMLInputElement&&o.files){e=M(o.files)}nn(s,e,n);if(i){sn(o,r)}}if(o instanceof HTMLFormElement){se(o.elements,function(e){if(t.indexOf(e)>=0){rn(e.name,e.value,n)}else{t.push(e)}if(i){sn(e,r)}});new FormData(o).forEach(function(e,t){if(e instanceof File&&e.name===""){return}nn(t,e,n)})}}function sn(e,t){const n=e;if(n.willValidate){he(n,"htmx:validation:validate");if(!n.checkValidity()){t.push({elt:n,message:n.validationMessage,validity:n.validity});he(n,"htmx:validation:failed",{message:n.validationMessage,validity:n.validity})}}}function ln(n,e){for(const t of e.keys()){n.delete(t)}e.forEach(function(e,t){n.append(t,e)});return n}function cn(e,t){const n=[];const r=new FormData;const o=new FormData;const i=[];const s=ie(e);if(s.lastButtonClicked&&!le(s.lastButtonClicked)){s.lastButtonClicked=null}let l=e instanceof HTMLFormElement&&e.noValidate!==true||te(e,"hx-validate")==="true";if(s.lastButtonClicked){l=l&&s.lastButtonClicked.formNoValidate!==true}if(t!=="get"){on(n,o,i,g(e,"form"),l)}on(n,r,i,e,l);if(s.lastButtonClicked||e.tagName==="BUTTON"||e.tagName==="INPUT"&&ee(e,"type")==="submit"){const u=s.lastButtonClicked||e;const a=ee(u,"name");nn(a,u.value,o)}const c=we(e,"hx-include");se(c,function(e){on(n,r,i,ue(e),l);if(!h(e,"form")){se(f(e).querySelectorAll(ot),function(e){on(n,r,i,e,l)})}});ln(r,o);return{errors:i,formData:r,values:An(r)}}function un(e,t,n){if(e!==""){e+="&"}if(String(n)==="[object Object]"){n=JSON.stringify(n)}const r=encodeURIComponent(n);e+=encodeURIComponent(t)+"="+r;return e}function an(e){e=qn(e);let n="";e.forEach(function(e,t){n=un(n,t,e)});return n}function fn(e,t,n){const r={"HX-Request":"true","HX-Trigger":ee(e,"id"),"HX-Trigger-Name":ee(e,"name"),"HX-Target":te(t,"id"),"HX-Current-URL":ne().location.href};bn(e,"hx-headers",false,r);if(n!==undefined){r["HX-Prompt"]=n}if(ie(e).boosted){r["HX-Boosted"]="true"}return r}function hn(n,e){const t=re(e,"hx-params");if(t){if(t==="none"){return new FormData}else if(t==="*"){return n}else if(t.indexOf("not ")===0){se(t.slice(4).split(","),function(e){e=e.trim();n.delete(e)});return n}else{const r=new FormData;se(t.split(","),function(t){t=t.trim();if(n.has(t)){n.getAll(t).forEach(function(e){r.append(t,e)})}});return r}}else{return n}}function dn(e){return!!ee(e,"href")&&ee(e,"href").indexOf("#")>=0}function gn(e,t){const n=t||re(e,"hx-swap");const r={swapStyle:ie(e).boosted?"innerHTML":Q.config.defaultSwapStyle,swapDelay:Q.config.defaultSwapDelay,settleDelay:Q.config.defaultSettleDelay};if(Q.config.scrollIntoViewOnBoost&&ie(e).boosted&&!dn(e)){r.show="top"}if(n){const s=F(n);if(s.length>0){for(let e=0;e0?o.join(":"):null;r.scroll=u;r.scrollTarget=i}else if(l.indexOf("show:")===0){const a=l.slice(5);var o=a.split(":");const f=o.pop();var i=o.length>0?o.join(":"):null;r.show=f;r.showTarget=i}else if(l.indexOf("focus-scroll:")===0){const h=l.slice("focus-scroll:".length);r.focusScroll=h=="true"}else if(e==0){r.swapStyle=l}else{O("Unknown modifier in hx-swap: "+l)}}}}return r}function pn(e){return re(e,"hx-encoding")==="multipart/form-data"||h(e,"form")&&ee(e,"enctype")==="multipart/form-data"}function mn(t,n,r){let o=null;Ft(n,function(e){if(o==null){o=e.encodeParameters(t,r,n)}});if(o!=null){return o}else{if(pn(n)){return ln(new FormData,qn(r))}else{return an(r)}}}function xn(e){return{tasks:[],elts:[e]}}function yn(e,t){const n=e[0];const r=e[e.length-1];if(t.scroll){var o=null;if(t.scrollTarget){o=ue(ae(n,t.scrollTarget))}if(t.scroll==="top"&&(n||o)){o=o||n;o.scrollTop=0}if(t.scroll==="bottom"&&(r||o)){o=o||r;o.scrollTop=o.scrollHeight}}if(t.show){var o=null;if(t.showTarget){let e=t.showTarget;if(t.showTarget==="window"){e="body"}o=ue(ae(n,e))}if(t.show==="top"&&(n||o)){o=o||n;o.scrollIntoView({block:"start",behavior:Q.config.scrollBehavior})}if(t.show==="bottom"&&(r||o)){o=o||r;o.scrollIntoView({block:"end",behavior:Q.config.scrollBehavior})}}}function bn(r,e,o,i){if(i==null){i={}}if(r==null){return i}const s=te(r,e);if(s){let e=s.trim();let t=o;if(e==="unset"){return null}if(e.indexOf("javascript:")===0){e=e.slice(11);t=true}else if(e.indexOf("js:")===0){e=e.slice(3);t=true}if(e.indexOf("{")!==0){e="{"+e+"}"}let n;if(t){n=vn(r,function(){return Function("return ("+e+")")()},{})}else{n=S(e)}for(const l in n){if(n.hasOwnProperty(l)){if(i[l]==null){i[l]=n[l]}}}}return bn(ue(c(r)),e,o,i)}function vn(e,t,n){if(Q.config.allowEval){return t()}else{fe(e,"htmx:evalDisallowedError");return n}}function wn(e,t){return bn(e,"hx-vars",true,t)}function Sn(e,t){return bn(e,"hx-vals",false,t)}function En(e){return ce(wn(e),Sn(e))}function Cn(t,n,r){if(r!==null){try{t.setRequestHeader(n,r)}catch(e){t.setRequestHeader(n,encodeURIComponent(r));t.setRequestHeader(n+"-URI-AutoEncoded","true")}}}function On(t){if(t.responseURL&&typeof URL!=="undefined"){try{const e=new URL(t.responseURL);return e.pathname+e.search}catch(e){fe(ne().body,"htmx:badResponseUrl",{url:t.responseURL})}}}function R(e,t){return t.test(e.getAllResponseHeaders())}function Rn(t,n,r){t=t.toLowerCase();if(r){if(r instanceof Element||typeof r==="string"){return de(t,n,null,null,{targetOverride:y(r)||ve,returnPromise:true})}else{let e=y(r.target);if(r.target&&!e||r.source&&!e&&!y(r.source)){e=ve}return de(t,n,y(r.source),r.event,{handler:r.handler,headers:r.headers,values:r.values,targetOverride:e,swapOverride:r.swap,select:r.select,returnPromise:true})}}else{return de(t,n,null,null,{returnPromise:true})}}function Hn(e){const t=[];while(e){t.push(e);e=e.parentElement}return t}function Tn(e,t,n){let r;let o;if(typeof URL==="function"){o=new URL(t,document.location.href);const i=document.location.origin;r=i===o.origin}else{o=t;r=l(t,document.location.origin)}if(Q.config.selfRequestsOnly){if(!r){return false}}return he(e,"htmx:validateUrl",ce({url:o,sameHost:r},n))}function qn(e){if(e instanceof FormData)return e;const t=new FormData;for(const n in e){if(e.hasOwnProperty(n)){if(e[n]&&typeof e[n].forEach==="function"){e[n].forEach(function(e){t.append(n,e)})}else if(typeof e[n]==="object"&&!(e[n]instanceof Blob)){t.append(n,JSON.stringify(e[n]))}else{t.append(n,e[n])}}}return t}function Ln(r,o,e){return new Proxy(e,{get:function(t,e){if(typeof e==="number")return t[e];if(e==="length")return t.length;if(e==="push"){return function(e){t.push(e);r.append(o,e)}}if(typeof t[e]==="function"){return function(){t[e].apply(t,arguments);r.delete(o);t.forEach(function(e){r.append(o,e)})}}if(t[e]&&t[e].length===1){return t[e][0]}else{return t[e]}},set:function(e,t,n){e[t]=n;r.delete(o);e.forEach(function(e){r.append(o,e)});return true}})}function An(o){return new Proxy(o,{get:function(e,t){if(typeof t==="symbol"){const r=Reflect.get(e,t);if(typeof r==="function"){return function(){return r.apply(o,arguments)}}else{return r}}if(t==="toJSON"){return()=>Object.fromEntries(o)}if(t in e){if(typeof e[t]==="function"){return function(){return o[t].apply(o,arguments)}}else{return e[t]}}const n=o.getAll(t);if(n.length===0){return undefined}else if(n.length===1){return n[0]}else{return Ln(e,t,n)}},set:function(t,n,e){if(typeof n!=="string"){return false}t.delete(n);if(e&&typeof e.forEach==="function"){e.forEach(function(e){t.append(n,e)})}else if(typeof e==="object"&&!(e instanceof Blob)){t.append(n,JSON.stringify(e))}else{t.append(n,e)}return true},deleteProperty:function(e,t){if(typeof t==="string"){e.delete(t)}return true},ownKeys:function(e){return Reflect.ownKeys(Object.fromEntries(e))},getOwnPropertyDescriptor:function(e,t){return Reflect.getOwnPropertyDescriptor(Object.fromEntries(e),t)}})}function de(t,n,r,o,i,D){let s=null;let l=null;i=i!=null?i:{};if(i.returnPromise&&typeof Promise!=="undefined"){var e=new Promise(function(e,t){s=e;l=t})}if(r==null){r=ne().body}const M=i.handler||Dn;const X=i.select||null;if(!le(r)){oe(s);return e}const c=i.targetOverride||ue(Ee(r));if(c==null||c==ve){fe(r,"htmx:targetError",{target:te(r,"hx-target")});oe(l);return e}let u=ie(r);const a=u.lastButtonClicked;if(a){const L=ee(a,"formaction");if(L!=null){n=L}const A=ee(a,"formmethod");if(A!=null){if(A.toLowerCase()!=="dialog"){t=A}}}const f=re(r,"hx-confirm");if(D===undefined){const K=function(e){return de(t,n,r,o,i,!!e)};const G={target:c,elt:r,path:n,verb:t,triggeringEvent:o,etc:i,issueRequest:K,question:f};if(he(r,"htmx:confirm",G)===false){oe(s);return e}}let h=r;let d=re(r,"hx-sync");let g=null;let F=false;if(d){const N=d.split(":");const I=N[0].trim();if(I==="this"){h=Se(r,"hx-sync")}else{h=ue(ae(r,I))}d=(N[1]||"drop").trim();u=ie(h);if(d==="drop"&&u.xhr&&u.abortable!==true){oe(s);return e}else if(d==="abort"){if(u.xhr){oe(s);return e}else{F=true}}else if(d==="replace"){he(h,"htmx:abort")}else if(d.indexOf("queue")===0){const W=d.split(" ");g=(W[1]||"last").trim()}}if(u.xhr){if(u.abortable){he(h,"htmx:abort")}else{if(g==null){if(o){const P=ie(o);if(P&&P.triggerSpec&&P.triggerSpec.queue){g=P.triggerSpec.queue}}if(g==null){g="last"}}if(u.queuedRequests==null){u.queuedRequests=[]}if(g==="first"&&u.queuedRequests.length===0){u.queuedRequests.push(function(){de(t,n,r,o,i)})}else if(g==="all"){u.queuedRequests.push(function(){de(t,n,r,o,i)})}else if(g==="last"){u.queuedRequests=[];u.queuedRequests.push(function(){de(t,n,r,o,i)})}oe(s);return e}}const p=new XMLHttpRequest;u.xhr=p;u.abortable=F;const m=function(){u.xhr=null;u.abortable=false;if(u.queuedRequests!=null&&u.queuedRequests.length>0){const e=u.queuedRequests.shift();e()}};const B=re(r,"hx-prompt");if(B){var x=prompt(B);if(x===null||!he(r,"htmx:prompt",{prompt:x,target:c})){oe(s);m();return e}}if(f&&!D){if(!confirm(f)){oe(s);m();return e}}let y=fn(r,c,x);if(t!=="get"&&!pn(r)){y["Content-Type"]="application/x-www-form-urlencoded"}if(i.headers){y=ce(y,i.headers)}const U=cn(r,t);let b=U.errors;const j=U.formData;if(i.values){ln(j,qn(i.values))}const V=qn(En(r));const v=ln(j,V);let w=hn(v,r);if(Q.config.getCacheBusterParam&&t==="get"){w.set("org.htmx.cache-buster",ee(c,"id")||"true")}if(n==null||n===""){n=ne().location.href}const S=bn(r,"hx-request");const _=ie(r).boosted;let E=Q.config.methodsThatUseUrlParams.indexOf(t)>=0;const C={boosted:_,useUrlParams:E,formData:w,parameters:An(w),unfilteredFormData:v,unfilteredParameters:An(v),headers:y,target:c,verb:t,errors:b,withCredentials:i.credentials||S.credentials||Q.config.withCredentials,timeout:i.timeout||S.timeout||Q.config.timeout,path:n,triggeringEvent:o};if(!he(r,"htmx:configRequest",C)){oe(s);m();return e}n=C.path;t=C.verb;y=C.headers;w=qn(C.parameters);b=C.errors;E=C.useUrlParams;if(b&&b.length>0){he(r,"htmx:validation:halted",C);oe(s);m();return e}const z=n.split("#");const $=z[0];const O=z[1];let R=n;if(E){R=$;const Z=!w.keys().next().done;if(Z){if(R.indexOf("?")<0){R+="?"}else{R+="&"}R+=an(w);if(O){R+="#"+O}}}if(!Tn(r,R,C)){fe(r,"htmx:invalidPath",C);oe(l);return e}p.open(t.toUpperCase(),R,true);p.overrideMimeType("text/html");p.withCredentials=C.withCredentials;p.timeout=C.timeout;if(S.noHeaders){}else{for(const k in y){if(y.hasOwnProperty(k)){const Y=y[k];Cn(p,k,Y)}}}const H={xhr:p,target:c,requestConfig:C,etc:i,boosted:_,select:X,pathInfo:{requestPath:n,finalRequestPath:R,responsePath:null,anchor:O}};p.onload=function(){try{const t=Hn(r);H.pathInfo.responsePath=On(p);M(r,H);if(H.keepIndicators!==true){Qt(T,q)}he(r,"htmx:afterRequest",H);he(r,"htmx:afterOnLoad",H);if(!le(r)){let e=null;while(t.length>0&&e==null){const n=t.shift();if(le(n)){e=n}}if(e){he(e,"htmx:afterRequest",H);he(e,"htmx:afterOnLoad",H)}}oe(s);m()}catch(e){fe(r,"htmx:onLoadError",ce({error:e},H));throw e}};p.onerror=function(){Qt(T,q);fe(r,"htmx:afterRequest",H);fe(r,"htmx:sendError",H);oe(l);m()};p.onabort=function(){Qt(T,q);fe(r,"htmx:afterRequest",H);fe(r,"htmx:sendAbort",H);oe(l);m()};p.ontimeout=function(){Qt(T,q);fe(r,"htmx:afterRequest",H);fe(r,"htmx:timeout",H);oe(l);m()};if(!he(r,"htmx:beforeRequest",H)){oe(s);m();return e}var T=Zt(r);var q=Yt(r);se(["loadstart","loadend","progress","abort"],function(t){se([p,p.upload],function(e){e.addEventListener(t,function(e){he(r,"htmx:xhr:"+t,{lengthComputable:e.lengthComputable,loaded:e.loaded,total:e.total})})})});he(r,"htmx:beforeSend",H);const J=E?null:mn(p,r,w);p.send(J);return e}function Nn(e,t){const n=t.xhr;let r=null;let o=null;if(R(n,/HX-Push:/i)){r=n.getResponseHeader("HX-Push");o="push"}else if(R(n,/HX-Push-Url:/i)){r=n.getResponseHeader("HX-Push-Url");o="push"}else if(R(n,/HX-Replace-Url:/i)){r=n.getResponseHeader("HX-Replace-Url");o="replace"}if(r){if(r==="false"){return{}}else{return{type:o,path:r}}}const i=t.pathInfo.finalRequestPath;const s=t.pathInfo.responsePath;const l=re(e,"hx-push-url");const c=re(e,"hx-replace-url");const u=ie(e).boosted;let a=null;let f=null;if(l){a="push";f=l}else if(c){a="replace";f=c}else if(u){a="push";f=s||i}if(f){if(f==="false"){return{}}if(f==="true"){f=s||i}if(t.pathInfo.anchor&&f.indexOf("#")===-1){f=f+"#"+t.pathInfo.anchor}return{type:a,path:f}}else{return{}}}function In(e,t){var n=new RegExp(e.code);return n.test(t.toString(10))}function Pn(e){for(var t=0;t0){E().setTimeout(e,x.swapDelay)}else{e()}}if(f){fe(o,"htmx:responseError",ce({error:"Response Status Error Code "+s.status+" from "+i.pathInfo.requestPath},i))}}const Mn={};function Xn(){return{init:function(e){return null},getSelectors:function(){return null},onEvent:function(e,t){return true},transformResponse:function(e,t,n){return e},isInlineSwap:function(e){return false},handleSwap:function(e,t,n,r){return false},encodeParameters:function(e,t,n){return null}}}function Fn(e,t){if(t.init){t.init(n)}Mn[e]=ce(Xn(),t)}function Bn(e){delete Mn[e]}function Un(e,n,r){if(n==undefined){n=[]}if(e==undefined){return n}if(r==undefined){r=[]}const t=te(e,"hx-ext");if(t){se(t.split(","),function(e){e=e.replace(/ /g,"");if(e.slice(0,7)=="ignore:"){r.push(e.slice(7));return}if(r.indexOf(e)<0){const t=Mn[e];if(t&&n.indexOf(t)<0){n.push(t)}}})}return Un(ue(c(e)),n,r)}var jn=false;ne().addEventListener("DOMContentLoaded",function(){jn=true});function Vn(e){if(jn||ne().readyState==="complete"){e()}else{ne().addEventListener("DOMContentLoaded",e)}}function _n(){if(Q.config.includeIndicatorStyles!==false){const e=Q.config.inlineStyleNonce?` nonce="${Q.config.inlineStyleNonce}"`:"";ne().head.insertAdjacentHTML("beforeend"," ."+Q.config.indicatorClass+"{opacity:0} ."+Q.config.requestClass+" ."+Q.config.indicatorClass+"{opacity:1; transition: opacity 200ms ease-in;} ."+Q.config.requestClass+"."+Q.config.indicatorClass+"{opacity:1; transition: opacity 200ms ease-in;} ")}}function zn(){const e=ne().querySelector('meta[name="htmx-config"]');if(e){return S(e.content)}else{return null}}function $n(){const e=zn();if(e){Q.config=ce(Q.config,e)}}Vn(function(){$n();_n();let e=ne().body;kt(e);const t=ne().querySelectorAll("[hx-trigger='restored'],[data-hx-trigger='restored']");e.addEventListener("htmx:abort",function(e){const t=e.target;const n=ie(t);if(n&&n.xhr){n.xhr.abort()}});const n=window.onpopstate?window.onpopstate.bind(window):null;window.onpopstate=function(e){if(e.state&&e.state.htmx){Wt();se(t,function(e){he(e,"htmx:restored",{document:ne(),triggerEvent:he})})}else{if(n){n(e)}}};E().setTimeout(function(){he(e,"htmx:load",{});e=null},0)});return Q}(); \ No newline at end of file diff --git a/public/js/htmx.preload.js b/public/js/htmx.preload.js deleted file mode 100644 index c4d22a6..0000000 --- a/public/js/htmx.preload.js +++ /dev/null @@ -1,418 +0,0 @@ -(function () { - /** - * This adds the "preload" extension to htmx. The extension will - * preload the targets of elements with "preload" attribute if: - * - they also have `href`, `hx-get` or `data-hx-get` attributes - * - they are radio buttons, checkboxes, select elements and submit - * buttons of forms with `method="get"` or `hx-get` attributes - * The extension relies on browser cache and for it to work - * server response must include `Cache-Control` header - * e.g. `Cache-Control: private, max-age=60`. - * For more details @see https://htmx.org/extensions/preload/ - */ - - htmx.defineExtension("preload", { - onEvent: function (name, event) { - // Process preload attributes on `htmx:afterProcessNode` - if (name === "htmx:afterProcessNode") { - // Initialize all nodes with `preload` attribute - const parent = event.target || event.detail.elt; - const preloadNodes = [ - ...(parent.hasAttribute("preload") ? [parent] : []), - ...parent.querySelectorAll("[preload]"), - ]; - preloadNodes.forEach(function (node) { - // Initialize the node with the `preload` attribute - init(node); - - // Initialize all child elements which has - // `href`, `hx-get` or `data-hx-get` attributes - node.querySelectorAll("[href],[hx-get],[data-hx-get]").forEach(init); - }); - return; - } - - // Intercept HTMX preload requests on `htmx:beforeRequest` and - // send them as XHR requests instead to avoid side-effects, - // such as showing loading indicators while preloading data. - if (name === "htmx:beforeRequest") { - const requestHeaders = event.detail.requestConfig.headers; - if ( - !( - "HX-Preloaded" in requestHeaders && - requestHeaders["HX-Preloaded"] === "true" - ) - ) { - return; - } - - event.preventDefault(); - // Reuse XHR created by HTMX with replaced callbacks - const xhr = event.detail.xhr; - xhr.onload = function () { - processResponse(event.detail.elt, xhr.responseText); - }; - xhr.onerror = null; - xhr.onabort = null; - xhr.ontimeout = null; - xhr.send(); - } - }, - }); - - /** - * Initialize `node`, set up event handlers based on own or inherited - * `preload` attributes and set `node.preloadState` to `READY`. - * - * `node.preloadState` can have these values: - * - `READY` - event handlers have been set up and node is ready to preload - * - `TIMEOUT` - a triggering event has been fired, but `node` is not - * yet being loaded because some time need to pass first e.g. user - * has to keep hovering over an element for 100ms for preload to start - * - `LOADING` means that `node` is in the process of being preloaded - * - `DONE` means that the preloading process is complete and `node` - * doesn't need a repeated preload (indicated by preload="always") - * @param {Node} node - */ - function init(node) { - // Guarantee that each node is initialized only once - if (node.preloadState !== undefined) { - return; - } - - if (!isValidNodeForPreloading(node)) { - return; - } - - // Initialize form element preloading - if (node instanceof HTMLFormElement) { - const form = node; - // Only initialize forms with `method="get"` or `hx-get` attributes - if ( - !( - (form.hasAttribute("method") && form.method === "get") || - form.hasAttribute("hx-get") || - form.hasAttribute("hx-data-get") - ) - ) { - return; - } - for (let i = 0; i < form.elements.length; i++) { - const element = form.elements.item(i); - init(element); - element.labels.forEach(init); - } - return; - } - - // Process node configuration from preload attribute - let preloadAttr = getClosestAttribute(node, "preload"); - node.preloadAlways = preloadAttr && preloadAttr.includes("always"); - if (node.preloadAlways) { - preloadAttr = preloadAttr.replace("always", "").trim(); - } - let triggerEventName = preloadAttr || "mousedown"; - - // Set up event handlers listening for triggering events - const needsTimeout = triggerEventName === "mouseover"; - node.addEventListener( - triggerEventName, - getEventHandler(node, needsTimeout), - ); - - // Add `touchstart` listener for touchscreen support - // if `mousedown` or `mouseover` is used - if (triggerEventName === "mousedown" || triggerEventName === "mouseover") { - node.addEventListener("touchstart", getEventHandler(node)); - } - - // If `mouseover` is used, set up `mouseout` listener, - // which will abort preloading if user moves mouse outside - // the element in less than 100ms after hovering over it - if (triggerEventName === "mouseover") { - node.addEventListener("mouseout", function (evt) { - if (evt.target === node && node.preloadState === "TIMEOUT") { - node.preloadState = "READY"; - } - }); - } - - // Mark the node as ready to be preloaded - node.preloadState = "READY"; - - // This event can be used to load content immediately - htmx.trigger(node, "preload:init"); - } - - /** - * Return event handler which can be called by event listener to start - * the preloading process of `node` with or without a timeout - * @param {Node} node - * @param {boolean=} needsTimeout - * @returns {function(): void} - */ - function getEventHandler(node, needsTimeout = false) { - return function () { - // Do not preload uninitialized nodes, nodes which are in process - // of being preloaded or have been preloaded and don't need repeat - if (node.preloadState !== "READY") { - return; - } - - if (needsTimeout) { - node.preloadState = "TIMEOUT"; - const timeoutMs = 100; - window.setTimeout(function () { - if (node.preloadState === "TIMEOUT") { - node.preloadState = "READY"; - load(node); - } - }, timeoutMs); - return; - } - - load(node); - }; - } - - /** - * Preload the target of node, which can be: - * - hx-get or data-hx-get attribute - * - href or form action attribute - * @param {Node} node - */ - function load(node) { - // Do not preload uninitialized nodes, nodes which are in process - // of being preloaded or have been preloaded and don't need repeat - if (node.preloadState !== "READY") { - return; - } - node.preloadState = "LOADING"; - - // Load nodes with `hx-get` or `data-hx-get` attribute - // Forms don't reach this because only their elements are initialized - const hxGet = - node.getAttribute("hx-get") || node.getAttribute("data-hx-get"); - if (hxGet) { - sendHxGetRequest(hxGet, node); - return; - } - - // Load nodes with `href` attribute - const hxBoost = getClosestAttribute(node, "hx-boost") === "true"; - if (node.hasAttribute("href")) { - const url = node.getAttribute("href"); - if (hxBoost) { - sendHxGetRequest(url, node); - } else { - sendXmlGetRequest(url, node); - } - return; - } - - // Load form elements - if (isPreloadableFormElement(node)) { - const url = - node.form.getAttribute("action") || - node.form.getAttribute("hx-get") || - node.form.getAttribute("data-hx-get"); - const formData = htmx.values(node.form); - const isStandardForm = !( - node.form.getAttribute("hx-get") || - node.form.getAttribute("data-hx-get") || - hxBoost - ); - const sendGetRequest = isStandardForm - ? sendXmlGetRequest - : sendHxGetRequest; - - // submit button - if (node.type === "submit") { - sendGetRequest(url, node.form, formData); - return; - } - - // select - const inputName = node.name || node.control.name; - if (node.tagName === "SELECT") { - Array.from(node.options).forEach((option) => { - if (option.selected) return; - formData.set(inputName, option.value); - const formDataOrdered = forceFormDataInOrder(node.form, formData); - sendGetRequest(url, node.form, formDataOrdered); - }); - return; - } - - // radio and checkbox - const inputType = - node.getAttribute("type") || node.control.getAttribute("type"); - const nodeValue = node.value || node.control?.value; - if (inputType === "radio") { - formData.set(inputName, nodeValue); - } else if (inputType === "checkbox") { - const inputValues = formData.getAll(inputName); - if (inputValues.includes(nodeValue)) { - formData[inputName] = inputValues.filter( - (value) => value !== nodeValue, - ); - } else { - formData.append(inputName, nodeValue); - } - } - const formDataOrdered = forceFormDataInOrder(node.form, formData); - sendGetRequest(url, node.form, formDataOrdered); - return; - } - } - - /** - * Force formData values to be in the order of form elements. - * This is useful to apply after alternating formData values - * and before passing them to a HTTP request because cache is - * sensitive to GET parameter order e.g., cached `/link?a=1&b=2` - * will not be used for `/link?b=2&a=1`. - * @param {HTMLFormElement} form - * @param {FormData} formData - * @returns {FormData} - */ - function forceFormDataInOrder(form, formData) { - const formElements = form.elements; - const orderedFormData = new FormData(); - for (let i = 0; i < formElements.length; i++) { - const element = formElements.item(i); - if (formData.has(element.name) && element.tagName === "SELECT") { - orderedFormData.append(element.name, formData.get(element.name)); - continue; - } - if ( - formData.has(element.name) && - formData.getAll(element.name).includes(element.value) - ) { - orderedFormData.append(element.name, element.value); - } - } - return orderedFormData; - } - - /** - * Send GET request with `hx-request` headers as if `sourceNode` - * target was loaded. Send alternated values if `formData` is set. - * - * Note that this request is intercepted and sent as XMLHttpRequest. - * It is necessary to use `htmx.ajax` to acquire correct headers which - * HTMX and extensions add based on `sourceNode`. But it cannot be used - * to perform the request due to side-effects e.g. loading indicators. - * @param {string} url - * @param {Node} sourceNode - * @param {FormData=} formData - */ - function sendHxGetRequest(url, sourceNode, formData = undefined) { - htmx.ajax("GET", url, { - source: sourceNode, - values: formData, - headers: { "HX-Preloaded": "true" }, - }); - } - - /** - * Send XML GET request to `url`. Send `formData` as URL params if set. - * @param {string} url - * @param {Node} sourceNode - * @param {FormData=} formData - */ - function sendXmlGetRequest(url, sourceNode, formData = undefined) { - const xhr = new XMLHttpRequest(); - if (formData) { - url += "?" + new URLSearchParams(formData.entries()).toString(); - } - xhr.open("GET", url); - xhr.setRequestHeader("HX-Preloaded", "true"); - xhr.onload = function () { - processResponse(sourceNode, xhr.responseText); - }; - xhr.send(); - } - - /** - * Process request response by marking node `DONE` to prevent repeated - * requests, except if preload attribute contains `always`, - * and load linked resources (e.g. images) returned in the response - * if `preload-images` attribute is `true` - * @param {Node} node - * @param {string} responseText - */ - function processResponse(node, responseText) { - node.preloadState = node.preloadAlways ? "READY" : "DONE"; - - if (getClosestAttribute(node, "preload-images") === "true") { - // Load linked resources - document.createElement("div").innerHTML = responseText; - } - } - - /** - * Gets attribute value from node or one of its parents - * @param {Node} node - * @param {string} attribute - * @returns { string | undefined } - */ - function getClosestAttribute(node, attribute) { - if (node == undefined) { - return undefined; - } - return ( - node.getAttribute(attribute) || - node.getAttribute("data-" + attribute) || - getClosestAttribute(node.parentElement, attribute) - ); - } - - /** - * Determines if node is valid for preloading and should be - * initialized by setting up event listeners and handlers - * @param {Node} node - * @returns {boolean} - */ - function isValidNodeForPreloading(node) { - // Add listeners only to nodes which include "GET" transactions - // or preloadable "GET" form elements - const getReqAttrs = ["href", "hx-get", "data-hx-get"]; - const includesGetRequest = (node) => - getReqAttrs.some((a) => node.hasAttribute(a)) || node.method === "get"; - const isPreloadableGetFormElement = - node.form instanceof HTMLFormElement && - includesGetRequest(node.form) && - isPreloadableFormElement(node); - if (!includesGetRequest(node) && !isPreloadableGetFormElement) { - return false; - } - - // Don't preload elements contained in