Compare commits

..

99 Commits

Author SHA1 Message Date
7dee0d1802 CSS fix
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m51s
2025-07-03 23:09:09 -06:00
8b38944954 Content updates and CSS fixes
All checks were successful
Docker Deploy / build-and-push (push) Successful in 4m3s
2025-07-03 00:25:58 -06:00
75e76fba8c Deps
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m31s
2025-07-03 00:04:12 -06:00
af5dbd1a64 LAST FIX
Some checks failed
Docker Deploy / build-and-push (push) Has been cancelled
2025-07-03 00:03:50 -06:00
5901c225c1 Ok THIS nix shell should work across architectures now... that was a huge issue earlier.
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m35s
2025-07-02 10:32:06 -06:00
cf88aa388e Updated shell.nix
All checks were successful
Docker Deploy / build-and-push (push) Successful in 4m11s
2025-07-02 01:40:03 -06:00
702062ab9a Update resume and make pdf template easier to modify
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m46s
2025-06-30 14:47:19 -06:00
1ffac7f118 README Updates
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m48s
2025-06-30 14:27:56 -06:00
3c6255a5a1 smol change
All checks were successful
Docker Deploy / build-and-push (push) Successful in 4m13s
2025-06-30 14:20:06 -06:00
6eda2edaa4 More optimizations
Some checks failed
Docker Deploy / build-and-push (push) Has been cancelled
2025-06-30 14:16:35 -06:00
831985bb3f fixed build
All checks were successful
Docker Deploy / build-and-push (push) Successful in 6m11s
2025-06-30 14:08:49 -06:00
9eb964ff06 Switched to playwright... puppeteer is kinda clunky
All checks were successful
Docker Deploy / build-and-push (push) Successful in 7m19s
2025-06-30 13:59:38 -06:00
0f6054701b Using nix for cross platform dev
All checks were successful
Docker Deploy / build-and-push (push) Successful in 6m34s
2025-06-30 13:49:26 -06:00
5649c9592f Deps
All checks were successful
Docker Deploy / build-and-push (push) Successful in 6m23s
2025-06-27 15:45:02 -06:00
9dbdd265ba Removed spotify... its hard to maintain and also fuck spotify
Some checks failed
Docker Deploy / build-and-push (push) Has been cancelled
2025-06-27 15:44:43 -06:00
6c2f4e1b81 Rename page header
All checks were successful
Docker Deploy / build-and-push (push) Successful in 7m40s
2025-06-26 23:43:15 -06:00
607ce7266d :)
Some checks failed
Docker Deploy / build-and-push (push) Has been cancelled
2025-06-26 23:42:07 -06:00
0d43c3af47 Fixed resume gen
Some checks failed
Docker Deploy / build-and-push (push) Has been cancelled
2025-06-26 23:41:29 -06:00
b4298e78ef ??
All checks were successful
Docker Deploy / build-and-push (push) Successful in 6m56s
2025-06-26 18:57:46 -06:00
43c96c73b2 Fixed term!
Some checks failed
Docker Deploy / build-and-push (push) Has been cancelled
2025-06-26 16:19:52 -06:00
f89d32d6ce Overhauled resume system
All checks were successful
Docker Deploy / build-and-push (push) Successful in 5m3s
2025-06-26 16:06:15 -06:00
5f7490d133 Fixed tags in posts
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m15s
2025-06-20 00:09:18 -06:00
a6336e293c SSE Fixes
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m27s
2025-06-19 23:48:18 -06:00
41614a49a8 Fixed spotify
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m26s
2025-06-19 23:34:44 -06:00
7161584dcd Bump astro version and moved to stable responsive images
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m22s
2025-06-19 23:17:57 -06:00
57238c9805 Fixxxx
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m34s
2025-06-15 00:34:01 -06:00
9babbd0368 img optimizations
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m40s
2025-06-15 00:22:56 -06:00
ad7cc25766 fixed terminal
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m34s
2025-06-13 00:15:30 -06:00
2a79d0da67 Pagespeed hates this one trick!
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m33s
2025-06-12 23:58:06 -06:00
28f41ac94d Optimized images and fixed tooltips
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m43s
2025-06-12 23:33:23 -06:00
9577cd8bc6 Icon handling was gross before. Fixing
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m22s
2025-06-12 16:24:55 -06:00
df33b94e38 a11y
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m36s
2025-06-12 16:16:38 -06:00
2ad6585a07 Spotify fallback
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m44s
2025-06-12 14:05:10 -06:00
55360c5e5d Delete .DS_Store
Some checks failed
Docker Deploy / build-and-push (push) Failing after 4m17s
2025-06-12 18:49:20 +00:00
b673932ba3 bump version
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m13s
2025-06-12 11:09:52 -06:00
ab2eb7eeac Major re-work!
Some checks failed
Docker Deploy / build-and-push (push) Has been cancelled
2025-06-12 11:09:24 -06:00
324449dd59 Refactor
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m35s
2025-06-12 01:13:07 -06:00
bfa3784f03 Add talks
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m45s
2025-06-12 00:41:44 -06:00
6b6b571dd6 Fixed terminal
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m34s
2025-06-09 12:44:53 -06:00
4985310ec2 Update README.md
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m46s
2025-06-09 06:20:13 +00:00
aa7dc5a339 Update README.md
Some checks failed
Docker Deploy / build-and-push (push) Failing after 1m34s
2025-06-09 06:13:34 +00:00
c5a6467de7 Fixed sl 2025-06-04 10:47:12 -06:00
ec2c2b8a8f Fix tab complete 2025-06-04 10:45:03 -06:00
146eff0a5f Merge pull request 'Adding Terminal' (#2) from terminal into main
Reviewed-on: atridad/atri.dad#2
2025-06-04 06:48:24 +00:00
3347ec2082 Added a terminal 2025-06-04 00:47:42 -06:00
5b2c4b0ede Removed. 2025-06-03 15:32:23 -06:00
69742a311c Fixed resume rendering (was bad) 2025-06-03 15:30:49 -06:00
5681e43341 oops 2025-06-03 15:13:30 -06:00
35a6992f55 fixed builds 2025-06-03 14:56:47 -06:00
5b1e13481b oops 2025-06-03 14:46:08 -06:00
5f518523e9 Removed garbage 2025-06-03 14:40:15 -06:00
3218432790 Failsafe 2025-06-03 14:33:12 -06:00
7e2a8e3bf7 Spotify integration 2025-06-03 14:31:38 -06:00
9491ef1c40 Create enshittified-dev-tools.md 2025-06-03 01:01:02 -06:00
61be83c906 Fixed home icons 2025-05-30 16:21:26 -06:00
b3c02e8098 Nav fix 2025-05-28 01:18:20 -06:00
b2426a6071 Logo and responsiveness changes 2025-05-28 01:07:13 -06:00
0b02d6d5a0 Updated Resume 2025-05-27 17:38:26 -06:00
e6b50d5ea5 Update resume animation 2025-05-23 00:32:49 -06:00
fc1a4e2560 Resume update 2025-05-22 12:51:37 -06:00
321fa66338 linter fixes 2025-05-20 00:43:02 -06:00
e0da76f503 RSS fix 2025-05-19 01:16:25 -06:00
1465b7dc24 Update .github/workflows/deploy.yml 2025-05-19 05:50:35 +00:00
44499ec6aa oops 2025-05-18 23:23:47 -06:00
f2b09dad7b Merge pull request 'Migrate to Astro' (#1) from fresh-2.0-migrate into main
Reviewed-on: atridad/atri.dad#1
2025-05-19 05:22:13 +00:00
dba6ebd497 Finalized 2025-05-18 23:21:12 -06:00
3d271e3c7c readme 2025-05-18 11:31:20 -06:00
066c1b4115 Posts working 2025-05-18 11:30:19 -06:00
6ceb4918f7 Added resume 2025-05-18 00:55:19 -06:00
d86ae2f16b Got the homepage sorted 2025-05-17 22:42:48 -06:00
b1cd87f20b Depsssss 2025-05-15 23:49:59 -06:00
4c094944db Update README.md 2025-05-14 21:22:45 +00:00
36fc01dcc4 oop 2025-05-04 00:39:30 -06:00
224fd31839 Resume page 2025-05-04 00:38:56 -06:00
68a817c0f4 deps 2025-05-03 23:28:53 -06:00
df3fcd669d Mobile fixes 2025-04-28 03:44:24 -06:00
5a9a02b772 ??? 2025-04-28 02:18:59 -06:00
ae10c14cc8 Chat changes 2025-04-27 10:53:03 -06:00
871000c333 Added a weird little chat for shits and giggles 2025-04-26 01:34:49 -06:00
a6a17e8969 Sizing fixes for mobile 2025-04-25 03:00:15 -06:00
16dd4463ae New article and homepage fix 2025-04-25 00:40:55 -06:00
9dc9225591 All gucci! 2025-04-24 20:27:25 -06:00
f859a12d2c Remove the weird ass cache stuff. Thanks stack overflow! 2025-04-24 13:14:42 -06:00
a50e73bb55 againagain 2025-04-24 13:03:04 -06:00
6194678607 This 2025-04-24 12:58:25 -06:00
67f29ec389 ? 2025-04-24 12:46:27 -06:00
5281eb71ab ?!?!?!?!?!?! 2025-04-24 12:20:48 -06:00
15b45f2a10 oeufx2 2025-04-24 12:16:29 -06:00
a0edba63bc oeuf 2025-04-24 12:13:58 -06:00
f33dc130b8 Does this work? 2025-04-24 12:03:03 -06:00
ee44847974 projects 2025-04-24 02:41:50 -06:00
8f2f8c3ff2 Posts 2025-04-24 02:24:42 -06:00
261aab9a4b Deno re-write 2025-04-23 01:15:21 -06:00
88aa5b27d7 More CSS fixes 2025-03-31 03:57:59 -06:00
9bc4df5d18 Oops 2025-03-31 03:50:38 -06:00
0a5d5df468 No more building CSS 2025-03-31 03:49:05 -06:00
2560ff159c jk 2025-03-24 01:30:59 -06:00
497abfe83f ???? 2025-03-24 01:22:20 -06:00
c812af90ad Deps 2025-03-24 01:16:24 -06:00
120 changed files with 9615 additions and 4616 deletions

View File

@ -1,7 +0,0 @@
**/atri.dad
**/.env
**/airbin
**/tmp
**/*.rdb
fly.toml
tailwind.config.*.js

2
.gitattributes vendored
View File

@ -1,2 +0,0 @@
*.css linguist-vendored
*.js linguist-vendored

View File

@ -28,7 +28,7 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
platforms: linux/amd64
push: true
tags: |
${{ secrets.REPO_HOST }}/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}

29
.gitignore vendored
View File

@ -1,9 +1,24 @@
atri.dad
main
# build output
dist/
# generated types
.astro/
# dependencies
node_modules/
# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# environment variables
.env
airbin
tmp/
*.rdb
.env.production
# macOS-specific files
.DS_Store
tailwind.config.js
lib/stylegen/tw
# jetbrains setting folder
.idea/

4
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}

View File

@ -1,44 +1,50 @@
FROM --platform=$BUILDPLATFORM golang:1.24.0-alpine AS builder
FROM node:24-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
# Install Chromium and dependencies for Playwright in a single layer
RUN apk add --no-cache \
chromium \
nss \
freetype \
freetype-dev \
harfbuzz \
ca-certificates \
ttf-freefont \
curl \
&& rm -rf /var/cache/apk/*
# Copy source code and Makefile
# Tell Playwright to use the installed Chromium
ENV PLAYWRIGHT_BROWSERS_PATH=/usr/bin
ENV PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium-browser
# Install pnpm
RUN npm i -g pnpm
# Copy package files
COPY package.json pnpm-lock.yaml ./
# Install all dependencies (including dev dependencies for build)
RUN pnpm install --frozen-lockfile
# Copy source code
COPY . .
# Install required tools and make scripts executable
RUN apk add --no-cache upx make bash && \
chmod +x /app/lib/stylegen/gen.sh
# Build the application
RUN pnpm run build
# Create necessary directories
RUN mkdir -p /app/public/css
# Install only production dependencies and clean up
RUN pnpm install --prod --frozen-lockfile \
&& pnpm store prune \
&& npm cache clean --force
# Generate assets and build with optimizations
SHELL ["/bin/bash", "-c"]
# Set environment variables
ENV HOST=0.0.0.0 \
PORT=4321 \
NODE_ENV=production
# 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
# Expose port
EXPOSE 4321
# 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"]
# Start the application
CMD ["node", "./dist/server/entry.mjs"]

232
LICENSE
View File

@ -1,232 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The GNU 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 <https://www.gnu.org/licenses/>.
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 <https://www.gnu.org/licenses/>.
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 <https://www.gnu.org/philosophy/why-not-lgpl.html>.

134
Makefile
View File

@ -1,134 +0,0 @@
# Emoji
CHECK :=
BUILD := 🔨
CLEAN := 🧹
RUN := 🚀
CSS := 🎨
TEST := 🧪
DOCKER := 🐳
WARN := ⚠️
DOCS := 📚
# Variables
BINARY_NAME := atri.dad
DOCKER_IMAGE := atri-dot-dad
GO_FILES := $(wildcard *.go)
CSS_INPUT := lib/stylegen/base.css
CSS_OUTPUT := public/css/styles.css
# 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 stylegen docker-dev docker-build docker-run test help reset ensure-swag
help:
@echo "Available commands:"
@echo "make clean - Remove build artifacts"
@echo "make reset - Clean and reset the project to initial state"
@echo "make build - Generate CSS, 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; \
}
reset:
@echo "$(CLEAN) Performing complete project reset..."
@rm -f $(BINARY_NAME)
@rm -f $(CSS_OUTPUT)
@rm -rf public/css/*
@rm -f tailwind.config.js
@rm -rf docs/docs.go docs/swagger.json docs/swagger.yaml
@go clean -cache -testcache -modcache
@rm -rf $(BASE_PATH)/tw # Remove the 'tw' directory
@echo "$(CHECK) Project reset complete"
clean:
@echo "$(CLEAN) Cleaning build artifacts..."
@rm -f $(BINARY_NAME)
@rm -f $(CSS_OUTPUT)
@rm -rf $(BASE_PATH)/lib/stylegen/tw # Remove the 'tw' directory
@echo "$(CHECK) Cleanup complete"
stylegen:
@echo "$(CSS) Generating CSS styles..."
@echo "Current working directory: $$(pwd)"
@echo "Contents of current directory:"
@ls -la
@echo "\nContents of lib/stylegen:"
@ls -la lib/stylegen
@chmod +x $(BASE_PATH)/lib/stylegen/gen.sh
@$(BASE_PATH)/lib/stylegen/gen.sh \
-e "html" \
-d "$(BASE_PATH)/pages/templates" \
-o "$(BASE_PATH)/public/css"
@echo "$(CHECK) CSS generation complete"
swaggergen: ensure-swag
@echo "$(DOCS) Generating Swagger documentation..."
@swag init
@echo "$(CHECK) Swagger docs generated"
# Combined generation target
generate: stylegen 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

191
README.md
View File

@ -1,21 +1,178 @@
# atri.dad
This is my personal website!
# Personal Website
## Stack:
- Backend: Golang + Echo
- Rendering: Golang templates
- Style: TailwindCSS + DaisyUI
- Content format: Markdown
My personal website built with Astro and Preact!
## Requirements:
- Golang 1.23.1
## Features
## 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`
- **Resume**
- **Blog Posts**
- **Projects**
- **Talks**
- **Terminal View**
## 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
** Nix shell is required for local development! Install it on your OS of choice OR use NixOS!
## Development
```bash
# Install dependencies
pnpm i
# Start development server
pnpm shell # Enter nix-shell
pnpm dev
# Build for production
pnpm build
```
## Resume Configuration
The resume system supports multiple sections that can be enabled, disabled, and customized.
### Available Resume Sections
| Section | Required Fields |
|---------|-----------------|
| **basics** | `name`, `email`, `profiles` |
| **summary** | `content` |
| **experience** | `company`, `position`, `location`, `date`, `description` |
| **education** | `institution`, `degree`, `field`, `date` |
| **skills** | `name`, `level` (1-5) |
| **volunteer** | `organization`, `position`, `date` |
| **awards** | `title`, `organization`, `date` |
| **profiles** | `network`, `username`, `url` |
### Section Configuration
Each section can be configured in `src/config/data.ts`:
```typescript
export const resumeConfig: ResumeConfig = {
tomlFile: "/files/resume.toml",
layout: {
leftColumn: ["experience", "volunteer", "awards"],
rightColumn: ["skills", "education"],
},
sections: {
summary: {
title: "Professional Summary",
enabled: true,
},
experience: {
title: "Work Experience",
enabled: true,
},
awards: {
title: "Awards & Recognition",
enabled: true,
},
// ... other sections
},
};
```
### Layout Configuration
The resume layout is fully customizable. You can control which sections appear in which column and their order:
```typescript
layout: {
leftColumn: ["experience", "volunteer", "awards"],
rightColumn: ["skills", "education"],
}
```
**Available sections for layout:**
- `experience` - Work experience
- `education` - Educational background
- `skills` - Technical and professional skills
- `volunteer` - Volunteer work
- `awards` - Awards and recognition
**Layout Rules:**
- Sections can be placed in either column
- Order within each column is determined by array order
- Missing sections are automatically excluded
- The `summary` section always appears at the top (full width)
- The `profiles` section appears in the header area
**Example Layouts:**
*Skills-focused layout:*
```typescript
layout: {
leftColumn: ["skills", "education"],
rightColumn: ["experience", "awards", "volunteer"],
}
```
*Experience-heavy layout:*
```typescript
layout: {
leftColumn: ["experience"],
rightColumn: ["skills", "education", "volunteer", "awards"],
}
```
### Resume Data Format (TOML)
Create a `resume.toml` file in the `public/files/` directory:
```toml
[basics]
name = "Your Name"
email = "your.email@example.com"
[[basics.profiles]]
network = "GitHub"
username = "yourusername"
url = "https://github.com/yourusername"
[[basics.profiles]]
network = "LinkedIn"
username = "yourname"
url = "https://linkedin.com/in/yourname"
[summary]
content = "Your professional summary here..."
[[experience]]
company = "Company Name"
position = "Job Title"
location = "City, State"
date = "2020 - Present"
description = [
"Achievement or responsibility 1",
"Achievement or responsibility 2"
]
url = "https://company.com"
[[education]]
institution = "University Name"
degree = "Bachelor of Science"
field = "Computer Science"
date = "2016 - 2020"
details = [
"Relevant coursework or achievements"
]
[[skills]]
name = "JavaScript"
level = 4
[[skills]]
name = "Python"
level = 5
[[volunteer]]
organization = "Organization Name"
position = "Volunteer Position"
date = "2019 - Present"
[[awards]]
title = "Award Title"
organization = "Awarding Organization"
date = "2023"
description = "Brief description of the award"
```

View File

@ -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!")
}

View File

@ -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, `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`)
}

View File

@ -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))
}

View File

@ -1,77 +0,0 @@
package api
import (
"fmt"
"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()
c.Response().Header().Set(echo.HeaderContentType, "text/event-stream")
c.Response().Header().Set(echo.HeaderConnection, "keep-alive")
c.Response().Header().Set(echo.HeaderCacheControl, "no-cache")
// Get origin from request
origin := c.Request().Header.Get(echo.HeaderOrigin)
// Only allow specific origins
if origin == "https://atri.dad" || origin == "http://localhost:3000" {
c.Response().Header().Set(echo.HeaderAccessControlAllowOrigin, origin)
c.Response().Header().Set(echo.HeaderAccessControlAllowCredentials, "true")
}
// Create a channel to receive messages from the lib.SSEServer
clientChan := make(chan string)
// Add the client to the lib.SSEServer
lib.SSEServer.AddClient(channel, clientChan)
defer func() {
// Remove the client from the lib.SSEServer when the connection is closed
lib.SSEServer.RemoveClient(channel, clientChan)
}()
// Create a ticker that fires every 15 seconds
ticker := time.NewTicker(30 * time.Second)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
// If the client has disconnected, stop the loop
return nil
case <-ticker.C:
// Every 30 seconds, send a comment to keep the connection alive
if _, err := c.Response().Write([]byte(": keep-alive\n\n")); err != nil {
return err
}
c.Response().Flush()
case msg := <-clientChan:
// Handle incoming messages from the lib.SSEServer
data := fmt.Sprintf("data: %s\n\n", msg)
if _, err := c.Response().Write([]byte(data)); err != nil {
return err
}
c.Response().Flush()
}
}
}

View File

@ -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)
}

View File

@ -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"})
}

64
astro.config.mjs Normal file
View File

@ -0,0 +1,64 @@
// @ts-check
import { defineConfig } from "astro/config";
import tailwindcss from "@tailwindcss/vite";
import preact from "@astrojs/preact";
import node from "@astrojs/node";
import icon from "astro-icon";
import mdx from "@astrojs/mdx";
// https://astro.build/config
export default defineConfig({
site: "https://atri.dad",
redirects: {
"/feed": "/rss.xml",
},
output: "server",
vite: {
plugins: [tailwindcss()],
},
// Configure default image behavior
image: {
responsiveStyles: true,
layout: "constrained",
objectFit: "cover",
objectPosition: "center",
},
integrations: [
preact(),
mdx(),
icon({
include: {
mdi: [
"clock",
"tag",
"arrow-right",
"link",
"email",
"rss",
"download",
"web",
"arrow-left",
],
"simple-icons": [
"gitea",
"bluesky",
"react",
"typescript",
"astro",
"go",
"postgresql",
"redis",
"docker",
"github",
"linkedin",
],
},
}),
],
adapter: node({
mode: "standalone",
}),
});

View File

@ -1,6 +0,0 @@
package contentfs
import "embed"
//go:embed *
var FS embed.FS

View File

@ -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.

View File

@ -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).

View File

@ -1,10 +0,0 @@
services:
app:
build:
context: .
dockerfile: Dockerfile
image: atridad:latest
command: ["/app"]
pull_policy: build
ports:
- "3000:3000"

View File

@ -1,6 +1,8 @@
services:
app:
image: ${IMAGE}
command: ["/app"]
ports:
- "3000:3000"
- "${APP_PORT}:4321"
environment:
NODE_ENV: production
restart: unless-stopped

View File

@ -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)
}

View File

@ -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"
}
}
}
}
}
}
}
}

View File

@ -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"

47
go.mod
View File

@ -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.24.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.0 // 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.0 // 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.35.0 // indirect
golang.org/x/text v0.22.0 // indirect
golang.org/x/time v0.10.0 // indirect
golang.org/x/tools v0.30.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.35.0 // indirect
golang.org/x/sys v0.30.0 // indirect
gopkg.in/yaml.v2 v2.4.0
)

105
go.sum
View File

@ -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.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
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.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
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.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs=
golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
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.24.0 h1:AN7zRgVsbvmTfNyqIbbOraYL8mSwcKncEj8ofjgzcMQ=
golang.org/x/image v0.24.0/go.mod h1:4b/ITuLfqYq1hqZcjofwctIhi7sZh2WaCjvsBNjjya8=
golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM=
golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
golang.org/x/time v0.10.0 h1:3usCWA8tQn0L8+hFJQNgzpWbd89begxN66o1Ojdn5L4=
golang.org/x/time v0.10.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY=
golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY=
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=

View File

@ -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")
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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,
}

View File

@ -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
}

View File

@ -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)
}

View File

@ -1,29 +0,0 @@
@import "tailwindcss";
@layer base {
html,
container,
body {
height: 100% !important;
width: 100% !important;
overflow-y: auto !important;
position: fixed !important;
}
main {
margin-left: auto !important;
margin-right: auto !important;
width: 100% !important;
max-width: 100% !important;
text-align: center !important;
}
.container {
margin-left: auto !important;
margin-right: auto !important;
display: flex !important;
flex-direction: column !important;
align-items: center !important;
justify-content: center !important;
}
}

View File

@ -1,112 +0,0 @@
#!/usr/bin/env bash
# Define the version of the binary to download
VERSION="v4.0.9"
# Parse command-line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-e|--extensions)
EXTENSIONS="$2"
shift; shift
;;
-d|--directory)
DIRECTORY="$2"
shift; shift
;;
-o|--output-dir)
OUTPUT_DIR="$2"
shift; shift
;;
*)
echo "Unknown argument: $1"
exit 1
;;
esac
done
# Get the directory where this script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Script directory: $SCRIPT_DIR"
OS=$(uname -s)
ARCH=$(uname -m)
# Normalize OS and ARCH identifiers
case $OS in
"Darwin")
OS="macos"
;;
"Linux")
OS="linux"
;;
"CYGWIN"*|"MINGW"*|"MSYS"*)
OS="windows"
;;
*)
echo "Unknown operating system: $OS"
exit 1
;;
esac
case $ARCH in
"x86_64")
ARCH="x64"
;;
"arm64"|"aarch64")
ARCH="arm64"
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac
echo "Detected OS: $OS"
echo "Detected Architecture: $ARCH"
# Function to construct the binary download URL based on version, OS, and architecture
get_binary_url() {
echo "https://github.com/tailwindlabs/tailwindcss/releases/download/$VERSION/tailwindcss-$OS-$ARCH"
}
# Create the 'tw' directory for storing the downloaded binary
TW_DIR="${SCRIPT_DIR}/tw"
mkdir -p "$TW_DIR"
# Set the binary path
BINARY="${TW_DIR}/tailwindcss-${OS}-${ARCH}"
# Check if the binary is already downloaded, otherwise download it
if [ ! -f "$BINARY" ]; then
echo "Binary not found, downloading version $VERSION..."
DOWNLOAD_URL=$(get_binary_url)
if [ -z "$DOWNLOAD_URL" ]; then
echo "No suitable release found for this OS and architecture."
exit 1
fi
# Download the binary
curl -L "$DOWNLOAD_URL" -o "$BINARY"
echo "Downloaded binary to: $BINARY"
fi
# Make the binary executable
chmod +x "$BINARY"
echo "Using binary: $BINARY"
echo "Extensions: $EXTENSIONS"
echo "Directory: $DIRECTORY"
echo "Output Directory: $OUTPUT_DIR"
# Generate the minified version for production
echo "Generating minified CSS for production..."
"$BINARY" -i "${SCRIPT_DIR}/base.css" -o "${OUTPUT_DIR}/styles.css" --minify
# Create empty daisyui.css and themes.css files if they don't exist
touch "${OUTPUT_DIR}/daisyui.css"
touch "${OUTPUT_DIR}/themes.css"
echo "All CSS files generated"

View File

@ -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
}

102
main.go
View File

@ -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)
}

41
package.json Normal file
View File

@ -0,0 +1,41 @@
{
"name": "atridotdad",
"type": "module",
"version": "1.0.0",
"scripts": {
"dev": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro",
"shell": "nix-shell"
},
"dependencies": {
"@astrojs/mdx": "^4.3.0",
"@astrojs/node": "^9.2.2",
"@astrojs/preact": "^4.1.0",
"@astrojs/rss": "^4.0.12",
"@iarna/toml": "^2.2.5",
"@preact/signals": "^2.2.1",
"@tailwindcss/typography": "^0.5.16",
"@tailwindcss/vite": "^4.1.11",
"astro": "^5.10.2",
"astro-icon": "^1.1.5",
"lucide-preact": "^0.525.0",
"playwright": "^1.53.2",
"preact": "^10.26.9",
"sharp": "^0.34.2",
"tailwindcss": "^4.1.11"
},
"devDependencies": {
"@iconify-json/mdi": "^1.2.3",
"@iconify-json/simple-icons": "^1.2.41",
"daisyui": "^5.0.43"
},
"pnpm": {
"onlyBuiltDependencies": [
"esbuild",
"sharp",
"puppeteer"
]
}
}

View File

@ -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)
}

File diff suppressed because one or more lines are too long

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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)
}

View File

@ -1,53 +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"}}
<h1 class="text-4xl font-extrabold text-white sm:text-8xl">
<span class="bg-gradient-to-r from-pink-500 to-blue-500 bg-clip-text text-transparent">{{.Title}}</span>
</h1>
<h2 class="text-2xl font-extrabold tracking-tight text-white sm:text-[2rem]">
{{.Subtitle}}
</h2>
<span>
<h2 class="mb-2 text-xl text-white sm:text-[1.5rem]">Places I exist:</h2>
<div class="flex flex-row flex-wrap items-center justify-center gap-4 text-center">
{{range .Socials}}
{{template "iconlinks" .}}
{{end}}
</div>
</span>
<span>
<h2 class="mb-2 text-xl text-white sm:text-[1.5rem]">Stuff I Use:</h2>
<div class="flex flex-row flex-wrap items-center justify-center gap-4 text-center">
{{range .Tech}}
{{template "iconlinks" .}}
{{end}}
</div>
</span>
<div class="flex flex-row flex-wrap gap-2 mx-auto justify-center">
{{range .ButtonsLinks}}
{{template "buttonlinks" .}}
{{end}}
</div>
{{end}}
{{define "foot"}}
{{end}}

View File

@ -1,28 +0,0 @@
{{define "base"}}
<!DOCTYPE html>
<html lang="en" data-theme="night">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/public/favicon.ico" />
<title>{{template "title" .}}</title>
<meta name="description" content="{{template "description" .}}">
<script defer src="https://analytics.atri.dad/script.js" data-website-id="0206740c-245f-402a-b433-125d6d48945a"></script>
<link href="/public/css/daisyui.css" rel="stylesheet" type="text/css" />
<link href="/public/css/themes.css" rel="stylesheet" type="text/css" />
<link href="/public/css/styles.css" rel="stylesheet" type="text/css" />
{{template "head" .}}
</head>
<body class="block h-[100%]" hx-ext="preload">
{{template "header" .}}
<main class="container flex flex-col items-center justify-center gap-3 sm:gap-6 p-4 text-center min-h-[calc(100%-64px)]">
{{template "main" .}}
</main>
<script src="/public/js/htmx.base.js"></script>
<script src="/public/js/htmx.preload.js"></script>
{{template "foot" .}}
</body>
</html>
{{end}}

View File

@ -1,90 +0,0 @@
{{define "post"}}
<!DOCTYPE html>
<html lang="en" data-theme="night">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/public/favicon.ico" />
<title>{{template "title" .}}</title>
<meta name="description" content="{{template "description" .}}">
<script defer src="https://analytics.atri.dad/script.js" data-website-id="0206740c-245f-402a-b433-125d6d48945a"></script>
<link href="/public/css/daisyui.css" rel="stylesheet" type="text/css" />
<link href="/public/css/styles.css" rel="stylesheet" type="text/css" />
<link href="/public/css/themes.css" rel="stylesheet" type="text/css" />
<link href="/public/css/markdown.css" rel="stylesheet" type="text/css" />
{{template "head" .}}
</head>
<body class="block h-[100%]">
{{template "header" .}}
<main class="mx-auto p-4 max-w-3xl">
<article>
<h1 class="mx-auto text-2xl sm:text-4xl font-bold tracking-tight text-center mb-4 max-w-[65ch]">{{.Name}}</h1>
<div class="flex flex-row flex-wrap justify-center gap-4 mb-6">
{{if .Date}}
<p>
<div class="flex flex-row flex-wrap items-center gap-1 text-md">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
class="lucide lucide-clock-4">
<circle cx="12" cy="12" r="10" />
<polyline points="12 6 12 12 16 14" />
</svg>
{{.Date}}
</div>
</p>
{{end}}
{{if .Tags}}
<div class="flex flex-row flex-wrap text-center items-center justify-center gap-1">
{{range .Tags}}
<div class="badge badge-accent">#{{.}}</div>
{{end}}
</div>
{{end}}
<div id="svgContainer" style="display: none;">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
class="lucide lucide-check-circle">
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" />
<path d="m9 11 3 3L22 4" />
</svg>
</div>
<button id="copyButton" aria-label="Copy Link to Post" hx-get="/api/post/copy" hx-swap="innerHTML"
hx-trigger="click delay:3s"
_='on click put #svgContainer.innerHTML into me.innerHTML then call navigator.clipboard.writeText(window.location.href)'>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
class="lucide lucide-copy">
<rect width="14" height="14" x="8" y="8" rx="2" ry="2" />
<path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />
</svg>
</button>
<a href="/posts" class="btn btn-primary btn-outline" preload="mouseover">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
class="lucide lucide-undo-2">
<path d="M9 14 4 9l5-5" />
<path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5v0a5.5 5.5 0 0 1-5.5 5.5H11" />
</svg>
Back
</a>
</div>
<hr class="my-6 border-t border-white w-full max-w-2xl mx-auto" />
<div class="markdown text-left mx-auto max-w-2xl">
{{template "main" .}}
</div>
</article>
</main>
<script src="/public/js/htmx.base.js"></script>
<script src="/public/js/htmx.preload.js"></script>
{{template "foot" .}}
</body>
</html>
{{end}}

View File

@ -1,37 +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}}
<section class="flex flex-row flex-wrap gap-2 justify-center align-middle">
{{range .Papers}}
{{template "cardlinks" .}}
{{end}}
</section>
{{end}}
{{if not .Papers}}
<section class="flex flex-row flex-wrap gap-2 justify-center align-middle">
<h2 class="text-2xl font-extrabold tracking-tight text-white sm:text-[2rem]">
Nothing to see here (yet)!
</h2>
</section>
{{end}}
{{end}}
{{define "foot"}}
{{end}}

View File

@ -1,15 +0,0 @@
{{define "buttonlinks"}}
{{if eq true .Internal}}
<a class="btn btn-primary btn-outline btn-md lg:btn-lg" href={{.Href}} preload="mouseover">
{{.Name}}
</a>
{{else}}
<a class="btn btn-primary btn-outline btn-md lg:btn-lg" href={{.Href}} target="_blank" rel="noreferrer">
{{.Name}}
</a>
{{end}}
{{end}}

View File

@ -1,55 +0,0 @@
{{define "cardlinks"}}
<div class="card card-compact w-64 bg-secondary shadow-xl">
<div class="card-body text-base-100 flex flex-col">
<h2 class="card-title text-base-100">{{.Name}}</h2>
{{if .Description}}
<p>{{.Description}}</p>
{{end}}
{{if .Date}}
<p>
<div class="flex flex-row flex-wrap items-center gap-1 text-md">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-clock-4"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
{{.Date}}
</div>
</p>
{{end}}
{{if .Tags}}
<div class="flex flex-row flex-wrap text-center items-center justify-center gap-1">
{{range .Tags}}
<div class="badge badge-accent">#{{.}}</div>
{{end}}
</div>
{{end}}
{{if .Href}}
<div class="card-actions justify-end">
{{if eq true .Internal}}
<a
role="button"
href={{.Href}}
aria-label={{.Name}}
class="btn btn-circle btn-base-100 btn-outline"
preload="mouseover"
>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-right"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg>
</a>
{{else}}
<a
role="button"
href={{.Href}}
aria-label={{.Name}}
class="btn btn-circle btn-base-100 btn-outline"
target="_blank"
rel="noopener noreferrer"
>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>
</a>
{{end}}
</div>
{{end}}
</div>
</div>
{{end}}

View File

@ -1,4 +0,0 @@
{{define "header"}}
<div class="fill-green-500 tooltip tooltip-top badge badge-success"></div>
{{end}}

View File

@ -1,21 +0,0 @@
{{define "header"}}
<header class="navbar bg-base-100">
<div class="navbar-start">
<a class="btn btn-ghost normal-case text-lg sm:text-xl text-white" href="/">{{template "navcontent".}}</a>
</div>
<div class="navbar-end z-50">
<div class="dropdown dropdown-end">
<label tabindex="0" class="btn btn-sm btn-ghost text-white">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-menu"><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></svg>
</label>
<ul
tabindex="0"
class="menu menu-sm dropdown-content gap-2 mt-3 p-2 shadow-md bg-base-100 rounded-box"
preload="mouseover"
>
{{template "navitems" .}}
</ul>
</div>
</div>
</header>
{{end}}

View File

@ -1,5 +0,0 @@
{{define "iconlinks"}}
<a class="fill-white hover:fill-pink-500" href={{.Href}} target="_blank" rel="me" aria-label={{.Name}}>
{{.Icon}}
</a>
{{end}}

View File

@ -1,20 +0,0 @@
{{define "navitems"}}
<li>
<a class="no-underline" href="/"> Home </a>
</li>
<li>
<a class="no-underline" href="/projects"> Projects </a>
</li>
<li>
<a class="no-underline" href="/papers"> Papers </a>
</li>
<li>
<a class="no-underline" href="/talks"> Talks </a>
</li>
<li>
<a class="no-underline" href="/posts"> Posts </a>
</li>
<li>
<a class="no-underline" href="/tools"> Tools </a>
</li>
{{end}}

View File

@ -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"}}
<script src="/public/js/hyperscript.js"></script>
{{end}}

View File

@ -1,37 +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}}
<section class="flex flex-row flex-wrap gap-2 justify-center align-middle">
{{range .Posts}}
{{template "cardlinks" .}}
{{end}}
</section>
{{end}}
{{if not .Posts}}
<section class="flex flex-row flex-wrap gap-2 justify-center align-middle">
<h2 class="text-2xl font-extrabold tracking-tight text-white sm:text-[2rem]">
Nothing to see here (yet)!
</h2>
</section>
{{end}}
{{end}}
{{define "foot"}}
{{end}}

View File

@ -1,37 +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}}
<section class="flex flex-row flex-wrap gap-2 justify-center align-middle">
{{range .Projects}}
{{template "cardlinks" .}}
{{end}}
</section>
{{end}}
{{if not .Projects}}
<section class="flex flex-row flex-wrap gap-2 justify-center align-middle">
<h2 class="text-2xl font-extrabold tracking-tight text-white sm:text-[2rem]">
Nothing to see here (yet)!
</h2>
</section>
{{end}}
{{end}}
{{define "foot"}}
{{end}}

View File

@ -1,37 +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}}
<section class="flex flex-row flex-wrap gap-2 justify-center align-middle">
{{range .Talks}}
{{template "cardlinks" .}}
{{end}}
</section>
{{end}}
{{if not .Talks}}
<section class="flex flex-row flex-wrap gap-2 justify-center align-middle">
<h2 class="text-2xl font-extrabold tracking-tight text-white sm:text-[2rem]">
Nothing to see here (yet)!
</h2>
</section>
{{end}}
{{end}}
{{define "foot"}}
{{end}}

View File

@ -1,6 +0,0 @@
package templatefs
import "embed"
//go:embed *
var FS embed.FS

View File

@ -1,37 +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}}
<section class="flex flex-row flex-wrap gap-2 justify-center align-middle">
{{range .Tools}}
{{template "cardlinks" .}}
{{end}}
</section>
{{end}}
{{if not .Tools}}
<section class="flex flex-row flex-wrap gap-2 justify-center align-middle">
<h2 class="text-2xl font-extrabold tracking-tight text-white sm:text-[2rem]">
Nothing to see here (yet)!
</h2>
</section>
{{end}}
{{end}}
{{define "foot"}}
{{end}}

View File

@ -1,34 +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"}}
<h2 class="text-2xl font-extrabold tracking-tight text-white sm:text-[2rem]">Image Resizer</h2>
<form action="/api/tools/resize" method="post" enctype="multipart/form-data" class="flex-col flex gap-4">
Select image to resize:
<input type="file" name="image" accept=".png,.jpg,.jpeg"
class="file-input file-input-bordered file-input-secondary w-full max-w-xs" required />
<br>
New width (px):
<input type="number" id="newWidth" name="width" min="1" class="input input-bordered w-full max-w-xs" required>
<br>
New height (px):
<input type="number" id="newHeight" name="height" min="1" class="input input-bordered w-full max-w-xs" required>
<br>
<button type="submit" class="btn btn-secondary">Resize Image</button>
</form>
{{end}}
{{define "foot"}}
{{end}}

View File

@ -1,40 +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 implimentation.
{{end}}
{{define "head"}}
{{end}}
{{define "main"}}
<h2 class="text-2xl font-extrabold tracking-tight text-white sm:text-[2rem]">Server Sent Events Demo</h2>
<p class="text-lg">This page demonstrates the use of the <a href="https://htmx.org/extensions/sse/">HTMX SSE
Extention</a> to receive Server Sent Events on the "default" channel.</p>
<p class="text-lg">Any events received on the "default" channel will appear below:</p>
<div hx-ext="sse" sse-connect="/api/sse" sse-swap="message">
Waiting for SSE Message...
</div>
<p class="text-lg">Here you can send messages on the default channel:</p>
<form hx-post="/api/tools/sendsse" hx-trigger="submit" hx-swap="none" class="flex-col flex gap-2">
<div class="label">
<span class="label-text">Message</span>
</div>
<input type="text" name="message" value="Hello world!" placeholder="Enter your message here"
class="input input-bordered input-primary w-full max-w-xs" />
<button type="submit" class="btn btn-primary">Send Event</button>
</form>
{{end}}
{{define "foot"}}
<script src="/public/js/htmx.sse.js"></script>
{{end}}

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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)
}

5717
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,180 +0,0 @@
/* Markdown styling */
.markdown {
color: #fff;
line-height: 1.6;
}
/* Headings */
.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
font-weight: 700;
margin-top: 1.5rem;
margin-bottom: 1rem;
color: #fff;
}
.markdown h1 {
font-size: 1.875rem;
line-height: 2.25rem;
}
.markdown h2 {
font-size: 1.5rem;
line-height: 2rem;
}
.markdown h3 {
font-size: 1.25rem;
line-height: 1.75rem;
}
.markdown h4 {
font-size: 1.125rem;
line-height: 1.75rem;
}
/* Paragraphs */
.markdown p {
margin-top: 1rem;
margin-bottom: 1rem;
}
/* Links */
.markdown a {
color: #60a5fa;
text-decoration: none;
}
.markdown a:hover {
text-decoration: underline;
}
/* Strong/Bold */
.markdown strong,
.markdown b {
font-weight: 700;
color: #fff;
}
/* Code blocks and inline code */
.markdown code {
background-color: rgba(55, 65, 81, 0.5);
border-radius: 0.25rem;
padding: 0.125rem 0.25rem;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: 0.875rem;
}
.markdown pre {
background-color: rgba(55, 65, 81, 0.5);
border-radius: 0.375rem;
padding: 1rem;
margin: 1rem 0;
overflow-x: auto;
}
.markdown pre code {
background-color: transparent;
padding: 0;
font-size: 0.875rem;
color: #f1f5f9;
display: block;
}
/* Lists */
.markdown ul {
list-style-type: disc;
padding-left: 1.5rem;
margin: 1rem 0;
}
.markdown ol {
list-style-type: decimal;
padding-left: 1.5rem;
margin: 1rem 0;
}
.markdown li {
margin: 0.25rem 0;
}
.markdown li > ul,
.markdown li > ol {
margin: 0;
}
/* Blockquotes */
.markdown blockquote {
border-left: 4px solid #60a5fa;
padding-left: 1rem;
margin: 1rem 0;
font-style: italic;
color: #d1d5db;
}
/* Images */
.markdown img {
max-width: 100%;
height: auto;
margin: 1rem auto;
border-radius: 0.375rem;
display: block;
}
/* Horizontal rule */
.markdown hr {
border: 0;
border-top: 1px solid #fff;
margin: 1.5rem 0;
}
/* Tables */
.markdown table {
width: 100%;
border-collapse: collapse;
margin: 1rem 0;
}
.markdown th {
background-color: rgba(55, 65, 81, 0.5);
padding: 0.5rem;
border: 1px solid #4b5563;
text-align: left;
}
.markdown td {
padding: 0.5rem;
border: 1px solid #4b5563;
}
.markdown tr:nth-child(even) {
background-color: rgba(55, 65, 81, 0.3);
}
/* Adjustments for code with line numbers */
.markdown .chroma {
background-color: rgba(55, 65, 81, 0.5);
border-radius: 0.375rem;
}
.markdown .lntable {
width: 100%;
border: none;
}
.markdown .lntd {
padding: 0;
border: none;
}
.markdown .lntd:first-child {
width: 10px;
text-align: right;
padding-right: 10px;
color: #6b7280;
user-select: none;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

180
public/files/resume.toml Normal file
View File

@ -0,0 +1,180 @@
[basics]
name = "Atridad Lahiji"
email = "me@atri.dad"
website = "https://atri.dad"
[[basics.profiles]]
network = "LinkedIn"
username = "atridadl"
url = "https://www.linkedin.com/in/atridadl/"
[[basics.profiles]]
network = "Gitea"
username = "atridad"
url = "https://git.atri.dad/atridad"
[summary]
content = "I am a full-stack web developer and researcher with a background maintaining and developing for large-scale enterprise software systems."
[[experience]]
company = "Atash Consulting"
position = "Owner/Developer"
location = "Edmonton, Alberta"
date = "June 2019 Present"
description = [
"Builds mobile and web applications for small-medium sized businesses",
"Provides consulting on application development, system architecture, DevOps, etc",
"Hosting websites for small-medium sized businesses",
]
url = "https://atash.dev"
[[experience]]
company = "University of Saskatchewan CEPHIL Lab"
position = "Research Technician"
location = "Saskatoon, Saskatchewan"
date = "November 2023 Present"
description = [
"Developing mobile and web applications",
"Coordinating with other grant researchers to deliver a minimum viable product",
"Gathering requirements from stakeholders to craft a product timeline",
"Acting as a technical lead and supervisor to a developer intern",
]
[[experience]]
company = "Alberta Motor Association"
position = "Software Developer II"
location = "Edmonton, Alberta"
date = "August 2021 November 2023"
description = [
"Developed and maintained internal enterprise-level business applications leveraging Amazon Web Services (AWS)",
"Used React and Create React App (CRA) for standalone applications and micro-front-ends",
"Developed an in-house payment gateway for all AMA services that integrates with Stripe",
"Provided tier 3 support for internal services",
"Participated in a bi-monthly 24/7 on-call rotation",
"Mentored students in the organization's Developer in Training program",
]
[[experience]]
company = "University of Alberta IST"
position = "Software Developer"
location = "Edmonton, Alberta"
date = "October 2019 August 2021"
description = [
"Front-end development of web applications using Vue.js",
"Leveraged Amazon Web Services to adopt a serverless architecture",
"Maintained a secure exam application developed in-house",
"Monitored and maintained an exam scheduling system hosted on-premises",
]
[[experience]]
company = "University of Alberta IST"
position = "Support Analyst"
location = "Edmonton, Alberta"
date = "July 2017 October 2019"
description = [
"Provided support for our Moodle installation to students, faculty, and staff",
"Front-end development of web applications using Vue.js",
]
[[education]]
institution = "University of Saskatchewan"
degree = "Masters"
field = "Computer Science"
date = "2024 Present"
details = [
"Supervisor: Dr. Nathaniel Osgood",
"CMPT 838: Computer Security",
"CMPT 815: Computer Systems and Performance Evaluation",
]
[[education]]
institution = "University of Saskatchewan"
degree = "Bachelors (3 Year)"
field = "Computer Science"
date = "2016 2019"
[[education]]
institution = "University of Saskatchewan"
degree = "Bachelors"
field = "Computer Engineering"
date = "2012 2017"
[[skills]]
name = "HTML + CSS + JavaScript"
level = 5
[[skills]]
name = "TypeScript"
level = 5
[[skills]]
name = "Vitest, Jest, and Playwright"
level = 4
[[skills]]
name = "Docker + Docker Compose"
level = 5
[[skills]]
name = "Go (Golang)"
level = 4
[[skills]]
name = "SQL (PostgreSQL, MySQL, SQLite)"
level = 4
[[skills]]
name = "Python"
level = 4
[[skills]]
name = "SCRUM"
level = 5
[[skills]]
name = "Amazon Web Services (AWS)"
level = 4
[[skills]]
name = "Ruby"
level = 2
[[skills]]
name = "Test Driven Development"
level = 3
[[skills]]
name = "C#"
level = 3
[[skills]]
name = "PHP"
level = 2
[[skills]]
name = "Time Management"
level = 4
[[skills]]
name = "Problem Solving"
level = 5
[[skills]]
name = "Attention to Detail"
level = 5
[[volunteer]]
organization = "Big Brother Big Sisters"
position = "Mentor"
date = "2021 2022"
[[awards]]
title = "IT Innovation Award - Team"
organization = "University of Alberta IST"
date = "2020"
description = "The IT Innovation Award recognizes one team for their innovative use of hardware and/or software technology to successfully deploy a major IT project with significant impact to research, teaching, administration and/or the University experience."
[[awards]]
title = "IT Client Service Award - Team"
organization = "University of Alberta IST"
date = "2021"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

File diff suppressed because one or more lines are too long

View File

@ -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 <input> elements contained in <label>
// to prevent sending two requests. Interaction on <input> in a
// <label><input></input></label> situation activates <label> too.
if (node instanceof HTMLInputElement && node.closest("label")) {
return false;
}
return true;
}
/**
* Determine if node is a form element which can be preloaded,
* i.e., `radio`, `checkbox`, `select` or `submit` button
* or a `label` of a form element which can be preloaded.
* @param {Node} node
* @returns {boolean}
*/
function isPreloadableFormElement(node) {
if (node instanceof HTMLInputElement || node instanceof HTMLButtonElement) {
const type = node.getAttribute("type");
return ["checkbox", "radio", "submit"].includes(type);
}
if (node instanceof HTMLLabelElement) {
return node.control && isPreloadableFormElement(node.control);
}
return node instanceof HTMLSelectElement;
}
})();

View File

@ -1,293 +0,0 @@
/*
Server Sent Events Extension
============================
This extension adds support for Server Sent Events to htmx. See /www/extensions/sse.md for usage instructions.
*/
(function () {
/** @type {import("../htmx").HtmxInternalApi} */
var api;
htmx.defineExtension("sse", {
/**
* Init saves the provided reference to the internal HTMX API.
*
* @param {import("../htmx").HtmxInternalApi} api
* @returns void
*/
init: function (apiRef) {
// store a reference to the internal API.
api = apiRef;
// set a function in the public API for creating new EventSource objects
if (htmx.createEventSource == undefined) {
htmx.createEventSource = createEventSource;
}
},
getSelectors: function () {
return [
"[sse-connect]",
"[data-sse-connect]",
"[sse-swap]",
"[data-sse-swap]",
];
},
/**
* onEvent handles all events passed to this extension.
*
* @param {string} name
* @param {Event} evt
* @returns void
*/
onEvent: function (name, evt) {
var parent = evt.target || evt.detail.elt;
switch (name) {
case "htmx:beforeCleanupElement":
var internalData = api.getInternalData(parent);
// Try to remove remove an EventSource when elements are removed
var source = internalData.sseEventSource;
if (source) {
api.triggerEvent(parent, "htmx:sseClose", {
source,
type: "nodeReplaced",
});
internalData.sseEventSource.close();
}
return;
// Try to create EventSources when elements are processed
case "htmx:afterProcessNode":
ensureEventSourceOnElement(parent);
}
},
});
/// ////////////////////////////////////////////
// HELPER FUNCTIONS
/// ////////////////////////////////////////////
/**
* createEventSource is the default method for creating new EventSource objects.
* it is hoisted into htmx.config.createEventSource to be overridden by the user, if needed.
*
* @param {string} url
* @returns EventSource
*/
function createEventSource(url) {
return new EventSource(url, { withCredentials: true });
}
/**
* registerSSE looks for attributes that can contain sse events, right
* now hx-trigger and sse-swap and adds listeners based on these attributes too
* the closest event source
*
* @param {HTMLElement} elt
*/
function registerSSE(elt) {
// Add message handlers for every `sse-swap` attribute
if (api.getAttributeValue(elt, "sse-swap")) {
// Find closest existing event source
var sourceElement = api.getClosestMatch(elt, hasEventSource);
if (sourceElement == null) {
// api.triggerErrorEvent(elt, "htmx:noSSESourceError")
return null; // no eventsource in parentage, orphaned element
}
// Set internalData and source
var internalData = api.getInternalData(sourceElement);
var source = internalData.sseEventSource;
var sseSwapAttr = api.getAttributeValue(elt, "sse-swap");
var sseEventNames = sseSwapAttr.split(",");
for (var i = 0; i < sseEventNames.length; i++) {
const sseEventName = sseEventNames[i].trim();
const listener = function (event) {
// If the source is missing then close SSE
if (maybeCloseSSESource(sourceElement)) {
return;
}
// If the body no longer contains the element, remove the listener
if (!api.bodyContains(elt)) {
source.removeEventListener(sseEventName, listener);
return;
}
// swap the response into the DOM and trigger a notification
if (!api.triggerEvent(elt, "htmx:sseBeforeMessage", event)) {
return;
}
swap(elt, event.data);
api.triggerEvent(elt, "htmx:sseMessage", event);
};
// Register the new listener
api.getInternalData(elt).sseEventListener = listener;
source.addEventListener(sseEventName, listener);
}
}
// Add message handlers for every `hx-trigger="sse:*"` attribute
if (api.getAttributeValue(elt, "hx-trigger")) {
// Find closest existing event source
var sourceElement = api.getClosestMatch(elt, hasEventSource);
if (sourceElement == null) {
// api.triggerErrorEvent(elt, "htmx:noSSESourceError")
return null; // no eventsource in parentage, orphaned element
}
// Set internalData and source
var internalData = api.getInternalData(sourceElement);
var source = internalData.sseEventSource;
var triggerSpecs = api.getTriggerSpecs(elt);
triggerSpecs.forEach(function (ts) {
if (ts.trigger.slice(0, 4) !== "sse:") {
return;
}
var listener = function (event) {
if (maybeCloseSSESource(sourceElement)) {
return;
}
if (!api.bodyContains(elt)) {
source.removeEventListener(ts.trigger.slice(4), listener);
}
// Trigger events to be handled by the rest of htmx
htmx.trigger(elt, ts.trigger, event);
htmx.trigger(elt, "htmx:sseMessage", event);
};
// Register the new listener
api.getInternalData(elt).sseEventListener = listener;
source.addEventListener(ts.trigger.slice(4), listener);
});
}
}
/**
* ensureEventSourceOnElement creates a new EventSource connection on the provided element.
* If a usable EventSource already exists, then it is returned. If not, then a new EventSource
* is created and stored in the element's internalData.
* @param {HTMLElement} elt
* @param {number} retryCount
* @returns {EventSource | null}
*/
function ensureEventSourceOnElement(elt, retryCount) {
if (elt == null) {
return null;
}
// handle extension source creation attribute
if (api.getAttributeValue(elt, "sse-connect")) {
var sseURL = api.getAttributeValue(elt, "sse-connect");
if (sseURL == null) {
return;
}
ensureEventSource(elt, sseURL, retryCount);
}
registerSSE(elt);
}
function ensureEventSource(elt, url, retryCount) {
var source = htmx.createEventSource(url);
source.onerror = function (err) {
// Log an error event
api.triggerErrorEvent(elt, "htmx:sseError", { error: err, source });
// If parent no longer exists in the document, then clean up this EventSource
if (maybeCloseSSESource(elt)) {
return;
}
// Otherwise, try to reconnect the EventSource
if (source.readyState === EventSource.CLOSED) {
retryCount = retryCount || 0;
retryCount = Math.max(Math.min(retryCount * 2, 128), 1);
var timeout = retryCount * 500;
window.setTimeout(function () {
ensureEventSourceOnElement(elt, retryCount);
}, timeout);
}
};
source.onopen = function (evt) {
api.triggerEvent(elt, "htmx:sseOpen", { source });
if (retryCount && retryCount > 0) {
const childrenToFix = elt.querySelectorAll(
"[sse-swap], [data-sse-swap], [hx-trigger], [data-hx-trigger]",
);
for (let i = 0; i < childrenToFix.length; i++) {
registerSSE(childrenToFix[i]);
}
// We want to increase the reconnection delay for consecutive failed attempts only
retryCount = 0;
}
};
api.getInternalData(elt).sseEventSource = source;
var closeAttribute = api.getAttributeValue(elt, "sse-close");
if (closeAttribute) {
// close eventsource when this message is received
source.addEventListener(closeAttribute, function () {
api.triggerEvent(elt, "htmx:sseClose", {
source,
type: "message",
});
source.close();
});
}
}
/**
* maybeCloseSSESource confirms that the parent element still exists.
* If not, then any associated SSE source is closed and the function returns true.
*
* @param {HTMLElement} elt
* @returns boolean
*/
function maybeCloseSSESource(elt) {
if (!api.bodyContains(elt)) {
var source = api.getInternalData(elt).sseEventSource;
if (source != undefined) {
api.triggerEvent(elt, "htmx:sseClose", {
source,
type: "nodeMissing",
});
source.close();
// source = null
return true;
}
}
return false;
}
/**
* @param {HTMLElement} elt
* @param {string} content
*/
function swap(elt, content) {
api.withExtensions(elt, function (extension) {
content = extension.transformResponse(content, null, elt);
});
var swapSpec = api.getSwapSpecification(elt);
var target = api.getTarget(elt);
api.swap(target, content, swapSpec);
}
function hasEventSource(node) {
return api.getInternalData(node).sseEventSource != null;
}
})();

View File

@ -1,517 +0,0 @@
/*
WebSockets Extension
============================
This extension adds support for WebSockets to htmx. See /www/extensions/ws.md for usage instructions.
*/
(function () {
/** @type {import("../htmx").HtmxInternalApi} */
var api;
htmx.defineExtension("ws", {
/**
* init is called once, when this extension is first registered.
* @param {import("../htmx").HtmxInternalApi} apiRef
*/
init: function (apiRef) {
// Store reference to internal API
api = apiRef;
// Default function for creating new EventSource objects
if (!htmx.createWebSocket) {
htmx.createWebSocket = createWebSocket;
}
// Default setting for reconnect delay
if (!htmx.config.wsReconnectDelay) {
htmx.config.wsReconnectDelay = "full-jitter";
}
},
/**
* onEvent handles all events passed to this extension.
*
* @param {string} name
* @param {Event} evt
*/
onEvent: function (name, evt) {
var parent = evt.target || evt.detail.elt;
switch (name) {
// Try to close the socket when elements are removed
case "htmx:beforeCleanupElement":
var internalData = api.getInternalData(parent);
if (internalData.webSocket) {
internalData.webSocket.close();
}
return;
// Try to create websockets when elements are processed
case "htmx:beforeProcessNode":
forEach(
queryAttributeOnThisOrChildren(parent, "ws-connect"),
function (child) {
ensureWebSocket(child);
},
);
forEach(
queryAttributeOnThisOrChildren(parent, "ws-send"),
function (child) {
ensureWebSocketSend(child);
},
);
}
},
});
function splitOnWhitespace(trigger) {
return trigger.trim().split(/\s+/);
}
function getLegacyWebsocketURL(elt) {
var legacySSEValue = api.getAttributeValue(elt, "hx-ws");
if (legacySSEValue) {
var values = splitOnWhitespace(legacySSEValue);
for (var i = 0; i < values.length; i++) {
var value = values[i].split(/:(.+)/);
if (value[0] === "connect") {
return value[1];
}
}
}
}
/**
* ensureWebSocket creates a new WebSocket on the designated element, using
* the element's "ws-connect" attribute.
* @param {HTMLElement} socketElt
* @returns
*/
function ensureWebSocket(socketElt) {
// If the element containing the WebSocket connection no longer exists, then
// do not connect/reconnect the WebSocket.
if (!api.bodyContains(socketElt)) {
return;
}
// Get the source straight from the element's value
var wssSource = api.getAttributeValue(socketElt, "ws-connect");
if (wssSource == null || wssSource === "") {
var legacySource = getLegacyWebsocketURL(socketElt);
if (legacySource == null) {
return;
} else {
wssSource = legacySource;
}
}
// Guarantee that the wssSource value is a fully qualified URL
if (wssSource.indexOf("/") === 0) {
var base_part =
location.hostname + (location.port ? ":" + location.port : "");
if (location.protocol === "https:") {
wssSource = "wss://" + base_part + wssSource;
} else if (location.protocol === "http:") {
wssSource = "ws://" + base_part + wssSource;
}
}
var socketWrapper = createWebsocketWrapper(socketElt, function () {
return htmx.createWebSocket(wssSource);
});
socketWrapper.addEventListener("message", function (event) {
if (maybeCloseWebSocketSource(socketElt)) {
return;
}
var response = event.data;
if (
!api.triggerEvent(socketElt, "htmx:wsBeforeMessage", {
message: response,
socketWrapper: socketWrapper.publicInterface,
})
) {
return;
}
api.withExtensions(socketElt, function (extension) {
response = extension.transformResponse(response, null, socketElt);
});
var settleInfo = api.makeSettleInfo(socketElt);
var fragment = api.makeFragment(response);
if (fragment.children.length) {
var children = Array.from(fragment.children);
for (var i = 0; i < children.length; i++) {
api.oobSwap(
api.getAttributeValue(children[i], "hx-swap-oob") || "true",
children[i],
settleInfo,
);
}
}
api.settleImmediately(settleInfo.tasks);
api.triggerEvent(socketElt, "htmx:wsAfterMessage", {
message: response,
socketWrapper: socketWrapper.publicInterface,
});
});
// Put the WebSocket into the HTML Element's custom data.
api.getInternalData(socketElt).webSocket = socketWrapper;
}
/**
* @typedef {Object} WebSocketWrapper
* @property {WebSocket} socket
* @property {Array<{message: string, sendElt: Element}>} messageQueue
* @property {number} retryCount
* @property {(message: string, sendElt: Element) => void} sendImmediately sendImmediately sends message regardless of websocket connection state
* @property {(message: string, sendElt: Element) => void} send
* @property {(event: string, handler: Function) => void} addEventListener
* @property {() => void} handleQueuedMessages
* @property {() => void} init
* @property {() => void} close
*/
/**
*
* @param socketElt
* @param socketFunc
* @returns {WebSocketWrapper}
*/
function createWebsocketWrapper(socketElt, socketFunc) {
var wrapper = {
socket: null,
messageQueue: [],
retryCount: 0,
/** @type {Object<string, Function[]>} */
events: {},
addEventListener: function (event, handler) {
if (this.socket) {
this.socket.addEventListener(event, handler);
}
if (!this.events[event]) {
this.events[event] = [];
}
this.events[event].push(handler);
},
sendImmediately: function (message, sendElt) {
if (!this.socket) {
api.triggerErrorEvent();
}
if (
!sendElt ||
api.triggerEvent(sendElt, "htmx:wsBeforeSend", {
message,
socketWrapper: this.publicInterface,
})
) {
this.socket.send(message);
sendElt &&
api.triggerEvent(sendElt, "htmx:wsAfterSend", {
message,
socketWrapper: this.publicInterface,
});
}
},
send: function (message, sendElt) {
if (this.socket.readyState !== this.socket.OPEN) {
this.messageQueue.push({ message, sendElt });
} else {
this.sendImmediately(message, sendElt);
}
},
handleQueuedMessages: function () {
while (this.messageQueue.length > 0) {
var queuedItem = this.messageQueue[0];
if (this.socket.readyState === this.socket.OPEN) {
this.sendImmediately(queuedItem.message, queuedItem.sendElt);
this.messageQueue.shift();
} else {
break;
}
}
},
init: function () {
if (this.socket && this.socket.readyState === this.socket.OPEN) {
// Close discarded socket
this.socket.close();
}
// Create a new WebSocket and event handlers
/** @type {WebSocket} */
var socket = socketFunc();
// The event.type detail is added for interface conformance with the
// other two lifecycle events (open and close) so a single handler method
// can handle them polymorphically, if required.
api.triggerEvent(socketElt, "htmx:wsConnecting", {
event: { type: "connecting" },
});
this.socket = socket;
socket.onopen = function (e) {
wrapper.retryCount = 0;
api.triggerEvent(socketElt, "htmx:wsOpen", {
event: e,
socketWrapper: wrapper.publicInterface,
});
wrapper.handleQueuedMessages();
};
socket.onclose = function (e) {
// If socket should not be connected, stop further attempts to establish connection
// If Abnormal Closure/Service Restart/Try Again Later, then set a timer to reconnect after a pause.
if (
!maybeCloseWebSocketSource(socketElt) &&
[1006, 1012, 1013].indexOf(e.code) >= 0
) {
var delay = getWebSocketReconnectDelay(wrapper.retryCount);
setTimeout(function () {
wrapper.retryCount += 1;
wrapper.init();
}, delay);
}
// Notify client code that connection has been closed. Client code can inspect `event` field
// to determine whether closure has been valid or abnormal
api.triggerEvent(socketElt, "htmx:wsClose", {
event: e,
socketWrapper: wrapper.publicInterface,
});
};
socket.onerror = function (e) {
api.triggerErrorEvent(socketElt, "htmx:wsError", {
error: e,
socketWrapper: wrapper,
});
maybeCloseWebSocketSource(socketElt);
};
var events = this.events;
Object.keys(events).forEach(function (k) {
events[k].forEach(function (e) {
socket.addEventListener(k, e);
});
});
},
close: function () {
this.socket.close();
},
};
wrapper.init();
wrapper.publicInterface = {
send: wrapper.send.bind(wrapper),
sendImmediately: wrapper.sendImmediately.bind(wrapper),
queue: wrapper.messageQueue,
};
return wrapper;
}
/**
* ensureWebSocketSend attaches trigger handles to elements with
* "ws-send" attribute
* @param {HTMLElement} elt
*/
function ensureWebSocketSend(elt) {
var legacyAttribute = api.getAttributeValue(elt, "hx-ws");
if (legacyAttribute && legacyAttribute !== "send") {
return;
}
var webSocketParent = api.getClosestMatch(elt, hasWebSocket);
processWebSocketSend(webSocketParent, elt);
}
/**
* hasWebSocket function checks if a node has webSocket instance attached
* @param {HTMLElement} node
* @returns {boolean}
*/
function hasWebSocket(node) {
return api.getInternalData(node).webSocket != null;
}
/**
* processWebSocketSend adds event listeners to the <form> element so that
* messages can be sent to the WebSocket server when the form is submitted.
* @param {HTMLElement} socketElt
* @param {HTMLElement} sendElt
*/
function processWebSocketSend(socketElt, sendElt) {
var nodeData = api.getInternalData(sendElt);
var triggerSpecs = api.getTriggerSpecs(sendElt);
triggerSpecs.forEach(function (ts) {
api.addTriggerHandler(sendElt, ts, nodeData, function (elt, evt) {
if (maybeCloseWebSocketSource(socketElt)) {
return;
}
/** @type {WebSocketWrapper} */
var socketWrapper = api.getInternalData(socketElt).webSocket;
var headers = api.getHeaders(sendElt, api.getTarget(sendElt));
var results = api.getInputValues(sendElt, "post");
var errors = results.errors;
var rawParameters = Object.assign({}, results.values);
var expressionVars = api.getExpressionVars(sendElt);
var allParameters = api.mergeObjects(rawParameters, expressionVars);
var filteredParameters = api.filterValues(allParameters, sendElt);
var sendConfig = {
parameters: filteredParameters,
unfilteredParameters: allParameters,
headers,
errors,
triggeringEvent: evt,
messageBody: undefined,
socketWrapper: socketWrapper.publicInterface,
};
if (!api.triggerEvent(elt, "htmx:wsConfigSend", sendConfig)) {
return;
}
if (errors && errors.length > 0) {
api.triggerEvent(elt, "htmx:validation:halted", errors);
return;
}
var body = sendConfig.messageBody;
if (body === undefined) {
var toSend = Object.assign({}, sendConfig.parameters);
if (sendConfig.headers) {
toSend.HEADERS = headers;
}
body = JSON.stringify(toSend);
}
socketWrapper.send(body, elt);
if (evt && api.shouldCancel(evt, elt)) {
evt.preventDefault();
}
});
});
}
/**
* getWebSocketReconnectDelay is the default easing function for WebSocket reconnects.
* @param {number} retryCount // The number of retries that have already taken place
* @returns {number}
*/
function getWebSocketReconnectDelay(retryCount) {
/** @type {"full-jitter" | ((retryCount:number) => number)} */
var delay = htmx.config.wsReconnectDelay;
if (typeof delay === "function") {
return delay(retryCount);
}
if (delay === "full-jitter") {
var exp = Math.min(retryCount, 6);
var maxDelay = 1000 * Math.pow(2, exp);
return maxDelay * Math.random();
}
logError(
'htmx.config.wsReconnectDelay must either be a function or the string "full-jitter"',
);
}
/**
* maybeCloseWebSocketSource checks to the if the element that created the WebSocket
* still exists in the DOM. If NOT, then the WebSocket is closed and this function
* returns TRUE. If the element DOES EXIST, then no action is taken, and this function
* returns FALSE.
*
* @param {*} elt
* @returns
*/
function maybeCloseWebSocketSource(elt) {
if (!api.bodyContains(elt)) {
var internalData = api.getInternalData(elt);
if (internalData.webSocket) {
internalData.webSocket.close();
return true;
}
return false;
}
return false;
}
/**
* createWebSocket is the default method for creating new WebSocket objects.
* it is hoisted into htmx.createWebSocket to be overridden by the user, if needed.
*
* @param {string} url
* @returns WebSocket
*/
function createWebSocket(url) {
var sock = new WebSocket(url, []);
sock.binaryType = htmx.config.wsBinaryType;
return sock;
}
/**
* queryAttributeOnThisOrChildren returns all nodes that contain the requested attributeName, INCLUDING THE PROVIDED ROOT ELEMENT.
*
* @param {HTMLElement} elt
* @param {string} attributeName
*/
function queryAttributeOnThisOrChildren(elt, attributeName) {
var result = [];
// If the parent element also contains the requested attribute, then add it to the results too.
if (
api.hasAttribute(elt, attributeName) ||
api.hasAttribute(elt, "hx-ws")
) {
result.push(elt);
}
// Search all child nodes that match the requested attribute
elt
.querySelectorAll(
"[" +
attributeName +
"], [data-" +
attributeName +
"], [data-hx-ws], [hx-ws]",
)
.forEach(function (node) {
result.push(node);
});
return result;
}
/**
* @template T
* @param {T[]} arr
* @param {(T) => void} func
*/
function forEach(arr, func) {
if (arr) {
for (var i = 0; i < arr.length; i++) {
func(arr[i]);
}
}
}
})();

File diff suppressed because one or more lines are too long

107
shell.nix Normal file
View File

@ -0,0 +1,107 @@
{ pkgs ? import <nixpkgs> {} }:
let
isDarwin = pkgs.stdenv.isDarwin;
isLinux = pkgs.stdenv.isLinux;
commonBuildInputs = with pkgs; [
nodejs_24
nodePackages.pnpm
git
curl
];
playwrightCommonLibs = with pkgs; [
glib
nss
nspr
dbus
atk
at-spi2-atk
at-spi2-core
cups
expat
libxkbcommon
cairo
pango
fontconfig
freetype
harfbuzz
icu
libpng
gnutls
];
playwrightLinuxSpecificLibs = with pkgs; [
glibc
libgcc
xorg.libX11
xorg.libxcb
xorg.libXext
xorg.libXfixes
xorg.libXrandr
xorg.libXcomposite
xorg.libXdamage
xorg.libXcursor
xorg.libXi
xorg.libXrender
xorg.libXtst
mesa
libglvnd
libdrm
udev
alsa-lib
];
playwrightSelfDownloadLibs = playwrightCommonLibs ++ (if isLinux then playwrightLinuxSpecificLibs else []);
playwrightLibPath = pkgs.lib.makeBinPath playwrightSelfDownloadLibs;
in
pkgs.mkShell {
buildInputs = commonBuildInputs ++ (
if isDarwin
then playwrightCommonLibs
else [ pkgs.chromium ] ++ playwrightSelfDownloadLibs
);
shellHook = ''
echo "🚀 atridotdad development environment loaded!"
echo "Node version: $(node --version)"
echo "pnpm version: $(pnpm --version)"
${if isDarwin then ''
echo "Chromium path: Playwright will download its own for macOS"
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=0
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=false
export LD_LIBRARY_PATH="${playwrightLibPath}:$LD_LIBRARY_PATH"
PLAYWRIGHT_BROWSERS_PATH="$HOME/.cache/ms-playwright"
if [ ! -d "$PLAYWRIGHT_BROWSERS_PATH" ] || [ -z "$(ls -A "$PLAYWRIGHT_BROWSERS_PATH")" ]; then
echo "🌐 Installing Playwright browsers (for macOS)..."
pnpm exec playwright install
else
echo " Playwright browsers already installed (for macOS)."
fi
'' else if isLinux then ''
echo "Chromium path: ${pkgs.chromium}/bin/chromium"
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
export PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH="${pkgs.chromium}/bin/chromium"
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
export PUPPETEER_EXECUTABLE_PATH="${pkgs.chromium}/bin/chromium"
'' else ''
echo "Unsupported OS detected."
''}
if [ ! -d "node_modules" ]; then
echo "📦 Installing pnpm dependencies..."
pnpm install
fi
'';
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = if isDarwin then "0" else "1";
PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH = if isDarwin then null else "${pkgs.chromium}/bin/chromium";
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = if isDarwin then "false" else "true";
PUPPETEER_EXECUTABLE_PATH = if isDarwin then null else "${pkgs.chromium}/bin/chromium";
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

BIN
src/assets/logo_real.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

View File

@ -0,0 +1,41 @@
import { Icon } from 'astro-icon/components';
import type { IconType, LucideIcon, AstroIconName, CustomIconComponent } from '../types';
interface IconRendererProps {
icon: IconType;
size?: number;
class?: string;
[key: string]: any; // For additional props like client:load for custom components
}
// Type guard functions
function isLucideIcon(icon: IconType): icon is LucideIcon {
return typeof icon === 'function' && icon.length <= 1; // Lucide icons are function components
}
function isAstroIconName(icon: IconType): icon is AstroIconName {
return typeof icon === 'string';
}
function isCustomComponent(icon: IconType): icon is CustomIconComponent {
return typeof icon === 'function' && !isLucideIcon(icon);
}
export default function IconRenderer({ icon, size, class: className, ...props }: IconRendererProps) {
if (isLucideIcon(icon)) {
const LucideComponent = icon;
return <LucideComponent size={size} class={className} {...props} />;
}
if (isAstroIconName(icon)) {
return <Icon name={icon} class={className} {...props} />;
}
if (isCustomComponent(icon)) {
const CustomComponent = icon;
return <CustomComponent class={className} {...props} />;
}
// Fallback
return null;
}

View File

@ -0,0 +1,120 @@
import { useComputed, useSignal } from "@preact/signals";
import { useEffect } from "preact/hooks";
import { navigationItems } from '../config/data';
import type { LucideIcon } from '../types';
interface NavigationBarProps {
currentPath: string;
}
export default function NavigationBar({ currentPath }: NavigationBarProps) {
const isScrolling = useSignal(false);
const prevScrollPos = useSignal(0);
const currentClientPath = useSignal(currentPath);
const isVisible = useComputed(() => {
if (prevScrollPos.value < 50) return true;
const currentPos = typeof window !== "undefined" ? globalThis.scrollY : 0;
return prevScrollPos.value > currentPos;
});
// Filter out disabled navigation items
const enabledNavigationItems = navigationItems.filter(item => item.enabled !== false);
// Update client path when location changes
useEffect(() => {
const updatePath = () => {
if (typeof window !== "undefined") {
currentClientPath.value = window.location.pathname;
}
};
// Set initial path
updatePath();
// Listen for Astro's view transition events
const handleAstroNavigation = () => {
updatePath();
};
// Listen for astro:page-load event which fires after navigation completes
document.addEventListener("astro:page-load", handleAstroNavigation);
// Also listen for astro:after-swap as a backup
document.addEventListener("astro:after-swap", handleAstroNavigation);
// Listen for regular navigation events as fallback
window.addEventListener("popstate", updatePath);
return () => {
document.removeEventListener("astro:page-load", handleAstroNavigation);
document.removeEventListener("astro:after-swap", handleAstroNavigation);
window.removeEventListener("popstate", updatePath);
};
}, []);
// Use the client path
const activePath = currentClientPath.value;
// Normalize path
const normalizedPath =
activePath.endsWith("/") && activePath.length > 1
? activePath.slice(0, -1)
: activePath;
useEffect(() => {
let scrollTimer: ReturnType<typeof setTimeout> | undefined;
const handleScroll = () => {
isScrolling.value = true;
prevScrollPos.value = globalThis.scrollY;
if (scrollTimer) clearTimeout(scrollTimer);
scrollTimer = setTimeout(() => {
isScrolling.value = false;
}, 200);
};
globalThis.addEventListener("scroll", handleScroll);
return () => {
globalThis.removeEventListener("scroll", handleScroll);
if (scrollTimer) clearTimeout(scrollTimer);
};
}, []);
return (
<div
class={`fixed bottom-3 sm:bottom-4 left-1/2 transform -translate-x-1/2 z-20 transition-all duration-300 ${
isScrolling.value ? "opacity-30" : "opacity-100"
} ${isVisible.value ? "translate-y-0" : "translate-y-20"}`}
>
<div class="overflow-visible">
<ul class="menu menu-horizontal bg-base-200 rounded-box p-1.5 sm:p-2 shadow-lg flex flex-nowrap whitespace-nowrap">
{enabledNavigationItems.map((item) => {
const Icon = item.icon as LucideIcon;
const isActive = item.isActive
? item.isActive(normalizedPath)
: normalizedPath === item.path;
return (
<li key={item.id} class="mx-0.5 sm:mx-1">
<a
href={item.path}
class={`tooltip tooltip-top min-h-[44px] min-w-[44px] inline-flex items-center justify-center ${isActive ? "menu-active" : ""}`}
aria-label={item.tooltip}
data-tip={item.tooltip}
>
<Icon size={18} class="sm:w-5 sm:h-5" />
<span class="sr-only">{item.name}</span>
</a>
</li>
);
})}
</ul>
</div>
</div>
);
}

View File

@ -0,0 +1,65 @@
---
import type { CollectionEntry } from "astro:content";
import { Icon } from "astro-icon/components";
export interface Props {
post: CollectionEntry<"posts">;
}
const { post } = Astro.props;
const { title, description: blurb, pubDate } = post.data;
const { slug } = post;
---
<div
class="card bg-accent shadow-lg w-full sm:w-[calc(50%-1rem)] md:w-96 min-w-[280px] max-w-sm shrink"
>
<div class="card-body p-3 break-words">
<h2
class="card-title text-base-100 justify-center text-center break-words font-bold text-lg mb-2"
>
{title}
</h2>
<p class="text-center text-base-100 break-words mb-3 text-base">
{blurb || "No description available."}
</p>
<div
class="flex flex-wrap items-center justify-center text-base-100 opacity-75 gap-2 text-sm mb-2"
>
<Icon name="mdi:clock" class="text-xl" />
<span>
{
new Date(pubDate).toLocaleDateString("en-us", {
month: "long",
day: "numeric",
year: "numeric",
})
}
</span>
</div>
{
post.data.tags && post.data.tags.length > 0 && (
<div class="flex gap-2 flex-wrap mb-2 justify-center">
{post.data.tags.map((tag: string) => (
<div class="badge badge-primary">
<Icon name="mdi:tag" class="text-lg" />
{tag}
</div>
))}
</div>
)
}
<div class="card-actions justify-end mt-2">
<a
href={`/post/${slug}`}
class="btn btn-circle btn-sm bg-base-100 hover:bg-base-200 text-accent"
aria-label={`Read more about ${title}`}
>
<Icon name="mdi:arrow-right" class="text-lg" />
</a>
</div>
</div>
</div>

View File

@ -0,0 +1,34 @@
---
import { Icon } from "astro-icon/components";
import type { Project } from '../types';
interface Props {
project: Project;
}
const { project } = Astro.props;
---
<div class="card bg-accent shadow-lg w-full sm:w-[calc(50%-1rem)] md:w-96 min-w-[280px] max-w-sm shrink">
<div class="card-body p-6 break-words">
<h2 class="card-title text-xl md:text-2xl font-bold justify-center text-center break-words text-base-100">
{project.name}
</h2>
<p class="text-center break-words my-4 text-base-100">
{project.description}
</p>
<div class="card-actions justify-end mt-4">
<a
href={project.link}
target="_blank"
rel="noopener noreferrer"
class="btn btn-circle btn-sm bg-base-100 hover:bg-base-200 text-accent"
aria-label={`Visit ${project.name}`}
>
<Icon name="mdi:link" class="text-lg" />
</a>
</div>
</div>
</div>

View File

@ -0,0 +1,66 @@
import { useState } from "preact/hooks";
interface ResumeDownloadButtonProps {
className?: string;
}
export default function ResumeDownloadButton({
className = "",
}: ResumeDownloadButtonProps) {
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const handleDownload = async () => {
setIsLoading(true);
setError(null);
try {
const response = await fetch(`/api/resume/pdf?t=${Date.now()}`);
if (!response.ok) {
throw new Error(
`Failed to generate PDF: ${response.status} ${response.statusText}`,
);
}
const blob = await response.blob();
const url = window.URL.createObjectURL(blob);
// Create a temporary link element and trigger download
const link = document.createElement("a");
link.href = url;
link.download = "Atridad_Lahiji_Resume.pdf";
document.body.appendChild(link);
link.click();
// Clean up
document.body.removeChild(link);
window.URL.revokeObjectURL(url);
} catch (err) {
console.error("Error downloading PDF:", err);
setError(err instanceof Error ? err.message : "Failed to download PDF");
} finally {
setIsLoading(false);
}
};
return (
<div class="text-center mb-6 sm:mb-8">
<button
onClick={handleDownload}
disabled={isLoading}
class={`btn btn-primary inline-flex items-center gap-2 text-sm sm:text-base ${className}`}
>
{isLoading ? (
<>
<span class="loading loading-spinner"></span>
Generating PDF...
</>
) : (
<>Download Resume</>
)}
</button>
{error && <div class="mt-2 text-error text-sm">{error}</div>}
</div>
);
}

View File

@ -0,0 +1,92 @@
import { useSignal } from "@preact/signals";
import { useEffect } from "preact/hooks";
interface Skill {
id: string;
name: string;
level: number;
}
interface ResumeSkillsProps {
skills: Skill[];
}
export default function ResumeSkills({ skills }: ResumeSkillsProps) {
const animatedLevels = useSignal<{ [key: string]: number }>({});
const hasAnimated = useSignal(false);
useEffect(() => {
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting && !hasAnimated.value) {
hasAnimated.value = true;
skills.forEach((skill) => {
animateSkill(skill.id, skill.level);
});
}
});
},
{ threshold: 0.3 },
);
const skillsElement = document.getElementById("skills-section");
if (skillsElement) {
observer.observe(skillsElement);
}
return () => {
if (skillsElement) {
observer.unobserve(skillsElement);
}
};
}, [skills]);
const animateSkill = (skillId: string, targetLevel: number) => {
const steps = 60;
const increment = targetLevel / steps;
let currentStep = 0;
const animate = () => {
if (currentStep <= steps) {
const currentValue = Math.min(increment * currentStep, targetLevel);
animatedLevels.value = {
...animatedLevels.value,
[skillId]: currentValue,
};
currentStep++;
requestAnimationFrame(animate);
}
};
requestAnimationFrame(animate);
};
return (
<div id="skills-section" class="grid grid-cols-1 md:grid-cols-2 gap-3 sm:gap-4">
{skills.map((skill) => {
const currentLevel = animatedLevels.value[skill.id] || 0;
const progressValue = currentLevel * 20;
return (
<div key={skill.id}>
<div class="flex justify-between items-center p-1 sm:p-2">
<span class="text-sm sm:text-base font-medium">
{skill.name}
</span>
<span class="text-xs sm:text-sm text-base-content/70">
{Math.round(currentLevel)}/5
</span>
</div>
<progress
class="progress progress-primary w-full h-2 sm:h-3 min-h-2 transition-all duration-100 ease-out"
value={progressValue}
max="100"
aria-label={`${skill.name} skill level: ${Math.round(currentLevel)} out of 5`}
></progress>
</div>
);
})}
</div>
);
}

View File

@ -0,0 +1,45 @@
import { useSignal } from "@preact/signals";
import { useEffect } from "preact/hooks";
import { ArrowUp } from 'lucide-preact';
export default function ScrollUpButton() {
const isVisible = useSignal(false);
useEffect(() => {
const checkScroll = () => {
isVisible.value = window.scrollY > 300;
};
checkScroll();
window.addEventListener("scroll", checkScroll);
return () => {
window.removeEventListener("scroll", checkScroll);
};
}, []);
const scrollToTop = () => {
window.scrollTo({
top: 0,
behavior: "smooth",
});
};
return (
<button
type="button"
onClick={scrollToTop}
class={`fixed bottom-20 right-4 z-20 bg-secondary hover:bg-primary
p-3 rounded-full shadow-lg transition-all duration-300 min-h-[44px] min-w-[44px] inline-flex items-center justify-center
${
isVisible.value
? "opacity-70 translate-y-0"
: "opacity-0 translate-y-10 pointer-events-none"
}`}
aria-label="Scroll to top"
>
<ArrowUp class="text-lg" />
</button>
);
}

View File

@ -0,0 +1,31 @@
---
import { Icon } from "astro-icon/components";
import { socialLinks } from "../config/data";
// Helper function to check if icon is a string (Astro icon)
function isAstroIcon(icon: any): icon is string {
return typeof icon === "string";
}
---
<div class="flex flex-row gap-4 text-3xl">
{
socialLinks.map((link) => {
return (
<a
href={link.url}
target={link.url.startsWith("http") ? "_blank" : undefined}
rel={
link.url.startsWith("http")
? "noopener noreferrer"
: undefined
}
aria-label={link.ariaLabel}
class="hover:text-primary transition-colors"
>
<Icon name={link.icon} />
</a>
);
})
}
</div>

View File

@ -0,0 +1,49 @@
---
import { Icon } from "astro-icon/components";
import type { Talk } from "../types";
interface Props {
talk: Talk;
}
const { talk } = Astro.props;
---
<div
class="card bg-accent shadow-lg w-full sm:w-[calc(50%-1rem)] md:w-96 min-w-[280px] max-w-sm shrink"
>
<div class="card-body p-6 break-words">
<h2
class="card-title text-xl md:text-2xl font-bold justify-center text-center break-words text-base-100"
>
{talk.name}
</h2>
<p class="text-center break-words my-4 text-base-100">
{talk.description}
</p>
<div class="flex flex-col gap-2 mb-4 text-sm">
{
talk.date && (
<div class="flex items-center gap-2">
<span class="font-semibold">Date:</span>
<span>{talk.date}</span>
</div>
)
}
</div>
<div class="card-actions justify-end mt-4">
<a
href={talk.link}
target="_blank"
rel="noopener noreferrer"
class="btn btn-circle btn-sm bg-base-100 hover:bg-base-200 text-accent"
aria-label={`Visit ${talk.name}`}
>
<Icon name="mdi:link" class="text-lg" />
</a>
</div>
</div>
</div>

View File

@ -0,0 +1,30 @@
---
import { Icon } from "astro-icon/components";
import { techLinks } from "../config/data";
// Helper function to check if icon is a string (Astro icon)
function isAstroIcon(icon: any): icon is string {
return typeof icon === "string";
}
---
<div class="flex flex-row gap-4 text-3xl">
{
techLinks.map((link) => {
if (isAstroIcon(link.icon)) {
return (
<a
href={link.url}
target="_blank"
rel="noopener noreferrer"
aria-label={link.ariaLabel}
class="hover:text-primary transition-colors"
>
<Icon name={link.icon} />
</a>
);
}
return null;
})
}
</div>

234
src/components/Terminal.tsx Normal file
View File

@ -0,0 +1,234 @@
import { useState, useEffect, useRef } from "preact/hooks";
import type { JSX } from "preact";
import type { Command } from "../utils/terminal/types";
import { buildFileSystem } from "../utils/terminal/fs";
import {
executeCommand,
type CommandContext,
} from "../utils/terminal/commands";
import {
getCompletions,
formatOutput,
saveCommandToHistory,
loadCommandHistory,
} from "../utils/terminal/utils";
const Terminal = () => {
const [currentPath, setCurrentPath] = useState("/");
const [commandHistory, setCommandHistory] = useState<Command[]>([
{
input: "",
output:
'Welcome to Atridad\'s Shell!\nType "help" to see available commands.\n',
timestamp: new Date(),
path: "/",
},
]);
const [currentInput, setCurrentInput] = useState("");
const [historyIndex, setHistoryIndex] = useState(-1);
const [fileSystem, setFileSystem] = useState<{ [key: string]: any }>({});
const [isTrainRunning, setIsTrainRunning] = useState(false);
const [trainPosition, setTrainPosition] = useState(100);
const [persistentHistory, setPersistentHistory] = useState<string[]>([]);
const inputRef = useRef<HTMLInputElement>(null);
const terminalRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (terminalRef.current && !isTrainRunning) {
terminalRef.current.scrollTop = terminalRef.current.scrollHeight;
}
}, [commandHistory, isTrainRunning]);
// Load command history from localStorage
useEffect(() => {
const history = loadCommandHistory();
setPersistentHistory(history);
}, []);
// Initialize file system
useEffect(() => {
buildFileSystem().then(setFileSystem);
}, []);
const handleSubmit = (e: JSX.TargetedEvent<HTMLFormElement>) => {
e.preventDefault();
const commandContext: CommandContext = {
currentPath,
fileSystem,
setCurrentPath,
setIsTrainRunning,
setTrainPosition,
};
const output = executeCommand(currentInput, commandContext);
const newCommand: Command = {
input: currentInput,
output,
timestamp: new Date(),
path: currentPath,
};
// Save command to persistent history
const updatedHistory = saveCommandToHistory(
currentInput,
persistentHistory,
);
setPersistentHistory(updatedHistory);
if (currentInput.trim().toLowerCase() === "clear") {
setCommandHistory([]);
} else {
setCommandHistory((prev: Command[]) => [...prev, newCommand]);
}
setCurrentInput("");
setHistoryIndex(-1);
};
const handleKeyDown = (e: JSX.TargetedKeyboardEvent<HTMLInputElement>) => {
if (e.key === "Tab") {
e.preventDefault();
const { completion, replaceFrom } = getCompletions(
currentInput,
currentPath,
fileSystem,
);
if (completion) {
const beforeReplacement = currentInput.substring(0, replaceFrom);
const newInput = beforeReplacement + completion;
setCurrentInput(newInput + (completion.endsWith("/") ? "" : " "));
}
} else if (e.key === "ArrowUp") {
e.preventDefault();
if (persistentHistory.length > 0) {
const newIndex =
historyIndex === -1
? persistentHistory.length - 1
: Math.max(0, historyIndex - 1);
setHistoryIndex(newIndex);
setCurrentInput(persistentHistory[newIndex]);
}
} else if (e.key === "ArrowDown") {
e.preventDefault();
if (historyIndex !== -1) {
const newIndex = Math.min(
persistentHistory.length - 1,
historyIndex + 1,
);
if (
newIndex === persistentHistory.length - 1 &&
historyIndex === newIndex
) {
setHistoryIndex(-1);
setCurrentInput("");
} else {
setHistoryIndex(newIndex);
setCurrentInput(persistentHistory[newIndex]);
}
}
}
};
return (
<div className="bg-base-100 text-base-content font-mono text-sm h-full flex flex-col rounded-lg border-2 border-primary shadow-2xl relative">
<div className="bg-base-200 px-4 py-2 rounded-t-lg border-b border-base-300">
<div className="flex items-center space-x-2">
<div className="w-3 h-3 bg-error rounded-full"></div>
<div className="w-3 h-3 bg-warning rounded-full"></div>
<div className="w-3 h-3 bg-success rounded-full"></div>
<span className="ml-4 text-base-content/70 text-xs">
guest@atri.dad: {currentPath}
</span>
</div>
</div>
<div
ref={terminalRef}
className={`flex-1 p-4 overflow-y-auto scrollbar-thin scrollbar-thumb-base-300 scrollbar-track-base-100 relative ${
isTrainRunning ? "opacity-0" : "opacity-100"
}`}
onClick={() => !isTrainRunning && inputRef.current?.focus()}
>
<div className="min-h-full">
{commandHistory.map((command: Command, index: number) => (
<div key={index} className="mb-2">
{command.input && (
<div className="flex items-center">
<span className="text-primary font-semibold">
guest@atri.dad
</span>
<span className="text-base-content">:</span>
<span className="text-secondary font-semibold">
{command.path}
</span>
<span className="text-base-content">$ </span>
<span className="text-accent">{command.input}</span>
</div>
)}
{command.output && (
<div
className="whitespace-pre-wrap text-base-content/80 mt-1"
dangerouslySetInnerHTML={{
__html: formatOutput(command.output),
}}
/>
)}
</div>
))}
{!isTrainRunning && (
<form onSubmit={handleSubmit} className="flex items-center">
<span className="text-primary font-semibold">guest@atri.dad</span>
<span className="text-base-content">:</span>
<span className="text-secondary font-semibold">
{currentPath}
</span>
<span className="text-base-content">$ </span>
<input
ref={inputRef}
type="text"
value={currentInput}
onInput={(e) =>
setCurrentInput((e.target as HTMLInputElement).value)
}
onKeyDown={handleKeyDown}
className="flex-1 bg-transparent border-none outline-none text-accent ml-1"
spellcheck={false}
/>
</form>
)}
</div>
</div>
{/* Train animation overlay - positioned over the content area but outside the opacity div */}
{isTrainRunning && (
<div className="absolute inset-x-0 top-16 bottom-0 flex items-center justify-center overflow-hidden pointer-events-none">
<div
className="text-white font-mono text-xs whitespace-nowrap"
style={{
transform: `translateX(${trainPosition}%)`,
transition: "none",
}}
>
<pre className="leading-none">{`
==== ________ ___________
_D _| |_______/ \\__I_I_____===__|_________|
|(_)--- | H\\________/ | | =|___ ___| _________________
/ | | H | | | | ||_| |_|| _| \\_____A
| | | H |__--------------------| [___] | =| |
| ________|___H__/__|_____/[][]~\\_______| | -| |
|/ | |-----------I_____I [][] [] D |=======|____|________________________|_
__/ =| o |=-O=====O=====O=====O \\ ____Y___________|__|__________________________|_
|/-=|___|= || || || |_____/~\\___/ |_D__D__D_| |_D__D__D_|
\\_/ \\__/ \\__/ \\__/ \\__/ \\_/ \\_/ \\_/ \\_/ \\_/`}</pre>
</div>
</div>
)}
</div>
);
};
export default Terminal;

330
src/config/data.ts Normal file
View File

@ -0,0 +1,330 @@
import type {
Talk,
Project,
SocialLink,
TechLink,
NavigationItem,
PersonalInfo,
HomepageSections,
SiteConfig,
ResumeConfig,
} from "../types";
// Import Lucide Icons
import {
Home,
Newspaper,
FileUser,
CodeXml,
Terminal as TerminalIcon,
Megaphone,
} from "lucide-preact";
import logo from "../assets/logo_real.webp";
// Astro Icon references
const EMAIL_ICON = "mdi:email";
const RSS_ICON = "mdi:rss";
const GITEA_ICON = "simple-icons:gitea";
const BLUESKY_ICON = "simple-icons:bluesky";
const REACT_ICON = "simple-icons:react";
const TYPESCRIPT_ICON = "simple-icons:typescript";
const ASTRO_ICON = "simple-icons:astro";
const GO_ICON = "simple-icons:go";
const POSTGRESQL_ICON = "simple-icons:postgresql";
const REDIS_ICON = "simple-icons:redis";
const DOCKER_ICON = "simple-icons:docker";
// Personal Information Configuration
export const personalInfo: PersonalInfo = {
name: "Atridad Lahiji",
profileImage: {
src: logo,
alt: "A drawing of Atridad Lahiji by Shelze!",
},
tagline: "Researcher, Full-Stack Developer, and IT Professional.",
description: "Researcher, Full-Stack Developer, and IT Professional.",
};
// Homepage Section Configuration
export const homepageSections: HomepageSections = {
socialLinks: {
title: "Places I Exist:",
description: "Find me across the web",
},
techStack: {
title: "Stuff I Use:",
description: "Technologies and tools I work with",
},
};
// Resume Configuration
export const resumeConfig: ResumeConfig = {
tomlFile: "/files/resume.toml",
pdfFile: {
path: "/files/Atridad_Lahiji_Resume.pdf",
filename: "Atridad_Lahiji_Resume.pdf",
displayText: "Download Resume (PDF)",
},
layout: {
leftColumn: ["experience", "volunteer"],
rightColumn: ["skills", "education", "awards"],
},
sections: {
enabled: [
"summary",
"experience",
"education",
"skills",
"volunteer",
"awards",
],
summary: {
title: "Summary",
enabled: true,
},
experience: {
title: "Professional Experience",
enabled: true,
},
education: {
title: "Education",
enabled: true,
},
skills: {
title: "Technical Skills",
enabled: true,
},
volunteer: {
title: "Volunteer Work",
enabled: true,
},
awards: {
title: "Awards & Recognition",
enabled: true,
},
},
};
// Site Metadata Configuration
export const siteConfig: SiteConfig = {
personal: personalInfo,
homepage: homepageSections,
resume: resumeConfig,
meta: {
title: "Atridad Lahiji",
description:
"Personal website of Atridad Lahiji - Researcher, Full-Stack Developer, and IT Professional",
url: "https://atri.dad",
author: "Atridad Lahiji",
},
};
export const talks: Talk[] = [
{
id: "devedmonton-hateoas",
name: "Hypermedia as the engine of application state - An Introduction",
description:
"A basic introduction to the concepts behind HATEOAS or Hypermedia as the engine of application state.",
link: "/files/DevEdmonton_Talk_HATEOAS.pdf",
},
];
export const projects: Project[] = [
{
id: "bluesky-pds-manager",
name: "BlueSky PDS Manager",
description:
"A web-based BlueSky PDS Manager. Manage your invite codes and users with a simple web UI.",
link: "https://pdsman.atri.dad",
},
{
id: "pollo",
name: "Pollo",
description: "A dead-simple real-time voting tool.",
link: "https://git.atri.dad/atridad/pollo",
},
{
id: "goth-stack",
name: "GOTH Stack",
description:
"🚀 A Web Application Template Powered by HTMX + Go + Tailwind 🚀",
link: "https://git.atri.dad/atridad/goth.stack",
},
{
id: "himbot",
name: "Himbot",
description:
"A discord bot written in Go. Loosly named after my username online (HimbothySwaggins).",
link: "https://git.atri.dad/atridad/himbot",
},
{
id: "loadr",
name: "loadr",
description:
"A lightweight REST load testing tool with robust support for different verbs, token auth, and performance reports.",
link: "https://git.atri.dad/atridad/loadr",
},
];
export const sections = {
resume: {
name: "Resume",
path: "/resume",
description: "Professional experience, skills, and background",
},
posts: {
name: "Blog Posts",
path: "/posts",
description: "Technical articles and thoughts",
},
talks: {
name: "Talks",
path: "/talks",
description: "Conference talks and presentations",
},
projects: {
name: "Projects",
path: "/projects",
description: "Personal and professional projects",
},
} as const;
export const socialLinks: SocialLink[] = [
{
id: "email",
name: "Email",
url: "mailto:me@atri.dad",
icon: EMAIL_ICON,
ariaLabel: "Email me",
},
{
id: "rss",
name: "RSS Feed",
url: "/feed",
icon: RSS_ICON,
ariaLabel: "RSS Feed",
},
{
id: "gitea",
name: "Forgejo (Git)",
url: "https://git.atri.dad/atridad",
icon: GITEA_ICON,
ariaLabel: "Forgejo (Git)",
},
{
id: "bluesky",
name: "Bluesky",
url: "https://bsky.app/profile/atri.dad",
icon: BLUESKY_ICON,
ariaLabel: "Bluesky Profile",
},
];
export const techLinks: TechLink[] = [
{
id: "react",
name: "React",
url: "https://react.dev/",
icon: REACT_ICON,
ariaLabel: "React",
},
{
id: "typescript",
name: "TypeScript",
url: "https://www.typescriptlang.org/",
icon: TYPESCRIPT_ICON,
ariaLabel: "TypeScript",
},
{
id: "astro",
name: "Astro",
url: "https://astro.build/",
icon: ASTRO_ICON,
ariaLabel: "Astro",
},
{
id: "go",
name: "Go",
url: "https://go.dev/",
icon: GO_ICON,
ariaLabel: "Go",
},
{
id: "postgresql",
name: "PostgreSQL",
url: "https://www.postgresql.org/",
icon: POSTGRESQL_ICON,
ariaLabel: "PostgreSQL",
},
{
id: "redis",
name: "Redis",
url: "https://redis.io/",
icon: REDIS_ICON,
ariaLabel: "Redis",
},
{
id: "docker",
name: "Docker",
url: "https://www.docker.com/",
icon: DOCKER_ICON,
ariaLabel: "Docker",
},
];
export const navigationItems: NavigationItem[] = [
{
id: "home",
name: "Home",
path: "/",
tooltip: "Home",
icon: Home,
enabled: true,
},
{
id: "posts",
name: "Posts",
path: "/posts",
tooltip: "Posts",
icon: Newspaper,
enabled: true,
isActive: (path: string) =>
path.startsWith("/posts") || path.startsWith("/post/"),
},
{
id: "resume",
name: "Resume",
path: "/resume",
tooltip: "Resume",
icon: FileUser,
enabled: !!(resumeConfig.tomlFile && resumeConfig.tomlFile.trim()),
},
{
id: "projects",
name: "Projects",
path: "/projects",
tooltip: "Projects",
icon: CodeXml,
enabled: true,
isActive: (path: string) => path.startsWith("/projects"),
},
{
id: "talks",
name: "Talks",
path: "/talks",
tooltip: "Talks",
icon: Megaphone,
enabled: true,
isActive: (path: string) => path.startsWith("/talks"),
},
{
id: "terminal",
name: "Terminal",
path: "/terminal",
tooltip: "Terminal",
icon: TerminalIcon,
enabled: true,
},
];

16
src/content/config.ts Normal file
View File

@ -0,0 +1,16 @@
import { defineCollection, z } from 'astro:content';
const postsCollection = defineCollection({
type: 'content',
schema: z.object({
title: z.string(),
description: z.string(),
pubDate: z.coerce.date(),
updatedDate: z.coerce.date().optional(),
tags: z.array(z.string()).default([]),
}),
});
export const collections = {
'posts': postsCollection,
};

View File

@ -0,0 +1,29 @@
---
title: "Current List of Favourite Tools"
description: "A running list of my favourite tools to use day-to-day."
pubDate: "2025-01-28"
tags: ["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.

Some files were not shown because too many files have changed in this diff Show More