53 lines
983 B
Go
53 lines
983 B
Go
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
|
|
}
|
|
|
|
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
|
|
}
|