personal-website/wde/wde.go

70 lines
1.3 KiB
Go
Raw Permalink Normal View History

2023-04-29 13:58:39 +00:00
package wde
import (
2023-05-02 00:12:43 +00:00
"path"
2023-04-29 13:58:39 +00:00
"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) {
2023-05-07 01:00:22 +00:00
// list, err := w.fs.NewListDeprecated(path)
// if err != nil {
// return nil, err
// }
2023-04-29 13:58:39 +00:00
return gin.H{
2023-05-07 01:00:22 +00:00
"Name": "Greg Brzezinski",
// "Files": list,
2023-04-29 13:58:39 +00:00
}, nil
}
2023-05-01 12:32:41 +00:00
2023-05-04 00:38:24 +00:00
func (w *WDE) RenderContextMenu() (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-02 00:59:11 +00:00
func (w *WDE) RenderFileTileView(directory string, host string) (gin.H, error) {
2023-05-07 01:00:22 +00:00
list, err := w.fs.ListDir(directory)
2023-05-01 12:32:41 +00:00
if err != nil {
return nil, err
}
2023-05-07 00:14:30 +00:00
2023-05-01 12:32:41 +00:00
for _, file := range list {
switch file.Type {
case "directory":
2023-05-02 00:59:11 +00:00
file.Icon = host + "/system/libs/img/get?path=/wde/icons/macos9/folder.png" //FIXME
2023-05-02 00:12:43 +00:00
case "jpeg":
fallthrough
case "png":
fallthrough
case "jpg":
2023-05-02 00:59:11 +00:00
file.Icon = host + "/system/libs/img/get?path=" + path.Join(directory, file.Name) //FIXME
2023-05-01 12:32:41 +00:00
default:
2023-05-02 00:59:11 +00:00
file.Icon = host + "/system/libs/img/get?path=/wde/icons/macos9/about-me.png" //FIXME
2023-05-01 12:32:41 +00:00
}
}
return gin.H{
"Files": list,
}, nil
}