Home

blog @main - refs - log -
-
https://git.jolheiser.com/blog.git
My nonexistent blog
tree log patch
feat: serve Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signature
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEgqEQpE3xoo1QwJO/uFOtpdp7v3oFAmXX9zoACgkQuFOtpdp7 v3p/bA//VFbF5+CHhesImBmlHnTLywmYZ0/xbuuwpHRndWAsV2GqfduVwaECsb6v EXeW+MNAqY7vDNPOGyq+NDXqJ0ArrJg1+2a0RF6HabU12xnhMIsxSjVyTIB8fght oonRgoMN7I4aIJGFdLDtyaY89q7oFfLZbcrzRBgTnkwWvL67qwzkw5ovdjiem55l RuQEVRnBv3fQ/i6Ovw8dvGqir0n/Gwpwa2/4VRU2TEmLwpvACarRHaK2snCehNZV dtiPGX+A3fpgQUwdjju6Kp3Isfcl/RoScjRRHnY76YcTuyINROSafF+8AWQ/8+xy J5d3R1xcIYplUenRZXoITGrKUseW69SUVucsTF6xe5Q+jJWfIN0x280So2TvA3JT faUa+TavOOv0nWisAEAd0WXybgNlIvcQVaMhf6RjW2gD5zYOpD66e5ML5BzDi82b /Gp+DKFwQi4h8aF1iEtCVYORcdUIUnrPEMpMY5EpGnWHLFR8inGZsKhRdsuBrs+y ktlALXLhiingWEE9H3v6iGL5o7z/e6ZVe5XJwyODn3cTKetKTeU8/R+FutP8qnDf pFns9stmwP6d4h3Wq0FmR5EYOnx8HpP0yr08W0SdpGkt/CRW2DiVfqp3EeYl9UBB t6aQ5CfoUXDIuWeUZUna/BWb97qPDA8qaknkU2h4fhaGjYPGQhI= =zfs0 -----END PGP SIGNATURE-----
jolheiser <john.olheiser@gmail.com>
9 months ago
4 changed files, 289 additions(+), 5 deletions(-)
M main.go -> main.go
diff --git a/main.go b/main.go
index f0c5c9ee09a29fe144c863df27be02a3a1bf7a3e..699fc9c7e531aab231d5297efcfa4f50cdf0d5b5 100644
--- a/main.go
+++ b/main.go
@@ -7,7 +7,9 @@ 	"context"
 	"embed"
 	"flag"
 	"fmt"
+	"io"
 	iofs "io/fs"
+	"net/http"
 	"os"
 	"path/filepath"
 
@@ -21,6 +23,8 @@ func maine() error {
 	fs := flag.NewFlagSet("blog", flag.ExitOnError)
 	outFlag := fs.String("out", "out", "Output directory")
 	fs.StringVar(outFlag, "o", *outFlag, "--out")
+	serveFlag := fs.Bool("serve", false, "Serve output dir after generation")
+	fs.BoolVar(serveFlag, "s", *serveFlag, "--serve")
 	if err := fs.Parse(os.Args[1:]); err != nil {
 		return err
 	}
@@ -53,13 +57,28 @@ 	if err := writeCSS(*outFlag); err != nil {
 		return err
 	}
 
+	sakuraDst := filepath.Join(*outFlag, "sakura.css")
+	if err := copyFile(sakuraDst, "sakura.css"); err != nil {
+		return err
+	}
+
 	fi, err := os.Create(filepath.Join(*outFlag, "index.html"))
 	if err != nil {
 		return err
 	}
 	defer fi.Close()
 
+	"context"
 
+		return err
+	}
+
+	if *serveFlag {
+		http.Handle("/", http.FileServer(http.Dir("out")))
+		http.ListenAndServe(":8080", nil)
+	}
+
+	return nil
 }
 
 func writeArticle(out string, article Article) error {
@@ -91,6 +111,26 @@ 	if err := CSS.WriteCSS(fi, styles.Get("catppuccin-mocha")); err != nil {
 		return err
 	}
 	fi.WriteString("}")
+	return nil
+}
+
+func copyFile(dst, src string) error {
+	srcFi, err := os.Open(src)
+	if err != nil {
+		return err
+	}
+	defer srcFi.Close()
+
+	dstFi, err := os.Create(dst)
+	if err != nil {
+		return err
+	}
+	defer dstFi.Close()
+
+	if _, err := io.Copy(dstFi, srcFi); err != nil {
+		return err
+	}
+
 	return nil
 }
 
I sakura.css
diff --git a/sakura.css b/sakura.css
new file mode 100644
index 0000000000000000000000000000000000000000..22b5a0a468044f3b8c4e4730e8439938c097c6c1
--- /dev/null
+++ b/sakura.css
@@ -0,0 +1,245 @@
+/* Sakura.css v1.5.0
+ * ================
+ * Minimal css theme.
+ * Project: https://github.com/oxalorg/sakura/
+ */
+
+:root {
+  --blossom: #179299;
+  --fade: #ea76cb;
+  --bg: #eff1f5;
+  --bg-alt: #dce0e8;
+  --text: #4c4f69;
+}
+
+@media (prefers-color-scheme: dark) {
+  :root {
+    --blossom: #94e2d5;
+    --fade: #f5c2e7;
+    --bg: #1e1e2e;
+    --bg-alt: #11111b;
+    --text: #cdd6f4; 
+  }
+}
+
+/* Body */
+html {
+  font-size: 62.5%;
+  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
+}
+
+body {
+  font-size: 1.8rem;
+  line-height: 1.618;
+  max-width: 38em;
+  margin: auto;
+  color: var(--text);
+  background-color: var(--bg);
+  padding: 13px;
+}
+
+@media (max-width: 684px) {
+  body {
+    font-size: 1.53rem;
+  }
+}
+@media (max-width: 382px) {
+  body {
+    font-size: 1.35rem;
+  }
+}
+h1, h2, h3, h4, h5, h6 {
+  line-height: 1.1;
+  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
+  font-weight: 700;
+  margin-top: 3rem;
+  margin-bottom: 1.5rem;
+  overflow-wrap: break-word;
+  word-wrap: break-word;
+  -ms-word-break: break-all;
+  word-break: break-word;
+}
+
+h1 {
+  font-size: 2.35em;
+}
+
+h2 {
+  font-size: 2em;
+}
+
+h3 {
+  font-size: 1.75em;
+}
+
+h4 {
+  font-size: 1.5em;
+}
+
+h5 {
+  font-size: 1.25em;
+}
+
+h6 {
+  font-size: 1em;
+}
+
+p {
+  margin-top: 0px;
+  margin-bottom: 2.5rem;
+}
+
+small, sub, sup {
+  font-size: 75%;
+}
+
+hr {
+  border-color: var(--blossom);
+}
+
+a {
+  text-decoration: none;
+  color: var(--blossom);
+}
+a:visited {
+  color: #144f5a;
+}
+a:hover {
+  color: var(--fade);
+  border-bottom: 2px solid var(--text);
+}
+
+ul {
+  padding-left: 1.4em;
+  margin-top: 0px;
+  margin-bottom: 2.5rem;
+}
+
+li {
+  margin-bottom: 0.4em;
+}
+
+blockquote {
+  margin-left: 0px;
+  margin-right: 0px;
+  padding-left: 1em;
+  padding-top: 0.8em;
+  padding-bottom: 0.8em;
+  padding-right: 0.8em;
+  border-left: 5px solid var(--blossom);
+  margin-bottom: 2.5rem;
+  background-color: var(--bg-alt);
+}
+
+blockquote p {
+  margin-bottom: 0;
+}
+
+img, video {
+  height: auto;
+  max-width: 100%;
+  margin-top: 0px;
+  margin-bottom: 2.5rem;
+}
+
+/* Pre and Code */
+pre {
+  background-color: var(--bg-alt);
+  display: block;
+  padding: 1em;
+  overflow-x: auto;
+  margin-top: 0px;
+  margin-bottom: 2.5rem;
+  font-size: 0.9em;
+}
+
+code, kbd, samp {
+  font-size: 0.9em;
+  padding: 0 0.5em;
+  background-color: var(--bg-alt);
+  white-space: pre-wrap;
+}
+
+pre > code {
+  padding: 0;
+  background-color: transparent;
+  white-space: pre;
+  font-size: 1em;
+}
+
+/* Tables */
+table {
+  text-align: justify;
+  width: 100%;
+  border-collapse: collapse;
+  margin-bottom: 2rem;
+}
+
+td, th {
+  padding: 0.5em;
+  border-bottom: 1px solid var(--bg-alt);
+}
+
+/* Buttons, forms and input */
+input, textarea {
+  border: 1px solid var(--text);
+}
+input:focus, textarea:focus {
+  border: 1px solid var(--blossom);
+}
+
+textarea {
+  width: 100%;
+}
+
+.button, button, input[type=submit], input[type=reset], input[type=button], input[type=file]::file-selector-button {
+  display: inline-block;
+  padding: 5px 10px;
+  text-align: center;
+  text-decoration: none;
+  white-space: nowrap;
+  background-color: var(--blossom);
+  color: var(--bg);
+  border-radius: 1px;
+  border: 1px solid var(--blossom);
+  cursor: pointer;
+  box-sizing: border-box;
+}
+.button[disabled], button[disabled], input[type=submit][disabled], input[type=reset][disabled], input[type=button][disabled], input[type=file]::file-selector-button[disabled] {
+  cursor: default;
+  opacity: 0.5;
+}
+.button:hover, button:hover, input[type=submit]:hover, input[type=reset]:hover, input[type=button]:hover, input[type=file]::file-selector-button:hover {
+  background-color: var(--fade);
+  color: var(--bg);
+  outline: 0;
+}
+.button:focus-visible, button:focus-visible, input[type=submit]:focus-visible, input[type=reset]:focus-visible, input[type=button]:focus-visible, input[type=file]::file-selector-button:focus-visible {
+  outline-style: solid;
+  outline-width: 2px;
+}
+
+textarea, select, input {
+  color: var(--text);
+  padding: 6px 10px; /* The 6px vertically centers text on FF, ignored by Webkit */
+  margin-bottom: 10px;
+  background-color: var(--bg-alt);
+  border: 1px solid var(--bg-alt);
+  border-radius: 4px;
+  box-shadow: none;
+  box-sizing: border-box;
+}
+textarea:focus, select:focus, input:focus {
+  border: 1px solid var(--blossom);
+  outline: 0;
+}
+
+input[type=checkbox]:focus {
+  outline: 1px dotted var(--blossom);
+}
+
+label, legend, fieldset {
+  display: block;
+  margin-bottom: 0.5rem;
+  font-weight: 600;
+}
M templates.templ -> templates.templ
diff --git a/templates.templ b/templates.templ
index daee1e81f364b2c7d571ffe38b7e3eb24d24def0..d974b5833560129812c609934c2a97b293f617fc 100644
--- a/templates.templ
+++ b/templates.templ
@@ -9,7 +9,7 @@ 			<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
 			<title>{ title }</title>
 			<meta property="og:title" content={ title }/>
 			<meta property="og:description" content={ description }/>
-			<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"/>
+			<link rel="stylesheet" href="/sakura.css"/>
 			<link rel="stylesheet" href="/chroma.css"/>
 		</head>
 		<body>
@@ -37,7 +37,7 @@ templ ArticleTemplate(article Article) {
 	@baseTemplate(article.Title, article.Summary) {
 		<header>
 			<h1>{ article.Title }</h1>
-			<h2>{ article.Date.Format("01/02/2006") }</h2>
+			<h3>{ article.Date.Format("01/02/2006") }</h3>
 		</header>
 		<main>@templ.Raw(article.Content)</main>
 	}
M templates_templ.go -> templates_templ.go
diff --git a/templates_templ.go b/templates_templ.go
index eb1a5286ff88f24036184a633dcb98ac78aa66d5..0ee91ec438bb7e3ec1045cac3e9e52db9e72d059 100644
--- a/templates_templ.go
+++ b/templates_templ.go
@@ -48,7 +48,7 @@ 		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(description))
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
-		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css\"><link rel=\"stylesheet\" href=\"/chroma.css\"></head><body>")
+		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><link rel=\"stylesheet\" href=\"/sakura.css\"><link rel=\"stylesheet\" href=\"/chroma.css\"></head><body>")
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
@@ -181,7 +181,7 @@ 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
-			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h1><h2>")
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h1><h3>")
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
@@ -190,7 +190,7 @@ 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
-			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h2></header><main>")
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h3></header><main>")
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}