Skip to content

Commit

Permalink
Update project to be more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
Piszmog committed Mar 30, 2024
1 parent d22aa39 commit 5a9be53
Show file tree
Hide file tree
Showing 31 changed files with 263 additions and 338 deletions.
2 changes: 1 addition & 1 deletion .air.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tmp_dir = "tmp"
post_cmd = []
pre_cmd = [
"templ generate -path ./components",
"tailwindcss -i ./styles/input.css -o ./assets/css/output@dev.css",
"tailwindcss -i ./styles/input.css -o ./dist/assets/css/output@dev.css",
]
rerun = true
rerun_delay = 500
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ Icon
Network Trash Folder
Temporary Items
.apdisk
output@dev.css
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Build
FROM golang:1.22-alpine AS build

ARG VERSION='dev'

RUN apk update && apk add --no-cache curl

RUN curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 \
&& chmod +x tailwindcss-linux-x64 \
&& mv tailwindcss-linux-x64 /usr/local/bin/tailwindcss

RUN go install github.com/a-h/templ/cmd/templ@v0.2.648

WORKDIR /app

COPY ./ /app

RUN templ generate -path ./components \
&& tailwindcss -i ./styles/input.css -o ./dist/assets/css/output@${VERSION}.css --minify

RUN go build -ldflags="-s -w -X version.Value=${VERSION}" -o pathwise

## Deploy
FROM gcr.io/distroless/static-debian12

WORKDIR /

COPY --from=build /app/pathwise /pathwise

EXPOSE 8080

CMD ["/pathwise"]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ generate-templ-watch:
@templ generate -path ./components -watch
generate-tailwind:
@echo "Generating tailwind files..."
@tailwindcss -i ./styles/input.css -o ./assets/css/output@dev.css --minify
@tailwindcss -i ./styles/input.css -o ./dist/assets/css/output@dev.css --minify
generate-tailwind-watch:
@echo "Generating tailwind files..."
@tailwindcss -i ./styles/input.css -o ./assets/css/output@dev.css --minify --watch
@tailwindcss -i ./styles/input.css -o ./dist/assets/css/output@dev.css --minify --watch
air:
@echo "Running air..."
@air
1 change: 0 additions & 1 deletion app.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
runtime: go122

env_variables:
DB_TYPE: turso
DB_URL: pathwise-piszmog
DB_TOKEN: ${secrets.DB_TOKEN}
VERSION: ${version}
Expand Down
8 changes: 5 additions & 3 deletions components/footer.templ
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package components

templ footer(version string) {
import "github.com/Piszmog/pathwise/version"

templ footer() {
<footer class="mt-16 bg-white border-t border-gray-900/10">
<div class="mx-auto max-w-7xl px-6 py-6 md:flex md:items-center md:justify-between lg:px-8">
<div class="flex justify-center space-x-6 md:order-2">
<p class="text-center text-xs leading-5 text-gray-500">
Version: { version }
Version: { version.Value }
</p>
</div>
<div class="mt-8 md:order-1 md:mt-0">
<p class="text-center text-xs leading-5 text-gray-500">
&copy; 2023 (Pending name). All rights reserved.
&copy; 2024 (Pending name). All rights reserved.
</p>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions components/head.templ
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package components

templ Head(version string) {
import "github.com/Piszmog/pathwise/version"

templ Head() {
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content="Track your job applications"/>
<title>Pathwise</title>
<script src="/assets/js/htmx@1.9.8.min.js"></script>
<script src="/assets/js/ext-response-targets@1.9.8.min.js"></script>
<link href={ "/assets/css/output@" + version + ".css" } rel="stylesheet"/>
<link href={ "/assets/css/output@" + version.Value + ".css" } rel="stylesheet"/>
</head>
}
26 changes: 13 additions & 13 deletions components/input_select.templ
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ templ inputSelect(opts types.SelectOpts) {
<label for={ opts.Name + "-select" } class="block text-sm font-medium leading-6 text-gray-900">{ opts.Label }</label>
<div class="relative mt-2 rounded-md shadow-sm">
<select
id={ opts.Name + "-select" }
name={ opts.Name }
class="bg-white block w-full rounded-md border-0 py-1.5 text-gray-900 ring-1 ring-inset ring-gray-300 focus:z-10 focus:ring-2 focus:ring-inset focus:ring-gray-600 sm:text-sm sm:leading-6"
required?={ opts.Required }
aria-invalid="false"
aria-describedby={ opts.Name + "-select" + "-error" }
id={ opts.Name + "-select" }
name={ opts.Name }
class="bg-white block w-full rounded-md border-0 py-1.5 text-gray-900 ring-1 ring-inset ring-gray-300 focus:z-10 focus:ring-2 focus:ring-inset focus:ring-gray-600 sm:text-sm sm:leading-6"
required?={ opts.Required }
aria-invalid="false"
aria-describedby={ opts.Name + "-select" + "-error" }
>
if opts.Placeholder != "" {
<option selected value="">{ opts.Placeholder }</option>
Expand All @@ -24,15 +24,15 @@ templ inputSelect(opts types.SelectOpts) {
if opts.Err != nil {
<div class="pointer-events-none absolute inset-y-0 right-5 flex items-center pr-3">
<svg
class="h-5 w-5 text-red-500"
viewBox="0 0 20 20"
fill="currentColor"
aria-hidden="true"
class="h-5 w-5 text-red-500"
viewBox="0 0 20 20"
fill="currentColor"
aria-hidden="true"
>
<path
fill-rule="evenodd"
d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z"
clip-rule="evenodd"
fill-rule="evenodd"
d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z"
clip-rule="evenodd"
></path>
</svg>
</div>
Expand Down
10 changes: 5 additions & 5 deletions components/main.templ
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package components

templ Main(version string) {
templ Main() {
<!DOCTYPE html>
<html lang="en">
@Head(version)
@body(version)
@Head()
@body()
</html>
}

templ body(version string) {
templ body() {
<body>
<main>
<style type="text/css">
Expand All @@ -23,7 +23,7 @@ templ body(version string) {
@drawer("new-job", "New Job Application") {
@jobApplicationForm()
}
@footer(version)
@footer()
</main>
</body>
}
Expand Down
90 changes: 45 additions & 45 deletions components/settings.templ
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package components

import "github.com/Piszmog/pathwise/types"

templ Settings(version string, user types.User) {
templ Settings(user types.User) {
<!DOCTYPE html>
<html lang="en">
@Head(version)
@Head()
<main>
@header(false)
@settings(user)
@footer(version)
@footer()
</main>
</html>
}
Expand Down Expand Up @@ -44,57 +44,57 @@ templ settings(user types.User) {
<p class="mt-1 text-sm leading-6 text-gray-400">Update your password associated with your account.</p>
</div>
<form
id="change-password-form"
class="md:col-span-2"
hx-post="/settings/changePassword"
hx-ext="response-targets"
hx-target-error="#change-password-error"
hx-on::after-request="this.reset()"
id="change-password-form"
class="md:col-span-2"
hx-post="/settings/changePassword"
hx-ext="response-targets"
hx-target-error="#change-password-error"
hx-on::after-request="this.reset()"
>
<div id="change-password-error"></div>
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:max-w-xl sm:grid-cols-6">
<div class="col-span-full">
<label for="currentPassword" class="block text-sm font-medium leading-6 text-gray-900">Current password</label>
<div class="mt-2">
<input
id="currentPassword"
name="currentPassword"
type="password"
autocomplete="currentPassword"
required
class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6"
id="currentPassword"
name="currentPassword"
type="password"
autocomplete="currentPassword"
required
class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6"
/>
</div>
</div>
<div class="col-span-full">
<label for="newPassword" class="block text-sm font-medium leading-6 text-gray-900">New password</label>
<div class="mt-2">
<input
id="newPassword"
name="newPassword"
type="password"
autocomplete="newPassword"
minLength="12"
pattern="(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{12,}"
title="Must contain at least one number, one uppercase letter, one special character (!@#$%^&*), and at least 12 or more characters"
required
class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6"
id="newPassword"
name="newPassword"
type="password"
autocomplete="newPassword"
minLength="12"
pattern="(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{12,}"
title="Must contain at least one number, one uppercase letter, one special character (!@#$%^&*), and at least 12 or more characters"
required
class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6"
/>
</div>
</div>
<div class="col-span-full">
<label for="confirmPassword" class="block text-sm font-medium leading-6 text-gray-900">Confirm password</label>
<div class="mt-2">
<input
id="confirmPassword"
name="confirmPassword"
type="password"
autocomplete="confirmPassword"
minLength="12"
pattern="(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{12,}"
title="Must contain at least one number, one uppercase letter, one special character (!@#$%^&*), and at least 12 or more characters"
required
class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6"
id="confirmPassword"
name="confirmPassword"
type="password"
autocomplete="confirmPassword"
minLength="12"
pattern="(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{12,}"
title="Must contain at least one number, one uppercase letter, one special character (!@#$%^&*), and at least 12 or more characters"
required
class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6"
/>
</div>
</div>
Expand All @@ -110,12 +110,12 @@ templ settings(user types.User) {
<p class="mt-1 text-sm leading-6 text-gray-400">Please enter your password to confirm you would like to log out of your other sessions across all of your devices.</p>
</div>
<form
id="logout-account-form"
class="md:col-span-2"
hx-post="/settings/logoutSessions"
hx-ext="response-targets"
hx-target-error="#logout-account-error"
hx-on::after-request="this.reset()"
id="logout-account-form"
class="md:col-span-2"
hx-post="/settings/logoutSessions"
hx-ext="response-targets"
hx-target-error="#logout-account-error"
hx-on::after-request="this.reset()"
>
<div id="logout-account-error"></div>
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:max-w-xl sm:grid-cols-6">
Expand All @@ -137,12 +137,12 @@ templ settings(user types.User) {
<p class="mt-1 text-sm leading-6 text-gray-400">No longer want to use our service? You can delete your account here. This action is not reversible. All information related to this account will be deleted permanently.</p>
</div>
<form
id="delete-account-form"
class="md:col-span-2"
hx-post="/settings/deleteAccount"
hx-ext="response-targets"
hx-target-error="#delete-account-error"
hx-on::after-request="this.reset()"
id="delete-account-form"
class="md:col-span-2"
hx-post="/settings/deleteAccount"
hx-ext="response-targets"
hx-target-error="#delete-account-error"
hx-on::after-request="this.reset()"
>
<div id="delete-account-error"></div>
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:max-w-xl sm:grid-cols-6">
Expand Down
28 changes: 14 additions & 14 deletions components/signin.templ
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package components

templ Signin(version string) {
templ Signin() {
<!DOCTYPE html>
<html lang="en">
@Head(version)
@Head()
<main>
@signin()
@footer(version)
@footer()
</main>
</html>
}
Expand All @@ -24,23 +24,23 @@ templ signin() {
</div>
<div class="mt-10 sm:mx-auto sm:w-full sm:max-w-sm">
<form
class="space-y-6"
id="signin-form"
hx-post="/signin"
hx-ext="response-targets"
hx-target-error="#login-error"
class="space-y-6"
id="signin-form"
hx-post="/signin"
hx-ext="response-targets"
hx-target-error="#login-error"
>
<div id="login-error"></div>
<div>
<label for="email" class="block text-sm font-medium leading-6 text-gray-900">Email address</label>
<div class="mt-2">
<input
id="email"
name="email"
type="email"
autocomplete="email"
required
class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6"
id="email"
name="email"
type="email"
autocomplete="email"
required
class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6"
/>
</div>
</div>
Expand Down
Loading

0 comments on commit 5a9be53

Please sign in to comment.