CurrentPath() func was moved to index.templ and was renamed to currentPathToLink().
This commit is contained in:
parent
dc2729ff91
commit
034216efd4
@ -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)
|
||||
}
|
||||
|
@ -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("/<a href=\"/")
|
||||
sb.WriteString(strings.Join(parts[:i+1], "/"))
|
||||
sb.WriteString("/\">")
|
||||
sb.WriteString(part)
|
||||
sb.WriteString("</a>")
|
||||
curPath += sb.String()
|
||||
}
|
||||
return
|
||||
}
|
@ -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("/<a href=\"/")
|
||||
sb.WriteString(strings.Join(parts[:i+1], "/"))
|
||||
sb.WriteString("/\">")
|
||||
sb.WriteString(part)
|
||||
sb.WriteString("</a>")
|
||||
curPath += sb.String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
templ Index(currentPath, progVer string, stat *files.DirStat, entries *[]files.DirEntry, r *http.Request) {
|
||||
<!doctype html>
|
||||
@ -39,7 +53,7 @@ templ Index(currentPath, progVer string, stat *files.DirStat, entries *[]files.D
|
||||
</header>
|
||||
<main>
|
||||
<section>
|
||||
<span><a href="/">{ i18n.T(ctx, "curpath-root") }</a>@templ.Raw(currentPath)</span>
|
||||
<span><a href="/">{ i18n.T(ctx, "curpath-root") }</a>@templ.Raw(currentPathToLink(currentPath))</span>
|
||||
<p>{ i18n.T(ctx, "stats.files") }: { strconv.FormatInt(stat.Files, 10) } ({ stat.FilesSize }); { i18n.T(ctx, "stats.directories") }: { strconv.FormatInt(stat.Directories, 10) }.</p>
|
||||
<input type="text" name="filter" placeholder={ i18n.T(ctx, "stats.filter") } class="hidden">
|
||||
</section>
|
||||
|
Loading…
Reference in New Issue
Block a user