personal-website/routewde/wde.go

38 lines
967 B
Go
Raw Normal View History

2023-03-17 01:16:51 +00:00
package routewde
import (
"net/http"
2023-04-29 13:58:39 +00:00
"personalwebsite/wde"
2023-03-17 01:16:51 +00:00
2023-05-02 00:59:11 +00:00
"github.com/gin-contrib/location"
2023-03-17 01:16:51 +00:00
"github.com/gin-gonic/gin"
)
func PublicRoutes(route *gin.RouterGroup, wde *wde.WDE) {
route.GET("/getbasicwindow", func(ctx *gin.Context) { //TODO Rename to renderGenericWindowFrame
2023-03-17 01:16:51 +00:00
ctx.HTML(http.StatusOK, "basic-window.html", nil)
})
2023-03-22 21:53:06 +00:00
2023-04-13 01:09:07 +00:00
route.GET("/renderMobileDesktop", func(ctx *gin.Context) {
ctx.HTML(http.StatusOK, "base/mobile-desktop.tmpl", nil)
})
2023-03-22 21:53:06 +00:00
widgets := route.Group("widgets")
{
widgets.GET("/file-tile-view", func(ctx *gin.Context) {
2023-05-02 00:59:11 +00:00
url := location.Get(ctx)
2023-04-29 13:58:39 +00:00
path := ctx.Query("path")
if path == "" {
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
return
}
2023-05-02 00:59:11 +00:00
ginH, err := wde.RenderFileTileView(path, url.Scheme+"://"+url.Host)
2023-04-29 13:58:39 +00:00
if err != nil {
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO
return
}
ctx.HTML(http.StatusOK, "wde-widgets/file-tile-view.tmpl", ginH)
2023-03-22 21:53:06 +00:00
})
}
2023-03-17 01:16:51 +00:00
}