Skip to content

Commit

Permalink
tidy: complete refactor to use tailwindcss and templ
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanthoma committed Oct 23, 2024
1 parent da67937 commit 2f2553c
Show file tree
Hide file tree
Showing 87 changed files with 1,171 additions and 1,676 deletions.
51 changes: 0 additions & 51 deletions .air.toml

This file was deleted.

34 changes: 22 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
/*
*

!README.md
!LICENSE

# go webserver code
!cmd/
# go
!internal/
!.air.toml
!go.mod
!go.sum
!gomod2nix.toml
cmd/webserver/public/js/

# blogs
!posts/

# odin wasm code
!client/
# uploader
!cmd/uploader

# nix code
!nix/
!nix/*
!flake.*

# docker
Makefile
!Makefile

# services
!services/**/default.nix
!services/**/*.go
!services/**/*.templ
services/**/*_templ.go

# webserver
!.air.toml
!services/webserver/public/**
services/webserver/**/*.js
!services/webserver/public/tailwind.config.js
!posts/

!*/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Ethan Thoma

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
64 changes: 60 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,65 @@
IMAGE_NAME = webserver
TAG = 0.1
PORT = 8080
SYSTEM = x86_64-linux

run: build
docker load < result
docker run --rm --env-file ./.env -p 127.0.0.1:8080:8080 -t $(IMAGE_NAME):$(TAG)
run:
nix run github:Mic92/nix-fast-build -- --flake '.#packages.$(SYSTEM).default'
nix run

build:
docker/build:
nix build .#container

docker: docker/build
docker load < result
docker run \
--rm \
--env-file ./.env \
-p 127.0.0.1:$(PORT):$(PORT) \
-t $(IMAGE_NAME):$(TAG)

live/templ:
templ generate \
--watch \
--proxy="http://localhost:3001" \
--open-browser=false \
-v \
--path=./services/webserver/

live/server:
air \
--build.cmd "go build -o tmp/bin/main personal-website/services/webserver" \
--build.bin "tmp/bin/main" \
--build.delay "100" \
--build.include_dir "personal-website/services/webserver" \
--build.include_ext "go" \
--build.stop_on_error "false" \
--misc.clean_on_exit true \
--proxy.enabled true \
--proxy.proxy_port 3001 \
--proxy.app_port $(PORT)

live/tailwind:
tailwindcss \
-c ./services/webserver/public/tailwind.config.js \
-i ./services/webserver/public/main.css \
-o ./public/main.css \
-m \
-w

live/sync_assets:
rsync -a ./services/webserver/public/* ./public --exclude='*.css'
sleep 0.1
air \
--build.cmd "templ generate --notify-proxy" \
--build.bin "true" \
--build.delay "100" \
--build.exclude_dir "" \
--build.include_dir "public" \
--build.include_ext "js,css"

live:
make live/templ & \
make live/server & \
make live/tailwind & \
make live/sync_assets
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h3 align="center">
<img
src="https://raw.githubusercontent.com/ethanthoma/personal-website/main/cmd/webserver/public/favicon/android-chrome-512x512.png"
src="https://raw.githubusercontent.com/ethanthoma/personal-website/main/service/webserver/public/favicon/android-chrome-512x512.png"
width="100"
alt="Logo"/>
<br/>
Expand All @@ -18,15 +18,34 @@

| Tech | Stack |
|-------|----------|
| Go | Backend |
| GO | Backend |
| Htmx | Frontend |
| Turso | Database |

We use [templ](https://github.com/a-h/templ) for templating and [tailwindcss](https://github.com/tailwindlabs/tailwindcss)
for styles. So it is technically more like the GoTTTH stack...

## Building + Running

The nix flake has three derivations:
The nix flake has four derivations:
- .#default: this produces the webserver binary
- .#container: docker image containing the webserver binary
- .#uploader: simple CLI to upload my markdown blogs
- .#blob: a WIP blob storage service I plan to use for my images

## Developing

The [make file](./Makefile) in root is setup for running air w/ livereload.
It will run tailwindcss, templ, and air.

> [!TIP]
> You can also locally deply the docker image using `make docker`.
The webserver assumes the port is set to ":8080". This should be set in your dotenv.
The dotenv file should contain:
- TURSO_DATABASE_URL
- TURSO_AUTH_TOKEN
- WEBSERVER_PORT

You can run it test the webserver locally with docker with `make run`.
> [!NOTE]
> WEBSERVER_PORT will probably be moved to the flake config instead
46 changes: 0 additions & 46 deletions client/main.odin

This file was deleted.

14 changes: 0 additions & 14 deletions cmd/webserver/components/ascii/ascii.css

This file was deleted.

21 changes: 0 additions & 21 deletions cmd/webserver/components/ascii/ascii.go

This file was deleted.

7 changes: 0 additions & 7 deletions cmd/webserver/components/ascii/ascii.tmpl

This file was deleted.

10 changes: 0 additions & 10 deletions cmd/webserver/components/footer/footer.css

This file was deleted.

19 changes: 0 additions & 19 deletions cmd/webserver/components/footer/footer.go

This file was deleted.

5 changes: 0 additions & 5 deletions cmd/webserver/components/footer/footer.tmpl

This file was deleted.

Loading

0 comments on commit 2f2553c

Please sign in to comment.