Compare commits

...

8 Commits

21 changed files with 641 additions and 271 deletions

View File

@ -0,0 +1,355 @@
package aboutme
import (
"errors"
"html/template"
"net/http"
"path"
"personalwebsite/apps/appCtx"
"personalwebsite/errormessage"
"personalwebsite/libs"
"personalwebsite/webfilesystem"
"github.com/gin-gonic/gin"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type AboutMeApp struct {
fs *webfilesystem.WebFileSystem
appID string
mLib libs.MarkdownLib
}
func NewAboutMeApp(webFs *webfilesystem.WebFileSystem) *AboutMeApp {
newApp := AboutMeApp{
fs: webFs,
appID: "AboutMe",
}
return &newApp
}
func (p *AboutMeApp) PublicRoutes(route *gin.RouterGroup) {
route.POST("render", func(ctx *gin.Context) {
filePath := ctx.Query("path")
if filePath == "" {
ctx.Status(http.StatusBadRequest)
return
}
appCtx := appCtx.AppContext{}
err := ctx.BindJSON(&appCtx)
if err != nil {
ctx.Status(http.StatusBadRequest)
return
}
ginH, err := p.Render(appCtx, filePath)
if err != nil {
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO
return
}
if appCtx.IsMobile {
ctx.HTML(http.StatusOK, "personal-properties/mobile-app.tmpl", ginH)
} else {
ctx.HTML(http.StatusOK, "personal-properties/app.tmpl", ginH)
}
})
}
func (p *AboutMeApp) PrivateRoutes(router *gin.RouterGroup) {
p.PublicRoutes(router)
// router.GET("writeMock", func(ctx *gin.Context) {
// err := p.WriteMock()
// if err != nil {
// ctx.Status(http.StatusInternalServerError)
// }
// ctx.Status(http.StatusOK)
// })
router.GET("getMock", func(ctx *gin.Context) {
ctx.JSON(http.StatusOK, PropertiesFileData{
Header: HeaderIsland{
Name: "",
IconPath: "",
Value1: "",
Value2: "",
},
Links: []HeaderLink{
{
Text: "",
Url: "",
Icon: "",
},
},
Islands: []Island{
{
Header: "qq",
Properties: []IslandProperty{
{
Key: "22",
KeyComments: []string{
"45",
"12",
},
Values: []string{
"aaaa",
},
},
},
},
},
})
})
router.GET("read", func(ctx *gin.Context) {
filePath := ctx.Query("path")
if filePath == "" {
ctx.JSON(http.StatusBadRequest, errormessage.ErrorMessage{
Message: "File path is empty",
})
return
}
propData, err := p.Read(filePath)
if err != nil {
ctx.JSON(http.StatusInternalServerError, errormessage.ErrorMessage{
Message: err.Error(),
})
return
}
ctx.JSON(http.StatusOK, propData)
})
router.POST("edit", func(ctx *gin.Context) {
filePath := ctx.Query("path")
if filePath == "" {
ctx.JSON(http.StatusBadRequest, errormessage.ErrorMessage{
Message: "File path is empty",
})
return
}
propsData := PropertiesFileData{}
err := ctx.BindJSON(&propsData)
if err != nil {
ctx.JSON(http.StatusBadRequest, errormessage.ErrorMessage{
Message: err.Error(),
})
return
}
err = p.Edit(filePath, propsData)
if err != nil {
ctx.JSON(http.StatusInternalServerError, errormessage.ErrorMessage{
Message: err.Error(),
})
return
}
ctx.Status(http.StatusOK)
})
}
func (p *AboutMeApp) GetAppID() string {
return p.appID
}
// func (p *AboutMeApp) WriteMock() error {
// fileHeader := webfilesystem.FileHeader{
// MongoId: primitive.NewObjectID(),
// Name: "aboutme.props",
// Type: "personal-properties",
// Icon: "",
// }
// fileData := PropertiesFileData{
// Header: HeaderIsland{
// Name: "Test Name",
// IconPath: "test icon path",
// Info1: "Info1",
// Info2: "Info2",
// },
// Props: []PropIsland{
// {
// Header: "Test Prop Header",
// Props: []PropElement{
// {
// Key: "Test key",
// KeyComments: []string{"Test key comment 1", "Test key comment 1"},
// Values: []Value{
// {
// Blocks: []ValueBlock{
// {
// Type: "string",
// Data: []string{"aappo"},
// },
// {
// Type: "link",
// Data: []string{"https://ya.ru", "Azazaza"},
// },
// },
// },
// },
// },
// },
// },
// {
// Header: "Test Prop Header 2",
// Props: []PropElement{
// {
// Key: "Test key",
// KeyComments: []string{"Test key comment 1", "Test key comment 1"},
// Values: []Value{
// {
// Blocks: []ValueBlock{
// {
// Type: "string",
// Data: []string{"aappo"},
// },
// {
// Type: "link",
// Data: []string{"https://ya.ru", "Azazaza"},
// },
// },
// },
// },
// },
// },
// },
// },
// }
// _, _, err := p.fs.Write("/Applications/AboutMe.app/aboutme.props", &fileHeader, fileData)
// return err
// }
func (p *AboutMeApp) Read(filePath string) (*PropertiesFileData, error) {
propData := PropertiesFileData{}
fileHeader, err := p.fs.Read(path.Join(filePath, "aboutme.props"), &propData)
if err != nil {
return nil, err
}
if fileHeader.Type != "personal-properties" {
return nil, errors.New("wrong file type")
}
return &propData, nil
}
func (p *AboutMeApp) Edit(filePath string, blogData PropertiesFileData) error {
propsPath := path.Join(filePath, "aboutme.props")
fileHeader, err := p.fs.Read(propsPath, nil)
if err != nil {
return err
}
if fileHeader.Type != "personal-properties" {
return errors.New("wrong file type")
}
err = p.fs.Remove(propsPath)
if err != nil {
return err
}
fileHeader.MongoId = primitive.NewObjectID()
_, _, err = p.fs.Write(propsPath, fileHeader, blogData)
if err != nil {
return err
}
return nil
}
func (p *AboutMeApp) Render(appCtx appCtx.AppContext, filePath string) (gin.H, error) {
//Read file from WebFS
propsData := &PropertiesFileData{}
filePath = p.fs.RelativeToAbsolute(appCtx, filePath)
_, err := p.fs.Read(filePath, &propsData)
if err != nil {
return nil, err
}
//Render Markdown strings
renderedIslands := []RenderedIsland{}
for _, island := range propsData.Islands {
newRenderedIsland := RenderedIsland{
Header: island.Header,
Properties: []RenderedIslandProperty{},
}
for _, property := range island.Properties {
newRenderedIslandProperty := RenderedIslandProperty{
Key: property.Key,
KeyComments: property.KeyComments,
Values: []template.HTML{},
}
for _, value := range property.Values {
renderedValue := p.mLib.Render([]byte(value), true)
newRenderedIslandProperty.Values = append(newRenderedIslandProperty.Values, renderedValue)
}
newRenderedIsland.Properties = append(newRenderedIsland.Properties, newRenderedIslandProperty)
}
renderedIslands = append(renderedIslands, newRenderedIsland)
}
//Make icon path absolute
propsData.Header.IconPath = p.fs.RelativeToAbsolute(appCtx, propsData.Header.IconPath)
absoluteLinks := []HeaderLink{}
for _, link := range propsData.Links {
absoluteLinks = append(absoluteLinks, HeaderLink{
Text: link.Text,
Url: link.Url,
Icon: p.fs.RelativeToAbsolute(appCtx, link.Icon),
})
}
return gin.H{
"HeaderProps": propsData.Header,
"Links": absoluteLinks,
"Islands": renderedIslands,
}, nil
}
type PropertiesFileData struct {
Header HeaderIsland `bson:"header" json:"header"`
Links []HeaderLink `bson:"links" json:"links"`
Islands []Island `bson:"islands" json:"islands"` //TODO rename
}
type HeaderIsland struct {
Name string `bson:"name" json:"name"`
IconPath string `bson:"iconpath" json:"iconpath"`
Value1 string `bson:"value1" json:"value1"` //TODO Rename to value
Value2 string `bson:"value2" json:"value2"`
}
type HeaderLink struct {
Text string `bson:"text" json:"text"`
Url string `bson:"url" json:"url"`
Icon string `bson:"icon" json:"icon"`
}
type Island struct {
Header string `bson:"header" json:"header"`
Properties []IslandProperty `bson:"properties" json:"properties"`
}
type IslandProperty struct {
Key string `bson:"key" json:"key"`
KeyComments []string `bson:"keycomment" json:"keycomment"`
Values []string `bson:"values" json:"values"`
}
type RenderedIsland struct {
Header string
Properties []RenderedIslandProperty
}
type RenderedIslandProperty struct {
Key string
KeyComments []string
Values []template.HTML
}
// type Value struct {
// Blocks []ValueBlock
// }
// type ValueBlock struct {
// Type string
// Data string
// }

View File

@ -1,6 +1,18 @@
package blogviewer
import "html/template"
type BlogFileData struct {
Header string `bson:"header"`
Blocks []*Block `bson:"blocks"`
}
type Block struct {
Type string `bson:"type"`
Data []string `bson:"data"`
}
type RenderedBlock struct {
Type string `bson:"type"`
Data []template.HTML `bson:"data"`
}

View File

@ -6,6 +6,7 @@ import (
"path"
"personalwebsite/apps/appCtx"
"personalwebsite/errormessage"
"personalwebsite/libs"
"personalwebsite/webfilesystem"
"github.com/gin-gonic/gin"
@ -15,12 +16,14 @@ import (
type BlogViewerApplication struct {
fs *webfilesystem.WebFileSystem
appID string
mLib libs.MarkdownLib
}
func NewBlogViewerApp(webFs *webfilesystem.WebFileSystem) *BlogViewerApplication {
return &BlogViewerApplication{
fs: webFs,
appID: "BlogViewer",
mLib: libs.MarkdownLib{},
}
}
@ -30,6 +33,37 @@ func (b *BlogViewerApplication) GetAppID() string {
func (b *BlogViewerApplication) PrivateRoutes(route *gin.RouterGroup) {
b.PublicRoutes(route)
route.POST("test", func(ctx *gin.Context) {
blogData := BlogFileData{}
err := ctx.BindJSON(&blogData)
if err != nil {
ctx.Status(http.StatusBadRequest)
return
}
mLib := libs.MarkdownLib{}
for _, block := range blogData.Blocks {
for _, str := range block.Data {
test := []byte(str)
mLib.Render(test, true)
}
}
})
route.GET("writeMockBlog", func(ctx *gin.Context) {
path := ctx.Query("path")
if path == "" {
ctx.JSON(http.StatusBadRequest, "no path provided")
return
}
err := b.WriteMock(path)
if err != nil {
ctx.Status(http.StatusInternalServerError)
return
}
ctx.JSON(http.StatusOK, "OK")
})
route.POST("edit", func(ctx *gin.Context) {
filePath := ctx.Query("path")
if filePath == "" {
@ -72,20 +106,8 @@ func (b *BlogViewerApplication) PrivateRoutes(route *gin.RouterGroup) {
ctx.JSON(http.StatusOK, blogData)
})
}
func (b *BlogViewerApplication) PublicRoutes(route *gin.RouterGroup) {
route.GET("writeMockBlog", func(ctx *gin.Context) {
path := ctx.Query("path")
if path == "" {
ctx.JSON(http.StatusBadRequest, "no path provided")
return
}
err := b.WriteMock(path)
if err != nil {
ctx.Status(http.StatusInternalServerError)
return
}
ctx.JSON(http.StatusOK, "OK")
})
route.POST("render", func(ctx *gin.Context) {
path := ctx.Query("path")
@ -207,22 +229,27 @@ func (b *BlogViewerApplication) Render(filePath string, appCtx appCtx.AppContext
return nil, err
}
newData := []RenderedBlock{}
for _, block := range data.Blocks {
if block.Type == "image" {
newData := []string{}
for _, image := range block.Data {
newData = append(newData, b.fs.RelativeToAbsolute(appCtx, image))
newBlock := RenderedBlock{}
switch block.Type {
case "image":
// for _, image := range block.Data {
// newData = append(newData, b.fs.RelativeToAbsolute(appCtx, image))
// }
case "markdown":
for _, data := range block.Data {
renderedMD := b.mLib.Render([]byte(data), true)
newBlock.Data = append(newBlock.Data, renderedMD)
}
block.Data = newData
newData = append(newData, newBlock)
}
// block.Data = newData
}
return gin.H{
"header": data.Header,
"blocks": data.Blocks,
"blocks": newData,
// "html": html,
}, nil
}
type Block struct {
Type string `bson:"type"`
Data []string `bson:"data"`
}

View File

@ -24,7 +24,7 @@ func (f *FinderApplication) PublicRoutes(routes *gin.RouterGroup) {
routes.GET("renderMobileDesktop", func(ctx *gin.Context) {
ctx.HTML(http.StatusOK, "finder/mobile-desktop.tmpl", gin.H{})
})
routes.GET("renderDesktop", func(ctx *gin.Context) {
routes.POST("renderDesktop", func(ctx *gin.Context) {
path := ctx.Query("path")
if path == "" {
ctx.JSON(http.StatusBadRequest, "no path provided")
@ -62,14 +62,17 @@ func (f *FinderApplication) PrivateRoutes(routes *gin.RouterGroup) {
err := ctx.BindJSON(&appCtx)
if err != nil {
ctx.JSON(http.StatusBadRequest, errormessage.ErrorMessage{
Message: "Error in decoding app context",
Message: "Error in decoding app bundle",
})
return
}
ctx.HTML(http.StatusOK, "finder/admin-app.tmpl", f.Render(appCtx))
})
routes.GET("renderDesktop", func(ctx *gin.Context) {
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")

View File

@ -1,145 +0,0 @@
package personalprops
import (
"net/http"
"personalwebsite/apps/appCtx"
"personalwebsite/webfilesystem"
"github.com/gin-gonic/gin"
"go.mongodb.org/mongo-driver/bson/primitive"
)
//TODO Rename to AboutMe
type PersonalPropertiesApp struct {
fs *webfilesystem.WebFileSystem
appID string
}
func NewPersPropsApp(webFs *webfilesystem.WebFileSystem) *PersonalPropertiesApp {
newApp := PersonalPropertiesApp{
fs: webFs,
appID: "AboutMe",
}
return &newApp
}
func (p *PersonalPropertiesApp) PublicRoutes(route *gin.RouterGroup) {
route.POST("render", func(ctx *gin.Context) {
filePath := ctx.Query("path")
if filePath == "" {
ctx.Status(http.StatusBadRequest)
return
}
appCtx := appCtx.AppContext{}
err := ctx.BindJSON(&appCtx)
if err != nil {
ctx.Status(http.StatusBadRequest)
return
}
ginH, err := p.Render(appCtx, filePath)
if err != nil {
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO
return
}
if appCtx.IsMobile {
ctx.HTML(http.StatusOK, "personal-properties/mobile-app.tmpl", ginH)
} else {
ctx.HTML(http.StatusOK, "personal-properties/app.tmpl", ginH)
}
})
}
func (p *PersonalPropertiesApp) PrivateRoutes(router *gin.RouterGroup) {
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) GetAppID() string {
return p.appID
}
func (p *PersonalPropertiesApp) WriteMock() error {
fileHeader := webfilesystem.FileHeader{
MongoId: primitive.NewObjectID(),
Name: "aboutme.props",
Type: "personal-properties",
Icon: "",
}
fileData := PropertiesFileData{
Header: HeaderIsland{
Name: "Test Name",
IconPath: "test icon path",
Info1: "Info1",
Info2: "Info2",
},
Props: []PropIsland{
{
Header: "Test Prop Header",
Props: []PropElement{
{
Key: "Test key",
KeyComments: []string{"Test key comment 1", "Test key comment 1"},
Values: []string{"test value1", "test value2"},
},
},
},
{
Header: "Test Prop Header 2",
Props: []PropElement{
{
Key: "Test key",
KeyComments: []string{"Test key comment 1", "Test key comment 1"},
Values: []string{"test value1", "test value2"},
},
},
},
},
}
_, _, err := p.fs.Write("/home/user/aboutme.props", &fileHeader, fileData)
return err
}
func (p *PersonalPropertiesApp) Render(appCtx appCtx.AppContext, filePath string) (gin.H, error) {
propsData := PropertiesFileData{}
filePath = p.fs.RelativeToAbsolute(appCtx, filePath)
_, err := p.fs.Read(filePath, &propsData)
if err != nil {
return nil, err
}
propsData.Header.IconPath = p.fs.RelativeToAbsolute(appCtx, propsData.Header.IconPath)
return gin.H{
"headerProps": propsData.Header,
"allprops": propsData.Props,
}, nil
}
type HeaderIsland struct {
Name string `bson:"name"`
IconPath string `bson:"iconpath"`
Info1 string `bson:"info1"`
Info2 string `bson:"info2"`
}
type PropElement struct {
Key string
KeyComments []string
Values []string
}
type PropIsland struct {
Header string
Props []PropElement
}
type PropertiesFileData struct {
Header HeaderIsland `bson:"header"`
Props []PropIsland `bson:"props"`
}

19
go.mod
View File

@ -5,7 +5,9 @@ go 1.18
require github.com/gin-gonic/gin v1.9.0
require (
github.com/aymerick/douceur v0.2.0 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/pkg/errors v0.9.1 // indirect
@ -13,14 +15,12 @@ require (
github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
)
require (
github.com/bytedance/sonic v1.8.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/disintegration/imaging v1.6.2
github.com/gin-contrib/cors v1.4.0
github.com/gin-contrib/location v0.0.2
github.com/gin-contrib/sse v0.1.0 // indirect
@ -28,27 +28,26 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.11.2 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/google/uuid v1.3.0
github.com/h2non/bimg v1.1.9
github.com/joho/godotenv v1.5.1
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mitchellh/mapstructure v1.5.0
github.com/microcosm-cc/bluemonday v1.0.24
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/russross/blackfriday v1.6.0
github.com/russross/blackfriday/v2 v2.1.0
github.com/thinkerou/favicon v0.2.0
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.9 // indirect
go.mongodb.org/mongo-driver v1.11.4
go.mongodb.org/mongo-driver v1.11.6
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

50
go.sum
View File

@ -1,3 +1,5 @@
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.8.0 h1:ea0Xadu+sHlu7x5O3gKhRpQ1IKiMrSiHttPF0ybECuA=
github.com/bytedance/sonic v1.8.0/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
@ -6,9 +8,8 @@ github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhD
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
github.com/gin-contrib/cors v1.4.0 h1:oJ6gwtUl3lqV0WEIwM/LxPF1QZ5qe2lGWdY2+bz7y0g=
github.com/gin-contrib/cors v1.4.0/go.mod h1:bs9pNM0x/UsmHPBWT2xZz9ROh8xYjYkiURUfmBoMlcs=
github.com/gin-contrib/location v0.0.2 h1:QZKh1+K/LLR4KG/61eIO3b7MLuKi8tytQhV6texLgP4=
@ -20,6 +21,7 @@ github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR
github.com/gin-gonic/gin v1.9.0 h1:OjyFBKICoexlu99ctXNR2gg+c5pKrKMuyjgARg9qeY8=
github.com/gin-gonic/gin v1.9.0/go.mod h1:W1Me9+hsUSyj3CePGrd1/QrKJMSJ1Tu/0hFEH89961k=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
@ -40,12 +42,11 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/h2non/bimg v1.1.9 h1:WH20Nxko9l/HFm4kZCA3Phbgu2cbHvYzxwxn9YROEGg=
github.com/h2non/bimg v1.1.9/go.mod h1:R3+UiYwkK4rQl6KVFTOFJHitgLbZXBZNFh2cv3AEbp8=
github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
@ -57,9 +58,11 @@ github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBF
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
@ -68,8 +71,8 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/microcosm-cc/bluemonday v1.0.24 h1:NGQoPtwGVcbGkKfvyYk1yRqknzBuoMiUrO6R7uFTPlw=
github.com/microcosm-cc/bluemonday v1.0.24/go.mod h1:ArQySAMps0790cHSkdPEJ7bGkF2VePWH773hsJNSHf8=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
@ -77,17 +80,21 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
@ -97,9 +104,11 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/thinkerou/favicon v0.2.0 h1:/qO//fFevzhx68pAAPjuiOwB2ykoKwLcZW9luMZ8PEU=
github.com/thinkerou/favicon v0.2.0/go.mod h1:PM31DMRkXDVi9/sGwb/a/evMB536N9VfVNC+Dtf4iDQ=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
@ -117,20 +126,18 @@ github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCO
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
go.mongodb.org/mongo-driver v1.11.4 h1:4ayjakA013OdpGyL2K3ZqylTac/rMjrJOMZ1EHizXas=
go.mongodb.org/mongo-driver v1.11.4/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g=
go.mongodb.org/mongo-driver v1.11.6 h1:XM7G6PjiGAO5betLF13BIa5TlLUUE3uJ/2Ox3Lz1K+o=
go.mongodb.org/mongo-driver v1.11.6/go.mod h1:G9TgswdsWjX4tmDA5zfs2+6AEPpYJwqblyjsfuh8oXY=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 h1:hVwzHzIUGRjiF7EcUjqNxk3NCfkPxbDKRdnNE1Rpg0U=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -140,17 +147,17 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
@ -158,6 +165,7 @@ google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

31
libs/markdown.go Normal file
View File

@ -0,0 +1,31 @@
package libs
import (
"html/template"
"strings"
"github.com/microcosm-cc/bluemonday"
"github.com/russross/blackfriday/v2"
)
type MarkdownLib struct {
}
func (ml *MarkdownLib) Render(md []byte, supressParagraph bool) template.HTML {
output := blackfriday.Run(md)
if supressParagraph {
output = []byte(strings.ReplaceAll(string(output), "<p>", ""))
output = []byte(strings.ReplaceAll(string(output), "</p>", ""))
}
_ = output
html := bluemonday.UGCPolicy().SanitizeBytes(output)
// println(string(html))
kek := template.HTML(html)
return kek
}
// func (ml MarkdownLib) MarkDowner(args ...interface{}) template.HTML {
// s := blackfriday.MarkdownCommon([]byte(fmt.Sprintf("%s", args...)))
// return template.HTML(s)
// }

View File

@ -8,10 +8,10 @@ import (
"personalwebsite/apps"
blogwriter "personalwebsite/apps/BlogWriter"
"personalwebsite/apps/aboutme"
"personalwebsite/apps/blogviewer"
"personalwebsite/apps/finder"
imgviewer "personalwebsite/apps/img-viewer"
"personalwebsite/apps/personalprops"
"personalwebsite/routes"
"personalwebsite/wde"
"personalwebsite/webfilesystem"
@ -67,7 +67,7 @@ func main() {
webde := wde.NewWDE(webfs)
//TODO Split to different apps init for private and public?
persPropsApp := personalprops.NewPersPropsApp(webfs)
persPropsApp := aboutme.NewAboutMeApp(webfs)
finderApp := finder.NewFinderApplication(webfs)
imgViewerApp := imgviewer.NewImgViewerApp(webfs)
blogViewerApp := blogviewer.NewBlogViewerApp(webfs)

View File

@ -30,7 +30,7 @@ class AboutMe{
newWindow.innerHTML = html
newWindow.style.height = 'auto'
newWindow.querySelector("#closeWindowButton").addEventListener('click', () => {
newWindow.querySelector("#closeWindowButton").addEventListener('click', () => {
WebDesktopEnvironment.CloseWindow(newWindow)
})
}

View File

@ -107,7 +107,27 @@
letter-spacing: 0.35px;
}
.PropertiesList .Links {
position: absolute;
right: 14px;
top: 27px;
/* background-color: aqua; */
height: auto;
width: auto;
/* Auto layout */
display: flex;
flex-direction: row;
align-items: left;
padding: 0px;
gap:4px;
}
.PropertiesList .Links .Link {
/* background-color:brown; */
width: 16px;
height: 16px;
}
.PropertiesList .Island{
width: 100%;

View File

@ -40,26 +40,32 @@ class FinderWindow{
fileView = undefined
windowElem = undefined
async Init(args, runContext){
if (args[1] === "-desktop"){
//todo pass div id, not div in args[]
async Init(args, appContext){
if (args[1] == "--desktop"){
let desktopNode = document.body.querySelector(`#${args[2]}`)
if (desktopNode == null){
WebDesktopEnvironment.Alert("Desktop node not found")
return
}
const params = new URLSearchParams({
isMobile: WebDesktopEnvironment.isMobile,
path: args[0]
})
const response = await fetch(`/app/${Finder.AppId}/renderDesktop?` + params,
{
method: "POST",
body: JSON.stringify(runContext)
body: JSON.stringify(appContext)
})
if (response.status != 200){
console.log(response.status)
WebDesktopEnvironment.Alert("Error in render desktop") //TODO
return
}
const html = await response.text()
args[2].innerHTML = html
desktopNode.innerHTML = html
this.fileView = new FileView(
args[2].querySelector(".FileTileView"), (event) =>{this.Click(event)},
desktopNode.querySelector(".FileTileView"), (event) =>{this.Click(event)},
(event) => { this.RightClick(event) },
(event, draggedElem) => { this.DropEvent(event, draggedElem)},
() => { this.ReRenderDir() }
@ -71,7 +77,7 @@ class FinderWindow{
const response = await fetch(`/app/${Finder.AppId}/render?` + params,
{
method: "POST",
body: JSON.stringify(runContext)
body: JSON.stringify(appContext)
})
if (response.status != 200){
const error = await response.json()

View File

@ -115,19 +115,18 @@ class FileView{
/** Get html of folder by path
* @param {string} path
*/
OpenFolder(path){
async OpenFolder(path){
this.path = path
fetch(`${window.location.origin}/system/wde/widgets/file-tile-view?path=${path}`) //TODO Move to wde func. Or Not?
.then((response) => response.text())
.then((html) => {
//TODO
// console.log(responseStatus)
// if (responseStatus != 200) {
// WebDesktopEnvironment.Alert("Error")
// }
this.parentElem.innerHTML = html
}).catch((error) => {
WebDesktopEnvironment.Alert(error);
const params = new URLSearchParams({
path: path
})
const response = await fetch(`/system/wde/widgets/file-tile-view?` + params)
if (response.status != 200){
//TODO Error text message
WebDesktopEnvironment.Alert("TODO")
return
}
let html = await response.text()
this.parentElem.innerHTML = html
}
}

View File

@ -34,9 +34,35 @@ class WebDesktopEnvironment{
}
async loadWDE(){
let autoStart = document.body.querySelector("wde-autostart")
if (autoStart == null){
WebDesktopEnvironment.Alert("Error in loading DE")
return
}
for (const child of autoStart.children) {
if (child.nodeName != "APP") continue
let appPath = child.getAttribute("app-path")
if (appPath == null) continue
let args = []
let argsRaw = child.querySelector("args")
if (argsRaw == null) continue
for (const argRaw of argsRaw.children) {
let arg = argRaw.getAttribute("string")
if (arg == null) continue
args.push(arg)
}
// console.log(appPath, args)
await WebDesktopEnvironment.Open(appPath, args)
}
autoStart.remove()
// await WebDesktopEnvironment.load2('/Applications/Finder.app', [ "desktop", document.querySelector('#desktop-layer')]) //FIXME
// await WebDesktopEnvironment.Open('/Applications/Finder.app', ["/home/user/.desktop", "-desktop", document.querySelector('#desktop-layer')])
await WebDesktopEnvironment.Open('/Applications/Finder.app', ["/home/user/Blogs",])
// await WebDesktopEnvironment.Open('/Applications/Finder.app', ["/home/user/Blogs",])
// await WebDesktopEnvironment.Open('/Applications/Finder.app', ["/home/user",])
// await WebDesktopEnvironment.Open('/Applications/Finder.app', ["/home",])
// WebDesktopEnvironment.Open('/Applications/AboutMe.app', [])

View File

@ -7,7 +7,6 @@ import (
"personalwebsite/apps"
"personalwebsite/errormessage"
"personalwebsite/libs"
"personalwebsite/routewde"
"personalwebsite/wde"
"personalwebsite/webfilesystem"
"time"
@ -18,6 +17,11 @@ import (
"github.com/thinkerou/favicon"
)
type AppString struct { //TODO temp
AppPath string
Args []string
}
func PrivateRoutes(port string, webfs *webfilesystem.WebFileSystem, webde *wde.WDE, appsStorage *apps.ApplicationsStorage) {
router := gin.New()
router.Use(location.Default())
@ -28,7 +32,30 @@ func PrivateRoutes(port string, webfs *webfilesystem.WebFileSystem, webde *wde.W
router.MaxMultipartMemory = 8 << 20 // 8 MiB
router.GET("/", func(ctx *gin.Context) {
ctx.HTML(http.StatusOK, "index.tmpl", gin.H{})
// appString := AppString{
// AppPath: "/Applications/Finder.app",
// Args: []string{"/home/user"},
// }
appString := AppString{
AppPath: "/Applications/BlogViewer.app",
Args: []string{"/home/user/Blogs/blog1.blog"},
}
aboutMe := AppString{
AppPath: "/Applications/AboutMe.app",
Args: []string{},
}
desktop := AppString{
AppPath: "/Applications/Finder.app",
Args: []string{"/home/user/", "--desktop", "desktop-layer"},
}
autostart := []AppString{desktop, appString, aboutMe}
ctx.HTML(http.StatusOK, "index.tmpl", gin.H{
"autostart": autostart,
})
})
systemGroup := router.Group("system")
{
@ -54,7 +81,7 @@ func PrivateRoutes(port string, webfs *webfilesystem.WebFileSystem, webde *wde.W
wdeGroup := systemGroup.Group("wde")
{
routewde.PublicRoutes(wdeGroup, webde)
wde.PublicRoutes(wdeGroup, webde)
}
fsGroup := systemGroup.Group("fs")

View File

@ -6,7 +6,7 @@ import (
"path"
"personalwebsite/apps"
"personalwebsite/libs"
"personalwebsite/routewde"
"personalwebsite/wde"
"personalwebsite/webfilesystem"
@ -45,7 +45,7 @@ func PublicRoutes(port string, webfs *webfilesystem.WebFileSystem, webde *wde.WD
wdeGroup := systemGroup.Group("wde")
{
routewde.PublicRoutes(wdeGroup, webde)
wde.PublicRoutes(wdeGroup, webde)
}
systemGroup.GET("/loadApp", func(ctx *gin.Context) {

View File

@ -20,9 +20,19 @@
<script src="res/dev-fs/wde/webfs.js"></script>
<script src="/res/dev-fs/wde/wde-scrollbar.js"></script>
<script src="/res/dev-fs/wde/file-view.js"></script>
</head>
<body>
<wde-autostart>
{{ range $app := .autostart }}
<app app-path="{{ $app.AppPath }}">
<args>
{{ range $arg := $app.Args }}
<arg string="{{ $arg }}"></arg>
{{ end }}
</args>
</app>
{{ end }}
</wde-autostart>
<div id="applications"></div>
<div id="desktop-layer"></div>
<div id="windows-layer"></div>

View File

@ -2,49 +2,48 @@
<div class="TitleBar DragArea">
<button id="closeWindowButton" class="Button" title="Close Window"></button>
<div id="Drag" class="VisualDragArea"></div>
<div class="Lable">
About me
</div>
<div class="Lable">About me</div>
<div id="Drag" class="VisualDragArea"></div>
</div>
<div class="ContentBorder AdjectiveElement">
<div class="PersPropsContent">
<div class="PropsView">
<div class="PropertiesList">
<div class="Links">
{{ range $link := .Links }}
<a href="{{$link.Url}}" target="_blank">
<img class="Link" src="/system/libs/img/get?path={{$link.Icon}}" alt="{{$link.Text}}">
</a>
{{ end }}
</div>
<div class="ShortBio">
<img class="Image" src="/system/libs/img/get?path={{ .headerProps.IconPath }}" alt="My Photo">
<img class="Image" src="/system/libs/img/get?path={{ .HeaderProps.IconPath }}" alt="My Photo">
<div class="Text">
<div class="Name">{{ .headerProps.Name }}</div>
<div>{{ .headerProps.Info1 }}</div>
<div>{{ .headerProps.Info2 }}</div>
<div class="Name">{{ .HeaderProps.Name }}</div>
<div>{{ .HeaderProps.Value1 }}</div>
<div>{{ .HeaderProps.Value2 }}</div>
</div>
</div>
{{ range $propIsland := .allprops }}
<!-- FIXME -->
<div class="Island">
<div class="Title">
{{$propIsland.Header}}:
</div>
{{ range $island := .Islands }}
<!-- FIXME -->
<div class="Island">
<div class="Title"> {{$island.Header}}:</div>
<div class="Content">
{{range $prop := $propIsland.Props}}
<div class="Row">
<div class="Key">
{{$prop.Key}}:
{{ range $value := $prop.KeyComments }}
<div class="KeyComment">
{{ $value }}
{{range $property := $island.Properties}}
<div class="Row">
<div class="Key">
{{$property.Key}}:
{{ range $keyComment := $property.KeyComments }}
<div class="KeyComment">{{ $keyComment }}</div>
{{ end }}
</div>
{{ end }}
</div>
<div class="Values">
{{ range $value := $prop.Values }}
<div class="Value">
{{ $value }}
<div class="Values">
{{ range $value := $property.Values }}
<div class="Value">{{ $value }}</div>
{{ end }}
</div>
{{ end }}
</div>
</div>
{{ end }}
{{ end }}
</div>
</div>
{{ end }}

BIN
test-img/folder.png (Stored with Git LFS)

Binary file not shown.

BIN
test-img/ohno.png (Stored with Git LFS)

Binary file not shown.

View File

@ -1,14 +1,13 @@
package routewde
package wde
import (
"net/http"
"personalwebsite/wde"
"github.com/gin-contrib/location"
"github.com/gin-gonic/gin"
)
func PublicRoutes(route *gin.RouterGroup, wde *wde.WDE) {
func PublicRoutes(route *gin.RouterGroup, wde *WDE) {
route.GET("/getbasicwindow", func(ctx *gin.Context) { //TODO Rename to renderGenericWindowFrame
ctx.HTML(http.StatusOK, "basic-window.html", nil)
})