moved packages out of pkg
This commit is contained in:
4
Makefile
4
Makefile
@@ -4,7 +4,7 @@
|
||||
BINARY_NAME=oslstats
|
||||
|
||||
build:
|
||||
tailwindcss -i ./pkg/embedfs/files/css/input.css -o ./pkg/embedfs/files/css/output.css && \
|
||||
tailwindcss -i ./internal/embedfs/web/css/input.css -o ./internal/embedfs/web/css/output.css && \
|
||||
go mod tidy && \
|
||||
templ generate && \
|
||||
go generate ./cmd/${BINARY_NAME} && \
|
||||
@@ -17,7 +17,7 @@ run:
|
||||
dev:
|
||||
templ generate --watch &\
|
||||
air &\
|
||||
tailwindcss -i ./pkg/embedfs/files/css/input.css -o ./pkg/embedfs/files/css/output.css --watch
|
||||
tailwindcss -i ./internal/embedfs/web/css/input.css -o ./internal/embedfs/web/css/output.css --watch
|
||||
|
||||
clean:
|
||||
go clean
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
"git.haelnorr.com/h/golib/hws"
|
||||
"git.haelnorr.com/h/golib/hwsauth"
|
||||
"git.haelnorr.com/h/oslstats/internal/config"
|
||||
"git.haelnorr.com/h/oslstats/internal/contexts"
|
||||
"git.haelnorr.com/h/oslstats/internal/db"
|
||||
"git.haelnorr.com/h/oslstats/internal/rbac"
|
||||
"git.haelnorr.com/h/oslstats/pkg/contexts"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/uptrace/bun"
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
|
||||
"git.haelnorr.com/h/oslstats/internal/config"
|
||||
"git.haelnorr.com/h/oslstats/internal/discord"
|
||||
"git.haelnorr.com/h/oslstats/internal/embedfs"
|
||||
"git.haelnorr.com/h/oslstats/internal/store"
|
||||
"git.haelnorr.com/h/oslstats/pkg/embedfs"
|
||||
)
|
||||
|
||||
// Initializes and runs the server
|
||||
|
||||
16
internal/contexts/devmode.go
Normal file
16
internal/contexts/devmode.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package contexts
|
||||
|
||||
import "context"
|
||||
|
||||
func DevMode(ctx context.Context) DevInfo {
|
||||
devmode, ok := ctx.Value(DevModeKey).(DevInfo)
|
||||
if !ok {
|
||||
return DevInfo{}
|
||||
}
|
||||
return devmode
|
||||
}
|
||||
|
||||
type DevInfo struct {
|
||||
WebsocketBase string
|
||||
HTMXLog bool
|
||||
}
|
||||
13
internal/contexts/keys.go
Normal file
13
internal/contexts/keys.go
Normal file
@@ -0,0 +1,13 @@
|
||||
// Package contexts provides utilities for loading and extracting structs from contexts
|
||||
package contexts
|
||||
|
||||
type Key string
|
||||
|
||||
func (c Key) String() string {
|
||||
return "oslstats context key " + string(c)
|
||||
}
|
||||
|
||||
var (
|
||||
DevModeKey Key = Key("devmode")
|
||||
PermissionCacheKey Key = Key("permissions")
|
||||
)
|
||||
@@ -1,4 +1,3 @@
|
||||
// Package contexts provides utilities for loading and extracting structs from contexts
|
||||
package contexts
|
||||
|
||||
import (
|
||||
@@ -8,30 +7,6 @@ import (
|
||||
"git.haelnorr.com/h/oslstats/internal/roles"
|
||||
)
|
||||
|
||||
type Key string
|
||||
|
||||
func (c Key) String() string {
|
||||
return "oslstats context key " + string(c)
|
||||
}
|
||||
|
||||
var (
|
||||
DevModeKey Key = Key("devmode")
|
||||
PermissionCacheKey Key = Key("permissions")
|
||||
)
|
||||
|
||||
func DevMode(ctx context.Context) DevInfo {
|
||||
devmode, ok := ctx.Value(DevModeKey).(DevInfo)
|
||||
if !ok {
|
||||
return DevInfo{}
|
||||
}
|
||||
return devmode
|
||||
}
|
||||
|
||||
type DevInfo struct {
|
||||
WebsocketBase string
|
||||
HTMXLog bool
|
||||
}
|
||||
|
||||
// Permissions retrieves the permission cache from context (type-safe)
|
||||
func Permissions(ctx context.Context) *PermissionCache {
|
||||
cache, ok := ctx.Value(PermissionCacheKey).(*PermissionCache)
|
||||
@@ -1,3 +1,4 @@
|
||||
// Package embedfs creates an embedded filesystem with the static web assets
|
||||
package embedfs
|
||||
|
||||
import (
|
||||
@@ -7,12 +8,12 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
//go:embed files/*
|
||||
//go:embed web/*
|
||||
var embeddedFiles embed.FS
|
||||
|
||||
// Gets the embedded files
|
||||
// GetEmbeddedFS gets the embedded files
|
||||
func GetEmbeddedFS() (fs.FS, error) {
|
||||
subFS, err := fs.Sub(embeddedFiles, "files")
|
||||
subFS, err := fs.Sub(embeddedFiles, "web")
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "fs.Sub")
|
||||
}
|
||||
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
BIN
internal/embedfs/web/assets/favicon.ico
Normal file
BIN
internal/embedfs/web/assets/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 140 KiB |
BIN
internal/embedfs/web/assets/logo.png
Normal file
BIN
internal/embedfs/web/assets/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 65 KiB |
@@ -6,10 +6,10 @@ import (
|
||||
"time"
|
||||
|
||||
"git.haelnorr.com/h/golib/hws"
|
||||
"git.haelnorr.com/h/oslstats/internal/contexts"
|
||||
"git.haelnorr.com/h/oslstats/internal/db"
|
||||
"git.haelnorr.com/h/oslstats/internal/permissions"
|
||||
"git.haelnorr.com/h/oslstats/internal/roles"
|
||||
"git.haelnorr.com/h/oslstats/pkg/contexts"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"context"
|
||||
|
||||
"git.haelnorr.com/h/golib/hws"
|
||||
"git.haelnorr.com/h/oslstats/internal/contexts"
|
||||
"git.haelnorr.com/h/oslstats/internal/db"
|
||||
"git.haelnorr.com/h/oslstats/internal/permissions"
|
||||
"git.haelnorr.com/h/oslstats/internal/roles"
|
||||
"git.haelnorr.com/h/oslstats/pkg/contexts"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
@@ -2,8 +2,8 @@ package nav
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.haelnorr.com/h/oslstats/internal/contexts"
|
||||
"git.haelnorr.com/h/oslstats/internal/db"
|
||||
"git.haelnorr.com/h/oslstats/pkg/contexts"
|
||||
)
|
||||
|
||||
type ProfileItem struct {
|
||||
|
||||
@@ -3,7 +3,7 @@ package layout
|
||||
import "git.haelnorr.com/h/oslstats/internal/view/component/popup"
|
||||
import "git.haelnorr.com/h/oslstats/internal/view/component/nav"
|
||||
import "git.haelnorr.com/h/oslstats/internal/view/component/footer"
|
||||
import "git.haelnorr.com/h/oslstats/pkg/contexts"
|
||||
import "git.haelnorr.com/h/oslstats/internal/contexts"
|
||||
|
||||
// Global page layout. Includes HTML document settings, header tags
|
||||
// navbar and footer
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 834 B |
Reference in New Issue
Block a user