personal-website/apps/finder/finder.go
2023-07-24 03:27:53 +03:00

92 lines
2.0 KiB
Go

package finder
import (
"path"
"personalwebsite/apps"
"personalwebsite/apps/appCtx"
"personalwebsite/wde"
"personalwebsite/webfilesystem"
"github.com/gin-gonic/gin"
)
type FinderApplication struct {
fs *webfilesystem.WebFileSystem
appID string
titleBarConfig wde.TitleBarConfig
path string
manifest apps.ApplicationManifest
// manifest apps.ApplicationManifest
}
func NewFinderApplication(webFs *webfilesystem.WebFileSystem) *FinderApplication {
manifest := apps.ApplicationManifest{}
_, err := webFs.Read(path.Join("/Applications/Finder.app", ".appmanifest"), &manifest)
if err != nil {
panic(err)
}
return &FinderApplication{
fs: webFs,
path: "/Applications/Finder.app",
appID: "Finder",
titleBarConfig: wde.TitleBarConfig{
Lable: "Finder",
CloseButton: true,
HasIcon: true,
IconPath: "/Icons/GenericFolder.icn",
IconSize: "16",
},
manifest: manifest,
}
}
func (f *FinderApplication) GetManifest() apps.ApplicationManifest {
return f.manifest
}
func (f *FinderApplication) GetAppID() string {
return f.appID
}
func (f *FinderApplication) GetPath() string {
return f.path
}
func (f *FinderApplication) Render(appCtx appCtx.AppContext) gin.H {
return gin.H{
"TitleBarConfig": f.titleBarConfig,
}
}
func (f *FinderApplication) RenderPublicContextMenu(context string, filePath string, data string) gin.H {
islands := [][]wde.ContexMenuRow{}
islands = append(islands, []wde.ContexMenuRow{})
//TODO: Links read as source files in props info
islands = append(islands, []wde.ContexMenuRow{
{Label: "Get Info", Action: "getInfo"},
})
if context == "FileTileView" {
return gin.H{
"Islands": islands,
}
}
switch context {
default:
}
return gin.H{
"Islands": islands,
}
}
func (f *FinderApplication) RenderProps(filePath string) (gin.H, error) {
fileHeader, err := f.fs.Read(filePath, nil)
if err != nil {
return nil, err
}
return gin.H{
"file": fileHeader,
}, nil
}