diff options
| -rw-r--r-- | assets/404-icon.xcf | bin | 6060 -> 4598 bytes | |||
| -rw-r--r-- | assets/404.xcf | bin | 0 -> 2009934 bytes | |||
| -rw-r--r-- | assets/icon.xcf | bin | 10690 -> 9411 bytes | |||
| -rw-r--r-- | assets/icon16x16.xcf | bin | 0 -> 1809 bytes | |||
| -rw-r--r-- | assets/kanna.xcf | bin | 72508 -> 61674 bytes | |||
| -rw-r--r-- | roseh.moe.go | 95 | ||||
| -rw-r--r-- | static/404/404.png | bin | 1034642 -> 0 bytes | |||
| -rw-r--r-- | static/404/404.webp | bin | 0 -> 87426 bytes | |||
| -rw-r--r-- | static/404/icon.png | bin | 3678 -> 0 bytes | |||
| -rw-r--r-- | static/404/icon.webp | bin | 0 -> 2576 bytes | |||
| -rw-r--r-- | static/favicon.ico | bin | 0 -> 1150 bytes | |||
| -rw-r--r-- | static/icon.png | bin | 7039 -> 0 bytes | |||
| -rw-r--r-- | static/icon.webp | bin | 0 -> 2942 bytes | |||
| -rw-r--r-- | static/index/kanna.png | bin | 54665 -> 0 bytes | |||
| -rw-r--r-- | static/index/kanna.webp | bin | 0 -> 6830 bytes | |||
| -rw-r--r-- | static/index/stars.gif | bin | 180039 -> 0 bytes | |||
| -rw-r--r-- | static/index/stars.webp | bin | 0 -> 134180 bytes | |||
| -rw-r--r-- | static/pong/icon.png | bin | 915 -> 0 bytes | |||
| -rw-r--r-- | static/pong/icon.webp | bin | 0 -> 1060 bytes | |||
| -rw-r--r-- | templates/404.html.template | 4 | ||||
| -rw-r--r-- | templates/blog/post.html.template | 5 | ||||
| -rw-r--r-- | templates/blog/posts/2024-10-22_nix_flakes.html.template | 82 | ||||
| -rw-r--r-- | templates/index.html.template | 10 | ||||
| -rw-r--r-- | templates/outline.html.template | 2 | ||||
| -rw-r--r-- | templates/pong.html.template | 2 |
25 files changed, 19 insertions, 181 deletions
diff --git a/assets/404-icon.xcf b/assets/404-icon.xcf Binary files differindex b63a0f6..fdc4ff0 100644 --- a/assets/404-icon.xcf +++ b/assets/404-icon.xcf diff --git a/assets/404.xcf b/assets/404.xcf Binary files differnew file mode 100644 index 0000000..0073a49 --- /dev/null +++ b/assets/404.xcf diff --git a/assets/icon.xcf b/assets/icon.xcf Binary files differindex d7363dd..34fbe31 100644 --- a/assets/icon.xcf +++ b/assets/icon.xcf diff --git a/assets/icon16x16.xcf b/assets/icon16x16.xcf Binary files differnew file mode 100644 index 0000000..7b53507 --- /dev/null +++ b/assets/icon16x16.xcf diff --git a/assets/kanna.xcf b/assets/kanna.xcf Binary files differindex 873bda4..64251a5 100644 --- a/assets/kanna.xcf +++ b/assets/kanna.xcf diff --git a/roseh.moe.go b/roseh.moe.go index 98febd1..df86f2d 100644 --- a/roseh.moe.go +++ b/roseh.moe.go @@ -10,7 +10,6 @@ import ( "net/http" "net/http/httputil" "net/url" - "slices" "strings" "time" ) @@ -47,89 +46,14 @@ var ( ) var ( - //go:embed templates/blog/post.html.template - postString string - - //go:embed templates/blog/posts - blogPostFiles embed.FS -) - -func mustParseBlogPostTemplates() map[string]*template.Template { - base, err := outlineTemplate.Clone() - if err != nil { - log.Fatalf("outlineTemplate.Clone: %s", err) - } - if _, err := base.New("body").Parse(postString); err != nil { - log.Fatalf("post.html.template: %s", err) - } - postFiles, err := blogPostFiles.ReadDir("templates/blog/posts") - if err != nil { - log.Fatalf("read blog post templates: %s", err) - } - posts := make(map[string]*template.Template, len(postFiles)) - for _, file := range postFiles { - fileContent, err := blogPostFiles.ReadFile("templates/blog/posts/" + file.Name()) - if err != nil { - log.Fatalf("read blog post template %q: %s", file.Name(), err) - } - tmpl, err := base.Clone() - if err != nil { - log.Fatalf("base.Clone: %s", err) - } - if _, err := tmpl.New("post").Parse(string(fileContent)); err != nil { - log.Fatalf("%q: %s", file.Name(), err) - } - posts[strings.TrimSuffix(file.Name(), ".html.template")] = tmpl - } - return posts -} - -var blogPostTemplates = mustParseBlogPostTemplates() - -func blog(w http.ResponseWriter, r *http.Request) { - tmpl, ok := blogPostTemplates[strings.TrimPrefix(r.URL.Path, "/blog/")] - if !ok { - notFound(w, r) - return - } - if err := tmpl.ExecuteTemplate(w, "outline", nil); err != nil { - log.Printf("Warning: blog: %s", err) - } -} - -type blogPost struct { - Name string - Slug string -} - -func mustLoadBlogPosts() []blogPost { - buf := new(strings.Builder) - posts := make([]blogPost, 0, len(blogPostTemplates)) - for slug, tmpl := range blogPostTemplates { - buf.Reset() - if err := tmpl.ExecuteTemplate(buf, "title", nil); err != nil { - log.Fatalf("blog post %q: title: %s", slug, err) - } - posts = append(posts, blogPost{ - Name: buf.String(), - Slug: slug, - }) - } - slices.SortFunc(posts, func(x, y blogPost) int { return strings.Compare(y.Slug, x.Slug) }) - return posts -} - -var ( //go:embed templates/index.html.template indexString string indexTemplate = template.Must(template.Must(outlineTemplate.Clone()).New("body").Parse(indexString)) - - blogPostsList = mustLoadBlogPosts() ) func index(w http.ResponseWriter, _ *http.Request) { - if err := indexTemplate.ExecuteTemplate(w, "outline", blogPostsList); err != nil { + if err := indexTemplate.ExecuteTemplate(w, "outline", nil); err != nil { log.Printf("Warning: index: %s", err) } } @@ -150,22 +74,28 @@ func pong(w http.ResponseWriter, _ *http.Request) { //go:embed static var staticFiles embed.FS -func static(w http.ResponseWriter, r *http.Request) { - fileName := strings.TrimPrefix(r.URL.Path, "/") - f, err := staticFiles.Open(fileName) +func serveStaticFile(w http.ResponseWriter, r *http.Request, path string) { + f, err := staticFiles.Open(path) if err != nil { notFound(w, r) return } defer f.Close() - http.ServeContent(w, r, fileName, serverStartTime, f.(io.ReadSeeker)) + http.ServeContent(w, r, path, serverStartTime, f.(io.ReadSeeker)) +} + +func static(w http.ResponseWriter, r *http.Request) { + serveStaticFile(w, r, strings.TrimPrefix(r.URL.Path, "/")) +} + +func favicon(w http.ResponseWriter, r *http.Request) { + serveStaticFile(w, r, "static/favicon.ico") } func main() { flag.Parse() mux := http.NewServeMux() - mux.HandleFunc("/blog/", blog) mux.HandleFunc("/pong", pong) jellyfinURL, err := url.Parse("http://localhost:8096") if err != nil { @@ -173,6 +103,7 @@ func main() { } mux.Handle("/cinema/", httputil.NewSingleHostReverseProxy(jellyfinURL)) mux.HandleFunc("/static/", static) + mux.HandleFunc("/favicon.ico", favicon) mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { if r.URL.Path == "/" { index(w, r) diff --git a/static/404/404.png b/static/404/404.png Binary files differdeleted file mode 100644 index 72d9d02..0000000 --- a/static/404/404.png +++ /dev/null diff --git a/static/404/404.webp b/static/404/404.webp Binary files differnew file mode 100644 index 0000000..c416a79 --- /dev/null +++ b/static/404/404.webp diff --git a/static/404/icon.png b/static/404/icon.png Binary files differdeleted file mode 100644 index 038ea8d..0000000 --- a/static/404/icon.png +++ /dev/null diff --git a/static/404/icon.webp b/static/404/icon.webp Binary files differnew file mode 100644 index 0000000..37bbfe3 --- /dev/null +++ b/static/404/icon.webp diff --git a/static/favicon.ico b/static/favicon.ico Binary files differnew file mode 100644 index 0000000..01a66aa --- /dev/null +++ b/static/favicon.ico diff --git a/static/icon.png b/static/icon.png Binary files differdeleted file mode 100644 index 8dfebb9..0000000 --- a/static/icon.png +++ /dev/null diff --git a/static/icon.webp b/static/icon.webp Binary files differnew file mode 100644 index 0000000..7330971 --- /dev/null +++ b/static/icon.webp diff --git a/static/index/kanna.png b/static/index/kanna.png Binary files differdeleted file mode 100644 index e144b96..0000000 --- a/static/index/kanna.png +++ /dev/null diff --git a/static/index/kanna.webp b/static/index/kanna.webp Binary files differnew file mode 100644 index 0000000..bb8907e --- /dev/null +++ b/static/index/kanna.webp diff --git a/static/index/stars.gif b/static/index/stars.gif Binary files differdeleted file mode 100644 index 2b7372f..0000000 --- a/static/index/stars.gif +++ /dev/null diff --git a/static/index/stars.webp b/static/index/stars.webp Binary files differnew file mode 100644 index 0000000..27c6f05 --- /dev/null +++ b/static/index/stars.webp diff --git a/static/pong/icon.png b/static/pong/icon.png Binary files differdeleted file mode 100644 index 70670b9..0000000 --- a/static/pong/icon.png +++ /dev/null diff --git a/static/pong/icon.webp b/static/pong/icon.webp Binary files differnew file mode 100644 index 0000000..03ab77e --- /dev/null +++ b/static/pong/icon.webp diff --git a/templates/404.html.template b/templates/404.html.template index a5cccf6..b30281f 100644 --- a/templates/404.html.template +++ b/templates/404.html.template @@ -2,7 +2,7 @@ <html lang="en"> <head> <title>Not Found</title> - <link rel="icon" href="/static/404/icon.png"> + <link rel="icon" href="/static/404/icon.webp"> </head> <body> <center> @@ -10,7 +10,7 @@ <font size="10"><code>{{.Path}}</code> was not found</font> </div> <div style="position:fixed;bottom:0px;width:100%"> - <img style="height:50vh" src="/static/404/404.png"> + <img style="height:50vh" src="/static/404/404.webp"> </div> </center> </body> diff --git a/templates/blog/post.html.template b/templates/blog/post.html.template deleted file mode 100644 index 80670d6..0000000 --- a/templates/blog/post.html.template +++ /dev/null @@ -1,5 +0,0 @@ -<section> - <a href="/">⬅️Home</a> - <h1>{{template "title" .}}</h1> -{{template "post"}} -</section> diff --git a/templates/blog/posts/2024-10-22_nix_flakes.html.template b/templates/blog/posts/2024-10-22_nix_flakes.html.template deleted file mode 100644 index d191908..0000000 --- a/templates/blog/posts/2024-10-22_nix_flakes.html.template +++ /dev/null @@ -1,82 +0,0 @@ -{{define "title"}}nix flakes for busy people{{end}} - -<h2>TL;DR</h2> - -<h4>To enable flakes on a NixOS system</h4> - -<p>Just put</p> - -<pre> - nix.settings.experimental-features = [ - "nix-command" - "flakes" - ]; -</pre> - -<p>in your <code>configuration.nix</code>. IMO it's a shame that flakes -have been locked behind experimental for so long, it's a large part of -why they have a bad reputation. It's absolutely worth enabling them -since they're so useful.</p> - -<h4>To use a flake from github</h4> - -<pre> -nix shell github:ggerganov/llama.cpp -</pre> - -<p>or to install a specific flake output:</p> - -<pre> -nix shell github:ggerganov/llama.cpp#rocm -</pre> - -<p>To list the outputs for a specific flake, you can usually type -<code>nix shell github:ggerganov/llama.cpp#<tab></code> and your -shell may or may not list the outputs. If anyone has a better way to do this, -please let me know.</p> - -<p>To install a flake in your system profile, use</p> - -<pre> -nix profile install github:ggerganov/llama.cpp -</pre> - -<p>Here is the greatest power of nix flakes: the ability to install and -use them as first-class packages just like anything from nixpkgs. It -feels a lot better integrated than something like the AUR.</p> - -<h4>To create a nix flake for your own project</h4> - -<pre> -nix flake init -t templates#go-hello -</pre> - -<p>Replace go-hello with whatever template you want that most closely -matches your project configuration. Unfortunately many of these templates -have the questionable behavior of also overwriting source files in the -current directory, so I recommend only running nix flake init in an -empty directory, and copying the flake.nix file over to your -existing project.</p> - -<h2>A philosophical intro to nix flakes</h2> - -<p>Flakes are a way to replace the centralized nixpkgs repository with -decentralized packages controlled directly by upstream. In many ways -Linux packaging has been moving more and more towards upstream with -things like appimages or flatpak, and being able to remove many of the -distro-specific hacks needed to make things run on various systems. Nix -flakes address this same issue, by allowing upstream to control their own -flake.nix, and pull in the specific versions of any dependencies they -might need. They also give an easy way to install any programs that -might not be packaged yet for nixpkgs, as long as anyone has written a -flake and published it online.</p> - -<h2>The bad parts</h2> - -<p>Nix flakes are still rough around the edges, and the worst part for -a new Nix user is the lack of documentation. This is a large part of why -I'm writing yet another nix flakes tutorial! -<a href="https://xeiaso.net/blog/nix-flakes-1-2022-02-21/">https://xeiaso.net/blog/nix-flakes-1-2022-02-21</a> -is really good, but reading this as a new user, I only wanted to know -how to install an app packaged with flakes, and I didn't care so much -about how to package my own stuff yet.</p> diff --git a/templates/index.html.template b/templates/index.html.template index 4737e3d..9591293 100644 --- a/templates/index.html.template +++ b/templates/index.html.template @@ -1,19 +1,13 @@ {{define "title"}}roseh.moe{{end}} -<div style="background-image:url(/static/index/stars.gif);background-repeat:repeat;height:500px;display:flex"> +<div style="background-image:url(/static/index/stars.webp);background-repeat:repeat;height:500px;display:flex"> <h1 style="margin:auto">roseh.moe</h1> </div> <section> <div style="display:flex"> - <img src="/static/index/kanna.png" alt="A dragon loli" style="border-radius:50%;margin:-100px auto 20px"> + <img src="/static/index/kanna.webp" alt="A dragon loli" style="border-radius:50%;margin:-100px auto 20px"> </div> <p><a href="/pong">Games?</a> (Warning: loud)</p> </section> - -{{range .}} -<section> - <a href="/blog/{{.Slug}}"><h2>{{.Name}}</h2></a> -</section> -{{end}} diff --git a/templates/outline.html.template b/templates/outline.html.template index 9dd6730..1dbc621 100644 --- a/templates/outline.html.template +++ b/templates/outline.html.template @@ -2,7 +2,7 @@ <html lang="en"> <head> <title>{{template "title" .}}</title> - <link rel="icon" href="/static/icon.png"> + <link rel="icon" href="/static/icon.webp"> <link rel="stylesheet" href="/static/styles.css"> </head> <body> diff --git a/templates/pong.html.template b/templates/pong.html.template index 141a685..777e0d0 100644 --- a/templates/pong.html.template +++ b/templates/pong.html.template @@ -2,7 +2,7 @@ <html lang="en" style="width:100%;height:100%;margin:0;padding:0"> <head> <title>Pong</title> - <link rel="icon" href="/static/pong/icon.png"> + <link rel="icon" href="/static/pong/icon.webp"> <script defer src="/static/pong/pong.js"></script> </head> <body style="width:100%;height:100%;margin:0;padding:0"> |
