Compare commits
No commits in common. "f81e15f1b8232bd43a35be76f7a338d7babd3b72" and "46ad190b2a9a156674bac651466887899d8e55db" have entirely different histories.
f81e15f1b8
...
46ad190b2a
57
libs/cat.go
57
libs/cat.go
@ -1,57 +0,0 @@
|
|||||||
package libs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"net/http"
|
|
||||||
"personalwebsite/webfilesystem"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Cat struct {
|
|
||||||
fs *webfilesystem.WebFileSystem
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewCatLib(webfs *webfilesystem.WebFileSystem) *Cat {
|
|
||||||
return &Cat{
|
|
||||||
fs: webfs,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Cat) Get(filePath string) (string, error) {
|
|
||||||
file, err := c.fs.Read(filePath, nil)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
if file.Type != "plaintext" {
|
|
||||||
return "", errors.New("todo")
|
|
||||||
}
|
|
||||||
|
|
||||||
fileData := webfilesystem.PlainTextFileData{}
|
|
||||||
_, err = c.fs.Read(filePath, &fileData)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return fileData.Data, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Cat) Route(route *gin.RouterGroup) {
|
|
||||||
route.GET("get", func(ctx *gin.Context) {
|
|
||||||
path := ctx.Query("path")
|
|
||||||
if path == "" {
|
|
||||||
ctx.String(http.StatusBadRequest, "TODO") //TODO json error struct
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
data, err := c.Get(path)
|
|
||||||
if err != nil {
|
|
||||||
ctx.Status(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.String(http.StatusOK, "plaintext", data)
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
@ -5,13 +5,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Libs struct {
|
type Libs struct {
|
||||||
Imglib *ImagLib
|
imglib *ImagLib
|
||||||
Cat *Cat
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLibs(webfs *webfilesystem.WebFileSystem) Libs {
|
func NewLibs(webfs *webfilesystem.WebFileSystem) Libs {
|
||||||
return Libs{
|
return Libs{
|
||||||
Imglib: NewImgLib(webfs),
|
imglib: NewImgLib(webfs),
|
||||||
Cat: NewCatLib(webfs),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
6
main.go
6
main.go
@ -89,12 +89,6 @@ func main() {
|
|||||||
imgLib.Route(imgLibGroup)
|
imgLib.Route(imgLibGroup)
|
||||||
}
|
}
|
||||||
|
|
||||||
catLibGroup := libsGroup.Group("cat")
|
|
||||||
{
|
|
||||||
catLib := libs.NewCatLib(webfs)
|
|
||||||
catLib.Route(catLibGroup)
|
|
||||||
}
|
|
||||||
|
|
||||||
appsStorageGroup := libsGroup.Group("apps")
|
appsStorageGroup := libsGroup.Group("apps")
|
||||||
{
|
{
|
||||||
appsStorage.Route(appsStorageGroup)
|
appsStorage.Route(appsStorageGroup)
|
||||||
|
@ -20,11 +20,14 @@ class WebDesktopEnvironment{
|
|||||||
static Applications = {};
|
static Applications = {};
|
||||||
static isMobile = false
|
static isMobile = false
|
||||||
constructor(){
|
constructor(){
|
||||||
// WebDesktopEnvironment.isMobile = WebDesktopEnvironment.CheckMobile()
|
// WebDesktopEnvironment.Open("finder", ["/home/user", "desktop", document.querySelector('#desktop-layer')])
|
||||||
document.body.style.setProperty('--zoom', 1)
|
//TODO create key -desktop-mode
|
||||||
|
|
||||||
|
|
||||||
this.wc = new WindowsCompositor()
|
this.wc = new WindowsCompositor()
|
||||||
this.loadWDE()
|
this.loadWDE()
|
||||||
return
|
return
|
||||||
|
// WebDesktopEnvironment.isMobile = WebDesktopEnvironment.CheckMobile()
|
||||||
|
|
||||||
// let applications = document.createElement("div")
|
// let applications = document.createElement("div")
|
||||||
// applications.setAttribute('id', 'applications')
|
// applications.setAttribute('id', 'applications')
|
||||||
@ -63,6 +66,7 @@ class WebDesktopEnvironment{
|
|||||||
})
|
})
|
||||||
|
|
||||||
} else{
|
} else{
|
||||||
|
document.body.style.setProperty('--zoom', 1)
|
||||||
|
|
||||||
// let desktopLayer = document.createElement("div")
|
// let desktopLayer = document.createElement("div")
|
||||||
// desktopLayer.setAttribute('id', 'desktop-layer')
|
// desktopLayer.setAttribute('id', 'desktop-layer')
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="ContentBorder" class="ContentBorder AdjectiveElement">
|
<div id="ContentBorder" class="ContentBorder AdjectiveElement">
|
||||||
<div class="FinderContent">
|
<div class="FinderContent">
|
||||||
<!-- TODO Fix ConvexElement -->
|
|
||||||
<div class="ToolBar ConvexElement">
|
<div class="ToolBar ConvexElement">
|
||||||
<button id="RootButton">/</button>
|
<button id="RootButton">/</button>
|
||||||
<button id="HomeButton">Home</button>
|
<button id="HomeButton">Home</button>
|
||||||
|
@ -44,11 +44,6 @@ type BinaryFileData struct {
|
|||||||
Bin []byte `bson:"bin" json:"-"`
|
Bin []byte `bson:"bin" json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PlainTextFileData struct {
|
|
||||||
MongoId primitive.ObjectID `bson:"_id" json:"-"`
|
|
||||||
Data string `bson:"data" json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated
|
// Deprecated
|
||||||
func (fs *WebFileSystem) ReadHeader(fileID primitive.ObjectID) (*FileHeader, error) {
|
func (fs *WebFileSystem) ReadHeader(fileID primitive.ObjectID) (*FileHeader, error) {
|
||||||
file := &FileHeader{}
|
file := &FileHeader{}
|
||||||
|
Loading…
Reference in New Issue
Block a user