1
0
Fork 0

Made use of DirStats struct in a template.

This commit is contained in:
Alexander Andreev 2022-06-27 23:26:33 +04:00
parent feda955c38
commit ca6e28b376
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F
2 changed files with 6 additions and 7 deletions

View File

@ -9,7 +9,6 @@ import (
"html"
"io"
"net/http"
"strconv"
)
const (
@ -27,7 +26,7 @@ const (
index__11 = `</td></tr>`
)
func Index(mainSite, currentPath string, totalFiles, totalFilesSize, totalDirectories int64, items *[]files.DirEntry, r *http.Request, wr io.Writer) {
func Index(mainSite, currentPath string, stats *files.DirStats, items *[]files.DirEntry, r *http.Request, wr io.Writer) {
buffer := &WriterAsBuffer{wr}
buffer.WriteString(index__0)
@ -35,11 +34,11 @@ func Index(mainSite, currentPath string, totalFiles, totalFilesSize, totalDirect
buffer.WriteString(index__1)
buffer.WriteString(currentPath)
buffer.WriteString(index__2)
buffer.WriteString(html.EscapeString(strconv.FormatInt(totalFiles, 10)))
buffer.WriteString(html.EscapeString(fmt.Sprintf("%v", stats.Files)))
buffer.WriteString(index__3)
buffer.WriteString(html.EscapeString(strconv.FormatInt(totalFilesSize, 10)))
buffer.WriteString(html.EscapeString(fmt.Sprintf("%v", stats.FilesSize)))
buffer.WriteString(index__4)
buffer.WriteString(html.EscapeString(strconv.FormatInt(totalDirectories, 10)))
buffer.WriteString(html.EscapeString(fmt.Sprintf("%v", stats.Directories)))
buffer.WriteString(index__5)
for _, item := range *items {

View File

@ -1,4 +1,4 @@
:go:func Index(mainSite, currentPath string, totalFiles, totalFilesSize, totalDirectories int64, items *[]files.DirEntry, r *http.Request)
:go:func Index(mainSite, currentPath string, stats *files.DirStats, items *[]files.DirEntry, r *http.Request)
:go:import "dwelling-files/pkg/files"
:go:import "dwelling-files/pkg/utils"
@ -25,7 +25,7 @@ html(lang='en')
h1 Files
section#files
span#current-path!= currentPath
p Files: #{totalFiles} (#{totalFilesSize}); Directories: #{totalDirectories}.
p Files: #{stats.Files} (#{stats.FilesSize}); Directories: #{stats.Directories}.
table
thead
tr