index — crispy-website @ 2f63b5375162f69d81458cf5009b0976dff33921

My personal homepage (very crispy)

test
crispy-caesus 114518720+crispy-caesus@users.noreply.github.com
Fri, 01 Nov 2024 13:52:52 +0100
commit

2f63b5375162f69d81458cf5009b0976dff33921

parent

76c4a5f9fd4a37025e77359fd8bfaaf4ab3ddc83

4 files changed, 136 insertions(+), 12 deletions(-)

jump to
M index.goindex.go

@@ -11,7 +11,7 @@ Title string

Body []byte } -var templates = template.Must(template.ParseFiles("index.html")) +var templates = template.Must(template.ParseFiles("templates/index.html")) func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) { err := templates.ExecuteTemplate(w, tmpl+".html", p)

@@ -21,11 +21,20 @@ }

} func viewHandler(w http.ResponseWriter, r *http.Request) { - p := &Page{Title: "index"} + title := r.URL.Path[len("/"):] // Extract title from URL path + if title == "" { + title = "Home" // Default title if none provided + } + p := &Page{Title: title} renderTemplate(w, "index", p) } func main() { + // Serve static files from the "static" directory at the "/static/" path + fs := http.FileServer(http.Dir("static")) + http.Handle("/static/", http.StripPrefix("/static/", fs)) + + // Set up the main route http.HandleFunc("/", viewHandler) log.Fatal(http.ListenAndServe(":8080", nil)) }
M index.htmlindex.html

@@ -1,28 +1,40 @@

-<title>home</title> +<!DOCTYPE html> +<html lang="en"> + +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>home</title> + <link rel="stylesheet" href="static/index.css"> +</head> <body> <article> <h1>hi</h1> <p>this is a work in progress (in case you couldn't tell)</p> - <p>I'm an 18 year old student from Germany, aspiring to become a system administrator. I like tinkering - around with my linux and write a little program here and there.</p> + <p>I'm an 18-year-old student from Germany, aspiring to become a system administrator. I like tinkering + around + with my Linux and write a little program here and there.</p> <p>Currently I'm learning a bunch about server monitoring, as part of a school project</p> <h2>some links</h2> <ul> <li> - <a title="github" href="https://github.com/crispy-caesus" />github</a> - <p>contains most of my little projects, as well as my dotfiles for my linux + <a title="github" href="https://github.com/crispy-caesus">github</a> + <p>contains most of my little projects, as well as my dotfiles for my Linux configuration</p> </li> <li> - <a title="anilist" href="https://anilist.co/user/crispycaesus/" />anilist</a> + <a title="anilist" href="https://anilist.co/user/crispycaesus/">anilist</a> <p>a list of the anime I have watched and plan to watch and some ratings and thoughts on - them - </p> + them</p> </li> <li> - <a title="stats.fm" href="https://stats.fm/caesus" />stats.fm</a> - <p>the music I listened to on spotify (have since switched to tidal)</p> + <a title="stats.fm" href="https://stats.fm/caesus">stats.fm</a> + <p>the music I listened to on Spotify (have since switched to Tidal)</p> + </li> + </ul> </article> </body> + +</html>
A static/index.css

@@ -0,0 +1,63 @@

+/* style.css */ + +/* Basic reset */ +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +/* Centering and box styling */ +body { + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + background-color: #f5f5f5; + font-family: Arial, sans-serif; + color: #333; + line-height: 1.6; +} + +article { + max-width: 600px; + width: 90%; + padding: 20px; + border: 2px solid #333; + background-color: #fff; + text-align: center; +} + +h1 { + font-size: 2em; + margin-bottom: 0.5em; +} + +h2 { + font-size: 1.5em; + margin-top: 1em; + margin-bottom: 0.5em; +} + +p { + margin-bottom: 1em; +} + +ul { + list-style-type: none; + padding: 0; +} + +li { + margin: 1em 0; +} + +a { + color: #0077cc; + text-decoration: none; + font-weight: bold; +} + +a:hover { + text-decoration: underline; +}
A templates/index.html

@@ -0,0 +1,40 @@

+<!DOCTYPE html> +<html lang="en"> + +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>home</title> + <link rel="stylesheet" href="index.css"> +</head> + +<body> + <article> + <h1>hi</h1> + <p>this is a work in progress (in case you couldn't tell)</p> + <p>I'm an 18-year-old student from Germany, aspiring to become a system administrator. I like tinkering + around + with my Linux and write a little program here and there.</p> + <p>Currently I'm learning a bunch about server monitoring, as part of a school project</p> + + <h2>some links</h2> + <ul> + <li> + <a title="github" href="https://github.com/crispy-caesus">github</a> + <p>contains most of my little projects, as well as my dotfiles for my Linux + configuration</p> + </li> + <li> + <a title="anilist" href="https://anilist.co/user/crispycaesus/">anilist</a> + <p>a list of the anime I have watched and plan to watch and some ratings and thoughts on + them</p> + </li> + <li> + <a title="stats.fm" href="https://stats.fm/caesus">stats.fm</a> + <p>the music I listened to on Spotify (have since switched to Tidal)</p> + </li> + </ul> + </article> +</body> + +</html>