29 lines
688 B
Go
29 lines
688 B
Go
package views
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.zervo.org/zervo/fileserver/internal/config"
|
|
"git.zervo.org/zervo/fileserver/internal/util/data"
|
|
"github.com/kataras/iris/v12"
|
|
)
|
|
|
|
type directorypage struct {
|
|
Directories []config.DirectoryConfig
|
|
}
|
|
|
|
// DirectoriesView renders the view for '/directories'.
|
|
func DirectoriesView(ctx iris.Context, cfg *config.ServerConfig) {
|
|
ctx.CompressWriter(true)
|
|
ctx.ViewData("", data.LayoutData{
|
|
ServerName: cfg.ServerName,
|
|
ServerVersion: "0.0.1",
|
|
Page: directorypage{
|
|
Directories: cfg.Directories,
|
|
},
|
|
})
|
|
if err := ctx.View("directories.html"); err != nil {
|
|
errorView(ctx, fmt.Errorf("Failed to render DirectoriesView: %v", err))
|
|
return
|
|
}
|
|
}
|