detached 654acb6

Integration Echo: ok

commit
654acb67ca3a378231b722b4d43b21d4c1b26708
author
bnema · · 2023-09-13 16:07 UTC
parent
8151903
signature
unsigned
6 files · +44 -40
M .gitignore +2 -5
@@ -1,10 +1,7 @@
11 .env
22 node_modules/
33 tmp/*
4-logs/
5-logs/app.log
6-logs/error.log
7-logs/http.log
8-logs/docker.log
94 gordon.yml
105 bun.lockb
6+*.log
7+
@@ -1,10 +1,7 @@
1 .env1 .env
2 node_modules/2 node_modules/
3 tmp/*3 tmp/*
4-logs/
5-logs/app.log
6-logs/error.log
7-logs/http.log
8-logs/docker.log
9 gordon.yml4 gordon.yml
10 bun.lockb5 bun.lockb
6+*.log
7+
M cmd/main.go +11 -1
@@ -1,10 +1,20 @@
11 package main
22
33 import (
4+ "fmt"
5+ "log/slog"
6+
47 "github.com/bnema/gordon/internal/app"
8+ "github.com/bnema/gordon/internal/httpserve"
9+ "github.com/labstack/echo/v4"
510 )
611
712 func main() {
813 a := app.NewApp()
9- a.Start()
14+ e := echo.New()
15+ e.HideBanner = true
16+ e.HidePort = true
17+ e = httpserve.RegisterRoutes(e, a)
18+ slog.Info("Starting server", "port", a.HttpPort)
19+ slog.Error("Server error", e.Start(fmt.Sprintf(":%d", a.HttpPort)))
1020 }
@@ -1,10 +1,20 @@
1 package main1 package main
2 2
3 import (3 import (
4+ "fmt"
5+ "log/slog"
6+
4 "github.com/bnema/gordon/internal/app"7 "github.com/bnema/gordon/internal/app"
8+ "github.com/bnema/gordon/internal/httpserve"
9+ "github.com/labstack/echo/v4"
5 )10 )
6 11
7 func main() {12 func main() {
8 a := app.NewApp()13 a := app.NewApp()
9- a.Start()14+ e := echo.New()
15+ e.HideBanner = true
16+ e.HidePort = true
17+ e = httpserve.RegisterRoutes(e, a)
18+ slog.Info("Starting server", "port", a.HttpPort)
19+ slog.Error("Server error", e.Start(fmt.Sprintf(":%d", a.HttpPort)))
10 }20 }
M internal/app/app.go +13 -32
@@ -1,7 +1,6 @@
11 package app
22
33 import (
4- "fmt"
54 "io/fs"
65
76 "github.com/bnema/gordon/internal/gotemplate"
@@ -11,6 +10,11 @@ import (
1110 const (
1211 BuildVersion = "0.0.2"
1312 BuildDir = "tmp"
13+ // Those configs should be read from a config file
14+ HttpPort = 1323
15+ TopDomain = "example.com"
16+ SubDomain = "gordon"
17+ AdminPath = "/admin"
1418 )
1519
1620 type App struct {
@@ -18,22 +22,10 @@ type App struct {
1822 PublicFS fs.FS
1923 BuildVersion string
2024 BuildDir string
21-}
22-
23-func (*App) GetTemplateFS() fs.FS {
24- return gotemplate.TemplateFS
25-}
26-
27-func (*App) GetPublicFS() fs.FS {
28- return webui.PublicFS
29-}
30-
31-func (*App) GetBuildVersion() string {
32- return BuildVersion
33-}
34-
35-func (*App) GetBuildDir() string {
36- return BuildDir
25+ TopDomain string
26+ SubDomain string
27+ AdminPath string
28+ HttpPort int16
3729 }
3830
3931 func NewApp() *App {
@@ -42,20 +34,9 @@ func NewApp() *App {
4234 PublicFS: webui.PublicFS,
4335 BuildVersion: BuildVersion,
4436 BuildDir: BuildDir,
45- }
46-}
47-
48-func (a *App) Start() {
49- fmt.Println("Starting app")
50-
51- // LS in the template directory
52- entries, err := fs.ReadDir(a.TemplateFS, ".") // List the root directory
53- if err != nil {
54- fmt.Println("Error reading directory:", err)
55- return
56- }
57-
58- for _, entry := range entries {
59- fmt.Println(entry.Name())
37+ TopDomain: TopDomain,
38+ SubDomain: SubDomain,
39+ AdminPath: AdminPath,
40+ HttpPort: HttpPort,
6041 }
6142 }
@@ -1,7 +1,6 @@
1 package app1 package app
2 2
3 import (3 import (
4- "fmt"
5 "io/fs"4 "io/fs"
6 5
7 "github.com/bnema/gordon/internal/gotemplate"6 "github.com/bnema/gordon/internal/gotemplate"
@@ -11,6 +10,11 @@ import (
11 const (10 const (
12 BuildVersion = "0.0.2"11 BuildVersion = "0.0.2"
13 BuildDir = "tmp"12 BuildDir = "tmp"
13+ // Those configs should be read from a config file
14+ HttpPort = 1323
15+ TopDomain = "example.com"
16+ SubDomain = "gordon"
17+ AdminPath = "/admin"
14 )18 )
15 19
16 type App struct {20 type App struct {
@@ -18,22 +22,10 @@ type App struct {
18 PublicFS fs.FS22 PublicFS fs.FS
19 BuildVersion string23 BuildVersion string
20 BuildDir string24 BuildDir string
21-}25+ TopDomain string
22-26+ SubDomain string
23-func (*App) GetTemplateFS() fs.FS {27+ AdminPath string
24- return gotemplate.TemplateFS28+ HttpPort int16
25-}
26-
27-func (*App) GetPublicFS() fs.FS {
28- return webui.PublicFS
29-}
30-
31-func (*App) GetBuildVersion() string {
32- return BuildVersion
33-}
34-
35-func (*App) GetBuildDir() string {
36- return BuildDir
37 }29 }
38 30
39 func NewApp() *App {31 func NewApp() *App {
@@ -42,20 +34,9 @@ func NewApp() *App {
42 PublicFS: webui.PublicFS,34 PublicFS: webui.PublicFS,
43 BuildVersion: BuildVersion,35 BuildVersion: BuildVersion,
44 BuildDir: BuildDir,36 BuildDir: BuildDir,
45- }37+ TopDomain: TopDomain,
46-}38+ SubDomain: SubDomain,
47-39+ AdminPath: AdminPath,
48-func (a *App) Start() {40+ HttpPort: HttpPort,
49- fmt.Println("Starting app")
50-
51- // LS in the template directory
52- entries, err := fs.ReadDir(a.TemplateFS, ".") // List the root directory
53- if err != nil {
54- fmt.Println("Error reading directory:", err)
55- return
56- }
57-
58- for _, entry := range entries {
59- fmt.Println(entry.Name())
60 }41 }
61 }42 }
D internal/httpserve/middleware/tmp/build-errors.log +0 -1
@@ -1,1 +0,0 @@
1-exit status 1⏎̸
@@ -1,1 +0,0 @@
1-exit status 1⏎̸
M internal/httpserve/router.go +17 -0
@@ -0,0 +1,17 @@
1+package httpserve
2+
3+import (
4+ "github.com/bnema/gordon/internal/app"
5+ "github.com/labstack/echo/v4"
6+)
7+
8+func RegisterRoutes(e *echo.Echo, a *app.App) *echo.Echo {
9+ AdminPath := a.AdminPath
10+ // Hello world on the admin path
11+ e.GET(AdminPath, helloWorld)
12+ return e
13+}
14+
15+func helloWorld(c echo.Context) error {
16+ return c.String(200, "Hello world")
17+}
@@ -0,0 +1,17 @@
1+package httpserve
2+
3+import (
4+ "github.com/bnema/gordon/internal/app"
5+ "github.com/labstack/echo/v4"
6+)
7+
8+func RegisterRoutes(e *echo.Echo, a *app.App) *echo.Echo {
9+ AdminPath := a.AdminPath
10+ // Hello world on the admin path
11+ e.GET(AdminPath, helloWorld)
12+ return e
13+}
14+
15+func helloWorld(c echo.Context) error {
16+ return c.String(200, "Hello world")
17+}
M internal/webui/embed.go +1 -1
@@ -11,4 +11,4 @@ import (
1111 //go:embed public/*
1212 var public embed.FS
1313
14-var PublicFS = echo.MustSubFS(public, "internal/webui/public")
14+var PublicFS = echo.MustSubFS(public, "public")
@@ -11,4 +11,4 @@ import (
11 //go:embed public/*11 //go:embed public/*
12 var public embed.FS12 var public embed.FS
13 13
14-var PublicFS = echo.MustSubFS(public, "internal/webui/public")14+var PublicFS = echo.MustSubFS(public, "public")

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close