personal-website/wde/routes.go

37 lines
935 B
Go
Raw Permalink Normal View History

2023-05-28 01:28:48 +00:00
package wde
2023-03-17 01:16:51 +00:00
import (
"net/http"
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"
)
2023-05-28 01:28:48 +00:00
func PublicRoutes(route *gin.RouterGroup, 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
}