detached 1e9fac5

Refactor project structure for better readability

commit
1e9fac5e62fba6b7dff25222257b6cbcab9d069e
author
bnema · · 2023-10-03 07:35 UTC
parent
23fbadb
signature
unsigned
38 files · +23 -21
M cmd/srv/main.go +1 -1
@@ -12,7 +12,7 @@ import (
1212
1313 "github.com/bnema/gordon/internal/app"
1414 "github.com/bnema/gordon/internal/httpserve"
15- "github.com/bnema/gordon/pkg/utils/docker"
15+ "github.com/bnema/gordon/pkg/docker"
1616 )
1717
1818 func cleanup(a *app.App, memDb *sql.DB) {
@@ -12,7 +12,7 @@ import (
12 12
13 "github.com/bnema/gordon/internal/app"13 "github.com/bnema/gordon/internal/app"
14 "github.com/bnema/gordon/internal/httpserve"14 "github.com/bnema/gordon/internal/httpserve"
15- "github.com/bnema/gordon/pkg/utils/docker"15+ "github.com/bnema/gordon/pkg/docker"
16 )16 )
17 17
18 func cleanup(a *app.App, memDb *sql.DB) {18 func cleanup(a *app.App, memDb *sql.DB) {
M internal/app/app.go +3 -3
@@ -7,9 +7,9 @@ import (
77 "log"
88 "os"
99
10- "github.com/bnema/gordon/internal/gotemplate"
10+ "github.com/bnema/gordon/internal/templates"
1111 "github.com/bnema/gordon/internal/webui"
12- "github.com/bnema/gordon/pkg/utils/docker"
12+ "github.com/bnema/gordon/pkg/docker"
1313 _ "github.com/joho/godotenv/autoload"
1414 "gopkg.in/yaml.v3"
1515 )
@@ -99,7 +99,7 @@ func NewApp() *App {
9999
100100 // Initialize App
101101 a := &App{
102- TemplateFS: gotemplate.TemplateFS,
102+ TemplateFS: templates.TemplateFS,
103103 PublicFS: webui.PublicFS,
104104 DBDir: DBDir,
105105 DBFilename: DBFilename,
@@ -7,9 +7,9 @@ import (
7 "log"7 "log"
8 "os"8 "os"
9 9
10- "github.com/bnema/gordon/internal/gotemplate"10+ "github.com/bnema/gordon/internal/templates"
11 "github.com/bnema/gordon/internal/webui"11 "github.com/bnema/gordon/internal/webui"
12- "github.com/bnema/gordon/pkg/utils/docker"12+ "github.com/bnema/gordon/pkg/docker"
13 _ "github.com/joho/godotenv/autoload"13 _ "github.com/joho/godotenv/autoload"
14 "gopkg.in/yaml.v3"14 "gopkg.in/yaml.v3"
15 )15 )
@@ -99,7 +99,7 @@ func NewApp() *App {
99 99
100 // Initialize App100 // Initialize App
101 a := &App{101 a := &App{
102- TemplateFS: gotemplate.TemplateFS,102+ TemplateFS: templates.TemplateFS,
103 PublicFS: webui.PublicFS,103 PublicFS: webui.PublicFS,
104 DBDir: DBDir,104 DBDir: DBDir,
105 DBFilename: DBFilename,105 DBFilename: DBFilename,
D internal/gotemplate/models/txt/test.txt +0 -0

no textual change.

M internal/httpserve/handler/adminroutes.go +1 -1
@@ -5,8 +5,8 @@ import (
55 "net/http"
66
77 "github.com/bnema/gordon/internal/app"
8- "github.com/bnema/gordon/internal/gotemplate/render"
98 "github.com/bnema/gordon/internal/httpserve/middleware"
9+ "github.com/bnema/gordon/internal/templates/render"
1010 "github.com/bnema/gordon/internal/webui"
1111 "github.com/labstack/echo/v4"
1212 )
@@ -5,8 +5,8 @@ import (
5 "net/http"5 "net/http"
6 6
7 "github.com/bnema/gordon/internal/app"7 "github.com/bnema/gordon/internal/app"
8- "github.com/bnema/gordon/internal/gotemplate/render"
9 "github.com/bnema/gordon/internal/httpserve/middleware"8 "github.com/bnema/gordon/internal/httpserve/middleware"
9+ "github.com/bnema/gordon/internal/templates/render"
10 "github.com/bnema/gordon/internal/webui"10 "github.com/bnema/gordon/internal/webui"
11 "github.com/labstack/echo/v4"11 "github.com/labstack/echo/v4"
12 )12 )
M internal/httpserve/handler/containers.go +3 -3
@@ -7,9 +7,9 @@ import (
77 "time"
88
99 "github.com/bnema/gordon/internal/app"
10- "github.com/bnema/gordon/internal/gotemplate/render"
11- "github.com/bnema/gordon/pkg/utils/docker"
12- "github.com/bnema/gordon/pkg/utils/humanize"
10+ "github.com/bnema/gordon/internal/templates/render"
11+ "github.com/bnema/gordon/pkg/docker"
12+ "github.com/bnema/gordon/pkg/humanize"
1313 "github.com/docker/docker/api/types"
1414 "github.com/labstack/echo/v4"
1515 )
@@ -7,9 +7,9 @@ import (
7 "time"7 "time"
8 8
9 "github.com/bnema/gordon/internal/app"9 "github.com/bnema/gordon/internal/app"
10- "github.com/bnema/gordon/internal/gotemplate/render"10+ "github.com/bnema/gordon/internal/templates/render"
11- "github.com/bnema/gordon/pkg/utils/docker"11+ "github.com/bnema/gordon/pkg/docker"
12- "github.com/bnema/gordon/pkg/utils/humanize"12+ "github.com/bnema/gordon/pkg/humanize"
13 "github.com/docker/docker/api/types"13 "github.com/docker/docker/api/types"
14 "github.com/labstack/echo/v4"14 "github.com/labstack/echo/v4"
15 )15 )
M internal/httpserve/handler/createcontainer.go +3 -3
@@ -4,9 +4,9 @@ import (
44 "fmt"
55
66 "github.com/bnema/gordon/internal/app"
7- "github.com/bnema/gordon/internal/gotemplate/render"
8- "github.com/bnema/gordon/pkg/utils/docker"
9- "github.com/bnema/gordon/pkg/utils/sanitize"
7+ "github.com/bnema/gordon/internal/templates/render"
8+ "github.com/bnema/gordon/pkg/docker"
9+ "github.com/bnema/gordon/pkg/sanitize"
1010 "github.com/labstack/echo/v4"
1111 )
1212
@@ -4,9 +4,9 @@ import (
4 "fmt"4 "fmt"
5 5
6 "github.com/bnema/gordon/internal/app"6 "github.com/bnema/gordon/internal/app"
7- "github.com/bnema/gordon/internal/gotemplate/render"7+ "github.com/bnema/gordon/internal/templates/render"
8- "github.com/bnema/gordon/pkg/utils/docker"8+ "github.com/bnema/gordon/pkg/docker"
9- "github.com/bnema/gordon/pkg/utils/sanitize"9+ "github.com/bnema/gordon/pkg/sanitize"
10 "github.com/labstack/echo/v4"10 "github.com/labstack/echo/v4"
11 )11 )
12 12
M internal/httpserve/handler/editcontainer.go +2 -2
@@ -5,8 +5,8 @@ import (
55 "strings"
66
77 "github.com/bnema/gordon/internal/app"
8- "github.com/bnema/gordon/internal/gotemplate/render"
9- "github.com/bnema/gordon/pkg/utils/docker"
8+ "github.com/bnema/gordon/internal/templates/render"
9+ "github.com/bnema/gordon/pkg/docker"
1010 "github.com/labstack/echo/v4"
1111 "gopkg.in/yaml.v3"
1212 )
@@ -5,8 +5,8 @@ import (
5 "strings"5 "strings"
6 6
7 "github.com/bnema/gordon/internal/app"7 "github.com/bnema/gordon/internal/app"
8- "github.com/bnema/gordon/internal/gotemplate/render"8+ "github.com/bnema/gordon/internal/templates/render"
9- "github.com/bnema/gordon/pkg/utils/docker"9+ "github.com/bnema/gordon/pkg/docker"
10 "github.com/labstack/echo/v4"10 "github.com/labstack/echo/v4"
11 "gopkg.in/yaml.v3"11 "gopkg.in/yaml.v3"
12 )12 )
M internal/httpserve/handler/oauth.go +1 -1
@@ -8,8 +8,8 @@ import (
88 "strings"
99
1010 "github.com/bnema/gordon/internal/app"
11- "github.com/bnema/gordon/internal/gotemplate/render"
1211 "github.com/bnema/gordon/internal/httpserve/middleware"
12+ "github.com/bnema/gordon/internal/templates/render"
1313 "github.com/bnema/gordon/internal/webui"
1414 _ "github.com/joho/godotenv/autoload"
1515 "github.com/labstack/echo-contrib/session"
@@ -8,8 +8,8 @@ import (
8 "strings"8 "strings"
9 9
10 "github.com/bnema/gordon/internal/app"10 "github.com/bnema/gordon/internal/app"
11- "github.com/bnema/gordon/internal/gotemplate/render"
12 "github.com/bnema/gordon/internal/httpserve/middleware"11 "github.com/bnema/gordon/internal/httpserve/middleware"
12+ "github.com/bnema/gordon/internal/templates/render"
13 "github.com/bnema/gordon/internal/webui"13 "github.com/bnema/gordon/internal/webui"
14 _ "github.com/joho/godotenv/autoload"14 _ "github.com/joho/godotenv/autoload"
15 "github.com/labstack/echo-contrib/session"15 "github.com/labstack/echo-contrib/session"
M internal/httpserve/handler/senderror.go +1 -1
@@ -3,7 +3,7 @@ package handler
33 import (
44 "net/http"
55
6- "github.com/bnema/gordon/pkg/utils/sanitize"
6+ "github.com/bnema/gordon/pkg/sanitize"
77 "github.com/labstack/echo/v4"
88 )
99
@@ -3,7 +3,7 @@ package handler
3 import (3 import (
4 "net/http"4 "net/http"
5 5
6- "github.com/bnema/gordon/pkg/utils/sanitize"6+ "github.com/bnema/gordon/pkg/sanitize"
7 "github.com/labstack/echo/v4"7 "github.com/labstack/echo/v4"
8 )8 )
9 9
M internal/httpserve/handler/uploadimage.go +2 -2
@@ -6,8 +6,8 @@ import (
66 "net/http"
77
88 "github.com/bnema/gordon/internal/app"
9- "github.com/bnema/gordon/internal/gotemplate/render"
10- "github.com/bnema/gordon/pkg/utils/store"
9+ "github.com/bnema/gordon/internal/templates/render"
10+ "github.com/bnema/gordon/pkg/store"
1111 "github.com/labstack/echo/v4"
1212 )
1313
@@ -6,8 +6,8 @@ import (
6 "net/http"6 "net/http"
7 7
8 "github.com/bnema/gordon/internal/app"8 "github.com/bnema/gordon/internal/app"
9- "github.com/bnema/gordon/internal/gotemplate/render"9+ "github.com/bnema/gordon/internal/templates/render"
10- "github.com/bnema/gordon/pkg/utils/store"10+ "github.com/bnema/gordon/pkg/store"
11 "github.com/labstack/echo/v4"11 "github.com/labstack/echo/v4"
12 )12 )
13 13
R internal/gotemplate/embed.go → internal/templates/embed.go +1 -1 renamed, 90% similar
@@ -1,4 +1,4 @@
1-package gotemplate
1+package templates
22
33 import (
44 "embed"
@@ -1,4 +1,4 @@
1-package gotemplate1+package templates
2 2
3 import (3 import (
4 "embed"4 "embed"
R internal/gotemplate/models/html/admin/dashboard.gohtml → internal/templates/models/html/admin/dashboard.gohtml +0 -0 renamed, 100% similar

renamed, 100% similar

R internal/gotemplate/models/html/admin/index.gohtml → internal/templates/models/html/admin/index.gohtml +0 -0 renamed, 100% similar

renamed, 100% similar

R internal/gotemplate/models/html/admin/install.gohtml → internal/templates/models/html/admin/install.gohtml +0 -0 renamed, 100% similar

renamed, 100% similar

R internal/gotemplate/models/html/admin/manager.gohtml → internal/templates/models/html/admin/manager.gohtml +0 -0 renamed, 100% similar

renamed, 100% similar

R internal/gotemplate/models/html/admin/user.gohtml → internal/templates/models/html/admin/user.gohtml +0 -0 renamed, 100% similar

renamed, 100% similar

R internal/gotemplate/models/html/fragments/components.gohtml → internal/templates/models/html/fragments/components.gohtml +0 -0 renamed, 100% similar

renamed, 100% similar

R internal/gotemplate/models/html/fragments/containerlist.gohtml → internal/templates/models/html/fragments/containerlist.gohtml +0 -0 renamed, 100% similar

renamed, 100% similar

R internal/gotemplate/models/html/fragments/createcontainer.gohtml → internal/templates/models/html/fragments/createcontainer.gohtml +0 -0 renamed, 100% similar

renamed, 100% similar

R internal/gotemplate/models/html/fragments/editcontainer.gohtml → internal/templates/models/html/fragments/editcontainer.gohtml +0 -0 renamed, 100% similar

renamed, 100% similar

R internal/gotemplate/models/html/fragments/footer.gohtml → internal/templates/models/html/fragments/footer.gohtml +0 -0 renamed, 100% similar

renamed, 100% similar

R internal/gotemplate/models/html/fragments/header.gohtml → internal/templates/models/html/fragments/header.gohtml +0 -0 renamed, 100% similar

renamed, 100% similar

R internal/gotemplate/models/html/fragments/imagelist.gohtml → internal/templates/models/html/fragments/imagelist.gohtml +0 -0 renamed, 100% similar

renamed, 100% similar

R internal/gotemplate/models/html/fragments/leftmenu.gohtml → internal/templates/models/html/fragments/leftmenu.gohtml +0 -0 renamed, 100% similar

renamed, 100% similar

R internal/gotemplate/models/html/fragments/uploadimage.gohtml → internal/templates/models/html/fragments/uploadimage.gohtml +0 -0 renamed, 100% similar

renamed, 100% similar

R internal/gotemplate/models/html/login/index.gohtml → internal/templates/models/html/login/index.gohtml +0 -0 renamed, 100% similar

renamed, 100% similar

R internal/gotemplate/models/strings.yml → internal/templates/models/strings.yml +0 -0 renamed, 100% similar

renamed, 100% similar

R internal/gotemplate/render/cmdparams.go → internal/templates/render/cmdparams.go +1 -1 renamed, 97% similar
@@ -4,7 +4,7 @@ import (
44 "fmt"
55 "strings"
66
7- "github.com/bnema/gordon/pkg/utils/docker"
7+ "github.com/bnema/gordon/pkg/docker"
88 )
99
1010 // FromInputsToCmdParams transforms the inputs map into a ContainerCommandParams struct
@@ -4,7 +4,7 @@ import (
4 "fmt"4 "fmt"
5 "strings"5 "strings"
6 6
7- "github.com/bnema/gordon/pkg/utils/docker"7+ "github.com/bnema/gordon/pkg/docker"
8 )8 )
9 9
10 // FromInputsToCmdParams transforms the inputs map into a ContainerCommandParams struct10 // FromInputsToCmdParams transforms the inputs map into a ContainerCommandParams struct
R internal/gotemplate/render/html.go → internal/templates/render/html.go +0 -0 renamed, 100% similar

renamed, 100% similar

M internal/webui/strings.go +1 -1
@@ -4,7 +4,7 @@ import (
44 "fmt"
55 "io/fs"
66
7- "github.com/bnema/gordon/pkg/utils/parser"
7+ "github.com/bnema/gordon/pkg/parser"
88 )
99
1010 type LangData map[string]interface{}
@@ -4,7 +4,7 @@ import (
4 "fmt"4 "fmt"
5 "io/fs"5 "io/fs"
6 6
7- "github.com/bnema/gordon/pkg/utils/parser"7+ "github.com/bnema/gordon/pkg/parser"
8 )8 )
9 9
10 type LangData map[string]interface{}10 type LangData map[string]interface{}
R pkg/utils/docker/client.go → pkg/docker/client.go +0 -0 renamed, 100% similar

renamed, 100% similar

R pkg/utils/docker/containers.go → pkg/docker/containers.go +0 -0 renamed, 100% similar

renamed, 100% similar

R pkg/utils/docker/images.go → pkg/docker/images.go +0 -0 renamed, 100% similar

renamed, 100% similar

R pkg/utils/htmx/htmlfragments.go → pkg/htmx/htmlfragments.go +0 -0 renamed, 100% similar

renamed, 100% similar

R pkg/utils/humanize/humanize.go → pkg/humanize/humanize.go +2 -0 renamed, 90% similar
@@ -5,6 +5,7 @@ import (
55 "time"
66 )
77
8+// BytesToReadableSize converts a number of bytes to a human-readable size
89 func BytesToReadableSize(size int64) string {
910 var unit string
1011 var converted float64
@@ -26,6 +27,7 @@ func BytesToReadableSize(size int64) string {
2627 return fmt.Sprintf("%.2f%s", converted, unit)
2728 }
2829
30+// TimeAgo returns a string representing the time elapsed since t
2931 func TimeAgo(t time.Time) string {
3032 var duration time.Duration
3133 now := time.Now()
@@ -5,6 +5,7 @@ import (
5 "time"5 "time"
6 )6 )
7 7
8+// BytesToReadableSize converts a number of bytes to a human-readable size
8 func BytesToReadableSize(size int64) string {9 func BytesToReadableSize(size int64) string {
9 var unit string10 var unit string
10 var converted float6411 var converted float64
@@ -26,6 +27,7 @@ func BytesToReadableSize(size int64) string {
26 return fmt.Sprintf("%.2f%s", converted, unit)27 return fmt.Sprintf("%.2f%s", converted, unit)
27 }28 }
28 29
30+// TimeAgo returns a string representing the time elapsed since t
29 func TimeAgo(t time.Time) string {31 func TimeAgo(t time.Time) string {
30 var duration time.Duration32 var duration time.Duration
31 now := time.Now()33 now := time.Now()
R pkg/utils/parser/yaml.go → pkg/parser/yaml.go +0 -0 renamed, 100% similar

renamed, 100% similar

R pkg/utils/sanitize/htmlsanitizer.go → pkg/sanitize/htmlsanitizer.go +0 -0 renamed, 100% similar

renamed, 100% similar

R pkg/utils/store/storeimages.go → pkg/store/storeimages.go +1 -1 renamed, 97% similar
@@ -7,7 +7,7 @@ import (
77 "path/filepath"
88
99 "github.com/bnema/gordon/internal/app"
10- "github.com/bnema/gordon/pkg/utils/docker"
10+ "github.com/bnema/gordon/pkg/docker"
1111 "github.com/docker/docker/api/types"
1212 )
1313
@@ -7,7 +7,7 @@ import (
7 "path/filepath"7 "path/filepath"
8 8
9 "github.com/bnema/gordon/internal/app"9 "github.com/bnema/gordon/internal/app"
10- "github.com/bnema/gordon/pkg/utils/docker"10+ "github.com/bnema/gordon/pkg/docker"
11 "github.com/docker/docker/api/types"11 "github.com/docker/docker/api/types"
12 )12 )
13 13

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