-
+
-
{{ .Name }}
-
{{ .BasicBio }}
+
{{ .headerProps.Name }}
+
{{ .headerProps.Info1 }}
+
{{ .headerProps.Info2 }}
{{ range $propIsland := .allprops }}
diff --git a/wde/imglib.go b/wde/imglib.go
new file mode 100644
index 0000000..6f549de
--- /dev/null
+++ b/wde/imglib.go
@@ -0,0 +1,29 @@
+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
+}
diff --git a/websiteapp/img-viewer/imgviewer.go b/websiteapp/img-viewer/imgviewer.go
index b03e32c..10fc7f8 100644
--- a/websiteapp/img-viewer/imgviewer.go
+++ b/websiteapp/img-viewer/imgviewer.go
@@ -1,12 +1,11 @@
package imgviewer
import (
- "errors"
+ "personalwebsite/wde"
"personalwebsite/webfilesystem"
"personalwebsite/websiteapp"
"github.com/gin-gonic/gin"
- "go.mongodb.org/mongo-driver/bson/primitive"
)
type ImgViewerApp struct {
@@ -37,16 +36,12 @@ func (p *ImgViewerApp) Render(path string, isMobile bool) (gin.H, error) {
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")
+ data, err := wde.ReadImage(img)
+ if err != nil {
+ return nil, err
}
return gin.H{
- "header": header,
- "base64": base64,
+ "header": data.Header,
+ "base64": data.Base64,
}, nil
}
diff --git a/websiteapp/personalprops/personalprops.go b/websiteapp/personalprops/personalprops.go
index 62857b9..429af55 100644
--- a/websiteapp/personalprops/personalprops.go
+++ b/websiteapp/personalprops/personalprops.go
@@ -1,6 +1,8 @@
package personalprops
import (
+ "errors"
+ "personalwebsite/wde"
"personalwebsite/webfilesystem"
"personalwebsite/websiteapp"
@@ -141,7 +143,27 @@ func (p *PersonalPropertiesApp) Render() (gin.H, error) {
if err != nil {
return nil, err
}
- _ = props
+ 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) {
@@ -150,8 +172,6 @@ func (p *PersonalPropertiesApp) Render() (gin.H, error) {
for _, prop := range v.(primitive.D).Map()["props"].(primitive.A) {
elem := PropElement{
Key: prop.(primitive.D).Map()["key"].(string),
- // KeyComments: prop.(primitive.D).Map()["keycomments"].([]string),
-
}
if prop.(primitive.D).Map()["keycomments"] != nil {
for _, keyComments := range prop.(primitive.D).Map()["keycomments"].(primitive.A) {
@@ -166,19 +186,17 @@ func (p *PersonalPropertiesApp) Render() (gin.H, error) {
allProps = append(allProps, island)
}
- // allProps = append(allProps)
return gin.H{
- // "Name": "Greg Brzezinski",
- // "BasicBio": "Born 27.09.1998 at Saint-Petersburg",
- // "BasicInfo": basicInfo,
- // "career": careerProps,
- "allprops": allProps,
+ "headerProps": hIsland,
+ "allprops": allProps,
}, nil
}
-type Book struct {
- Title string
- Author string
+type HeaderIsland struct {
+ Name string
+ Icon *wde.Base64Img
+ Info1 string
+ Info2 string
}
type PropElement struct {
@@ -195,7 +213,3 @@ type PropIsland struct {
type PropertiesFile struct {
Props []PropIsland `bson:"props"`
}
-
-// func (p *PersonalPropertiesApp) GetContent(ctx *gin.Context) interface{} {
-
-// }