2023-03-15 12:32:41 +00:00
package personalprops
2023-03-17 01:16:51 +00:00
import (
2023-04-29 20:17:34 +00:00
"errors"
2023-05-03 21:50:08 +00:00
"net/http"
websiteapp "personalwebsite/apps"
2023-05-02 00:12:43 +00:00
"personalwebsite/libs"
2023-04-29 19:37:08 +00:00
"personalwebsite/webfilesystem"
2023-03-17 01:16:51 +00:00
"github.com/gin-gonic/gin"
2023-04-29 19:37:08 +00:00
"go.mongodb.org/mongo-driver/bson/primitive"
2023-03-17 01:16:51 +00:00
)
2023-03-15 12:32:41 +00:00
type PersonalPropertiesApp struct {
2023-04-29 19:37:08 +00:00
fs * webfilesystem . WebFileSystem
2023-03-17 01:16:51 +00:00
manifest websiteapp . ApplicationManifest
2023-03-15 12:32:41 +00:00
}
2023-04-29 19:37:08 +00:00
func NewPersPropsApp ( webFs * webfilesystem . WebFileSystem ) PersonalPropertiesApp {
2023-03-17 01:16:51 +00:00
newApp := PersonalPropertiesApp {
2023-04-29 19:37:08 +00:00
fs : webFs ,
2023-03-17 01:16:51 +00:00
manifest : websiteapp . ApplicationManifest {
AppId : "personal-properties" ,
WindowName : "About me" ,
} ,
}
2023-03-15 12:32:41 +00:00
return newApp
}
2023-05-03 21:50:08 +00:00
func ( p * PersonalPropertiesApp ) Route ( route * gin . RouterGroup ) {
route . GET ( "render" , func ( ctx * gin . Context ) {
isMobileParam := ctx . Query ( "isMobile" )
isMobile := isMobileParam == "true"
ginH , err := p . Render ( )
if err != nil {
ctx . JSON ( http . StatusInternalServerError , "TODO" ) //TODO
}
if isMobile {
ctx . HTML ( http . StatusOK , "personal-properties/mobile-app.tmpl" , ginH )
} else {
ctx . HTML ( http . StatusOK , "personal-properties/app.tmpl" , ginH )
}
} )
}
2023-03-17 01:16:51 +00:00
func ( p * PersonalPropertiesApp ) GetManifest ( ) websiteapp . ApplicationManifest {
return p . manifest
}
func ( p * PersonalPropertiesApp ) GetId ( ) string {
return p . manifest . AppId
}
2023-04-29 19:37:08 +00:00
func ( p * PersonalPropertiesApp ) WriteToDb ( ) {
2023-03-18 00:34:56 +00:00
allProps := make ( [ ] PropIsland , 0 )
2023-03-17 01:16:51 +00:00
2023-03-18 00:34:56 +00:00
// 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" ,
} ,
2023-03-17 01:16:51 +00:00
} ,
2023-03-18 00:34:56 +00:00
{
Key : "Game Art" ,
Values : [ ] string {
"Professional modeling" ,
"Complete knowledge in CG render theory" ,
} ,
} ,
2023-03-17 01:16:51 +00:00
} ,
2023-03-18 00:34:56 +00:00
}
eduIsland := PropIsland {
Header : "Education" ,
Props : [ ] PropElement {
{
2023-03-18 02:16:32 +00:00
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" } ,
2023-03-18 00:34:56 +00:00
} ,
{
2023-03-18 02:16:32 +00:00
Key : "Lyceum 281" ,
KeyComments : [ ] string { "2015-2016" } ,
Values : [ ] string { "Extended IT and Physical sciences course" } ,
2023-03-18 00:34:56 +00:00
} ,
{
2023-03-18 02:16:32 +00:00
Key : "University" ,
KeyComments : [ ] string { "2017-2019" } ,
Values : [ ] string { "Faculty: Info-communication Networks and Systems" , "Specialty: Information Security" } ,
2023-03-18 00:34:56 +00:00
} ,
2023-03-17 16:13:41 +00:00
} ,
2023-03-18 00:34:56 +00:00
}
careerProps := PropIsland {
Header : "Career" ,
Props : [ ] PropElement {
{
2023-03-18 02:16:32 +00:00
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" } ,
2023-03-18 00:34:56 +00:00
} ,
{
2023-03-18 02:16:32 +00:00
Key : "3d artist" ,
KeyComments : [ ] string { "Space Time VR" , "2020-2020" } ,
Values : [ ] string { "Creating 3d assets for VR game" } ,
2023-03-18 00:34:56 +00:00
} ,
{
2023-03-18 02:16:32 +00:00
Key : "Jr. Techartist" ,
KeyComments : [ ] string { "MP Games" } ,
Values : [ ] string { "Game content integration and production" , "Shader coding" , "Optimization asset production in artists pipeline" } ,
2023-03-18 00:34:56 +00:00
} ,
{
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" } ,
} ,
2023-03-17 01:16:51 +00:00
} ,
}
2023-03-18 00:34:56 +00:00
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" ,
2023-03-18 02:16:32 +00:00
"Took a part on creating ranking system for players" ,
2023-03-18 00:34:56 +00:00
"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" ,
} ,
} ,
} ,
}
2023-04-29 19:37:08 +00:00
2023-03-18 00:34:56 +00:00
allProps = append ( allProps , expertiseIsland , careerProps , eduIsland , volunteerProps )
2023-04-29 19:37:08 +00:00
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
}
2023-04-29 20:17:34 +00:00
if props . Data == nil || props . Type != "props" {
return nil , errors . New ( "bad file" )
}
headerProps := props . Data . ( primitive . D ) . Map ( ) [ "headerprops" ] . ( primitive . D ) . Map ( )
2023-05-01 12:32:41 +00:00
// file, err := p.fs.Read(headerProps["icon"].(string))
2023-04-29 20:17:34 +00:00
if err != nil {
2023-04-29 21:16:37 +00:00
//TODO err catch
2023-04-29 20:17:34 +00:00
}
2023-05-01 12:32:41 +00:00
// data, err := wde.ReadImage(file)
// if err != nil {
// return nil, err
// }
2023-04-29 20:17:34 +00:00
hIsland := HeaderIsland {
2023-05-01 12:32:41 +00:00
Name : headerProps [ "name" ] . ( string ) ,
// Icon: data,
2023-04-29 20:17:34 +00:00
Info1 : "LLL" ,
Info2 : "QQQ" ,
}
2023-04-29 19:37:08 +00:00
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 )
}
2023-03-17 01:16:51 +00:00
return gin . H {
2023-04-29 20:17:34 +00:00
"headerProps" : hIsland ,
"allprops" : allProps ,
2023-04-29 19:37:08 +00:00
} , nil
2023-03-15 12:32:41 +00:00
}
2023-04-29 20:17:34 +00:00
type HeaderIsland struct {
Name string
2023-05-02 00:12:43 +00:00
Icon * libs . Base64Img
2023-04-29 20:17:34 +00:00
Info1 string
Info2 string
2023-03-15 12:32:41 +00:00
}
2023-03-17 01:16:51 +00:00
2023-03-17 16:13:41 +00:00
type PropElement struct {
2023-03-18 02:16:32 +00:00
Key string
KeyComments [ ] string
Values [ ] string
2023-03-17 01:16:51 +00:00
}
2023-03-18 00:34:56 +00:00
type PropIsland struct {
Header string
Props [ ] PropElement
}
2023-04-29 19:37:08 +00:00
type PropertiesFile struct {
Props [ ] PropIsland ` bson:"props" `
}