package finder import ( "net/http" "personalwebsite/apps/appCtx" "personalwebsite/errormessage" "github.com/gin-gonic/gin" ) func (f *FinderApplication) PublicRoutes(routes *gin.RouterGroup) { routes.POST("render", func(ctx *gin.Context) { appCtx := appCtx.AppContext{} err := ctx.BindJSON(&appCtx) if err != nil { ctx.JSON(http.StatusBadRequest, errormessage.ErrorMessage{ Message: "Error in decoding app bundle", }) return } ctx.HTML(http.StatusOK, "finder/app.tmpl", f.Render(appCtx)) }) //Obsolete routes.GET("renderMobileDesktop", func(ctx *gin.Context) { ctx.HTML(http.StatusOK, "finder/mobile-desktop.tmpl", gin.H{}) }) routes.POST("renderDesktop", func(ctx *gin.Context) { path := ctx.Query("path") if path == "" { ctx.JSON(http.StatusBadRequest, "no path provided") return } ctx.HTML(http.StatusOK, "finder/desktop.tmpl", gin.H{}) }) routes.GET("contextMenu", func(ctx *gin.Context) { context := ctx.Query("context") filePath := ctx.Query("path") if filePath == "" { ctx.Status(http.StatusBadRequest) return } data := ctx.Query("data") ginH := f.RenderPublicContextMenu(context, filePath, data) ctx.HTML(http.StatusOK, "wde-widgets/context-menu.tmpl", ginH) }) routes.GET("renderProps", func(ctx *gin.Context) { filePath := ctx.Query("path") ginH, err := f.RenderProps(filePath) if err != nil { ctx.Status(http.StatusInternalServerError) return } ctx.HTML(http.StatusOK, "finder/props.tmpl", ginH) }) } func (f *FinderApplication) PrivateRoutes(routes *gin.RouterGroup) { routes.POST("render", func(ctx *gin.Context) { appCtx := appCtx.AppContext{} err := ctx.BindJSON(&appCtx) if err != nil { ctx.JSON(http.StatusBadRequest, errormessage.ErrorMessage{ Message: "Error in decoding app bundle", }) return } ctx.HTML(http.StatusOK, "finder/admin-app.tmpl", f.Render(appCtx)) }) routes.GET("renderMobileDesktop", func(ctx *gin.Context) { ctx.HTML(http.StatusOK, "finder/mobile-desktop.tmpl", gin.H{}) }) routes.POST("renderDesktop", func(ctx *gin.Context) { path := ctx.Query("path") if path == "" { ctx.JSON(http.StatusBadRequest, "no path provided") return } ctx.HTML(http.StatusOK, "finder/desktop.tmpl", gin.H{}) }) routes.GET("contextMenu", func(ctx *gin.Context) { context := ctx.Query("context") filePath := ctx.Query("path") if filePath == "" { ctx.Status(http.StatusBadRequest) return } data := ctx.Query("data") ginH := f.RenderPrivateContextMenu(context, filePath, data) ctx.HTML(http.StatusOK, "wde-widgets/context-menu.tmpl", ginH) }) routes.GET("renderProps", func(ctx *gin.Context) { filePath := ctx.Query("path") ginH, err := f.RenderProps(filePath) if err != nil { ctx.Status(http.StatusInternalServerError) return } ctx.HTML(http.StatusOK, "finder/props.tmpl", ginH) }) }