87 lines
1.9 KiB
Go
87 lines
1.9 KiB
Go
package sunboard
|
|
|
|
import (
|
|
"net/http"
|
|
"path"
|
|
"personalwebsite/apps"
|
|
"personalwebsite/wde"
|
|
"personalwebsite/webfilesystem"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type SunboardApp struct {
|
|
fs *webfilesystem.WebFileSystem
|
|
wde *wde.WDE
|
|
appID string
|
|
appStorage *apps.ApplicationsStorage
|
|
path string
|
|
manifest apps.ApplicationManifest
|
|
}
|
|
|
|
func NewSunboardApp(webFs *webfilesystem.WebFileSystem, wde *wde.WDE, appStorage *apps.ApplicationsStorage) *SunboardApp {
|
|
manifest := apps.ApplicationManifest{}
|
|
_, err := webFs.Read(path.Join("/Applications/Sunboard.app", ".appmanifest"), &manifest)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
newApp := SunboardApp{
|
|
fs: webFs,
|
|
wde: wde,
|
|
appID: "Sunboard",
|
|
appStorage: appStorage,
|
|
path: "/Applications/Sunboard.app",
|
|
manifest: manifest,
|
|
}
|
|
return &newApp
|
|
}
|
|
|
|
func (a *SunboardApp) GetAppID() string {
|
|
return a.appID
|
|
}
|
|
|
|
func (a *SunboardApp) PublicRoutes(route *gin.RouterGroup) {
|
|
}
|
|
|
|
func (a *SunboardApp) GetPath() string {
|
|
return a.path
|
|
}
|
|
func (a *SunboardApp) GetManifest() apps.ApplicationManifest {
|
|
return a.manifest
|
|
}
|
|
|
|
func (a *SunboardApp) PrivateRoutes(router *gin.RouterGroup) {
|
|
router.POST("render", func(ctx *gin.Context) {
|
|
appIcons := []appIcon{}
|
|
for _, app := range a.appStorage.Apps {
|
|
if app.GetAppID() == "Sunboard" { //FIXME
|
|
continue
|
|
}
|
|
|
|
if app.GetManifest().Iconpath == "" {
|
|
continue
|
|
}
|
|
println(app.GetAppID() + " : " + app.GetPath())
|
|
// iconPath := path.Join(, "icon.icn")
|
|
appIcons = append(appIcons, appIcon{
|
|
Type: "Icon",
|
|
Icon: "/system/libs/img/icon/get?path=" + app.GetManifest().Iconpath + "&size=32",
|
|
Lable: app.GetAppID(),
|
|
AppId: app.GetAppID(),
|
|
Path: app.GetPath(),
|
|
})
|
|
}
|
|
ctx.HTML(http.StatusOK, "sunboard/sunboard.html", gin.H{
|
|
"AppsIcons": appIcons,
|
|
})
|
|
})
|
|
}
|
|
|
|
type appIcon struct {
|
|
AppId string
|
|
Type string
|
|
Icon string
|
|
Lable string
|
|
Path string
|
|
}
|