Personal props
This commit is contained in:
parent
405f45e788
commit
1beba0f0ee
@ -4,10 +4,10 @@ import (
|
||||
"errors"
|
||||
"net/http"
|
||||
websiteapp "personalwebsite/apps"
|
||||
"personalwebsite/libs"
|
||||
"personalwebsite/webfilesystem"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
@ -34,6 +34,7 @@ func (p *PersonalPropertiesApp) Route(route *gin.RouterGroup) {
|
||||
ginH, err := p.Render()
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO
|
||||
return
|
||||
}
|
||||
if isMobile {
|
||||
ctx.HTML(http.StatusOK, "personal-properties/mobile-app.tmpl", ginH)
|
||||
@ -50,170 +51,62 @@ func (p *PersonalPropertiesApp) GetId() string {
|
||||
return p.manifest.AppId
|
||||
}
|
||||
|
||||
// func (p *PersonalPropertiesApp) WriteToDb() {
|
||||
// allProps := make([]PropIsland, 0)
|
||||
|
||||
// // careerProps := make([]Prop, 0)
|
||||
// expertiseIsland := PropIsland{
|
||||
// Header: "Area Of Expertise",
|
||||
// Props: []PropElement{{
|
||||
// Key: "Programming",
|
||||
// Values: []string{
|
||||
// "Creating tools and plugins for artists",
|
||||
// "Editor and basic gameplay scripting",
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// Key: "Game Art",
|
||||
// Values: []string{
|
||||
// "Professional modeling",
|
||||
// "Complete knowledge in CG render theory",
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
// eduIsland := PropIsland{
|
||||
// Header: "Education",
|
||||
// Props: []PropElement{
|
||||
// {
|
||||
// Key: "Gymnasium 526",
|
||||
// KeyComments: []string{"2005-2015"},
|
||||
// Values: []string{"Extended natural sciences course", "Additional C++, media production and computer graphics courses", "Winner of conference “The future of a strong Russia is in high technology” in programming section"},
|
||||
// },
|
||||
// {
|
||||
// Key: "Lyceum 281",
|
||||
// KeyComments: []string{"2015-2016"},
|
||||
// Values: []string{"Extended IT and Physical sciences course"},
|
||||
// },
|
||||
// {
|
||||
// Key: "University",
|
||||
// KeyComments: []string{"2017-2019"},
|
||||
// Values: []string{"Faculty: Info-communication Networks and Systems", "Specialty: Information Security"},
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
// careerProps := PropIsland{
|
||||
// Header: "Career",
|
||||
// Props: []PropElement{
|
||||
// {
|
||||
// Key: "VR lab assistant",
|
||||
// KeyComments: []string{"Academy of Digital Technologies", "2019-2020"},
|
||||
// Values: []string{"Teaching lessons for students in Unreal Engine 4, Unity and Blender editor courses", "Training students for World Skills Russia"},
|
||||
// },
|
||||
// {
|
||||
// Key: "3d artist",
|
||||
// KeyComments: []string{"Space Time VR", "2020-2020"},
|
||||
// Values: []string{"Creating 3d assets for VR game"},
|
||||
// },
|
||||
// {
|
||||
// Key: "Jr. Techartist",
|
||||
// KeyComments: []string{"MP Games"},
|
||||
// Values: []string{"Game content integration and production", "Shader coding", "Optimization asset production in artists pipeline"},
|
||||
// },
|
||||
// {
|
||||
// Key: "Techartist",
|
||||
// Values: []string{"Game content optimization and production", "Profiling and debugging render pipeline", "Creating in-house tools for pipeline software", "Working process pipeline integration and maintenance", "Linux servers administration"},
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
// volunteerProps := PropIsland{
|
||||
// Header: "Volunteer Experience",
|
||||
// Props: []PropElement{
|
||||
// {
|
||||
// Key: "Metrostroi Mod",
|
||||
// Values: []string{
|
||||
// "Help unite fragmented community on one social platform",
|
||||
// "Worked on social elements of official site, create ranking",
|
||||
// "Took a part on creating ranking system for players",
|
||||
// "Creating models and maps for Steam Workshop"},
|
||||
// },
|
||||
// {
|
||||
// Key: "Age of Silence",
|
||||
// Values: []string{
|
||||
// "Start as tech-artist, create naming system in big ue4 project",
|
||||
// "Promoted to chief of 3d Department",
|
||||
// "Project win Unreal Day 2019",
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
|
||||
// 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.NewRead("/home/user/personal.props")
|
||||
propsFile, err := p.fs.NewRead("/home/user/About Me.props")
|
||||
if err != nil {
|
||||
println(err.Error())
|
||||
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 err catch
|
||||
|
||||
if propsFile.Type != "pers-props" {
|
||||
return nil, errors.New("file is not a directory")
|
||||
}
|
||||
|
||||
// data, err := wde.ReadImage(file)
|
||||
fileData, err := castToPersPropsData(propsFile.Data)
|
||||
if err != nil {
|
||||
println(err.Error())
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_ = fileData
|
||||
|
||||
// file := castToFile(fileRaw)
|
||||
|
||||
// return file, nil
|
||||
|
||||
// if propsFile.Data == nil || propsFile.Type != "pers-props" {
|
||||
// return nil, errors.New("bad file")
|
||||
// }
|
||||
|
||||
// props, err := castToPersPropsData(propsFileRaw)
|
||||
// _ = props
|
||||
// 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,
|
||||
"allprops": allProps,
|
||||
// "headerProps": props.Header,
|
||||
// "allprops": props.Props,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func castToPersPropsData(fileData interface{}) (*PropertiesFileData, error) {
|
||||
propsData := PropertiesFileData{
|
||||
Header.Name: fileData.(primitive.D).Map()["name"].(string),
|
||||
}
|
||||
err := mapstructure.Decode(fileData.(primitive.D).Map(), &propsData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &propsData, nil
|
||||
|
||||
}
|
||||
|
||||
type HeaderIsland struct {
|
||||
Name string
|
||||
Icon *libs.Base64Img
|
||||
Info1 string
|
||||
Info2 string
|
||||
Name string `bson:"name"`
|
||||
IconPath string `bson:"iconpath"`
|
||||
Info1 string `bson:"info1"`
|
||||
Info2 string `bson:"info2"`
|
||||
}
|
||||
|
||||
type PropElement struct {
|
||||
@ -230,3 +123,8 @@ type PropIsland struct {
|
||||
type PropertiesFile struct {
|
||||
Props []PropIsland `bson:"props"`
|
||||
}
|
||||
|
||||
type PropertiesFileData struct {
|
||||
Header HeaderIsland `bson:"header"`
|
||||
Props []PropIsland `bson:"props"`
|
||||
}
|
||||
|
@ -15,17 +15,17 @@
|
||||
|
||||
.blog-viewer .header-h1{
|
||||
font-size:x-large;
|
||||
padding: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.blog-viewer .header-h2{
|
||||
font-size:large;
|
||||
padding: 6px;
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
|
||||
.blog-viewer .header-h3{
|
||||
font-size:larger;
|
||||
padding: 2px;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
.blog-viewer .plain-text{
|
||||
|
@ -36,9 +36,9 @@ class Finder{
|
||||
)
|
||||
this.OpenDir(this.path)
|
||||
|
||||
// newWindow.querySelector("#BackButton").addEventListener('click', () =>{
|
||||
// this.OpenPreviousDir()
|
||||
// })
|
||||
newWindow.querySelector("#RootButton").addEventListener('click', () =>{
|
||||
this.OpenDir('/')
|
||||
})
|
||||
|
||||
// newWindow.querySelector("#HomeButton").addEventListener('click', () =>{
|
||||
// this.OpenDir(this.homePath)
|
||||
@ -125,7 +125,7 @@ class Finder{
|
||||
* @param {string} path
|
||||
*/
|
||||
OpenDir(path){
|
||||
this.fileView.OpenFolder(this.path)
|
||||
this.fileView.OpenFolder(path)
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,9 +4,9 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
// console.log(window.screen.width)
|
||||
wde = new WebDesktopEnvironment
|
||||
if (!WebDesktopEnvironment.isMobile){
|
||||
WebDesktopEnvironment.Open("finder", ["/home/user"])
|
||||
// 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"])
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
<div id="ContentBorder" class="ContentBorder AdjectiveElement">
|
||||
<div class="FinderContent">
|
||||
<div class="ToolBar ConvexElement">
|
||||
<button id="BackButton">Back</button>
|
||||
<button id="RootButton">/</button>
|
||||
<button id="HomeButton">Home</button>
|
||||
</div>
|
||||
<div class="FinderFileView">
|
||||
|
@ -11,8 +11,9 @@
|
||||
<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="/system/libs/img/get?path={{ .headerProps.IconPath }}" alt="My Photo" style="width: 48px;height: 48px;">
|
||||
<div class="Personal-properties-textbio">
|
||||
{{ .headerProps.IconPath }}
|
||||
<div>{{ .headerProps.Name }}</div>
|
||||
<div>{{ .headerProps.Info1 }}</div>
|
||||
<div>{{ .headerProps.Info2 }}</div>
|
||||
|
@ -7,12 +7,12 @@ import (
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type readStruct struct {
|
||||
type ReadStruct struct {
|
||||
File interface{}
|
||||
Filter interface{}
|
||||
}
|
||||
|
||||
func (fs *WebFileSystem) readMongo(read readStruct) (*interface{}, error) {
|
||||
func (fs *WebFileSystem) ReadMongo(read ReadStruct) (*interface{}, error) {
|
||||
err := fs.webfsCollection.FindOne(fs.ctx, read.Filter).Decode(read.File)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -8,13 +8,13 @@ import (
|
||||
|
||||
func (fs *WebFileSystem) NewRead(filePath string) (*WebFSFile, error) {
|
||||
splittedPath := fs.SplitPath(filePath)
|
||||
read := readStruct{
|
||||
read := ReadStruct{
|
||||
File: &WebFSFile{},
|
||||
Filter: primitive.M{
|
||||
"name": splittedPath[len(splittedPath)-1],
|
||||
},
|
||||
}
|
||||
fileRaw, err := fs.readMongo(read)
|
||||
fileRaw, err := fs.ReadMongo(read)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user