diff --git a/.gitignore b/.gitignore index 21f56b8..f785746 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,2 @@ -# local env files -.env.local -.env.*.local - -# Editor directories and files -.idea +build/ .vscode -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? diff --git a/README.md b/README.md new file mode 100644 index 0000000..aed7a9a --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# keyemail.dev + +Welcome to the official repo for the site https://keyemail.dev! This site is to display all about the user `Keyemail`, it displays the About Me, Gallery Photos, Socials, and Videos! This project is done under Go, but was orginally made in Vue. + +## Installation + +### Automatic (Easy Way) + +Make the `build.sh` an executable by: +```console +chmod +x ./build.sh +``` +and then run: +```console +./build.sh +``` + +After that, go into the build folder and run the executable that is in there. + +### Manual (Hard Way) + +First create the directory: +```console +mkdir build/ +``` + +then, copy src to ./build using: +```console +cp -r src/ ./build +``` + +then, build using Go: +```console +go build -o ./build +``` + +Your done! Go into the build folder and run the executable. + +## Support + +No support is offered on this package, this is a personal project to learn Go. + +## Credits + +Built by `keyemail`, `kuubeu` helped inspire this project, as well as some svg work. diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..53fc94a --- /dev/null +++ b/build.sh @@ -0,0 +1,13 @@ +#! /bin/bash +echo "Building.." + +echo "Making build folder" +mkdir build/ + +echo "Copying files into build folder" +cp -r src/ ./build/ + +echo "Building executable" +go build -o ./build/ + +echo "Done building!" diff --git a/go.mod b/go.mod index 7d0df39..fc56b55 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module serve +module keyemail-dev-v1.0 go 1.22.3 diff --git a/main.go b/main.go index 98325e5..dcf1734 100644 --- a/main.go +++ b/main.go @@ -5,31 +5,184 @@ import ( "os" "log" "html/template" + "strings" + "strconv" ) type Index struct { WebpageTitle string + WebpageIcon string + WebpageKeywords string + WebpageDescription string + GalleryItems []GalleryItems + SocialItems []SocialItems + VideoItems []VideoItems + GalleryPhoto *GalleryItems + VideoContent *VideoItems + Nav bool +} + +type GalleryItems struct { + URL string + ID int + Title string +} + +type SocialItems struct { + URL string + Name string + Username string + Icon string + Color string +} + +type VideoItems struct { + URL string + ID int + Title string + Description string + Thumbnail string +} + +var data = &Index { + WebpageTitle: "Keyemail", + WebpageIcon: "/src/assets/main/favicon.ico", + WebpageKeywords: "keyemail", + WebpageDescription: "Welcome to keyemail.dev! A profile based on Keyemail.", + GalleryItems: galleryItems, + SocialItems: socialItems, + VideoItems: videoItems, +} + +var currentData = &Index{} + +var galleryItems = []GalleryItems { + {"/src/assets/gallery/2_cats.jpg", 1, "Resting Day"}, + {"/src/assets/gallery/friend_cat.jpg", 2, "Orange Furr"}, + {"/src/assets/gallery/miku_poster.jpg", 3, "Miku Spotted"}, + {"/src/assets/gallery/networking.jpg", 4, "Wires of Networking"}, + {"/src/assets/gallery/another_friend_cat.jpg", 5, "Night Cat"}, + {"/src/assets/gallery/pc_case_stickers.jpg", 6, "I use arch BTW"}, + {"/src/assets/gallery/movie_picture_1.jpg", 7, "Prime Cut Cafe"}, + {"/src/assets/gallery/movie_picture_2.jpg", 8, "Big Fountain"}, + {"/src/assets/gallery/bird.jpg", 9, "Birds Eye"}, + {"/src/assets/gallery/japanese_garden_1.jpg", 10, "Pond of Fishes"}, + {"/src/assets/gallery/japanese_garden_2.jpg", 11, "Waterfall Pond"}, + {"/src/assets/gallery/japanese_garden_3.jpg", 12, "Bridge of Faith"}, + {"/src/assets/gallery/japanese_garden_4.jpg", 13, "Little Rocks"}, + {"/src/assets/gallery/japanese_garden_5.jpg", 14, "Arc over Pond"}, + {"/src/assets/gallery/japanese_garden_6.jpg", 15, "Beautiful Pond"}, +} + +var socialItems = []SocialItems { + {"https://discord.gg/VTEn4zuh", "Discord", "keyemail", "/src/assets/icons/discord.svg", "5865F2"}, + {"https://github.com/Keyemail", "GitHub", "Keyemail", "/src/assets/icons/github.svg", "171515"}, + {"https://steamcommunity.com/id/keyemail/", "Steam", "Keyemail", "/src/assets/icons/steam.svg", "000000"}, + {"https://open.spotify.com/user/316yuurxrw3zcprxsnrvgamxktp4", "Spotify", "Keyemail", "/src/assets/icons/spotify.svg", "1DB954"}, + {"https://www.youtube.com/channel/UCCNkKG8XoZCh52vLCbXYy7g", "YouTube", "Keyemail", "/src/assets/icons/youtube.svg", "CD201F"}, + {"https://www.instagram.com/keyemail1?igsh=OGQ5ZDc2ODk2ZA%3D%3D&utm_source=qr", "Instagram", "keyemail1", "/src/assets/icons/instagram.svg", "C13584"}, +} + +var videoItems = []VideoItems { + {"/src/assets/videos/JP-Installing-Windows-Project.mp4", 1, "JP Installing Windows Project", "This is a guide in japanese where I teach you how to install windows completely. This was made because of a JP Project I had to do.", "/src/assets/video_thumbnails/JP-Installing-Windows-Project.png"}, + {"/src/assets/videos/orange-cat.mp4", 2, "Orange Cat", "Cute little orange cat that my friend has!! Hes so cute lol.", "/src/assets/video_thumbnails/orange-cat.png"}, +} + +func renderTemplate(w http.ResponseWriter, tmpl string, data *Index, nav bool) { + var templateFiles[]string + + templateFiles = append(templateFiles, "src/pages/" + tmpl + ".tmpl", "src/index.tmpl", "src/components/navbar.tmpl") + + templates, err := template.ParseFiles(templateFiles...) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + data.Nav = nav + + err = templates.ExecuteTemplate(w, "base", data) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } + + log.Println("GET /" + tmpl) +} + +func galleryContentHandler(w http.ResponseWriter, req *http.Request) { + parts := strings.Split(req.URL.Path, "/") + + if len(parts) == 3 && parts[1] == "gallery" { + idStr := parts[2] + id, err := strconv.Atoi(idStr) + if err != nil || id < 1 || id > len(galleryItems) { + renderTemplate(w, "404", data, true) + return + } + + var item GalleryItems + for _, gi := range galleryItems { + if gi.ID == id { + item = gi + break + } + } + + *currentData = *data + currentData.GalleryPhoto = &item + currentData.GalleryItems = nil + + renderTemplate(w, "gallery_content", currentData, true) + return + } + + renderTemplate(w, "404", data, true) +} + +func videoContentHandler(w http.ResponseWriter, req *http.Request) { + parts := strings.Split(req.URL.Path, "/") + + if len(parts) == 3 && parts[1] == "videos" { + idStr := parts[2] + id, err := strconv.Atoi(idStr) + if err!= nil || id < 1 || id > len(videoItems) { + renderTemplate(w, "404", data, true) + return + } + + var item VideoItems + for _, gi := range videoItems { + if gi.ID == id { + item = gi + break + } + } + + *currentData = *data + currentData.VideoContent = &item + currentData.VideoItems = nil + + renderTemplate(w, "video_content", currentData, true) + return + } + + renderTemplate(w, "404", data, true) +} + +func videoHandler(w http.ResponseWriter, req *http.Request) { + renderTemplate(w, "video", data, true); +} + +func socialsHandler(w http.ResponseWriter, req *http.Request) { + renderTemplate(w, "socials", data, true); +} + +func galleryHandler(w http.ResponseWriter, req *http.Request) { + renderTemplate(w, "gallery", data, true); } func indexHandler(w http.ResponseWriter, req *http.Request) { - tmpl, err := template.ParseFiles("src/index.tmpl") - if err != nil { - http.Error(w, "Error loading template", http.StatusInternalServerError) - log.Println("Error parsing template:", err) - return - } - - data := &Index{ - WebpageTitle: "Keyemail", - } - - err = tmpl.Execute(w, data) - - if err != nil { - http.Error(w, "Error loading template", http.StatusInternalServerError) - log.Println("Error executing template:", err) - return - } + renderTemplate(w, "home", data, true); } func main() { @@ -37,9 +190,17 @@ func main() { log.Fatal("Template file does not exist:\n", err) } + fs := http.FileServer(http.Dir("./src")) + http.Handle("/src/", http.StripPrefix("/src/", fs)) + port := ":3939" http.HandleFunc("/", indexHandler) + http.HandleFunc("/socials", socialsHandler) + http.HandleFunc("/gallery", galleryHandler) + http.HandleFunc("/videos", videoHandler) + http.HandleFunc("/gallery/", galleryContentHandler) + http.HandleFunc("/videos/", videoContentHandler) log.Println("Server running at http://localhost" + port) http.ListenAndServe(port, nil) } diff --git a/serve b/serve deleted file mode 100755 index 0123f65..0000000 Binary files a/serve and /dev/null differ diff --git a/src/assets/badges/code.svg b/src/assets/badges/code.svg new file mode 100644 index 0000000..c85afe8 --- /dev/null +++ b/src/assets/badges/code.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/badges/css.svg b/src/assets/badges/css.svg new file mode 100644 index 0000000..51338c4 --- /dev/null +++ b/src/assets/badges/css.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/badges/golang.svg b/src/assets/badges/golang.svg new file mode 100644 index 0000000..8507a77 --- /dev/null +++ b/src/assets/badges/golang.svg @@ -0,0 +1 @@ + diff --git a/src/assets/badges/html.svg b/src/assets/badges/html.svg new file mode 100644 index 0000000..29382dd --- /dev/null +++ b/src/assets/badges/html.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/badges/js.svg b/src/assets/badges/js.svg new file mode 100644 index 0000000..80a1922 --- /dev/null +++ b/src/assets/badges/js.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/badges/vue.svg b/src/assets/badges/vue.svg new file mode 100644 index 0000000..f861daa --- /dev/null +++ b/src/assets/badges/vue.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/gallery/2_cats.jpg b/src/assets/gallery/2_cats.jpg new file mode 100644 index 0000000..38ea3fd Binary files /dev/null and b/src/assets/gallery/2_cats.jpg differ diff --git a/src/assets/gallery/another_friend_cat.jpg b/src/assets/gallery/another_friend_cat.jpg new file mode 100644 index 0000000..49923d5 Binary files /dev/null and b/src/assets/gallery/another_friend_cat.jpg differ diff --git a/src/assets/gallery/bird.jpg b/src/assets/gallery/bird.jpg new file mode 100644 index 0000000..f236470 Binary files /dev/null and b/src/assets/gallery/bird.jpg differ diff --git a/src/assets/gallery/friend_cat.jpg b/src/assets/gallery/friend_cat.jpg new file mode 100644 index 0000000..f9f4e2e Binary files /dev/null and b/src/assets/gallery/friend_cat.jpg differ diff --git a/src/assets/gallery/japanese_garden_1.jpg b/src/assets/gallery/japanese_garden_1.jpg new file mode 100644 index 0000000..071c3de Binary files /dev/null and b/src/assets/gallery/japanese_garden_1.jpg differ diff --git a/src/assets/gallery/japanese_garden_2.jpg b/src/assets/gallery/japanese_garden_2.jpg new file mode 100644 index 0000000..c87a8e9 Binary files /dev/null and b/src/assets/gallery/japanese_garden_2.jpg differ diff --git a/src/assets/gallery/japanese_garden_3.jpg b/src/assets/gallery/japanese_garden_3.jpg new file mode 100644 index 0000000..baf763d Binary files /dev/null and b/src/assets/gallery/japanese_garden_3.jpg differ diff --git a/src/assets/gallery/japanese_garden_4.jpg b/src/assets/gallery/japanese_garden_4.jpg new file mode 100644 index 0000000..1517587 Binary files /dev/null and b/src/assets/gallery/japanese_garden_4.jpg differ diff --git a/src/assets/gallery/japanese_garden_5.jpg b/src/assets/gallery/japanese_garden_5.jpg new file mode 100644 index 0000000..f24af69 Binary files /dev/null and b/src/assets/gallery/japanese_garden_5.jpg differ diff --git a/src/assets/gallery/japanese_garden_6.jpg b/src/assets/gallery/japanese_garden_6.jpg new file mode 100644 index 0000000..e9f074f Binary files /dev/null and b/src/assets/gallery/japanese_garden_6.jpg differ diff --git a/src/assets/gallery/miku_poster.jpg b/src/assets/gallery/miku_poster.jpg new file mode 100644 index 0000000..4aa7f29 Binary files /dev/null and b/src/assets/gallery/miku_poster.jpg differ diff --git a/src/assets/gallery/movie_picture_1.jpg b/src/assets/gallery/movie_picture_1.jpg new file mode 100644 index 0000000..52187fb Binary files /dev/null and b/src/assets/gallery/movie_picture_1.jpg differ diff --git a/src/assets/gallery/movie_picture_2.jpg b/src/assets/gallery/movie_picture_2.jpg new file mode 100644 index 0000000..6fdf6dd Binary files /dev/null and b/src/assets/gallery/movie_picture_2.jpg differ diff --git a/src/assets/gallery/networking.jpg b/src/assets/gallery/networking.jpg new file mode 100644 index 0000000..193b69b Binary files /dev/null and b/src/assets/gallery/networking.jpg differ diff --git a/src/assets/gallery/pc_case_stickers.jpg b/src/assets/gallery/pc_case_stickers.jpg new file mode 100644 index 0000000..da5cab3 Binary files /dev/null and b/src/assets/gallery/pc_case_stickers.jpg differ diff --git a/src/assets/icons/arrow-left.svg b/src/assets/icons/arrow-left.svg new file mode 100644 index 0000000..b1b6099 --- /dev/null +++ b/src/assets/icons/arrow-left.svg @@ -0,0 +1 @@ + diff --git a/src/assets/icons/discord.svg b/src/assets/icons/discord.svg new file mode 100644 index 0000000..033db31 --- /dev/null +++ b/src/assets/icons/discord.svg @@ -0,0 +1 @@ + diff --git a/src/assets/icons/github.svg b/src/assets/icons/github.svg new file mode 100644 index 0000000..d46872b --- /dev/null +++ b/src/assets/icons/github.svg @@ -0,0 +1 @@ + diff --git a/src/assets/icons/instagram.svg b/src/assets/icons/instagram.svg new file mode 100644 index 0000000..403e6f4 --- /dev/null +++ b/src/assets/icons/instagram.svg @@ -0,0 +1 @@ + diff --git a/src/assets/icons/spotify.svg b/src/assets/icons/spotify.svg new file mode 100644 index 0000000..d4c7c6a --- /dev/null +++ b/src/assets/icons/spotify.svg @@ -0,0 +1 @@ + diff --git a/src/assets/icons/steam.svg b/src/assets/icons/steam.svg new file mode 100644 index 0000000..7be10e3 --- /dev/null +++ b/src/assets/icons/steam.svg @@ -0,0 +1 @@ + diff --git a/src/assets/icons/youtube.svg b/src/assets/icons/youtube.svg new file mode 100644 index 0000000..4b7ce32 --- /dev/null +++ b/src/assets/icons/youtube.svg @@ -0,0 +1 @@ + diff --git a/src/assets/main/favicon.ico b/src/assets/main/favicon.ico new file mode 100644 index 0000000..c9fa5a6 Binary files /dev/null and b/src/assets/main/favicon.ico differ diff --git a/src/assets/profile/profile.jpg b/src/assets/profile/profile.jpg new file mode 100644 index 0000000..222c066 Binary files /dev/null and b/src/assets/profile/profile.jpg differ diff --git a/src/assets/video_thumbnails/JP-Installing-Windows-Project.png b/src/assets/video_thumbnails/JP-Installing-Windows-Project.png new file mode 100644 index 0000000..b984d59 Binary files /dev/null and b/src/assets/video_thumbnails/JP-Installing-Windows-Project.png differ diff --git a/src/assets/video_thumbnails/orange-cat.png b/src/assets/video_thumbnails/orange-cat.png new file mode 100644 index 0000000..5c2549c Binary files /dev/null and b/src/assets/video_thumbnails/orange-cat.png differ diff --git a/src/assets/videos/JP-Installing-Windows-Project.mp4 b/src/assets/videos/JP-Installing-Windows-Project.mp4 new file mode 100644 index 0000000..321761e Binary files /dev/null and b/src/assets/videos/JP-Installing-Windows-Project.mp4 differ diff --git a/src/assets/videos/orange-cat.mp4 b/src/assets/videos/orange-cat.mp4 new file mode 100644 index 0000000..4161813 Binary files /dev/null and b/src/assets/videos/orange-cat.mp4 differ diff --git a/src/components/navbar.tmpl b/src/components/navbar.tmpl new file mode 100644 index 0000000..f6a10fd --- /dev/null +++ b/src/components/navbar.tmpl @@ -0,0 +1,22 @@ +{{ define "navbar" }} + +{{ end }} diff --git a/src/index.tmpl b/src/index.tmpl index a6f9397..a5bff89 100644 --- a/src/index.tmpl +++ b/src/index.tmpl @@ -1,9 +1,25 @@ - - +{{ define "base" }} + +
{{ template "head" . }} -This page has not been found, click here to return back home.
+I specialize in IT and web development-related stuff, but I also love doing a variety of different hobbies such as Flight Simulator, or learning Japanese. I daily run an Arch Linux machine as my main system and support Linux in every way. I'm glad to meet you!
+{{ .VideoContent.Description }}
+
My Socials!
++ {{ range .SocialItems }} + +-
+
+
+ {{ end }}
+
+{{ .Name }}
+{{ .Username }}
+ +