Compare commits
No commits in common. "e9422f797b72ef9d5ad43436e8d240ce4a7f10a7" and "5f6d5e7a48ffe59a1543ec0578df71db8a62823b" have entirely different histories.
e9422f797b
...
5f6d5e7a48
11
main.go
11
main.go
@ -63,8 +63,7 @@ func main() {
|
||||
|
||||
webfs := webfilesystem.NewWebFileSystem(client, dBName, webFsCollection)
|
||||
wde := wde.NewWDE(webfs)
|
||||
persPropsApp := personalprops.NewPersPropsApp(webfs)
|
||||
|
||||
persPropsApp := personalprops.NewPersPropsApp()
|
||||
// finderApp := finder.FinderApplication{}
|
||||
finderApp := finder.NewFinderApplication(webfs)
|
||||
imgViewerApp := imgviewer.NewImgViewerApp(webfs)
|
||||
@ -187,14 +186,10 @@ func main() {
|
||||
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)
|
||||
ctx.HTML(http.StatusOK, "personal-properties/mobile-app.tmpl", persPropsApp.Render())
|
||||
} else {
|
||||
ctx.HTML(http.StatusOK, "personal-properties/app.tmpl", ginH)
|
||||
ctx.HTML(http.StatusOK, "personal-properties/app.tmpl", persPropsApp.Render())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -5,13 +5,12 @@
|
||||
.Img-Viewer-Picture{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
/* background-image: url("./test-image.jpg");
|
||||
background-image: url("./test-image.jpg");
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center; */
|
||||
background-position: center center;
|
||||
}
|
||||
|
||||
|
||||
.Img-Viewer-Picture-Toolbar{
|
||||
width: 100%;
|
||||
height: 35px;
|
||||
|
@ -4,7 +4,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
if (!WebDesktopEnvironment.isMobile){
|
||||
WebDesktopEnvironment.Open("finder", ["/home/user"])
|
||||
// WebDesktopEnvironment.Open("blog-viewer", ["/home/user/blog/test-1.blog"])
|
||||
WebDesktopEnvironment.Open("personal-properties", ["kek"])
|
||||
// WebDesktopEnvironment.Open("personal-properties", ["kek"])
|
||||
} else {
|
||||
WebDesktopEnvironment.Open("blog-viewer", ["/home/user/blog/test-1.blog"])
|
||||
}
|
||||
|
@ -11,9 +11,9 @@
|
||||
<!-- <div class="Img-Viewer-Picture-Toolbar">
|
||||
Toolbar
|
||||
</div> -->
|
||||
|
||||
<img class="Img-Viewer-Picture-Container"src="data:{{.header}},{{.base64}}">
|
||||
|
||||
<div class="Img-Viewer-Picture-Container">
|
||||
<img src="data:{{.header}},{{.base64}}">
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{{ define "personal-properties/app.tmpl" }}
|
||||
<!-- <div id="WindowBorder" class="PersonalPropertiesFrame"> -->
|
||||
<div id="TestWindowHeader" class="WindowFrameTopBar DragArea">
|
||||
<div id="TestWindowHeader" class="WindowFrameTopBar">
|
||||
<button id="closeWindowButton" class="WindowFrameTopBarButton" title="Close Window"></button>
|
||||
<div id="Drag" class="WindowDragArea"></div>
|
||||
<div class="WindowFrameTitle">
|
||||
@ -13,11 +13,10 @@
|
||||
<div class="ScrollContent">
|
||||
<div class="PropertiesList">
|
||||
<div class="Personal-properties-bio">
|
||||
<img src="data:{{ .headerProps.Icon.Header }},{{ .headerProps.Icon.Base64 }}" alt="My Photo" style="width: 48px;height: 48px;">
|
||||
<img src="res/img/default-avatar-photo-placeholder-profile-picture-vector.jpg" alt="My Photo" style="width: 48px;height: 48px;">
|
||||
<div class="Personal-properties-textbio">
|
||||
<div>{{ .headerProps.Name }}</div>
|
||||
<div>{{ .headerProps.Info1 }}</div>
|
||||
<div>{{ .headerProps.Info2 }}</div>
|
||||
<div>{{ .Name }}</div>
|
||||
<div>{{ .BasicBio }}</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ range $propIsland := .allprops }}
|
||||
|
@ -1,29 +0,0 @@
|
||||
package wde
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"personalwebsite/webfilesystem"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
func ReadImage(img *webfilesystem.WebFSFile) (*Base64Img, error) {
|
||||
header, ok := img.Data.(primitive.D).Map()["header"].(string)
|
||||
if !ok {
|
||||
return nil, errors.New("error in file decoding")
|
||||
}
|
||||
base64, ok := img.Data.(primitive.D).Map()["base64"].(string)
|
||||
if !ok {
|
||||
return nil, errors.New("error in file decoding")
|
||||
}
|
||||
|
||||
return &Base64Img{
|
||||
Header: header,
|
||||
Base64: base64,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type Base64Img struct {
|
||||
Header string
|
||||
Base64 string
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
package imgviewer
|
||||
|
||||
import (
|
||||
"personalwebsite/wde"
|
||||
"errors"
|
||||
"personalwebsite/webfilesystem"
|
||||
"personalwebsite/websiteapp"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type ImgViewerApp struct {
|
||||
@ -36,12 +37,16 @@ func (p *ImgViewerApp) Render(path string, isMobile bool) (gin.H, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
data, err := wde.ReadImage(img)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
header, ok := img.Data.(primitive.D).Map()["header"]
|
||||
if !ok {
|
||||
return nil, errors.New("error in file decoding")
|
||||
}
|
||||
base64, ok := img.Data.(primitive.D).Map()["base64"]
|
||||
if !ok {
|
||||
return nil, errors.New("error in file decoding")
|
||||
}
|
||||
return gin.H{
|
||||
"header": data.Header,
|
||||
"base64": data.Base64,
|
||||
"header": header,
|
||||
"base64": base64,
|
||||
}, nil
|
||||
}
|
||||
|
@ -1,23 +1,17 @@
|
||||
package personalprops
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"personalwebsite/wde"
|
||||
"personalwebsite/webfilesystem"
|
||||
"personalwebsite/websiteapp"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type PersonalPropertiesApp struct {
|
||||
fs *webfilesystem.WebFileSystem
|
||||
manifest websiteapp.ApplicationManifest
|
||||
}
|
||||
|
||||
func NewPersPropsApp(webFs *webfilesystem.WebFileSystem) PersonalPropertiesApp {
|
||||
func NewPersPropsApp() PersonalPropertiesApp {
|
||||
newApp := PersonalPropertiesApp{
|
||||
fs: webFs,
|
||||
manifest: websiteapp.ApplicationManifest{
|
||||
AppId: "personal-properties",
|
||||
WindowName: "About me",
|
||||
@ -33,7 +27,16 @@ func (p *PersonalPropertiesApp) GetId() string {
|
||||
return p.manifest.AppId
|
||||
}
|
||||
|
||||
func (p *PersonalPropertiesApp) WriteToDb() {
|
||||
func (p *PersonalPropertiesApp) Render() gin.H {
|
||||
// books := make([]Book, 0)
|
||||
// books = append(books, Book{
|
||||
// Title: "Title 1",
|
||||
// Author: "Author 1",
|
||||
// })
|
||||
// books = append(books, Book{
|
||||
// Title: "Title 2",
|
||||
// Author: "Author 2",
|
||||
// })
|
||||
allProps := make([]PropIsland, 0)
|
||||
|
||||
// careerProps := make([]Prop, 0)
|
||||
@ -120,83 +123,26 @@ func (p *PersonalPropertiesApp) WriteToDb() {
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// testKeys := PropIsland{
|
||||
// Header: "Test",
|
||||
// Props: []PropElement{{
|
||||
// Key: "Urtt",
|
||||
// Values: []string{"BakaBaka"},
|
||||
// }},
|
||||
// }
|
||||
allProps = append(allProps, expertiseIsland, careerProps, eduIsland, volunteerProps)
|
||||
file := webfilesystem.WebFSFile{
|
||||
MongoId: primitive.NewObjectID(),
|
||||
Name: "personal.props",
|
||||
Type: "props",
|
||||
Data: PropertiesFile{
|
||||
Props: allProps,
|
||||
},
|
||||
}
|
||||
err := p.fs.CreateFile(&file, "/home/user/")
|
||||
if err != nil {
|
||||
println(err.Error())
|
||||
} else {
|
||||
println("Ok")
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PersonalPropertiesApp) Render() (gin.H, error) {
|
||||
props, err := p.fs.Read("/home/user/personal.props")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if props.Data == nil || props.Type != "props" {
|
||||
return nil, errors.New("bad file")
|
||||
}
|
||||
headerProps := props.Data.(primitive.D).Map()["headerprops"].(primitive.D).Map()
|
||||
file, err := p.fs.Read(headerProps["icon"].(string))
|
||||
if err != nil {
|
||||
//TODO
|
||||
}
|
||||
|
||||
data, err := wde.ReadImage(file)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hIsland := HeaderIsland{
|
||||
Name: headerProps["name"].(string),
|
||||
Icon: data,
|
||||
Info1: "LLL",
|
||||
Info2: "QQQ",
|
||||
}
|
||||
|
||||
allProps := make([]PropIsland, 0)
|
||||
|
||||
for _, v := range props.Data.(primitive.D).Map()["props"].(primitive.A) {
|
||||
island := PropIsland{}
|
||||
island.Header = v.(primitive.D).Map()["header"].(string)
|
||||
for _, prop := range v.(primitive.D).Map()["props"].(primitive.A) {
|
||||
elem := PropElement{
|
||||
Key: prop.(primitive.D).Map()["key"].(string),
|
||||
}
|
||||
if prop.(primitive.D).Map()["keycomments"] != nil {
|
||||
for _, keyComments := range prop.(primitive.D).Map()["keycomments"].(primitive.A) {
|
||||
elem.KeyComments = append(elem.KeyComments, keyComments.(string))
|
||||
}
|
||||
}
|
||||
for _, elemValues := range prop.(primitive.D).Map()["values"].(primitive.A) {
|
||||
elem.Values = append(elem.Values, elemValues.(string))
|
||||
}
|
||||
island.Props = append(island.Props, elem)
|
||||
}
|
||||
allProps = append(allProps, island)
|
||||
}
|
||||
|
||||
return gin.H{
|
||||
"headerProps": hIsland,
|
||||
"Name": "Greg Brzezinski",
|
||||
"BasicBio": "Born 27.09.1998 at Saint-Petersburg",
|
||||
// "BasicInfo": basicInfo,
|
||||
// "career": careerProps,
|
||||
"allprops": allProps,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
type HeaderIsland struct {
|
||||
Name string
|
||||
Icon *wde.Base64Img
|
||||
Info1 string
|
||||
Info2 string
|
||||
type Book struct {
|
||||
Title string
|
||||
Author string
|
||||
}
|
||||
|
||||
type PropElement struct {
|
||||
@ -210,6 +156,6 @@ type PropIsland struct {
|
||||
Props []PropElement
|
||||
}
|
||||
|
||||
type PropertiesFile struct {
|
||||
Props []PropIsland `bson:"props"`
|
||||
}
|
||||
// func (p *PersonalPropertiesApp) GetContent(ctx *gin.Context) interface{} {
|
||||
|
||||
// }
|
||||
|
Loading…
Reference in New Issue
Block a user