2023-04-29 13:58:39 +00:00
|
|
|
package wde
|
|
|
|
|
|
|
|
import (
|
|
|
|
"personalwebsite/webfilesystem"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
type WDE struct {
|
|
|
|
fs *webfilesystem.WebFileSystem
|
|
|
|
FilesWidget FilesWidget
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewWDE(webFs *webfilesystem.WebFileSystem) *WDE {
|
|
|
|
return &WDE{
|
|
|
|
fs: webFs,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type FilesWidget struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *WDE) Render(path string) (gin.H, error) {
|
|
|
|
list, err := w.fs.List(path)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return gin.H{
|
|
|
|
"Name": "Greg Brzezinski",
|
|
|
|
"Files": list,
|
|
|
|
}, nil
|
|
|
|
}
|
2023-05-01 12:32:41 +00:00
|
|
|
|
|
|
|
func (w *WDE) RenderFileTileView(path string) (gin.H, error) {
|
|
|
|
list, err := w.fs.List(path)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
for _, file := range list {
|
|
|
|
switch file.Type {
|
|
|
|
case "directory":
|
|
|
|
file.Icon = "TODO"
|
|
|
|
case "base64img":
|
|
|
|
file.Icon = "http://localhost:8080/system/imglib/get?path=/home/user/cat2-test.jpeg&min=min32"
|
|
|
|
default:
|
|
|
|
file.Icon = "http://localhost:8080/system/imglib/get?path=/home/user/cat2-test.jpeg&min=min32"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return gin.H{
|
|
|
|
"Files": list,
|
|
|
|
}, nil
|
|
|
|
}
|