Skip to content

Commit 79a589d

Browse files
Swap Bulma for DaisyUI (Tailwind) (#111)
1 parent 2a546df commit 79a589d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1124
-632
lines changed

.air.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ tmp_dir = "tmp"
55
[build]
66
args_bin = []
77
bin = "./tmp/main"
8-
cmd = "go build -o ./tmp/main ./cmd/web"
8+
cmd = "make build"
99
delay = 1000
10-
exclude_dir = ["assets", "tmp", "vendor", "testdata", "uploads", "dbs"]
10+
exclude_dir = ["assets", "tmp", "vendor", "testdata", "uploads", "dbs", "public"]
1111
exclude_file = []
1212
exclude_regex = ["_test.go"]
1313
exclude_unchanged = false
1414
follow_symlink = false
1515
full_bin = ""
1616
include_dir = []
17-
include_ext = ["go", "tpl", "tmpl", "html"]
17+
include_ext = ["go", "tpl", "tmpl", "html", "css"]
1818
include_file = []
1919
kill_delay = "0s"
2020
log = "build-errors.log"

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.idea
22
dbs
33
uploads
4-
tmp
4+
tmp
5+
tailwindcss
6+
daisyui*

Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1+
# The Tailwind CSS CLI package to install (pick the one that matches your OS: https://github.com/tailwindlabs/tailwindcss/releases/latest)
2+
TAILWIND_PACKAGE = tailwindcss-linux-x64
3+
14
.PHONY: help
25
help: ## Print make targets
36
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
47

8+
.PHONY: install
9+
install: ent-install air-install tailwind-install ## Install all dependencies
10+
11+
.PHONY: tailwind-install
12+
tailwind-install: ## Install the Tailwind CSS CLI
13+
curl -sLo tailwindcss https://github.com/tailwindlabs/tailwindcss/releases/latest/download/$(TAILWIND_PACKAGE)
14+
chmod +x tailwindcss
15+
curl -sLO https://github.com/saadeghi/daisyui/releases/latest/download/daisyui.js
16+
curl -sLO https://github.com/saadeghi/daisyui/releases/latest/download/daisyui-theme.js
17+
518
.PHONY: ent-install
619
ent-install: ## Install Ent code-generation module
720
go get entgo.io/ent/cmd/ent
@@ -39,3 +52,11 @@ test: ## Run all tests
3952
.PHONY: check-updates
4053
check-updates: ## Check for direct dependency updates
4154
go list -u -m -f '{{if not .Indirect}}{{.}}{{end}}' all | grep "\["
55+
56+
.PHONY: css
57+
css: ## Build and minify Tailwind CSS
58+
./tailwindcss -i tailwind.css -o public/static/main.css -m
59+
60+
.PHONY: build
61+
build: css ## Build CSS and compile the application binary
62+
go build -o ./tmp/main ./cmd/web

README.md

Lines changed: 101 additions & 23 deletions
Large diffs are not rendered by default.

config/config.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ import (
88
"github.com/spf13/viper"
99
)
1010

11-
const (
12-
// StaticDir stores the name of the directory that will serve static files.
13-
StaticDir = "static"
14-
15-
// StaticPrefix stores the URL prefix used when serving static files.
16-
StaticPrefix = "files"
17-
)
18-
1911
type environment string
2012

2113
const (
@@ -25,8 +17,8 @@ const (
2517
// EnvTest represents the test environment.
2618
EnvTest environment = "test"
2719

28-
// EnvDevelop represents the development environment.
29-
EnvDevelop environment = "dev"
20+
// EnvDevelopment represents the development environment.
21+
EnvDevelopment environment = "dev"
3022

3123
// EnvStaging represents the staging environment.
3224
EnvStaging environment = "staging"
@@ -92,7 +84,7 @@ type (
9284
CacheConfig struct {
9385
Capacity int
9486
Expiration struct {
95-
StaticFile time.Duration
87+
PublicFile time.Duration
9688
}
9789
}
9890

config/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ app:
2727
cache:
2828
capacity: 100000
2929
expiration:
30-
staticFile: "4380h"
30+
publicFile: "4380h"
3131

3232
database:
3333
driver: "sqlite3"

pkg/handlers/admin.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (h *Admin) EntityAddSubmit(n *gen.Type) echo.HandlerFunc {
128128
return func(ctx echo.Context) error {
129129
err := h.admin.Create(ctx, n.Name)
130130
if err != nil {
131-
msg.Danger(ctx, err.Error())
131+
msg.Error(ctx, err.Error())
132132
return h.EntityAdd(n)(ctx)
133133
}
134134

@@ -154,7 +154,7 @@ func (h *Admin) EntityEditSubmit(n *gen.Type) echo.HandlerFunc {
154154
id := ctx.Get(context.AdminEntityIDKey).(int)
155155
err := h.admin.Update(ctx, n.Name, id)
156156
if err != nil {
157-
msg.Danger(ctx, err.Error())
157+
msg.Error(ctx, err.Error())
158158
return h.EntityEdit(n)(ctx)
159159
}
160160

@@ -178,7 +178,7 @@ func (h *Admin) EntityDeleteSubmit(n *gen.Type) echo.HandlerFunc {
178178
return func(ctx echo.Context) error {
179179
id := ctx.Get(context.AdminEntityIDKey).(int)
180180
if err := h.admin.Delete(ctx, n.Name, id); err != nil {
181-
msg.Danger(ctx, err.Error())
181+
msg.Error(ctx, err.Error())
182182
return h.EntityDelete(n)(ctx)
183183
}
184184

pkg/handlers/auth.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (h *Auth) LoginSubmit(ctx echo.Context) error {
134134
authFailed := func() error {
135135
input.SetFieldError("Email", "")
136136
input.SetFieldError("Password", "")
137-
msg.Danger(ctx, "Invalid credentials. Please try again.")
137+
msg.Error(ctx, "Invalid credentials. Please try again.")
138138
return h.LoginPage(ctx)
139139
}
140140

@@ -185,7 +185,7 @@ func (h *Auth) Logout(ctx echo.Context) error {
185185
if err := h.auth.Logout(ctx); err == nil {
186186
msg.Success(ctx, "You have been logged out successfully.")
187187
} else {
188-
msg.Danger(ctx, "An error occurred. Please try again.")
188+
msg.Error(ctx, "An error occurred. Please try again.")
189189
}
190190
return redirect.New(ctx).
191191
Route(routenames.Home).

pkg/handlers/files.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (h *Files) Page(ctx echo.Context) error {
5454
func (h *Files) Submit(ctx echo.Context) error {
5555
file, err := ctx.FormFile("file")
5656
if err != nil {
57-
msg.Danger(ctx, "A file is required.")
57+
msg.Error(ctx, "A file is required.")
5858
return h.Page(ctx)
5959
}
6060

pkg/handlers/pages.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func (h *Pages) fetchPosts(pager *pager.Pager) []models.Post {
4242

4343
for k := range posts {
4444
posts[k] = models.Post{
45+
ID: k + 1,
4546
Title: fmt.Sprintf("Post example #%d", k+1),
4647
Body: fmt.Sprintf("Lorem ipsum example #%d ddolor sit amet, consectetur adipiscing elit. Nam elementum vulputate tristique.", k+1),
4748
}

0 commit comments

Comments
 (0)