From 3c6689c75ddf99954fee55c5ef5e2a7d98a9633b Mon Sep 17 00:00:00 2001 From: Hatsune Patrick Date: Mon, 9 Sep 2024 13:03:00 -0700 Subject: [PATCH] Added java badge --- main.go | 296 ++++++++++++++++++------------------- src/assets/badges/java.svg | 1 + src/pages/home.tmpl | 4 + 3 files changed, 153 insertions(+), 148 deletions(-) create mode 100644 src/assets/badges/java.svg diff --git a/main.go b/main.go index 5027329..f125178 100644 --- a/main.go +++ b/main.go @@ -1,219 +1,219 @@ package main import ( - "net/http" - "os" - "log" - "html/template" - "strings" - "strconv" + "html/template" + "log" + "net/http" + "os" + "strconv" + "strings" ) type Index struct { - WebpageTitle string - WebpageIcon string - WebpageKeywords string - WebpageDescription string - WebpageURL string - GalleryItems []GalleryItems - SocialItems []SocialItems - VideoItems []VideoItems - GalleryPhoto *GalleryItems - VideoContent *VideoItems - Nav bool + WebpageTitle string + WebpageIcon string + WebpageKeywords string + WebpageDescription string + WebpageURL string + GalleryItems []GalleryItems + SocialItems []SocialItems + VideoItems []VideoItems + GalleryPhoto *GalleryItems + VideoContent *VideoItems + Nav bool } type responseWriter struct { - http.ResponseWriter - status int + http.ResponseWriter + status int } type GalleryItems struct { - URL string - ID int - Title string + URL string + ID int + Title string } type SocialItems struct { - URL string - Name string - Username string - Icon string - Color string + URL string + Name string + Username string + Icon string + Color string } type VideoItems struct { - URL string - ID int - Title string - Description string - Thumbnail string + 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.", - WebpageURL: "https://keyemail.dev", - GalleryItems: galleryItems, - SocialItems: socialItems, - VideoItems: videoItems, +var data = &Index{ + WebpageTitle: "Keyemail", + WebpageIcon: "/src/assets/main/favicon.ico", + WebpageKeywords: "keyemail", + WebpageDescription: "Welcome to keyemail.dev! A profile based on Keyemail.", + WebpageURL: "https://keyemail.dev", + 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 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 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"}, +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 + var templateFiles []string - templateFiles = append(templateFiles, "src/pages/" + tmpl + ".tmpl", "src/index.tmpl", "src/components/navbar.tmpl") + 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 - } + templates, err := template.ParseFiles(templateFiles...) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } - data.Nav = nav + data.Nav = nav - err = templates.ExecuteTemplate(w, "base", data) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - } + err = templates.ExecuteTemplate(w, "base", data) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } - log.Println("GET /" + tmpl) + log.Println("GET /" + tmpl) } func galleryContentHandler(w http.ResponseWriter, req *http.Request) { - parts := strings.Split(req.URL.Path, "/") + 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 - } + 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 - } - } + var item GalleryItems + for _, gi := range galleryItems { + if gi.ID == id { + item = gi + break + } + } - *currentData = *data - currentData.GalleryPhoto = &item - currentData.GalleryItems = nil + *currentData = *data + currentData.GalleryPhoto = &item + currentData.GalleryItems = nil - renderTemplate(w, "gallery_content", currentData, true) - return - } + renderTemplate(w, "gallery_content", currentData, true) + return + } - renderTemplate(w, "404", data, true) + renderTemplate(w, "404", data, true) } func videoContentHandler(w http.ResponseWriter, req *http.Request) { - parts := strings.Split(req.URL.Path, "/") + 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 - } + 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 - } - } + 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 - } + *currentData = *data + currentData.VideoContent = &item + currentData.VideoItems = nil - renderTemplate(w, "404", data, true) + 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) + renderTemplate(w, "video", data, true) } func socialsHandler(w http.ResponseWriter, req *http.Request) { - renderTemplate(w, "socials", data, true) + renderTemplate(w, "socials", data, true) } func galleryHandler(w http.ResponseWriter, req *http.Request) { - renderTemplate(w, "gallery", data, true) + renderTemplate(w, "gallery", data, true) } func indexHandler(w http.ResponseWriter, req *http.Request) { - if req.URL.Path != "/" { - renderTemplate(w, "404", data, true) - return - } + if req.URL.Path != "/" { + renderTemplate(w, "404", data, true) + return + } - renderTemplate(w, "home", data, true) + renderTemplate(w, "home", data, true) } func main() { - if _, err := os.Stat("src/index.tmpl"); os.IsNotExist(err) { - log.Fatal("Template file does not exist:\n", err) - } + if _, err := os.Stat("src/index.tmpl"); os.IsNotExist(err) { + log.Fatal("Template file does not exist:\n", err) + } - fs := http.FileServer(http.Dir("./src")) - http.Handle("/src/", http.StripPrefix("/src/", fs)) + fs := http.FileServer(http.Dir("./src")) + http.Handle("/src/", http.StripPrefix("/src/", fs)) - port := ":3939" + 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) + 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/src/assets/badges/java.svg b/src/assets/badges/java.svg new file mode 100644 index 0000000..804fdb4 --- /dev/null +++ b/src/assets/badges/java.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/pages/home.tmpl b/src/pages/home.tmpl index c6c1b29..cdcf1b6 100644 --- a/src/pages/home.tmpl +++ b/src/pages/home.tmpl @@ -58,6 +58,10 @@
nginx
+
  • + +
    Java
    +