]> localhost Git - homepage.git/commitdiff
feat: go
authorJansen <[email protected]>
Sun, 6 Jul 2025 13:52:34 +0000 (09:52 -0400)
committerJansen <[email protected]>
Sun, 6 Jul 2025 13:52:34 +0000 (09:52 -0400)
15 files changed:
cmd/main.go
pkg/routes/404.go [new file with mode: 0644]
pkg/routes/blog-post.go [new file with mode: 0644]
pkg/routes/blog.go [new file with mode: 0644]
pkg/routes/index.go [new file with mode: 0644]
pkg/routes/nothing-to-see.go [new file with mode: 0644]
pkg/routes/projects.go [new file with mode: 0644]
static/assets/css/projects.css
static/assets/imgs/nothing-to-see.png [new file with mode: 0644]
static/templates/404.html
static/templates/blog.html
static/templates/blog/blog-you-most-likely-dont-need-aws.html [moved from static/templates/blog/you-most-likely-dont-need-aws.html with 80% similarity]
static/templates/index.html
static/templates/nothing-to-see.html [new file with mode: 0644]
static/templates/projects.html

index 43520f13a1e3840612c4809e6fcc4f5761ff95de..5445caaac56219c9d25cd958ede9fc486a21c5b7 100644 (file)
@@ -1,24 +1,37 @@
 package main
 
 import (
+       "html/template"
        "log"
        "net/http"
-)
+       "os"
 
-func index(w http.ResponseWriter, _ *http.Request) {
-       w.Write([]byte("Hello, from my RPI!"))
-}
+       "jsdaj.com/homepage/pkg/routes"
+)
 
 func main() {
        router := http.NewServeMux()
-       router.HandleFunc("/", index)
 
-       server := http.Server {
-               Addr: ":8000",
+       templateFS := os.DirFS("static/templates")
+
+       templates, err := template.ParseFS(templateFS, "*.html", "blog/*.html")
+       if err != nil {
+               log.Fatal(err)
+       }
+
+       router.HandleFunc("GET /static/assets/{$}", routes.NothingToSee(templates))
+       router.Handle("GET /static/assets/", http.FileServer(http.Dir(".")))
+       router.HandleFunc("GET /projects", routes.Projects(templates))
+       router.HandleFunc("GET /blog/{post}", routes.BlogPost(templates))
+       router.HandleFunc("GET /blog", routes.Blog(templates))
+       router.HandleFunc("GET /{$}", routes.Index(templates))
+       router.HandleFunc("/", routes.NotFound(templates))
+
+       server := http.Server{
+               Addr:    ":8000",
                Handler: router,
        }
 
        log.Println("Starting server at :8000")
        server.ListenAndServe()
 }
-
diff --git a/pkg/routes/404.go b/pkg/routes/404.go
new file mode 100644 (file)
index 0000000..f7e0c93
--- /dev/null
@@ -0,0 +1,16 @@
+package routes
+
+import (
+       "html/template"
+       "log"
+       "net/http"
+)
+
+func NotFound(templ *template.Template) http.HandlerFunc {
+       return func(w http.ResponseWriter, _ *http.Request) {
+               err := templ.ExecuteTemplate(w, "404.html", "")
+               if err != nil {
+                       log.Fatal(err)
+               }
+       }
+}
diff --git a/pkg/routes/blog-post.go b/pkg/routes/blog-post.go
new file mode 100644 (file)
index 0000000..ab80e98
--- /dev/null
@@ -0,0 +1,19 @@
+package routes
+
+import (
+       "fmt"
+       "html/template"
+       "log"
+       "net/http"
+)
+
+func BlogPost(templ *template.Template) http.HandlerFunc {
+       return func(w http.ResponseWriter, r *http.Request) {
+               post := r.PathValue("post")
+
+               err := templ.ExecuteTemplate(w, fmt.Sprintf("%s.html", post), "")
+               if err != nil {
+                       log.Fatal(err)
+               }
+       }
+}
diff --git a/pkg/routes/blog.go b/pkg/routes/blog.go
new file mode 100644 (file)
index 0000000..1a50df1
--- /dev/null
@@ -0,0 +1,16 @@
+package routes
+
+import (
+       "html/template"
+       "log"
+       "net/http"
+)
+
+func Blog(templ *template.Template) http.HandlerFunc {
+       return func(w http.ResponseWriter, _ *http.Request) {
+               err := templ.ExecuteTemplate(w, "blog.html", "")
+               if err != nil {
+                       log.Fatal(err)
+               }
+       }
+}
diff --git a/pkg/routes/index.go b/pkg/routes/index.go
new file mode 100644 (file)
index 0000000..cd6ca59
--- /dev/null
@@ -0,0 +1,16 @@
+package routes
+
+import (
+       "html/template"
+       "log"
+       "net/http"
+)
+
+func Index(templ *template.Template) http.HandlerFunc {
+       return func(w http.ResponseWriter, _ *http.Request) {
+               err := templ.ExecuteTemplate(w, "index.html", "")
+               if err != nil {
+                       log.Fatal(err)
+               }
+       }
+}
diff --git a/pkg/routes/nothing-to-see.go b/pkg/routes/nothing-to-see.go
new file mode 100644 (file)
index 0000000..94ec3c3
--- /dev/null
@@ -0,0 +1,16 @@
+package routes
+
+import (
+       "html/template"
+       "log"
+       "net/http"
+)
+
+func NothingToSee(templ *template.Template) http.HandlerFunc {
+       return func(w http.ResponseWriter, _ *http.Request) {
+               err := templ.ExecuteTemplate(w, "nothing-to-see.html", "")
+               if err != nil {
+                       log.Fatal(err)
+               }
+       }
+}
diff --git a/pkg/routes/projects.go b/pkg/routes/projects.go
new file mode 100644 (file)
index 0000000..a97f2ff
--- /dev/null
@@ -0,0 +1,16 @@
+package routes
+
+import (
+       "html/template"
+       "log"
+       "net/http"
+)
+
+func Projects(templ *template.Template) http.HandlerFunc {
+       return func(w http.ResponseWriter, _ *http.Request) {
+               err := templ.ExecuteTemplate(w, "projects.html", "")
+               if err != nil {
+                       log.Fatal(err)
+               }
+       }
+}
index 7a9f137c5ffeec10c9487feed84014dd36e49b92..086206a51f876174b2599990f23dfe02621c4bc0 100644 (file)
@@ -147,3 +147,7 @@ body {
   background-color: #f0db4f;
   color: black;
 }
+
+.tag.go {
+  background-color: #00ADD8 ;
+}
diff --git a/static/assets/imgs/nothing-to-see.png b/static/assets/imgs/nothing-to-see.png
new file mode 100644 (file)
index 0000000..6ba1b58
Binary files /dev/null and b/static/assets/imgs/nothing-to-see.png differ
index 85897a03d265a9dba58481be9b76ad2bd64f0537..0057d392f7dbb8e5da04c50b775e6af393cb7d60 100644 (file)
@@ -1,19 +1,19 @@
-<!DOCUMENT html>
+<!DOCTYPE html>
 <html>
   <head>
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>Jansen Saunier</title>
 
-    <link rel="stylesheet" href="assets/css/themes/codeclocks.css">
-    <link rel="stylesheet" href="assets/css/index.css">
+    <link rel="stylesheet" href="/static/assets/css/themes/codeclocks.css">
+    <link rel="stylesheet" href="/static/assets/css/index.css">
   </head>
 
   <body>
     <div id="terminal">
       <div class="terminal-line"><i>$</i> show-not-found</div>
       <div class="terminal-content">
-        <img src="/assets/imgs/kirby.png" alt="kirby" />
+        <img src="/static/assets/imgs/kirby.png" alt="kirby" />
         <div class="terminal-lines">
           <div class="terminal-line"><b>!!!Hold up there, pal!!!</b></div>
           <div class="terminal-line"><i>------------------------</i></div>
index 8cdd50f58dfbd492a14b6b82612dca546fe04121..4cc2c4a03911c04edd6a7a56f1b6b7648230d68d 100644 (file)
@@ -1,28 +1,30 @@
-<!DOCUMENT html>
+<!DOCTYPE html>
 <html>
   <head>
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>Jansen Saunier</title>
 
-    <link rel="stylesheet" href="assets/css/themes/codeclocks.css">
-    <link rel="stylesheet" href="assets/css/blog.css">
+    <link rel="stylesheet" href="static/assets/css/themes/codeclocks.css">
+    <link rel="stylesheet" href="static/assets/css/blog.css">
   </head>
   <body>
     <ul class="header">
       <li><b><a href="/">Go Back</a></b></li>
     </ul>
 
-    <ul class="post-list">
-      <li class="post">
-        <a class="post-link" href="/blog/you-most-likely-dont-need-aws.html">
-          <div class="post-header">
-            <h1 class="title">You (most likely) don't need AWS</h1>
-            <p class="date">2025-07-04</p>
-          </div>
-          <p class="summary">Some thoughts on how (once again) marketing and entrepreneurship destroyed everyone's mind (again).</p>
-        </a>
-      </li>
-    </ul>
+    <h1>WIP</h1>
+
+    <!-- <ul class="post-list"> -->
+    <!--   <li class="post"> -->
+    <!--     <a class="post-link" href="/blog/blog-you-most-likely-dont-need-aws"> -->
+    <!--       <div class="post-header"> -->
+    <!--         <h1 class="title">You (most likely) don't need AWS</h1> -->
+    <!--         <p class="date">2025-07-04</p> -->
+    <!--       </div> -->
+    <!--       <p class="summary">Some thoughts on how (once again) marketing and entrepreneurship destroyed everyone's mind (again).</p> -->
+    <!--     </a> -->
+    <!--   </li> -->
+    <!-- </ul> -->
   </body>
 </html>
similarity index 80%
rename from static/templates/blog/you-most-likely-dont-need-aws.html
rename to static/templates/blog/blog-you-most-likely-dont-need-aws.html
index 7bee4ec33a17bcbe2312f0a01012cbc2bd920a5d..5c6395543485399bb972d260647c62afb5a268a8 100644 (file)
@@ -1,16 +1,16 @@
-<!DOCUMENT html>
+<!DOCTYPE html>
 <html>
   <head>
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>Jansen Saunier</title>
 
-    <link rel="stylesheet" href="/assets/css/themes/codeclocks.css">
-    <link rel="stylesheet" href="/assets/css/blog-post.css">
+    <link rel="stylesheet" href="/static/assets/css/themes/codeclocks.css">
+    <link rel="stylesheet" href="/static/assets/css/blog-post.css">
   </head>
   <body>
     <ul class="header">
-      <li><b><a href="/">Go Back</a></b></li>
+      <li><b><a href="/blog">Go Back</a></b></li>
     </ul>
 
     <header>
@@ -33,7 +33,7 @@
     </main>
 
     <ul class="header">
-      <li><b><a href="/">Go Back</a></b></li>
+      <li><b><a href="/blog">Go Back</a></b></li>
     </ul>
   </body>
 </html>
index f3421875c4eb45395bbd9fa32395893b1002d77c..3b1fc9185e5909799043f937b526bd5f797f4d80 100644 (file)
@@ -1,19 +1,19 @@
-<!DOCUMENT html>
+<!DOCTYPE html>
 <html>
   <head>
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>Jansen Saunier</title>
 
-    <link rel="stylesheet" href="assets/css/themes/codeclocks.css">
-    <link rel="stylesheet" href="assets/css/index.css">
+    <link rel="stylesheet" href="static/assets/css/themes/codeclocks.css">
+    <link rel="stylesheet" href="static/assets/css/index.css">
   </head>
 
   <body>
     <div id="terminal">
       <div class="terminal-line"><i>$</i> fastfetch</div>
       <div class="terminal-content">
-        <img src="/assets/imgs/kirby-home.png" alt="kirby" />
+        <img src="static/assets/imgs/kirby-home.png" alt="kirby" />
         <div class="terminal-lines">
           <div class="terminal-line"><b>jj</b>@<i>jsdaj.com</i></div>
           <div class="terminal-line">------------</div>
@@ -73,9 +73,9 @@
     </div>
     <p class="ascii-source">img src @ <a target="_blank" href="https://www.reddit.com/r/powerscales/comments/1hispp8/kirby_vs_medaka_kurokami_who_wins_and_why/?tl=pt-br">reddit</a></p>
     <ul class="useful-links">
-      <li><b><a href="/projects.html">Projects Showcase</a></b></li>
+      <li><b><a href="/projects">Projects Showcase</a></b></li>
       <li>-</li>
-      <li><b><a href="/blog.html">Blog</a></b></li>
+      <li><b><a href="/blog">Blog</a></b></li>
     </ul>
   </body>
 </html>
diff --git a/static/templates/nothing-to-see.html b/static/templates/nothing-to-see.html
new file mode 100644 (file)
index 0000000..232d475
--- /dev/null
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Jansen Saunier</title>
+
+    <link rel="stylesheet" href="/static/assets/css/themes/codeclocks.css">
+    <link rel="stylesheet" href="/static/assets/css/index.css">
+  </head>
+
+  <body>
+    <div id="terminal">
+      <div class="terminal-line"><i>$</i> nothing-to-see</div>
+      <div class="terminal-content">
+        <img src="/static/assets/imgs/nothing-to-see.png" alt="meta-knight" />
+        <div class="terminal-lines">
+          <div class="terminal-line"><b>!!! OBJECTION !!!</b></div>
+          <div class="terminal-line"><i>------------------------</i></div>
+          <br />
+          <div class="terminal-line">You sure know what you're doing, right?</div>
+          <div class="terminal-line">And you also know you weren't supposed to be here, right?</div>
+          <br />
+          <div class="terminal-line">Instead of poking around just check the <a href="https://codeberg.org/jansen44/homepage">code here.</a></div>
+          <div class="terminal-line">(You'll probably die from boredom anyway...)</div>
+          <br />
+          <div class="terminal-line">
+            My suggestion is try to find something else to <a href="/projects">play here</a> (some of my projects had you in mind with some hidden CTFs (something like this one, but not so obvious), so <a target="_blank" href="mailto:[email protected]?subject=I'm smarter than you">let me know</a> if you find anything :D)
+          </div>
+        </div>
+      </div>
+          <div class="terminal-line"><i>$</i></div>
+    </div>
+    <p class="ascii-source">img src @ <a target="_blank" href="https://static.wikia.nocookie.net/aceattorney/images/a/a2/AA1_Phoenix_Point.png/revision/latest?cb=20250510212524">pngitem</a></p>
+    <ul class="useful-links">
+      <li><b><a href="/">Go Back</a></b></li>
+    </ul>
+  </body>
+</html>
index ddb00fb067b1db6186e20b9c3dab0b71c2e99b8b..a64c5dc94a7eefbf7f803cf046cd4fd53ee7a5eb 100644 (file)
@@ -1,12 +1,12 @@
-<!DOCUMENT html>
+<!DOCTYPE html>
 <html>
   <head>
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>Jansen Saunier</title>
 
-    <link rel="stylesheet" href="assets/css/themes/codeclocks.css">
-    <link rel="stylesheet" href="assets/css/projects.css">
+    <link rel="stylesheet" href="static/assets/css/themes/codeclocks.css">
+    <link rel="stylesheet" href="static/assets/css/projects.css">
   </head>
   <body>
     <ul class="header">
@@ -18,8 +18,8 @@
     </p>
 
     <div class="content">
-      <a href="https://jsdaj.com" class="project-card" id="project-home">
-        <img src="assets/imgs/projects-home.png" alt="home-project-img" />
+      <a href="https://codeberg.org/jansen44/homepage" class="project-card" id="project-home">
+        <img src="static/assets/imgs/projects-home.png" alt="home-project-img" />
         <div class="info">
           <p class="title">My Personal Website </p>
           <p class="description">A personal website as simple as I could do. Simple and static stuff is so charming, don't you think?</p>
@@ -27,7 +27,7 @@
           <div class="tags">
             <p class="tag html">#html</p>
             <p class="tag css">#css</p>
-            <p class="tag js">#js</p>
+            <p class="tag go">#go</p>
             <p class="tag no-ai-code">#ai-code-free</p>
             <p class="tag ai-free">#ai-free</p>
           </div>