Create public and private modes for website
This commit is contained in:
parent
d2ea95a182
commit
6a93f418d5
@ -2,7 +2,6 @@ package blogviewer
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"personalwebsite/apps"
|
|
||||||
"personalwebsite/webfilesystem"
|
"personalwebsite/webfilesystem"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@ -11,27 +10,23 @@ import (
|
|||||||
|
|
||||||
type BlogViewerApplication struct {
|
type BlogViewerApplication struct {
|
||||||
fs *webfilesystem.WebFileSystem
|
fs *webfilesystem.WebFileSystem
|
||||||
manifest apps.ApplicationManifest
|
appID string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBlogViewerApp(webFs *webfilesystem.WebFileSystem) *BlogViewerApplication {
|
func NewBlogViewerApp(webFs *webfilesystem.WebFileSystem) *BlogViewerApplication {
|
||||||
return &BlogViewerApplication{
|
return &BlogViewerApplication{
|
||||||
fs: webFs,
|
fs: webFs,
|
||||||
manifest: apps.ApplicationManifest{
|
appID: "BlogViewer",
|
||||||
AppId: "blog-viewer",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BlogViewerApplication) GetManifest() apps.ApplicationManifest {
|
func (b *BlogViewerApplication) GetAppID() string {
|
||||||
return b.manifest
|
return b.appID
|
||||||
}
|
}
|
||||||
|
func (b *BlogViewerApplication) PrivateRoutes(route *gin.RouterGroup) {
|
||||||
func (b *BlogViewerApplication) GetId() string {
|
b.PublicRoutes(route)
|
||||||
return b.manifest.AppId
|
|
||||||
}
|
}
|
||||||
|
func (b *BlogViewerApplication) PublicRoutes(route *gin.RouterGroup) {
|
||||||
func (b *BlogViewerApplication) Route(route *gin.RouterGroup) {
|
|
||||||
route.GET("writeMockBlog", func(ctx *gin.Context) {
|
route.GET("writeMockBlog", func(ctx *gin.Context) {
|
||||||
path := ctx.Query("path")
|
path := ctx.Query("path")
|
||||||
if path == "" {
|
if path == "" {
|
||||||
|
@ -10,12 +10,14 @@ import (
|
|||||||
|
|
||||||
type FinderApplication struct {
|
type FinderApplication struct {
|
||||||
fs *webfilesystem.WebFileSystem
|
fs *webfilesystem.WebFileSystem
|
||||||
|
appID string
|
||||||
manifest apps.ApplicationManifest
|
manifest apps.ApplicationManifest
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFinderApplication(webFs *webfilesystem.WebFileSystem) *FinderApplication {
|
func NewFinderApplication(webFs *webfilesystem.WebFileSystem) *FinderApplication {
|
||||||
return &FinderApplication{
|
return &FinderApplication{
|
||||||
fs: webFs,
|
fs: webFs,
|
||||||
|
appID: "Finder",
|
||||||
manifest: apps.ApplicationManifest{
|
manifest: apps.ApplicationManifest{
|
||||||
AppId: "finder",
|
AppId: "finder",
|
||||||
},
|
},
|
||||||
@ -24,15 +26,15 @@ func NewFinderApplication(webFs *webfilesystem.WebFileSystem) *FinderApplication
|
|||||||
func (f *FinderApplication) GetManifest() apps.ApplicationManifest {
|
func (f *FinderApplication) GetManifest() apps.ApplicationManifest {
|
||||||
return f.manifest
|
return f.manifest
|
||||||
}
|
}
|
||||||
func (f *FinderApplication) GetId() string {
|
func (f *FinderApplication) GetAppID() string {
|
||||||
return f.manifest.AppId
|
return f.appID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FinderApplication) Render(isMobile bool) gin.H {
|
func (f *FinderApplication) Render(isMobile bool) gin.H {
|
||||||
return gin.H{}
|
return gin.H{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FinderApplication) RenderContextMenu(context string, filePath string, data string) gin.H {
|
func (f *FinderApplication) RenderPrivateContextMenu(context string, filePath string, data string) gin.H {
|
||||||
islands := [][]wde.ContexMenuRow{}
|
islands := [][]wde.ContexMenuRow{}
|
||||||
islands = append(islands, []wde.ContexMenuRow{})
|
islands = append(islands, []wde.ContexMenuRow{})
|
||||||
|
|
||||||
@ -68,6 +70,27 @@ func (f *FinderApplication) RenderContextMenu(context string, filePath string, d
|
|||||||
"Islands": islands,
|
"Islands": islands,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func (f *FinderApplication) RenderPublicContextMenu(context string, filePath string, data string) gin.H {
|
||||||
|
islands := [][]wde.ContexMenuRow{}
|
||||||
|
islands = append(islands, []wde.ContexMenuRow{})
|
||||||
|
|
||||||
|
islands = append(islands, []wde.ContexMenuRow{
|
||||||
|
{Label: "Get Info", Action: "getInfo"},
|
||||||
|
})
|
||||||
|
if context == "FileTileView" {
|
||||||
|
return gin.H{
|
||||||
|
"Islands": islands,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch context {
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
return gin.H{
|
||||||
|
"Islands": islands,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (f *FinderApplication) RenderProps(filePath string) (gin.H, error) {
|
func (f *FinderApplication) RenderProps(filePath string) (gin.H, error) {
|
||||||
// file, err := f.fs.NewReadDeprecated(filePath)
|
// file, err := f.fs.NewReadDeprecated(filePath)
|
||||||
|
@ -6,19 +6,9 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f *FinderApplication) Routes(routes *gin.RouterGroup) {
|
func (f *FinderApplication) PublicRoutes(routes *gin.RouterGroup) {
|
||||||
routes.GET("render", func(ctx *gin.Context) {
|
routes.GET("render", func(ctx *gin.Context) {
|
||||||
isMobileParam := ctx.Query("isMobile")
|
isMobile := ctx.Query("isMobile") == "true"
|
||||||
isMobile := isMobileParam == "true"
|
|
||||||
admin := true
|
|
||||||
if isMobile {
|
|
||||||
ctx.HTML(http.StatusOK, "finder/mobile-app.tmpl", f.Render(isMobile))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if admin {
|
|
||||||
ctx.HTML(http.StatusOK, "finder/admin-app.tmpl", f.Render(isMobile))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ctx.HTML(http.StatusOK, "finder/app.tmpl", f.Render(isMobile))
|
ctx.HTML(http.StatusOK, "finder/app.tmpl", f.Render(isMobile))
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -46,7 +36,49 @@ func (f *FinderApplication) Routes(routes *gin.RouterGroup) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
data := ctx.Query("data")
|
data := ctx.Query("data")
|
||||||
ginH := f.RenderContextMenu(context, filePath, data)
|
// ginH := f.RenderPrivateContextMenu(context, filePath, 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.GET("render", func(ctx *gin.Context) {
|
||||||
|
isMobile := ctx.Query("isMobile") == "true"
|
||||||
|
ctx.HTML(http.StatusOK, "finder/admin-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{})
|
||||||
|
})
|
||||||
|
|
||||||
|
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)
|
ctx.HTML(http.StatusOK, "wde-widgets/context-menu.tmpl", ginH)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package imgviewer
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
websiteapp "personalwebsite/apps"
|
|
||||||
"personalwebsite/webfilesystem"
|
"personalwebsite/webfilesystem"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@ -10,20 +9,20 @@ import (
|
|||||||
|
|
||||||
type ImgViewerApp struct {
|
type ImgViewerApp struct {
|
||||||
fs *webfilesystem.WebFileSystem
|
fs *webfilesystem.WebFileSystem
|
||||||
manifest websiteapp.ApplicationManifest
|
appID string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewImgViewerApp(webFs *webfilesystem.WebFileSystem) ImgViewerApp {
|
func NewImgViewerApp(webFs *webfilesystem.WebFileSystem) *ImgViewerApp {
|
||||||
newApp := ImgViewerApp{
|
newApp := ImgViewerApp{
|
||||||
fs: webFs,
|
fs: webFs,
|
||||||
manifest: websiteapp.ApplicationManifest{
|
appID: "ImgViewer",
|
||||||
AppId: "img-viewer",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
return newApp
|
return &newApp
|
||||||
}
|
}
|
||||||
|
func (p *ImgViewerApp) PrivateRoutes(route *gin.RouterGroup) {
|
||||||
func (p *ImgViewerApp) Route(route *gin.RouterGroup) {
|
p.PublicRoutes(route)
|
||||||
|
}
|
||||||
|
func (p *ImgViewerApp) PublicRoutes(route *gin.RouterGroup) {
|
||||||
route.GET("render", func(ctx *gin.Context) {
|
route.GET("render", func(ctx *gin.Context) {
|
||||||
isMobileParam := ctx.Query("isMobile")
|
isMobileParam := ctx.Query("isMobile")
|
||||||
isMobile := isMobileParam == "true"
|
isMobile := isMobileParam == "true"
|
||||||
@ -45,11 +44,8 @@ func (p *ImgViewerApp) Route(route *gin.RouterGroup) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ImgViewerApp) GetManifest() websiteapp.ApplicationManifest {
|
func (p *ImgViewerApp) GetAppID() string {
|
||||||
return p.manifest
|
return p.appID
|
||||||
}
|
|
||||||
func (p *ImgViewerApp) GetId() string {
|
|
||||||
return p.manifest.AppId
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ImgViewerApp) Render(filePath string, isMobile bool) (gin.H, error) {
|
func (p *ImgViewerApp) Render(filePath string, isMobile bool) (gin.H, error) {
|
||||||
|
@ -2,36 +2,27 @@ package personalprops
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
websiteapp "personalwebsite/apps"
|
|
||||||
"personalwebsite/webfilesystem"
|
"personalwebsite/webfilesystem"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//TODO Rename to AboutMe
|
||||||
type PersonalPropertiesApp struct {
|
type PersonalPropertiesApp struct {
|
||||||
fs *webfilesystem.WebFileSystem
|
fs *webfilesystem.WebFileSystem
|
||||||
manifest websiteapp.ApplicationManifest
|
appID string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPersPropsApp(webFs *webfilesystem.WebFileSystem) PersonalPropertiesApp {
|
func NewPersPropsApp(webFs *webfilesystem.WebFileSystem) *PersonalPropertiesApp {
|
||||||
newApp := PersonalPropertiesApp{
|
newApp := PersonalPropertiesApp{
|
||||||
fs: webFs,
|
fs: webFs,
|
||||||
manifest: websiteapp.ApplicationManifest{
|
appID: "AboutMe",
|
||||||
AppId: "personal-properties",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
return newApp
|
return &newApp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PersonalPropertiesApp) Route(route *gin.RouterGroup) {
|
func (p *PersonalPropertiesApp) PublicRoutes(route *gin.RouterGroup) {
|
||||||
route.GET("writeMock", func(ctx *gin.Context) {
|
|
||||||
err := p.WriteMock()
|
|
||||||
if err != nil {
|
|
||||||
ctx.Status(http.StatusInternalServerError)
|
|
||||||
}
|
|
||||||
ctx.Status(http.StatusOK)
|
|
||||||
})
|
|
||||||
route.GET("render", func(ctx *gin.Context) {
|
route.GET("render", func(ctx *gin.Context) {
|
||||||
isMobileParam := ctx.Query("isMobile")
|
isMobileParam := ctx.Query("isMobile")
|
||||||
isMobile := isMobileParam == "true"
|
isMobile := isMobileParam == "true"
|
||||||
@ -53,11 +44,20 @@ func (p *PersonalPropertiesApp) Route(route *gin.RouterGroup) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PersonalPropertiesApp) GetManifest() websiteapp.ApplicationManifest {
|
func (p *PersonalPropertiesApp) PrivateRoutes(router *gin.RouterGroup) {
|
||||||
return p.manifest
|
p.PublicRoutes(router)
|
||||||
|
router.GET("writeMock", func(ctx *gin.Context) {
|
||||||
|
err := p.WriteMock()
|
||||||
|
if err != nil {
|
||||||
|
ctx.Status(http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
ctx.Status(http.StatusOK)
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
func (p *PersonalPropertiesApp) GetId() string {
|
|
||||||
return p.manifest.AppId
|
func (p *PersonalPropertiesApp) GetAppID() string {
|
||||||
|
return p.appID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PersonalPropertiesApp) WriteMock() error {
|
func (p *PersonalPropertiesApp) WriteMock() error {
|
||||||
|
@ -12,9 +12,12 @@ import (
|
|||||||
//TODO to libs
|
//TODO to libs
|
||||||
type WebDEApplication interface {
|
type WebDEApplication interface {
|
||||||
// Render()
|
// Render()
|
||||||
GetManifest() ApplicationManifest
|
GetAppID() string
|
||||||
|
PublicRoutes(*gin.RouterGroup)
|
||||||
|
PrivateRoutes(*gin.RouterGroup)
|
||||||
|
// GetManifest() ApplicationManifest //TODO: Delete
|
||||||
// GEtHtml()
|
// GEtHtml()
|
||||||
GetId() string
|
// GetId() string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApplicationManifest struct {
|
type ApplicationManifest struct {
|
||||||
@ -58,12 +61,6 @@ func (as *ApplicationsStorage) createApp(appName string, appId string, appPath s
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// func NewApplicationsStorage() *ApplicationsStorage {
|
|
||||||
// newStorage := ApplicationsStorage{}
|
|
||||||
|
|
||||||
// return &newStorage
|
|
||||||
// }
|
|
||||||
|
|
||||||
func (aStorage *ApplicationsStorage) Route(route *gin.RouterGroup) {
|
func (aStorage *ApplicationsStorage) Route(route *gin.RouterGroup) {
|
||||||
route.GET("/get", func(ctx *gin.Context) {
|
route.GET("/get", func(ctx *gin.Context) {
|
||||||
appId := ctx.Query("appid")
|
appId := ctx.Query("appid")
|
||||||
@ -71,12 +68,13 @@ func (aStorage *ApplicationsStorage) Route(route *gin.RouterGroup) {
|
|||||||
ctx.Status(http.StatusBadRequest)
|
ctx.Status(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
app, isExist := aStorage.Apps[appId]
|
// app, isExist := aStorage.Apps[appId]
|
||||||
if !isExist {
|
// if !isExist {
|
||||||
ctx.Status(http.StatusNoContent)
|
// ctx.Status(http.StatusNoContent)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
ctx.JSON(http.StatusOK, app.GetManifest())
|
// ctx.JSON(http.StatusOK, app.GetManifest())
|
||||||
|
ctx.String(http.StatusMovedPermanently, "Obsolete")
|
||||||
})
|
})
|
||||||
|
|
||||||
route.GET("/loadApp", func(ctx *gin.Context) {
|
route.GET("/loadApp", func(ctx *gin.Context) {
|
||||||
|
10
libs/cat.go
10
libs/cat.go
@ -38,7 +38,7 @@ func (c *Cat) Get(filePath string) (string, error) {
|
|||||||
return fileData.Data, nil
|
return fileData.Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cat) Route(route *gin.RouterGroup) {
|
func (c *Cat) PublicRoutes(route *gin.RouterGroup) {
|
||||||
route.GET("get", func(ctx *gin.Context) {
|
route.GET("get", func(ctx *gin.Context) {
|
||||||
path := ctx.Query("path")
|
path := ctx.Query("path")
|
||||||
if path == "" {
|
if path == "" {
|
||||||
@ -52,7 +52,13 @@ func (c *Cat) Route(route *gin.RouterGroup) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mode := ctx.Query("mode")
|
||||||
|
switch mode {
|
||||||
|
case "json":
|
||||||
|
ctx.JSON(http.StatusOK, data)
|
||||||
|
default:
|
||||||
ctx.String(http.StatusOK, "plaintext", data)
|
ctx.String(http.StatusOK, "plaintext", data)
|
||||||
})
|
}
|
||||||
|
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ func NewImgLib(webfs *webfilesystem.WebFileSystem) *ImagLib {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *ImagLib) Route(route *gin.RouterGroup) {
|
func (l *ImagLib) PublicRoutes(route *gin.RouterGroup) {
|
||||||
route.GET("get", func(ctx *gin.Context) {
|
route.GET("get", func(ctx *gin.Context) {
|
||||||
path := ctx.Query("path")
|
path := ctx.Query("path")
|
||||||
if path == "" {
|
if path == "" {
|
||||||
@ -31,10 +31,6 @@ func (l *ImagLib) Route(route *gin.RouterGroup) {
|
|||||||
ctx.Status(http.StatusInternalServerError)
|
ctx.Status(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// _, err = l.fs.readFSDocs(fileId, &imgData)
|
|
||||||
// if err != nil {
|
|
||||||
// ctx.Status(http.StatusInternalServerError)
|
|
||||||
// }
|
|
||||||
|
|
||||||
ctx.Data(http.StatusOK, "image/jpeg", imgData.Bin)
|
ctx.Data(http.StatusOK, "image/jpeg", imgData.Bin)
|
||||||
})
|
})
|
||||||
|
213
main.go
213
main.go
@ -4,23 +4,17 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
"os"
|
"os"
|
||||||
"time"
|
|
||||||
|
|
||||||
"personalwebsite/apps"
|
"personalwebsite/apps"
|
||||||
"personalwebsite/apps/blogviewer"
|
"personalwebsite/apps/blogviewer"
|
||||||
"personalwebsite/apps/finder"
|
"personalwebsite/apps/finder"
|
||||||
imgviewer "personalwebsite/apps/img-viewer"
|
imgviewer "personalwebsite/apps/img-viewer"
|
||||||
"personalwebsite/apps/personalprops"
|
"personalwebsite/apps/personalprops"
|
||||||
"personalwebsite/libs"
|
"personalwebsite/routes"
|
||||||
"personalwebsite/routewde"
|
|
||||||
"personalwebsite/wde"
|
"personalwebsite/wde"
|
||||||
"personalwebsite/webfilesystem"
|
"personalwebsite/webfilesystem"
|
||||||
|
|
||||||
"github.com/gin-contrib/cors"
|
|
||||||
"github.com/gin-contrib/location"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
@ -56,122 +50,127 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
router := gin.New()
|
|
||||||
router.Use(location.Default())
|
|
||||||
router.LoadHTMLGlob("templates/**/*")
|
|
||||||
router.Static("/res", "resources")
|
|
||||||
// Set a lower memory limit for multipart forms (default is 32 MiB)
|
|
||||||
router.MaxMultipartMemory = 8 << 20 // 8 MiB
|
|
||||||
|
|
||||||
router.GET("/", func(ctx *gin.Context) {
|
|
||||||
ctx.HTML(http.StatusOK, "index.tmpl", gin.H{})
|
|
||||||
})
|
|
||||||
|
|
||||||
webfs := webfilesystem.NewWebFileSystem(client, dBName, webFsCollection)
|
webfs := webfilesystem.NewWebFileSystem(client, dBName, webFsCollection)
|
||||||
|
appsStorage := apps.NewApplicationsStorage(map[string]apps.WebDEApplication{}, webfs)
|
||||||
|
// router := gin.New()
|
||||||
|
// router.Use(location.Default())
|
||||||
|
// router.LoadHTMLGlob("templates/**/*")
|
||||||
|
// router.Static("/res", "resources")
|
||||||
|
// // Set a lower memory limit for multipart forms (default is 32 MiB)
|
||||||
|
// router.MaxMultipartMemory = 8 << 20 // 8 MiB
|
||||||
|
|
||||||
|
// router.GET("/", func(ctx *gin.Context) {
|
||||||
|
// ctx.HTML(http.StatusOK, "index.tmpl", gin.H{})
|
||||||
|
// })
|
||||||
|
|
||||||
webde := wde.NewWDE(webfs)
|
webde := wde.NewWDE(webfs)
|
||||||
|
|
||||||
persPropsApp := personalprops.NewPersPropsApp(webfs)
|
persPropsApp := personalprops.NewPersPropsApp(webfs)
|
||||||
// finderApp := finder.FinderApplication{}
|
|
||||||
finderApp := finder.NewFinderApplication(webfs)
|
finderApp := finder.NewFinderApplication(webfs)
|
||||||
imgViewerApp := imgviewer.NewImgViewerApp(webfs)
|
imgViewerApp := imgviewer.NewImgViewerApp(webfs)
|
||||||
blogViewerApp := blogviewer.NewBlogViewerApp(webfs)
|
blogViewerApp := blogviewer.NewBlogViewerApp(webfs)
|
||||||
appsStorage := apps.NewApplicationsStorage(map[string]apps.WebDEApplication{}, webfs)
|
appsStorage.Apps["personal-properties"] = persPropsApp
|
||||||
appsStorage.Apps["personal-properties"] = &persPropsApp
|
|
||||||
appsStorage.Apps["finder"] = finderApp
|
appsStorage.Apps["finder"] = finderApp
|
||||||
appsStorage.Apps["img-viewer"] = &imgViewerApp
|
appsStorage.Apps["img-viewer"] = imgViewerApp
|
||||||
appsStorage.Apps["blog-viewer"] = blogViewerApp
|
appsStorage.Apps["blog-viewer"] = blogViewerApp
|
||||||
|
|
||||||
system := router.Group("system")
|
go routes.PublicRoutes(webfs, webde, appsStorage)
|
||||||
{
|
routes.PrivateRoutes(webfs, webde, appsStorage)
|
||||||
libsGroup := system.Group("libs")
|
|
||||||
{
|
|
||||||
imgLibGroup := libsGroup.Group("img")
|
|
||||||
{
|
|
||||||
imgLib := libs.NewImgLib(webfs)
|
|
||||||
imgLib.Route(imgLibGroup)
|
|
||||||
}
|
|
||||||
|
|
||||||
catLibGroup := libsGroup.Group("cat")
|
// system := router.Group("system")
|
||||||
{
|
// {
|
||||||
catLib := libs.NewCatLib(webfs)
|
// libsGroup := system.Group("libs")
|
||||||
catLib.Route(catLibGroup)
|
// {
|
||||||
}
|
// imgLibGroup := libsGroup.Group("img")
|
||||||
|
// {
|
||||||
|
// imgLib := libs.NewImgLib(webfs)
|
||||||
|
// imgLib.PublicRoutes(imgLibGroup)
|
||||||
|
// }
|
||||||
|
|
||||||
appsStorageGroup := libsGroup.Group("apps")
|
// catLibGroup := libsGroup.Group("cat")
|
||||||
{
|
// {
|
||||||
appsStorage.Route(appsStorageGroup)
|
// catLib := libs.NewCatLib(webfs)
|
||||||
}
|
// catLib.PublicRoutes(catLibGroup)
|
||||||
}
|
// }
|
||||||
|
|
||||||
wdeGroup := system.Group("wde")
|
// appsStorageGroup := libsGroup.Group("apps")
|
||||||
{
|
// {
|
||||||
routewde.Route(wdeGroup, webde)
|
// appsStorage.Route(appsStorageGroup)
|
||||||
}
|
// }
|
||||||
apps := system.Group("applications") //TODO to libs
|
// }
|
||||||
{
|
|
||||||
apps.GET("/:appid/:method", func(ctx *gin.Context) {
|
|
||||||
appId := ctx.Param("appid")
|
|
||||||
method := ctx.Param("method")
|
|
||||||
|
|
||||||
app, isExist := appsStorage.Apps[appId]
|
// wdeGroup := system.Group("wde")
|
||||||
if !isExist {
|
// {
|
||||||
ctx.Status(http.StatusNoContent)
|
// routewde.PublicRoutes(wdeGroup, webde)
|
||||||
return
|
// }
|
||||||
}
|
// apps := system.Group("applications") //TODO to libs
|
||||||
switch method {
|
// {
|
||||||
case "getmanifest":
|
// apps.GET("/:appid/:method", func(ctx *gin.Context) {
|
||||||
ctx.JSON(http.StatusOK, app.GetManifest())
|
// appId := ctx.Param("appid")
|
||||||
case "app.js":
|
// method := ctx.Param("method")
|
||||||
ctx.File("resources/sys/" + appId + "/" + appId + ".js")
|
|
||||||
case "app.css":
|
|
||||||
ctx.File("resources/sys/" + appId + "/" + appId + ".css")
|
|
||||||
default:
|
|
||||||
ctx.Status(http.StatusBadRequest)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fs := router.Group("fs")
|
// app, isExist := appsStorage.Apps[appId]
|
||||||
{
|
// if !isExist {
|
||||||
webfs.Route(fs)
|
// ctx.Status(http.StatusNoContent)
|
||||||
}
|
// return
|
||||||
app := router.Group("app")
|
// }
|
||||||
{
|
// switch method {
|
||||||
persPropApp := app.Group("AboutMe")
|
// case "getmanifest":
|
||||||
{
|
// ctx.JSON(http.StatusOK, app.GetManifest())
|
||||||
persPropsApp.Route(persPropApp)
|
// case "app.js":
|
||||||
}
|
// ctx.File("resources/sys/" + appId + "/" + appId + ".js")
|
||||||
finderAppRoute := app.Group("Finder")
|
// case "app.css":
|
||||||
{
|
// ctx.File("resources/sys/" + appId + "/" + appId + ".css")
|
||||||
finderApp.Routes(finderAppRoute)
|
// default:
|
||||||
}
|
// ctx.Status(http.StatusBadRequest)
|
||||||
imgViewerRoute := app.Group("img-viewer")
|
// }
|
||||||
{
|
// })
|
||||||
imgViewerApp.Route(imgViewerRoute)
|
// }
|
||||||
}
|
// }
|
||||||
blogViewerRoute := app.Group("blog-viewer")
|
|
||||||
{
|
|
||||||
blogViewerApp.Route(blogViewerRoute)
|
|
||||||
}
|
|
||||||
|
|
||||||
router.Use(cors.New(cors.Config{
|
// fs := router.Group("fs")
|
||||||
AllowAllOrigins: true,
|
// {
|
||||||
// AllowOrigins: []string{"http://localhost:8080", "http://localhost:9090"},
|
// fsGroup := systemGroup.Group("fs")
|
||||||
// AllowMethods: []string{"PUT", "PATCH"},
|
// {
|
||||||
// AllowHeaders: []string{"Origin"},
|
// webfs.PublicRoutes(fsGroup)
|
||||||
ExposeHeaders: []string{"Content-Length"},
|
// }
|
||||||
AllowCredentials: true,
|
// }
|
||||||
// AllowOriginFunc: func(origin string) bool {
|
// app := router.Group("app")
|
||||||
// return origin == "https://github.com"
|
// {
|
||||||
// },
|
// persPropApp := app.Group("AboutMe")
|
||||||
MaxAge: 12 * time.Hour,
|
// {
|
||||||
}))
|
// persPropsApp.Route(persPropApp)
|
||||||
err = router.Run(":8080")
|
// }
|
||||||
if err != nil {
|
// finderAppRoute := app.Group("Finder")
|
||||||
log.Panicf("error: %s", err)
|
// {
|
||||||
}
|
// finderApp.Routes(finderAppRoute)
|
||||||
}
|
// }
|
||||||
|
// imgViewerRoute := app.Group("img-viewer")
|
||||||
|
// {
|
||||||
|
// imgViewerApp.Route(imgViewerRoute)
|
||||||
|
// }
|
||||||
|
// blogViewerRoute := app.Group("blog-viewer")
|
||||||
|
// {
|
||||||
|
// blogViewerApp.Route(blogViewerRoute)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// router.Use(cors.New(cors.Config{
|
||||||
|
// AllowAllOrigins: true,
|
||||||
|
// // AllowOrigins: []string{"http://localhost:8080", "http://localhost:9090"},
|
||||||
|
// // AllowMethods: []string{"PUT", "PATCH"},
|
||||||
|
// // AllowHeaders: []string{"Origin"},
|
||||||
|
// ExposeHeaders: []string{"Content-Length"},
|
||||||
|
// AllowCredentials: true,
|
||||||
|
// // AllowOriginFunc: func(origin string) bool {
|
||||||
|
// // return origin == "https://github.com"
|
||||||
|
// // },
|
||||||
|
// MaxAge: 12 * time.Hour,
|
||||||
|
// }))
|
||||||
|
// err = router.Run(":8080")
|
||||||
|
// if err != nil {
|
||||||
|
// log.Panicf("error: %s", err)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// func index(c *gin.Context) {
|
// func index(c *gin.Context) {
|
||||||
|
@ -14,15 +14,18 @@ class Finder{
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
static async RenderProperites(path){
|
static async RenderProperites(path){
|
||||||
|
if (path == null || path ==""){
|
||||||
|
return
|
||||||
|
}
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
path: path
|
path: path
|
||||||
})
|
})
|
||||||
const response = await fetch(`/application/${Finder.AppId}/renderProps?` + params)
|
const response = await fetch(`/app/${Finder.AppId}/renderProps?` + params)
|
||||||
if (response.status != 200){
|
if (response.status != 200){
|
||||||
WebDesktopEnvironment.Alert("Error in properties render") //TODO
|
WebDesktopEnvironment.Alert("Error in properties render") //TODO
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
const html = response.text()
|
const html = await response.text()
|
||||||
let newWindow = WebDesktopEnvironment.CreateNewWindow(Finder.AppId, 350, 500 )
|
let newWindow = WebDesktopEnvironment.CreateNewWindow(Finder.AppId, 350, 500 )
|
||||||
newWindow.innerHTML = html
|
newWindow.innerHTML = html
|
||||||
newWindow.querySelector("#closeWindowButton").addEventListener('click', function (params) {
|
newWindow.querySelector("#closeWindowButton").addEventListener('click', function (params) {
|
||||||
@ -96,7 +99,6 @@ class FinderWindow{
|
|||||||
|
|
||||||
let scrollBar = new WdeScrollBar(newWindow.querySelector(".ScrollbarPlace"), newWindow.querySelector(".FileTileView"))
|
let scrollBar = new WdeScrollBar(newWindow.querySelector(".ScrollbarPlace"), newWindow.querySelector(".FileTileView"))
|
||||||
|
|
||||||
|
|
||||||
this.windowElem = newWindow
|
this.windowElem = newWindow
|
||||||
this.RenderDir(args[0])
|
this.RenderDir(args[0])
|
||||||
}
|
}
|
||||||
@ -199,7 +201,7 @@ class FinderWindow{
|
|||||||
*/
|
*/
|
||||||
async CreateContextMenu(target, pos){
|
async CreateContextMenu(target, pos){
|
||||||
let context = ""
|
let context = ""
|
||||||
const fileName = target.getAttribute("name")
|
const fileName = target.getAttribute("name") //TODO check for null
|
||||||
const fileType = target.getAttribute("fileType")
|
const fileType = target.getAttribute("fileType")
|
||||||
if (target.classList.contains("FileTileView"))
|
if (target.classList.contains("FileTileView"))
|
||||||
{
|
{
|
||||||
@ -207,7 +209,14 @@ class FinderWindow{
|
|||||||
} else {
|
} else {
|
||||||
context = fileType
|
context = fileType
|
||||||
}
|
}
|
||||||
const params = new URLSearchParams({context: context, path: `${this.curPath}/${fileName}`})
|
let path = ""
|
||||||
|
if (fileName === null){
|
||||||
|
console.log(fileName)
|
||||||
|
path = this.curPath
|
||||||
|
} else {
|
||||||
|
path = `${this.curPath}/${fileName}`
|
||||||
|
}
|
||||||
|
const params = new URLSearchParams({context: context, path: path})
|
||||||
const response = await fetch(`/app/${Finder.AppId}/contextMenu?` + params)
|
const response = await fetch(`/app/${Finder.AppId}/contextMenu?` + params)
|
||||||
if (response.status != 200){
|
if (response.status != 200){
|
||||||
WebDesktopEnvironment.Alert("ERROR in Context menu TODO"); //TODO
|
WebDesktopEnvironment.Alert("ERROR in Context menu TODO"); //TODO
|
||||||
@ -252,7 +261,7 @@ class FinderWindow{
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
case "getInfo":
|
case "getInfo":
|
||||||
res = await Finder.RenderProperites(`${this.curPath}/${fileName}`)
|
Finder.RenderProperites(path)
|
||||||
break
|
break
|
||||||
case "openAsDir":
|
case "openAsDir":
|
||||||
WebDesktopEnvironment.Open(`/Applications/${Finder.AppId}.app`,[`${this.curPath}/${fileName}`])
|
WebDesktopEnvironment.Open(`/Applications/${Finder.AppId}.app`,[`${this.curPath}/${fileName}`])
|
||||||
|
@ -82,11 +82,13 @@ class WebDesktopEnvironment{
|
|||||||
* @returns {Object | undefined} //FIXME
|
* @returns {Object | undefined} //FIXME
|
||||||
*/
|
*/
|
||||||
static async fetchApp(path){
|
static async fetchApp(path){
|
||||||
const params = new URLSearchParams({path: path})
|
console.log("path: " + path )
|
||||||
const response = await fetch(`/system/libs/apps/loadApp?` + params)
|
const params = new URLSearchParams({path: path, mode: "json"})
|
||||||
|
const response = await fetch(`/system/loadApp?` + params)
|
||||||
if (response.status != 200){
|
if (response.status != 200){
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
//TODO Validate manifest
|
||||||
const appManifest = response.json()
|
const appManifest = response.json()
|
||||||
return appManifest
|
return appManifest
|
||||||
}
|
}
|
||||||
|
119
routes/private.go
Normal file
119
routes/private.go
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
package routes
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"path"
|
||||||
|
"personalwebsite/apps"
|
||||||
|
"personalwebsite/libs"
|
||||||
|
"personalwebsite/routewde"
|
||||||
|
"personalwebsite/wde"
|
||||||
|
"personalwebsite/webfilesystem"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gin-contrib/cors"
|
||||||
|
"github.com/gin-contrib/location"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func PrivateRoutes(webfs *webfilesystem.WebFileSystem, webde *wde.WDE, appsStorage *apps.ApplicationsStorage) {
|
||||||
|
router := gin.New()
|
||||||
|
router.Use(location.Default())
|
||||||
|
router.LoadHTMLGlob("templates/**/*")
|
||||||
|
router.Static("/res", "resources")
|
||||||
|
// Set a lower memory limit for multipart forms (default is 32 MiB)
|
||||||
|
router.MaxMultipartMemory = 8 << 20 // 8 MiB
|
||||||
|
|
||||||
|
router.GET("/", func(ctx *gin.Context) {
|
||||||
|
ctx.HTML(http.StatusOK, "index.tmpl", gin.H{})
|
||||||
|
})
|
||||||
|
systemGroup := router.Group("system")
|
||||||
|
{
|
||||||
|
libsGroup := systemGroup.Group("libs")
|
||||||
|
{
|
||||||
|
imgLibGroup := libsGroup.Group("img")
|
||||||
|
{
|
||||||
|
imgLib := libs.NewImgLib(webfs)
|
||||||
|
imgLib.PublicRoutes(imgLibGroup)
|
||||||
|
}
|
||||||
|
|
||||||
|
catLibGroup := libsGroup.Group("cat")
|
||||||
|
{
|
||||||
|
catLib := libs.NewCatLib(webfs)
|
||||||
|
catLib.PublicRoutes(catLibGroup)
|
||||||
|
}
|
||||||
|
|
||||||
|
appsStorageGroup := libsGroup.Group("apps")
|
||||||
|
{
|
||||||
|
appsStorage.Route(appsStorageGroup)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wdeGroup := systemGroup.Group("wde")
|
||||||
|
{
|
||||||
|
routewde.PublicRoutes(wdeGroup, webde)
|
||||||
|
}
|
||||||
|
fsGroup := systemGroup.Group("fs")
|
||||||
|
{
|
||||||
|
webfs.PrivateRoutes(fsGroup)
|
||||||
|
}
|
||||||
|
systemGroup.GET("/loadApp", func(ctx *gin.Context) {
|
||||||
|
appPath := ctx.Query("path")
|
||||||
|
if appPath == "" {
|
||||||
|
ctx.Status(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
appBundleData := webfilesystem.DirectoryData{}
|
||||||
|
appBundle, err := webfs.Read(appPath, &appBundleData)
|
||||||
|
if err != nil {
|
||||||
|
ctx.Status(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if appBundle.Type != "directory" {
|
||||||
|
ctx.Status(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
appManifestData := apps.ApplicationManifest{}
|
||||||
|
appManifestHeader, err := webfs.Read(path.Join(appPath, ".appmanifest"), &appManifestData)
|
||||||
|
if err != nil {
|
||||||
|
ctx.Status(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if appManifestHeader.Type != "application-manifest" {
|
||||||
|
ctx.Status(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.JSON(http.StatusOK, appManifestData)
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
appsGroup := router.Group("app")
|
||||||
|
{
|
||||||
|
for _, app := range appsStorage.Apps {
|
||||||
|
appsRoutes := appsGroup.Group(app.GetAppID())
|
||||||
|
app.PrivateRoutes(appsRoutes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
router.Use(cors.New(cors.Config{
|
||||||
|
AllowAllOrigins: true,
|
||||||
|
// AllowOrigins: []string{"http://localhost:8080", "http://localhost:9090"},
|
||||||
|
// AllowMethods: []string{"PUT", "PATCH"},
|
||||||
|
// AllowHeaders: []string{"Origin"},
|
||||||
|
ExposeHeaders: []string{"Content-Length"},
|
||||||
|
AllowCredentials: true,
|
||||||
|
// AllowOriginFunc: func(origin string) bool {
|
||||||
|
// return origin == "https://github.com"
|
||||||
|
// },
|
||||||
|
MaxAge: 12 * time.Hour,
|
||||||
|
}))
|
||||||
|
err := router.Run(":8080")
|
||||||
|
if err != nil {
|
||||||
|
log.Panicf("error: %s", err)
|
||||||
|
}
|
||||||
|
}
|
101
routes/public.go
Normal file
101
routes/public.go
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
package routes
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"path"
|
||||||
|
"personalwebsite/apps"
|
||||||
|
"personalwebsite/libs"
|
||||||
|
"personalwebsite/routewde"
|
||||||
|
"personalwebsite/wde"
|
||||||
|
"personalwebsite/webfilesystem"
|
||||||
|
|
||||||
|
"github.com/gin-contrib/location"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func PublicRoutes(webfs *webfilesystem.WebFileSystem, webde *wde.WDE, appsStorage *apps.ApplicationsStorage) {
|
||||||
|
router := gin.New()
|
||||||
|
router.Use(location.Default())
|
||||||
|
router.LoadHTMLGlob("templates/**/*")
|
||||||
|
router.Static("/res", "resources")
|
||||||
|
|
||||||
|
router.GET("/", func(ctx *gin.Context) {
|
||||||
|
ctx.HTML(http.StatusOK, "index.tmpl", gin.H{})
|
||||||
|
})
|
||||||
|
|
||||||
|
systemGroup := router.Group("system")
|
||||||
|
{
|
||||||
|
libsGroup := systemGroup.Group("libs")
|
||||||
|
{
|
||||||
|
imgLibGroup := libsGroup.Group("img")
|
||||||
|
{
|
||||||
|
imgLib := libs.NewImgLib(webfs)
|
||||||
|
imgLib.PublicRoutes(imgLibGroup)
|
||||||
|
}
|
||||||
|
|
||||||
|
catLibGroup := libsGroup.Group("cat")
|
||||||
|
{
|
||||||
|
catLib := libs.NewCatLib(webfs)
|
||||||
|
catLib.PublicRoutes(catLibGroup)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wdeGroup := systemGroup.Group("wde")
|
||||||
|
{
|
||||||
|
routewde.PublicRoutes(wdeGroup, webde)
|
||||||
|
}
|
||||||
|
|
||||||
|
systemGroup.GET("/loadApp", func(ctx *gin.Context) {
|
||||||
|
appPath := ctx.Query("path")
|
||||||
|
if appPath == "" {
|
||||||
|
ctx.Status(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
appBundleData := webfilesystem.DirectoryData{}
|
||||||
|
appBundle, err := webfs.Read(appPath, &appBundleData)
|
||||||
|
if err != nil {
|
||||||
|
ctx.Status(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if appBundle.Type != "directory" {
|
||||||
|
ctx.Status(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
appManifestData := apps.ApplicationManifest{}
|
||||||
|
appManifestHeader, err := webfs.Read(path.Join(appPath, ".appmanifest"), &appManifestData)
|
||||||
|
if err != nil {
|
||||||
|
ctx.Status(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if appManifestHeader.Type != "application-manifest" {
|
||||||
|
ctx.Status(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.JSON(http.StatusOK, appManifestData)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
// fsGroup := systemGroup.Group("fs")
|
||||||
|
// {
|
||||||
|
// webfs.PublicRoutes(fsGroup)
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
appGroup := router.Group("app")
|
||||||
|
{
|
||||||
|
for _, app := range appsStorage.Apps {
|
||||||
|
appRoutes := appGroup.Group(app.GetAppID())
|
||||||
|
app.PublicRoutes(appRoutes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err := router.Run(":7070")
|
||||||
|
if err != nil {
|
||||||
|
log.Panicf("error: %s", err)
|
||||||
|
}
|
||||||
|
}
|
@ -8,8 +8,8 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Route(route *gin.RouterGroup, wde *wde.WDE) {
|
func PublicRoutes(route *gin.RouterGroup, wde *wde.WDE) {
|
||||||
route.GET("/getbasicwindow", func(ctx *gin.Context) {
|
route.GET("/getbasicwindow", func(ctx *gin.Context) { //TODO Rename to renderGenericWindowFrame
|
||||||
ctx.HTML(http.StatusOK, "basic-window.html", nil)
|
ctx.HTML(http.StatusOK, "basic-window.html", nil)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -21,7 +21,6 @@ func Route(route *gin.RouterGroup, wde *wde.WDE) {
|
|||||||
{
|
{
|
||||||
widgets.GET("/file-tile-view", func(ctx *gin.Context) {
|
widgets.GET("/file-tile-view", func(ctx *gin.Context) {
|
||||||
url := location.Get(ctx)
|
url := location.Get(ctx)
|
||||||
// _ = url
|
|
||||||
path := ctx.Query("path")
|
path := ctx.Query("path")
|
||||||
if path == "" {
|
if path == "" {
|
||||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||||
|
@ -1,24 +1,27 @@
|
|||||||
{{ define "finder/app.tmpl" }}
|
{{ define "finder/app.tmpl" }}
|
||||||
<div class="TitleBar DragArea">
|
<div class="TitleBar DragArea">
|
||||||
<button id="closeWindowButton" class="Button" title="Close Window"></button>
|
<button id="closeWindowButton" class="Button" title="Close Window"></button>
|
||||||
<div class="TitleBarTest">
|
|
||||||
<div id="Drag" class="VisualDragArea"></div>
|
<div id="Drag" class="VisualDragArea"></div>
|
||||||
<div class="Lable">
|
<div class="Lable">
|
||||||
Files
|
Finder
|
||||||
</div>
|
</div>
|
||||||
<div id="Drag" class="VisualDragArea"></div>
|
<div id="Drag" class="VisualDragArea"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<div id="ContentBorder" class="ContentBorder AdjectiveElement">
|
||||||
|
<div class="FinderContent">
|
||||||
|
<!-- TODO Fix ConvexElement -->
|
||||||
|
<div class="ToolBar ConvexElement">
|
||||||
</div>
|
</div>
|
||||||
<div class="ToolBar">
|
<div class="FinderFileView">
|
||||||
<button id="BackButton">Back</button>
|
|
||||||
<button id="HomeButton">Home</button>
|
|
||||||
</div>
|
|
||||||
<div class="ContentBorder ConvexElement">
|
|
||||||
<div class="FileTileView">
|
<div class="FileTileView">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{{template "wde-widgets/scrollbar.tmpl" .}}
|
{{template "wde-widgets/scrollbar.tmpl" .}}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
|
@ -7,9 +7,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type DirectoryData struct {
|
type DirectoryData struct {
|
||||||
MongoId primitive.ObjectID `bson:"_id"`
|
MongoId primitive.ObjectID `bson:"_id" json:"-"`
|
||||||
Parent primitive.ObjectID `bson:"parent_id"`
|
Parent primitive.ObjectID `bson:"parent_id" json:"parent"`
|
||||||
Children []primitive.ObjectID `bson:"children_id"`
|
Children []primitive.ObjectID `bson:"children_id" json:"children"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *WebFileSystem) CreateDirectory(dirPath string) (primitive.ObjectID, primitive.ObjectID, error) {
|
func (fs *WebFileSystem) CreateDirectory(dirPath string) (primitive.ObjectID, primitive.ObjectID, error) {
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (fs *WebFileSystem) Route(route *gin.RouterGroup) {
|
func (fs *WebFileSystem) PrivateRoutes(route *gin.RouterGroup) {
|
||||||
route.POST("/upload", func(ctx *gin.Context) { //TODO To PUT request
|
route.POST("/upload", func(ctx *gin.Context) { //TODO To PUT request
|
||||||
// fileName := ctx.Query("fileName")
|
// fileName := ctx.Query("fileName")
|
||||||
// if fileName == "" {
|
// if fileName == "" {
|
||||||
@ -189,3 +189,7 @@ func (fs *WebFileSystem) Route(route *gin.RouterGroup) {
|
|||||||
ctx.Status(http.StatusOK)
|
ctx.Status(http.StatusOK)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (fs *WebFileSystem) PublicRoutes(route *gin.RouterGroup) {
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user