Move apps to classes
This commit is contained in:
parent
0ae5eb4325
commit
139831365a
@ -1,8 +1,9 @@
|
||||
package blogviewer
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"personalwebsite/apps"
|
||||
"personalwebsite/webfilesystem"
|
||||
"personalwebsite/websiteapp"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
@ -10,20 +11,20 @@ import (
|
||||
|
||||
type BlogViewerApplication struct {
|
||||
fs *webfilesystem.WebFileSystem
|
||||
manifest websiteapp.ApplicationManifest
|
||||
manifest apps.ApplicationManifest
|
||||
}
|
||||
|
||||
func NewBlogViewerApp(webFs *webfilesystem.WebFileSystem) *BlogViewerApplication {
|
||||
return &BlogViewerApplication{
|
||||
fs: webFs,
|
||||
manifest: websiteapp.ApplicationManifest{
|
||||
manifest: apps.ApplicationManifest{
|
||||
AppId: "blog-viewer",
|
||||
WindowName: "",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (b *BlogViewerApplication) GetManifest() websiteapp.ApplicationManifest {
|
||||
func (b *BlogViewerApplication) GetManifest() apps.ApplicationManifest {
|
||||
return b.manifest
|
||||
}
|
||||
|
||||
@ -31,6 +32,41 @@ func (b *BlogViewerApplication) GetId() string {
|
||||
return b.manifest.AppId
|
||||
}
|
||||
|
||||
func (b *BlogViewerApplication) Route(route *gin.RouterGroup) {
|
||||
route.GET("writeMockBlog", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "no path provided")
|
||||
return
|
||||
}
|
||||
b.WriteMock(path)
|
||||
ctx.JSON(http.StatusOK, "OK")
|
||||
})
|
||||
|
||||
route.GET("render", func(ctx *gin.Context) {
|
||||
isMobileParam := ctx.Query("isMobile")
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "no path provided")
|
||||
return
|
||||
}
|
||||
|
||||
isMobile := isMobileParam == "true"
|
||||
ginH, err := b.Render(path, isMobile)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO")
|
||||
return
|
||||
}
|
||||
|
||||
if isMobile {
|
||||
ctx.HTML(http.StatusOK, "blog-viewer/mobile-app.tmpl", ginH)
|
||||
} else {
|
||||
ctx.HTML(http.StatusOK, "blog-viewer/app.tmpl", ginH)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
func (b *BlogViewerApplication) WriteMock(path string) {
|
||||
blogFile := webfilesystem.WebFSFile{
|
||||
MongoId: primitive.NewObjectID(),
|
59
apps/finder/finder.go
Normal file
59
apps/finder/finder.go
Normal file
@ -0,0 +1,59 @@
|
||||
package finder
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"personalwebsite/apps"
|
||||
"personalwebsite/webfilesystem"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type FinderApplication struct {
|
||||
fs *webfilesystem.WebFileSystem
|
||||
manifest apps.ApplicationManifest
|
||||
}
|
||||
|
||||
func NewFinderApplication(webFs *webfilesystem.WebFileSystem) *FinderApplication {
|
||||
return &FinderApplication{
|
||||
fs: webFs,
|
||||
manifest: apps.ApplicationManifest{
|
||||
AppId: "finder",
|
||||
WindowName: "TODO DELETE", //TODO DELETE
|
||||
},
|
||||
}
|
||||
}
|
||||
func (f *FinderApplication) GetManifest() apps.ApplicationManifest {
|
||||
return f.manifest
|
||||
}
|
||||
func (f *FinderApplication) GetId() string {
|
||||
return f.manifest.AppId
|
||||
}
|
||||
|
||||
func (f *FinderApplication) Render(isMobile bool) gin.H {
|
||||
|
||||
return gin.H{}
|
||||
}
|
||||
|
||||
func (f *FinderApplication) Routes(routes *gin.RouterGroup) {
|
||||
routes.GET("render", func(ctx *gin.Context) {
|
||||
isMobileParam := ctx.Query("isMobile")
|
||||
isMobile := isMobileParam == "true"
|
||||
if isMobile {
|
||||
ctx.HTML(http.StatusOK, "finder/mobile-app.tmpl", f.Render(isMobile))
|
||||
} else {
|
||||
ctx.HTML(http.StatusOK, "finder/app.tmpl", f.Render(isMobile))
|
||||
}
|
||||
|
||||
})
|
||||
routes.GET("renderMobileDesktop", func(ctx *gin.Context) {
|
||||
ctx.HTML(http.StatusOK, "finder/mobile-desktop.tmpl", gin.H{})
|
||||
})
|
||||
routes.GET("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{})
|
||||
})
|
||||
}
|
22
apps/finder/finderadmin.go
Normal file
22
apps/finder/finderadmin.go
Normal file
@ -0,0 +1,22 @@
|
||||
package finder
|
||||
|
||||
import (
|
||||
"personalwebsite/apps"
|
||||
"personalwebsite/webfilesystem"
|
||||
)
|
||||
|
||||
type FinderAdminApp struct {
|
||||
fs *webfilesystem.WebFileSystem
|
||||
manifest apps.ApplicationManifest
|
||||
}
|
||||
|
||||
func NewFinderAdminApp(webfs *webfilesystem.WebFileSystem) FinderAdminApp {
|
||||
return FinderAdminApp{
|
||||
fs: webfs,
|
||||
manifest: apps.ApplicationManifest{},
|
||||
}
|
||||
}
|
||||
|
||||
func (f *FinderAdminApp) RenderWindow() {
|
||||
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
package imgviewer
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
websiteapp "personalwebsite/apps"
|
||||
"personalwebsite/libs"
|
||||
"personalwebsite/webfilesystem"
|
||||
"personalwebsite/websiteapp"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -24,6 +25,28 @@ func NewImgViewerApp(webFs *webfilesystem.WebFileSystem) ImgViewerApp {
|
||||
return newApp
|
||||
}
|
||||
|
||||
func (p *ImgViewerApp) Route(route *gin.RouterGroup) {
|
||||
route.GET("render", func(ctx *gin.Context) {
|
||||
isMobileParam := ctx.Query("isMobile")
|
||||
isMobile := isMobileParam == "true"
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "no path provided")
|
||||
return
|
||||
}
|
||||
ginH, err := p.Render(path, isMobile)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO")
|
||||
return
|
||||
}
|
||||
if isMobile {
|
||||
ctx.HTML(http.StatusOK, "img-viewer/mobile-app.tmpl", ginH)
|
||||
} else {
|
||||
ctx.HTML(http.StatusOK, "img-viewer/app.tmpl", ginH)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (p *ImgViewerApp) GetManifest() websiteapp.ApplicationManifest {
|
||||
return p.manifest
|
||||
}
|
@ -2,9 +2,10 @@ package personalprops
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
websiteapp "personalwebsite/apps"
|
||||
"personalwebsite/libs"
|
||||
"personalwebsite/webfilesystem"
|
||||
"personalwebsite/websiteapp"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
@ -26,6 +27,22 @@ func NewPersPropsApp(webFs *webfilesystem.WebFileSystem) PersonalPropertiesApp {
|
||||
return newApp
|
||||
}
|
||||
|
||||
func (p *PersonalPropertiesApp) Route(route *gin.RouterGroup) {
|
||||
route.GET("render", func(ctx *gin.Context) {
|
||||
isMobileParam := ctx.Query("isMobile")
|
||||
isMobile := isMobileParam == "true"
|
||||
ginH, err := p.Render()
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO
|
||||
}
|
||||
if isMobile {
|
||||
ctx.HTML(http.StatusOK, "personal-properties/mobile-app.tmpl", ginH)
|
||||
} else {
|
||||
ctx.HTML(http.StatusOK, "personal-properties/app.tmpl", ginH)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (p *PersonalPropertiesApp) GetManifest() websiteapp.ApplicationManifest {
|
||||
return p.manifest
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package websiteapp
|
||||
package apps
|
||||
|
||||
import (
|
||||
"net/http"
|
234
main.go
234
main.go
@ -8,14 +8,14 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"personalwebsite/apps"
|
||||
"personalwebsite/apps/blogviewer"
|
||||
"personalwebsite/apps/finder"
|
||||
imgviewer "personalwebsite/apps/img-viewer"
|
||||
"personalwebsite/apps/personalprops"
|
||||
"personalwebsite/routewde"
|
||||
"personalwebsite/wde"
|
||||
"personalwebsite/webfilesystem"
|
||||
"personalwebsite/websiteapp"
|
||||
"personalwebsite/websiteapp/blogviewer"
|
||||
"personalwebsite/websiteapp/finder"
|
||||
imgviewer "personalwebsite/websiteapp/img-viewer"
|
||||
"personalwebsite/websiteapp/personalprops"
|
||||
|
||||
"github.com/gin-contrib/location"
|
||||
"github.com/gin-gonic/gin"
|
||||
@ -74,8 +74,8 @@ func main() {
|
||||
finderApp := finder.NewFinderApplication(webfs)
|
||||
imgViewerApp := imgviewer.NewImgViewerApp(webfs)
|
||||
blogViewerApp := blogviewer.NewBlogViewerApp(webfs)
|
||||
appsStorage := websiteapp.ApplicationsStorage{
|
||||
Apps: map[string]websiteapp.WebDEApplication{},
|
||||
appsStorage := apps.ApplicationsStorage{
|
||||
Apps: map[string]apps.WebDEApplication{},
|
||||
}
|
||||
appsStorage.Apps["personal-properties"] = &persPropsApp
|
||||
appsStorage.Apps["finder"] = finderApp
|
||||
@ -140,216 +140,66 @@ func main() {
|
||||
{
|
||||
routewde.Route(wdeGroup, webde)
|
||||
}
|
||||
apps := system.Group("applications")
|
||||
{
|
||||
apps.GET("/:appid/:method", func(ctx *gin.Context) {
|
||||
appId := ctx.Param("appid")
|
||||
method := ctx.Param("method")
|
||||
// apps := system.Group("applications")
|
||||
// {
|
||||
// apps.GET("/:appid/:method", func(ctx *gin.Context) {
|
||||
// appId := ctx.Param("appid")
|
||||
// method := ctx.Param("method")
|
||||
|
||||
app, isExist := appsStorage.Apps[appId]
|
||||
if !isExist {
|
||||
ctx.Status(http.StatusNoContent)
|
||||
return
|
||||
}
|
||||
switch method {
|
||||
case "getmanifest":
|
||||
ctx.JSON(http.StatusOK, app.GetManifest())
|
||||
case "app.js":
|
||||
ctx.File("resources/sys/" + appId + "/" + appId + ".js")
|
||||
case "app.css":
|
||||
ctx.File("resources/sys/" + appId + "/" + appId + ".css")
|
||||
default:
|
||||
ctx.Status(http.StatusBadRequest)
|
||||
}
|
||||
})
|
||||
}
|
||||
// app, isExist := appsStorage.Apps[appId]
|
||||
// if !isExist {
|
||||
// ctx.Status(http.StatusNoContent)
|
||||
// return
|
||||
// }
|
||||
// switch method {
|
||||
// case "getmanifest":
|
||||
// ctx.JSON(http.StatusOK, app.GetManifest())
|
||||
// case "app.js":
|
||||
// ctx.File("resources/sys/" + appId + "/" + appId + ".js")
|
||||
// case "app.css":
|
||||
// ctx.File("resources/sys/" + appId + "/" + appId + ".css")
|
||||
// default:
|
||||
// ctx.Status(http.StatusBadRequest)
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
websiteapp.Route(apps.Group("/storage"), &appsStorage)
|
||||
// apps.Route(apps.Group("/storage"), &appsStorage)
|
||||
}
|
||||
|
||||
fs := router.Group("fs")
|
||||
{
|
||||
fs.GET("writeFile", func(ctx *gin.Context) {
|
||||
parentPath := ctx.Query("parentPath")
|
||||
if parentPath == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
file := webfilesystem.WebFSFile{
|
||||
MongoId: primitive.NewObjectID(),
|
||||
Name: "pp",
|
||||
Type: "test",
|
||||
Data: nil,
|
||||
}
|
||||
err := webfs.CreateFile(&file, parentPath)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, "OK")
|
||||
})
|
||||
fs.GET("createDir", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
err := webfs.CreateDirectory(path)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, "OK")
|
||||
})
|
||||
|
||||
fs.GET("list", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
files, err := webfs.List(path)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, &files)
|
||||
})
|
||||
|
||||
fs.GET("read", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
file, err := webfs.Read(path)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, &file)
|
||||
})
|
||||
webfs.Route(fs)
|
||||
}
|
||||
app := router.Group("application")
|
||||
{
|
||||
persPropApp := app.Group("personal-properties")
|
||||
{
|
||||
persPropApp.GET("render", func(ctx *gin.Context) {
|
||||
isMobileParam := ctx.Query("isMobile")
|
||||
isMobile := isMobileParam == "true"
|
||||
ginH, err := persPropsApp.Render()
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO
|
||||
}
|
||||
if isMobile {
|
||||
ctx.HTML(http.StatusOK, "personal-properties/mobile-app.tmpl", ginH)
|
||||
} else {
|
||||
ctx.HTML(http.StatusOK, "personal-properties/app.tmpl", ginH)
|
||||
}
|
||||
})
|
||||
persPropsApp.Route(persPropApp)
|
||||
}
|
||||
finderAppRoute := app.Group("finder")
|
||||
{
|
||||
finderAppRoute.GET("render", func(ctx *gin.Context) {
|
||||
isMobileParam := ctx.Query("isMobile")
|
||||
isMobile := isMobileParam == "true"
|
||||
if isMobile {
|
||||
ctx.HTML(http.StatusOK, "finder/mobile-app.tmpl", finderApp.Render(isMobile))
|
||||
} else {
|
||||
ctx.HTML(http.StatusOK, "finder/app.tmpl", finderApp.Render(isMobile))
|
||||
}
|
||||
|
||||
})
|
||||
finderAppRoute.GET("renderMobileDesktop", func(ctx *gin.Context) {
|
||||
ctx.HTML(http.StatusOK, "finder/mobile-desktop.tmpl", gin.H{})
|
||||
})
|
||||
finderAppRoute.GET("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{})
|
||||
})
|
||||
finderApp.Routes(finderAppRoute)
|
||||
}
|
||||
imgViewerRoute := app.Group("img-viewer")
|
||||
{
|
||||
imgViewerRoute.GET("render", func(ctx *gin.Context) {
|
||||
isMobileParam := ctx.Query("isMobile")
|
||||
isMobile := isMobileParam == "true"
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "no path provided")
|
||||
return
|
||||
}
|
||||
ginH, err := imgViewerApp.Render(path, isMobile)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO")
|
||||
return
|
||||
}
|
||||
if isMobile {
|
||||
ctx.HTML(http.StatusOK, "img-viewer/mobile-app.tmpl", ginH)
|
||||
} else {
|
||||
ctx.HTML(http.StatusOK, "img-viewer/app.tmpl", ginH)
|
||||
}
|
||||
|
||||
})
|
||||
imgViewerApp.Route(imgViewerRoute)
|
||||
}
|
||||
blogViewerRoute := app.Group("blog-viewer")
|
||||
{
|
||||
blogViewerRoute.GET("writeMockBlog", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "no path provided")
|
||||
return
|
||||
}
|
||||
blogViewerApp.WriteMock(path)
|
||||
ctx.JSON(http.StatusOK, "OK")
|
||||
})
|
||||
blogViewerApp.Route(blogViewerRoute)
|
||||
}
|
||||
|
||||
blogViewerRoute.GET("render", func(ctx *gin.Context) {
|
||||
isMobileParam := ctx.Query("isMobile")
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "no path provided")
|
||||
return
|
||||
}
|
||||
|
||||
isMobile := isMobileParam == "true"
|
||||
ginH, err := blogViewerApp.Render(path, isMobile)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO")
|
||||
return
|
||||
}
|
||||
|
||||
if isMobile {
|
||||
ctx.HTML(http.StatusOK, "blog-viewer/mobile-app.tmpl", ginH)
|
||||
} else {
|
||||
ctx.HTML(http.StatusOK, "blog-viewer/app.tmpl", ginH)
|
||||
}
|
||||
|
||||
})
|
||||
err = router.Run(":8080")
|
||||
if err != nil {
|
||||
log.Panicf("error: %s", err)
|
||||
}
|
||||
}
|
||||
router.GET("/test", func(ctx *gin.Context) {
|
||||
ctx.HTML(200, "kek/kek.tmpl", gin.H{})
|
||||
})
|
||||
|
||||
if err := router.Run(":8080"); err != nil {
|
||||
log.Panicf("error: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func index(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "base.html", nil)
|
||||
}
|
||||
// func index(c *gin.Context) {
|
||||
// c.HTML(http.StatusOK, "base.html", nil)
|
||||
// }
|
||||
|
||||
func FindEnv(parameter string) (string, error) {
|
||||
path, exists := os.LookupEnv(parameter)
|
||||
|
@ -3,8 +3,10 @@ package webfilesystem
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
@ -172,6 +174,76 @@ func (fs *WebFileSystem) GetParentPath(path string) string {
|
||||
return parentPath
|
||||
}
|
||||
|
||||
func (fs *WebFileSystem) Route(route *gin.RouterGroup) {
|
||||
route.GET("writeFile", func(ctx *gin.Context) {
|
||||
parentPath := ctx.Query("parentPath")
|
||||
if parentPath == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
file := WebFSFile{
|
||||
MongoId: primitive.NewObjectID(),
|
||||
Name: "pp",
|
||||
Type: "test",
|
||||
Data: nil,
|
||||
}
|
||||
err := fs.CreateFile(&file, parentPath)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, "OK")
|
||||
})
|
||||
route.GET("createDir", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
err := fs.CreateDirectory(path)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, "OK")
|
||||
})
|
||||
|
||||
route.GET("list", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
files, err := fs.List(path)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, &files)
|
||||
})
|
||||
|
||||
route.GET("read", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
file, err := fs.Read(path)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, &file)
|
||||
})
|
||||
}
|
||||
|
||||
type WebFSFile struct {
|
||||
MongoId primitive.ObjectID `bson:"_id" json:"-"`
|
||||
Name string `bson:"name" json:"name"`
|
||||
|
@ -1,34 +0,0 @@
|
||||
package finder
|
||||
|
||||
import (
|
||||
"personalwebsite/webfilesystem"
|
||||
"personalwebsite/websiteapp"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type FinderApplication struct {
|
||||
fs *webfilesystem.WebFileSystem
|
||||
manifest websiteapp.ApplicationManifest
|
||||
}
|
||||
|
||||
func NewFinderApplication(webFs *webfilesystem.WebFileSystem) *FinderApplication {
|
||||
return &FinderApplication{
|
||||
fs: webFs,
|
||||
manifest: websiteapp.ApplicationManifest{
|
||||
AppId: "finder",
|
||||
WindowName: "TODO DELETE", //TODO DELETE
|
||||
},
|
||||
}
|
||||
}
|
||||
func (f *FinderApplication) GetManifest() websiteapp.ApplicationManifest {
|
||||
return f.manifest
|
||||
}
|
||||
func (f *FinderApplication) GetId() string {
|
||||
return f.manifest.AppId
|
||||
}
|
||||
|
||||
func (f *FinderApplication) Render(isMobile bool) gin.H {
|
||||
|
||||
return gin.H{}
|
||||
}
|
Loading…
Reference in New Issue
Block a user