sophuwu.site > myweb
okay shit i have not commited for over 18 hours
idk what i've done but its a lot
intermediate commit just cause too long
sophuwu sophie@skisiel.com
Sat, 16 Nov 2024 13:36:24 +0100
commit

d1c28596805603653e4a4eb511ffec910a1bb529

parent

9b5ff48e7d376f81e0403ae4cf00b524fa2f980d

D config.yaml

@@ -1,13 +0,0 @@

-Server: - Port: "8085" - IP: "127.0.0.1" - Url: "https://skisiel.com" - -Paths: - Static: "../githttp/static" - Templates: "./templates" - Media: "./media" - -Contact: - Name: "Sophie Kisiel" - Email: "sophie@skisiel.com"
M config/config.goconfig/config.go

@@ -6,54 +6,18 @@ "log"

"os" ) -// Server is a struct that holds the configuration for the server -type Server struct { - Port string `yaml:"Port"` - IP string `yaml:"IP"` -} - -// Host is function that returns the host string -func (s Server) Host() string { - return s.IP + ":" + s.Port -} - -// Dirs is a struct that holds directories needed for the server -type Dirs struct { - Static string `yaml:"Static"` - Templates string `yaml:"Templates"` - Media string `yaml:"Media"` -} - -// Link is a struct that holds the configuration for a link -type Link struct { - Name string `yaml:"Name"` - URL string `yaml:"URL"` -} - -// ContactInfo is a struct that holds the configuration for the contact information -type ContactInfo struct { - Email string `yaml:"Email"` - Name string `yaml:"Name"` -} - -// WebInfo is a struct that holds the configuration for the website information -type WebInfo struct { - Title string `yaml:"Title"` - Description string `yaml:"Description"` - Url string `yaml:"Url"` - Extras []Link `yaml:"ExternalLinks"` -} - -// Config is a struct that holds the configuration for the server, directories, and contact information -type Config struct { - Server Server `yaml:"Server"` - Paths Dirs `yaml:"Paths"` - Contact ContactInfo `yaml:"Contact"` - Website WebInfo `yaml:"Website"` -} +var ( + ListenAddr string + TemplateDir string + StaticDir string + MediaDir string + DBPath string + Email string + Name string + URL string +) -// Cfg is a variable that holds the configuration -var Cfg Config +var m map[string]string func init() { var path string = "config.yaml"

@@ -64,7 +28,7 @@ file, err := os.ReadFile(path)

if err != nil { log.Fatalf("Error opening config: %v", err) } - err = yaml.Unmarshal(file, &Cfg) + err = yaml.Unmarshal(file, &cfg) if err != nil { log.Fatalf("Error parsing config: %v", err) }
M main.gomain.go

@@ -8,26 +8,34 @@ "path/filepath"

"sophuwu.site/myweb/config" ) -func main() { - http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { +var Tplt *template.Template - tpath := filepath.Join(config.Cfg.Paths.Templates, "*") - t := template.Must(template.ParseGlob(tpath)) - data := make(map[string]string) - data["Title"] = config.Cfg.Website.Title - data["WebsiteTitle"] = config.Cfg.Website.Title - data["Description"] = config.Cfg.Website.Description - data["Url"] = config.Cfg.Website.Url + r.URL.Path +func ParseTemplates() { + Tplt = template.Must(template.ParseGlob(filepath.Join(config.Cfg.Paths.Templates, "*"))) +} - if err := t.ExecuteTemplate(w, "index", data); err != nil { - log.Println(err) - return - } - }) +func HttpIndex(w http.ResponseWriter, r *http.Request) { + data := make(map[string]string) + data["Title"] = config.Name + data["Description"] = "Blogs and projects by " + config.Name + "." + data["Url"] = config.Cfg.Website.Url + r.URL.Path + data["Email"] = config.Cfg.Contact.Email + data["Name"] = config.Cfg.Contact.Name + + if err := Tplt.ExecuteTemplate(w, "index", data); err != nil { + log.Println(err) + return + } +} + +func main() { + ParseTemplates() + + http.HandleFunc("/", HttpIndex) http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir(config.Cfg.Paths.Static)))) http.Handle("/media/", http.StripPrefix("/media/", http.FileServer(http.Dir(config.Cfg.Paths.Media)))) - http.ListenAndServe(config.Cfg.Server.Host(), nil) + http.ListenAndServe(config.ListenAddr(), nil) }
D templates/head.html

@@ -1,16 +0,0 @@

-{{ define "head" }} -<head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <link rel="stylesheet" href="/static/normalize.css" type="text/css"> - <link rel="stylesheet" href="/static/style.css" type="text/css"> - <link rel="stylesheet" href="/static/style_dark.css" type="text/css"> - <link rel="stylesheet" href="/static/icons.css" type="text/css"> - <link rel="icon" type="image/ico" href="/static/favicon.ico"> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <title>{{ .Title }}</title> - <meta content="{{ .Title }}" property="og:title"> - <meta content="{{ .Description }}" property="og:description"> - <meta content="{{ .Url }}" property="og:url"> -</head> -{{ end }}
D templates/header.html

@@ -1,14 +0,0 @@

-{{ define "header" }} -<header> - <div> - <a class="favicon" href="/">&nbsp;</a> - <h2 style="font-size: 2cap;">Sophie Kisiel</h2> - <a href="/" style="margin-left: auto;"><button class="headbutt"><label class="fa fa-home"></label> Home</button></a> - <a href="/blog/"><button class="headbutt"><label class="fa fa-book"></label> Blog</button></a> - <a href="//sophuwu.site/"><button class="headbutt"><label class="fa fa-code-fork"></label> Git Repo</button></a> - <a href="/animations/"><button class="headbutt"><label class="fa fa-image"></label> Animations</button></a> - </div> - - <hr style="margin-top: 5px;"> -</header> -{{ end }}
D templates/index.html

@@ -1,14 +0,0 @@

-{{ define "index" }} -<!DOCTYPE html> -<html lang="en"> -{{ template "head" . }} -<body> -{{ template "header" . }} -<main> - <p> - {{ .Description }} - </p> -</main> -</body> -</html> -{{ end }}
A webhome/myweb.conf

@@ -0,0 +1,14 @@

+## The port to listen for http requests. +port=8085 + +## The address to listen for http requests. +address=127.0.0.1 + +## The url for the root of the website. +## This is used to generate URLs for sharing. +url=https://skisiel.com + +## The name of the person who maintains the website. +Name=Sophie Kisiel +## Their email address. +Email=sophie@skisiel.com
A webhome/static/normalize.css

@@ -0,0 +1,349 @@

+/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */ + +/* Document + ========================================================================== */ + +/** + * 1. Correct the line height in all browsers. + * 2. Prevent adjustments of font size after orientation changes in iOS. + */ + +html { + line-height: 1.15; /* 1 */ + -webkit-text-size-adjust: 100%; /* 2 */ +} + +/* Sections + ========================================================================== */ + +/** + * Remove the margin in all browsers. + */ + +body { + margin: 0; +} + +/** + * Render the `main` element consistently in IE. + */ + +main { + display: block; +} + +/** + * Correct the font size and margin on `h1` elements within `section` and + * `article` contexts in Chrome, Firefox, and Safari. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +/* Grouping content + ========================================================================== */ + +/** + * 1. Add the correct box sizing in Firefox. + * 2. Show the overflow in Edge and IE. + */ + +hr { + box-sizing: content-box; /* 1 */ + height: 0; /* 1 */ + overflow: visible; /* 2 */ +} + +/** + * 1. Correct the inheritance and scaling of font size in all browsers. + * 2. Correct the odd `em` font sizing in all browsers. + */ + +pre { + font-family: monospace, monospace; /* 1 */ + font-size: 1em; /* 2 */ +} + +/* Text-level semantics + ========================================================================== */ + +/** + * Remove the gray background on active links in IE 10. + */ + +a { + background-color: transparent; +} + +/** + * 1. Remove the bottom border in Chrome 57- + * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari. + */ + +abbr[title] { + border-bottom: none; /* 1 */ + text-decoration: underline; /* 2 */ + text-decoration: underline dotted; /* 2 */ +} + +/** + * Add the correct font weight in Chrome, Edge, and Safari. + */ + +b, +strong { + font-weight: bolder; +} + +/** + * 1. Correct the inheritance and scaling of font size in all browsers. + * 2. Correct the odd `em` font sizing in all browsers. + */ + +code, +kbd, +samp { + font-family: monospace, monospace; /* 1 */ + font-size: 1em; /* 2 */ +} + +/** + * Add the correct font size in all browsers. + */ + +small { + font-size: 80%; +} + +/** + * Prevent `sub` and `sup` elements from affecting the line height in + * all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sub { + bottom: -0.25em; +} + +sup { + top: -0.5em; +} + +/* Embedded content + ========================================================================== */ + +/** + * Remove the border on images inside links in IE 10. + */ + +img { + border-style: none; +} + +/* Forms + ========================================================================== */ + +/** + * 1. Change the font styles in all browsers. + * 2. Remove the margin in Firefox and Safari. + */ + +button, +input, +optgroup, +select, +textarea { + font-family: inherit; /* 1 */ + font-size: 100%; /* 1 */ + line-height: 1.15; /* 1 */ + margin: 0; /* 2 */ +} + +/** + * Show the overflow in IE. + * 1. Show the overflow in Edge. + */ + +button, +input { /* 1 */ + overflow: visible; +} + +/** + * Remove the inheritance of text transform in Edge, Firefox, and IE. + * 1. Remove the inheritance of text transform in Firefox. + */ + +button, +select { /* 1 */ + text-transform: none; +} + +/** + * Correct the inability to style clickable types in iOS and Safari. + */ + +button, +[type="button"], +[type="reset"], +[type="submit"] { + -webkit-appearance: button; +} + +/** + * Remove the inner border and padding in Firefox. + */ + +button::-moz-focus-inner, +[type="button"]::-moz-focus-inner, +[type="reset"]::-moz-focus-inner, +[type="submit"]::-moz-focus-inner { + border-style: none; + padding: 0; +} + +/** + * Restore the focus styles unset by the previous rule. + */ + +button:-moz-focusring, +[type="button"]:-moz-focusring, +[type="reset"]:-moz-focusring, +[type="submit"]:-moz-focusring { + outline: 1px dotted ButtonText; +} + +/** + * Correct the padding in Firefox. + */ + +fieldset { + padding: 0.35em 0.75em 0.625em; +} + +/** + * 1. Correct the text wrapping in Edge and IE. + * 2. Correct the color inheritance from `fieldset` elements in IE. + * 3. Remove the padding so developers are not caught out when they zero out + * `fieldset` elements in all browsers. + */ + +legend { + box-sizing: border-box; /* 1 */ + color: inherit; /* 2 */ + display: table; /* 1 */ + max-width: 100%; /* 1 */ + padding: 0; /* 3 */ + white-space: normal; /* 1 */ +} + +/** + * Add the correct vertical alignment in Chrome, Firefox, and Opera. + */ + +progress { + vertical-align: baseline; +} + +/** + * Remove the default vertical scrollbar in IE 10+. + */ + +textarea { + overflow: auto; +} + +/** + * 1. Add the correct box sizing in IE 10. + * 2. Remove the padding in IE 10. + */ + +[type="checkbox"], +[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Correct the cursor style of increment and decrement buttons in Chrome. + */ + +[type="number"]::-webkit-inner-spin-button, +[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +/** + * 1. Correct the odd appearance in Chrome and Safari. + * 2. Correct the outline style in Safari. + */ + +[type="search"] { + -webkit-appearance: textfield; /* 1 */ + outline-offset: -2px; /* 2 */ +} + +/** + * Remove the inner padding in Chrome and Safari on macOS. + */ + +[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/** + * 1. Correct the inability to style clickable types in iOS and Safari. + * 2. Change font properties to `inherit` in Safari. + */ + +::-webkit-file-upload-button { + -webkit-appearance: button; /* 1 */ + font: inherit; /* 2 */ +} + +/* Interactive + ========================================================================== */ + +/* + * Add the correct display in Edge, IE 10+, and Firefox. + */ + +details { + display: block; +} + +/* + * Add the correct display in all browsers. + */ + +summary { + display: list-item; +} + +/* Misc + ========================================================================== */ + +/** + * Add the correct display in IE 10+. + */ + +template { + display: none; +} + +/** + * Add the correct display in IE 10. + */ + +[hidden] { + display: none; +}
A webhome/static/robots.txt

@@ -0,0 +1,2 @@

+User-agent: * +Disallow: /admin/
A webhome/static/scripts.js

@@ -0,0 +1,41 @@

+function setCookie(cname,cvalue,exdays) { + const d = new Date(); + d.setTime(d.getTime() + (exdays*24*60*60*1000)); + let expires = "expires=" + d.toUTCString(); + document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; +} + +function getCookie(cname) { + let name = cname + "="; + let decodedCookie = decodeURIComponent(document.cookie); + let ca = decodedCookie.split(';'); + for(let i = 0; i < ca.length; i++) { + let c = ca[i]; + while (c.charAt(0) === ' ') { + c = c.substring(1); + } + if (c.indexOf(name) === 0) { + return c.substring(name.length, c.length); + } + } + return ""; +} + +function check_theme() { + let theme = getCookie("light_theme"); + if (theme === "light") { + document.getElementById("csstheme").href = "/static/style_light.css"; + } else { + document.getElementById("csstheme").href = "/static/style_dark.css"; + } +} + +function toggle_theme() { + let theme = getCookie("light_theme"); + if (theme === "light") { + setCookie("light_theme", "dark", 30); + } else { + setCookie("light_theme", "light", 30); + } + check_theme(); +}
A webhome/static/style_dark.css

@@ -0,0 +1,114 @@

+html, body { + background-color: #262833; +} +*{ + color: white; +} +a { + color: #5da5ff; +} +a:hover { + color: #40d8ff; +} +button:hover { + color: #fff; + background-color: #131419; + box-shadow: rgba(0, 0, 0, 0.5) 8px 8px 15px; +} +button:active { + box-shadow: none; +} + +button { + background-color: rgba(0, 0, 0, 0.25); + border: 3px solid transparent; + color: #ffffff; +} +p, li { + color: #dddddd; +} +hr { + border-color: #444444; +} +::-webkit-scrollbar-track { + background: #353545; +} +::-webkit-scrollbar-thumb { + background: #555566; + border: 3px solid #353545; +} +::-webkit-scrollbar-thumb:hover { + background: #888899; +} +.project-meta { + color: #aaaaaa; +} +.filebutton { + background-color: #111111; + border: 2px solid #aaaaaa; +} +.fullbutton:hover, .filebutton:hover, .showbutton:hover { + color: #fff; + background-color: #111111; +} +.filebutton { + background-color: #111111; +} +.codeblock, .codestuff { + border: 1px solid #777777; +} +.terminal { + background-color: rgba(0, 0, 0, 0.5); + border: 1px solid #ffffff37; +} +.hljs, .codeblock { + background: #0b0a33; +} + +.hljs-built_in, +.hljs-selector-tag, +.hljs-section, +.hljs-link { + color: #00d0ff; +} + +.hljs-keyword { + color: #ff0090; +} + +.hljs, +.hljs-subst { + color: #ffffff; +} + +.hljs-title, +.hljs-attr, +.hljs-meta-keyword { + color: #50f4fa; +} + +.hljs-string { + color: lightgreen; +} +.hljs-meta, +.hljs-name, +.hljs-type, +.hljs-symbol, +.hljs-bullet, +.hljs-addition, +.hljs-variable, +.hljs-template-tag, +.hljs-template-variable { + color: #f1fa8c; +} + +.hljs-comment, +.hljs-quote, +.hljs-deletion { + color: #6272a4; +} + +.hljs-literal, +.hljs-number { + color: #aa70fc; +}
A webhome/static/style_light.css

@@ -0,0 +1,116 @@

+html, body { + background-color: #f0f0f0 +} +*{ + color: #1a1a1a; +} +a { + color: #0055cc; +} +a:hover { + color: #004499; +} +button:hover { + color: #333; + background-color: rgba(0, 0, 0, 0.09); + box-shadow: rgba(0, 0, 0, 0.5) 8px 8px 15px; +} +button:active { + box-shadow: none; +} + +button { + background-color: rgba(0, 0, 0, 0.1); + border: 3px solid transparent; + color: #1a1a1a; +} +p, li { + color: #1a1a1a; +} +hr { + border-color: #cccccc; +} +::-webkit-scrollbar-track { + background: #cccccc; +} +::-webkit-scrollbar-thumb { + background: #eeeeee; + border: 3px solid #cccccc; +} +::-webkit-scrollbar-thumb:hover { + background: #dddddd; +} +.project-meta { + color: #333; +} +.filebutton { + background-color: #111111; + border: 2px solid #aaaaaa; +} +.fullbutton:hover, .filebutton:hover, .showbutton:hover { + color: #fff; + background-color: #111111; +} +.filebutton { + background-color: #111111; +} +.codeblock, .codestuff { + border: 1px solid #777777; +} +.terminal { + background-color: rgba(0, 0, 0, 0.75); + border: 1px solid #000000; + color: white; +} + +.hljs, .codeblock { + background: #f6f6f6; +} + +.hljs-built_in, +.hljs-selector-tag, +.hljs-section, +.hljs-link { + color: #3a8dff; /* Adjusted for contrast */ +} + +.hljs-keyword { + color: #ff00c2; /* Adjusted for contrast */ +} + +.hljs, +.hljs-subst { + color: #000000; /* Changed to black for contrast */ +} + +.hljs-title, +.hljs-attr, +.hljs-meta-keyword { + color: #00bdff; /* Adjusted for contrast */ +} + +.hljs-string { + color: #00a100; /* Darker shade of green for contrast */ +} +.hljs-meta, +.hljs-name, +.hljs-type, +.hljs-symbol, +.hljs-bullet, +.hljs-addition, +.hljs-variable, +.hljs-template-tag, +.hljs-template-variable { + color: #b7b700; /* Darker shade for contrast */ +} + +.hljs-comment, +.hljs-quote, +.hljs-deletion { + color: #6c6c6c; /* Adjusted for better visibility */ +} + +.hljs-literal, +.hljs-number { + color: #ff006a; /* Darker purple for better contrast */ +}
A webhome/static/style_main.css

@@ -0,0 +1,135 @@

+@import url('https://fonts.googleapis.com/css2?family=Comfortaa:wght@300..700&family=Ubuntu+Sans:ital,wght@0,100..800;1,100..800&family=Victor+Mono:wght@100..700&display=swap'); +:root { + font-variant-ligatures: none!important; + font-size: 18px; + @media (min-width: 2000px) { + font-size: 22px; + } + @media (max-width: 2000px) and (min-width: 1500px) { + font-size: 20px; + } + @media (max-width: 1500px) and (min-width: 1200px) { + font-size: 18px; + } + @media (max-width: 1200px) and (min-width: 800px) { + font-size: 16px; + } + + @media (max-width: 800px) and (min-width: 600px) { + font-size: 14px; + } + @media (max-width: 600px) and (min-width: 400px) { + font-size: 12px; + } + @media (max-width: 400px) { + font-size: 10px; + } +} + +html, body, p { + font-family: "Ubuntu Sans", sans-serif; +} +h1, h2, h3, h4, h5, h6, button, a{ + font-family: "Comfortaa", cursive; +} +pre, code { + font-family: "Victor Mono", monospace; +} + +html { + height: 100%; + width: 100%; + margin: 0; + padding: 0; +} +body { + width: calc(100% - 50px); + max-width: 1500px; + margin: 0 auto; + padding: 0; + min-height: 100%; + height: auto; + max-height: max-content; +} + +header { + padding: 0; + margin: 0; + display: block; + position: sticky; + width: 100%; + top: 0; + background-color: inherit; +} +header > div { + display: flex; + flex-direction: row; + justify-content: flex-start; + align-items: center; + flex-wrap: wrap; +} +header a { + display: contents; +} + +header h1 { + font-weight: 700; + margin: 0; + padding: 0; + line-height: 1.5; +} +header h1::before { + content: ' '; + display: inline-block; + width: 0.9em; + aspect-ratio: 1; + transform: translateY(0.1em); + background-repeat: no-repeat; + background-size: contain; + background-position: center center; + background-image: url("/static/favicon.png"); + padding: 0; + margin: 0 0.25ch 0 0; +} +header nav { + margin: 0 0 0 auto; +} + +hr { + margin: 0; + padding: 0; + border: none; + border-bottom-style: solid; + border-bottom-width: 1px; +} + +button:hover { + transform: translateY(-2px); +} +button:active { + transform: translateY(0); +} +button { + border-radius: 1ch; + box-sizing: border-box; + cursor: pointer; + font-size: 1rem; + font-weight: 700; + padding: 0.5ch 1ch; + margin: 0 0 0 0.5ch; + text-decoration: none; + transition: all 300ms cubic-bezier(.23, 1, 0.32, 1); +} + +@font-face { + font-family: "iconfont"; + src: url("/static/icons.ttf") format("truetype"); +} + +.icon { + font-family: "iconfont"; + font-size: inherit; + font-weight: normal; + font-style: normal; + height: 1em; +}
A webhome/templates/blogs.html

@@ -0,0 +1,24 @@

+{{ define "blogs" }} +<html lang="en"> +{{ template "head" . }} +<body> +{{ template "header" . }} +<main> + <h1>Blogs</h1> + <p> + {{ len .Blogs }} blogs found. + </p> + <hr> + {{ range .Blogs }} + <section> + <a href="/blog/{{ .Name }}" class="index-name">{{ .Name }}</a> + <span style="margin: 0 10px;">{{ .Date }}</span> + <br> + <span style="text-align: justify; width: 100% !important;" class="desc">{{ .Desc }}</span> + <hr> + </section> + {{ end }} +</main> +</body> +</html> +{{ end }}
A webhome/templates/head.html

@@ -0,0 +1,19 @@

+{{ define "head" }} +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel="stylesheet" href="/static/normalize.css" type="text/css"> + <link rel="stylesheet" href="/static/style_main.css" type="text/css"> + <link rel="stylesheet" id="csstheme" href="/static/style_dark.css" type="text/css"> + <link rel="icon" type="image/ico" href="/static/favicon.ico"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <script src="/static/scripts.js"></script> + <style id="tmpcss"></style> + <title>{{ .Title }}</title> + <meta content="{{ .Title }}" property="og:title" name="twitter:title"> + <meta content="{{ .Description }}" property="og:description" name="twitter:description"> + <meta content="{{ .Url }}" property="og:url" name="url"> + <meta name="author" content="{{ .Name }}"> + <meta name="robots" content="index, follow"> +</head> +{{ end }}
A webhome/templates/header.html

@@ -0,0 +1,15 @@

+{{ define "header" }} +<header> + <div> + <h1>Sophie Kisiel</h1> + <nav> + <a href="/" ><button ><b class="icon">u</b> About</button></a> + <a href="/blog/"><button ><b class="icon">b</b> Blog</button></a> + <a href="/animations/"><button ><b class="icon">a</b> Art</button></a> + <a href="//sophuwu.site/"><button ><b class="icon">g</b> Git</button></a> + <button onclick="toggle_theme()"><b class="icon">s&leftrightarrow;m</b></button> + </nav> + </div> + <hr > +</header> +{{ end }}
A webhome/templates/index.html

@@ -0,0 +1,23 @@

+{{ define "index" }} +<html lang="en"> +{{ template "head" . }} +<body> +{{ template "header" . }} +<main> + + <h1> + Sophie Kisiel + </h1> + + <p> + Welcome to my website! I'm a software engineer and I love to code. + </p> + + <textarea style="height: 2000%;"></textarea> + + + +</main> +</body> +</html> +{{ end }}