diff --git a/cmd/dwelling-files/main.go b/cmd/dwelling-files/main.go index 6362d65..8cde8f5 100644 --- a/cmd/dwelling-files/main.go +++ b/cmd/dwelling-files/main.go @@ -107,5 +107,5 @@ func Index(w http.ResponseWriter, r *http.Request) { return } - web.Index(files.CurrentPath(path), version, &stats, &entries, r).Render(r.Context(), w) + web.Index(path, version, &stats, &entries, r).Render(r.Context(), w) } diff --git a/pkg/files/curpath.go b/pkg/files/curpath.go deleted file mode 100644 index b51d9db..0000000 --- a/pkg/files/curpath.go +++ /dev/null @@ -1,19 +0,0 @@ -package files - -import ( - "strings" -) - -func CurrentPath(path string) (curPath string) { - parts := strings.Split(path, "/")[1:] - for i, part := range parts { - var sb strings.Builder - sb.WriteString("/") - sb.WriteString(part) - sb.WriteString("") - curPath += sb.String() - } - return -} diff --git a/web/index.templ b/web/index.templ index 302e348..d3b553b 100644 --- a/web/index.templ +++ b/web/index.templ @@ -5,7 +5,21 @@ import "net/http" import "dwelling-files/pkg/files" import "dwelling-files/pkg/utils" import "strconv" +import "strings" +func currentPathToLink(path string) (curPath string) { + parts := strings.Split(path, "/")[1:] + for i, part := range parts { + var sb strings.Builder + sb.WriteString("/") + sb.WriteString(part) + sb.WriteString("") + curPath += sb.String() + } + return +} templ Index(currentPath, progVer string, stat *files.DirStat, entries *[]files.DirEntry, r *http.Request) { @@ -39,7 +53,7 @@ templ Index(currentPath, progVer string, stat *files.DirStat, entries *[]files.D
- { i18n.T(ctx, "curpath-root") }@templ.Raw(currentPath) + { i18n.T(ctx, "curpath-root") }@templ.Raw(currentPathToLink(currentPath))

{ i18n.T(ctx, "stats.files") }: { strconv.FormatInt(stat.Files, 10) } ({ stat.FilesSize }); { i18n.T(ctx, "stats.directories") }: { strconv.FormatInt(stat.Directories, 10) }.