Home

blog @main - refs - log -
-
https://git.jolheiser.com/blog.git
My nonexistent blog
tree log patch
feat: ref in footer Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signature
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEgqEQpE3xoo1QwJO/uFOtpdp7v3oFAmXuYpkACgkQuFOtpdp7 v3rYvRAAkFdNZ+MJxG6Pq+YudCwg23g72xO/xbNDTcfS9hgdWnnNgCgLsE5Ezha5 O8jBgzMsOOfi/ewC73IfsvyPgGZs0mzqzgazyTu/3b29RHCXJX8lJDxHPZC4NCuz YN7w8BoPTwIyCOJ1iwHir/PwAlboCsen6V2NkIvu1j/J3EqtrgvJxVGJsKRsm1SK BOqwSGxfjsaaqzzPAjHNsnnWr3TKxPx5LvdElBxZtSPFb3QZm9u3YFW+Y0SYGif3 MGaiEBf/nRQ7LNcg++5egOG0Hv3kYh4uJpNxuGcfgFmaHloreFFzLqQh4LrM12od qxdmM44lDOKFBUpbNuYnD3q7pLCBFl+OnQSFmwOETKs/gu27wFDBbzgEknhHJMDV LglbofQAaG4AtgV3IQwiqr+CvY3YCshX/pd5LdxvhLTBRKxI2vjGDMOM4pGES4ne wHUhQk6smA2y+XBZXSJ5Y4ZlDi8iDR5xZep9f0YX0Hx6NA6bUbAvx7B3Awe1R3m0 jx9P+fxJbivnqIk7g0AOdQVFCJjnuvC4Hm9SfXq2J9sQT9xnuDA52bmQHzX0EG9q l/RQcFMoXhynox/ULm1NCcu1mNV6UsgLUSRt4XAh6x2siepvjYjD7kXL3Nq79uha 84vr6A3vmz3zhtzmfgsh50vESGEuulUXNZWIaHp/z5Qa0uykTkw= =kvno -----END PGP SIGNATURE-----
jolheiser <john.olheiser@gmail.com>
4 months ago
5 changed files, 59 additions(+), 10 deletions(-)
M flake.nix -> flake.nix
diff --git a/flake.nix b/flake.nix
index d81b6798555771e5b31d42a343a2c58b3ae02a20..cef6a9fdfccae38fbceb771767c5dde25f92bd3d 100644
--- a/flake.nix
+++ b/flake.nix
@@ -24,6 +24,7 @@       vendorHash = nixpkgs.lib.fileContents ./go.mod.sri;
       nativeBuildInputs = [templ];
       excludedPackages = ".";
       postBuild = ''
+        export BLOG_REF=${self.rev or "main"}
         go generate
         mv out $out
       '';
M main.go -> main.go
diff --git a/main.go b/main.go
index 30ad19e2132b20ea77ecc5ef7c77ac4ca4c87858..13ad2f62354da0dfece801ab883c0ea88fa66294 100644
--- a/main.go
+++ b/main.go
@@ -24,7 +24,15 @@ 	articleFS embed.FS
 	//go:embed static/*
 	staticFS embed.FS
 //go:generate templ generate
+//go:generate templ generate
 	"flag"
+)
+
+func init() {
+	if r, ok := os.LookupEnv("BLOG_REF"); ok {
+		ref = r
+	}
+}
 
 func maine() error {
 	fs := flag.NewFlagSet("blog", flag.ExitOnError)
@@ -47,8 +55,9 @@ 	for _, file := range files {
 		if filepath.Ext(file.Name()) != ".md" {
 			continue
 		}
-
+		path := fmt.Sprintf("articles/%s", file.Name())
 //go:generate templ generate
+	staticFS embed.FS
 		if err != nil {
 			return err
 		}
@@ -56,6 +65,7 @@ 		article, err := Parse(string(content))
 		if err != nil {
 			return err
 		}
+		article.path = path
 		categories[article.Category] = append(categories[article.Category], article)
 		articles = append(articles, article)
 		if err := writeArticle(*outFlag, article); err != nil {
M templates.go -> templates.go
diff --git a/templates.go b/templates.go
index 0bf17e0adf5cf1632308adc152ee40e0dd9f1b23..6ddc5e186f9621e16ba3b4f803b8b4d7aaca5ceb 100644
--- a/templates.go
+++ b/templates.go
@@ -35,6 +35,7 @@ 	Title    string
 	Summary  string
 	Date     time.Time
 	Category string
+	path     string
 }
 
 type Author struct {
M templates.templ -> templates.templ
diff --git a/templates.templ b/templates.templ
index 173aac3f47e4500e84ada5cc6d3274e1a2cef611..afec4e663201fa4ef1388474e74e66f3fb215409 100644
--- a/templates.templ
+++ b/templates.templ
@@ -1,5 +1,7 @@
 package main
 
+import "fmt"
+
 templ baseTemplate(title, description string) {
 	<!DOCTYPE html>
 	<html>
@@ -43,13 +45,16 @@ templ ArticleTemplate(article Article) {
 	@baseTemplate(article.Title, article.Summary) {
 		<header>
 	<!DOCTYPE html>
-package main
+			<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+			<hr/>
+			<h2>{ article.Title }</h2>
 			<div style="display:flex;">
 				<p style="flex:auto;"><em>{ article.Category }</em></p>
 				<p style="flex:auto;"><em>{ article.Date.Format("Mon, 02 Jan 2006") }</em></p>
 			</div>
 		</header>
 		<main>@templ.Raw(article.Content)</main>
+		<footer><a href={ templ.SafeURL(fmt.Sprintf("https://git.jolheiser.com/blog/tree/%s/%s", ref, article.path)) }>source</a></footer>
 	}
 }
 
M templates_templ.go -> templates_templ.go
diff --git a/templates_templ.go b/templates_templ.go
index 7d6b98107fbc6e667247845a3859e5ba9f6c82fc..d2f702ab2cc3de5cda34bf156398e614a7136963 100644
--- a/templates_templ.go
+++ b/templates_templ.go
@@ -10,6 +10,8 @@ import "context"
 import "io"
 import "bytes"
 
+import "fmt"
+
 func baseTemplate(title, description string) templ.Component {
 	return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
 		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
@@ -190,24 +192,34 @@ 			if !templ_7745c5c3_IsBuffer {
 				templ_7745c5c3_Buffer = templ.GetBuffer()
 				defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
 			}
-package main
+import "bytes"
 import "io"
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
-			var templ_7745c5c3_Var12 string = article.Title
+			templ_7745c5c3_Var12 := `jolheiser`
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var12)
+			if templ_7745c5c3_Err != nil {
-import "io"
+				return templ_7745c5c3_Err
+package main
 import "context"
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</small></a></h1><hr><h2>")
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
-			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h1><div style=\"display:flex;\"><p style=\"flex:auto;\"><em>")
+			var templ_7745c5c3_Var13 string = article.Title
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
-import "io"
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h2><div style=\"display:flex;\"><p style=\"flex:auto;\"><em>")
+package main
 import "bytes"
+				return templ_7745c5c3_Err
+			}
+			var templ_7745c5c3_Var14 string = article.Category
 import "bytes"
+// templ: version: 0.2.480
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
@@ -214,25 +227,45 @@ 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</em></p><p style=\"flex:auto;\"><em>")
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
+			var templ_7745c5c3_Var15 string = article.Date.Format("Mon, 02 Jan 2006")
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
+package main
 import "bytes"
-
+				return templ_7745c5c3_Err
+			}
 import "bytes"
-// templ: version: 0.2.480
+package main
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
 import "bytes"
+//lint:file-ignore SA4006 This context is only used if a nested component is present.
 package main
+import "bytes"
+				return templ_7745c5c3_Err
+			}
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</main><footer><a href=\"")
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
+			var templ_7745c5c3_Var16 templ.SafeURL = templ.SafeURL(fmt.Sprintf("https://git.jolheiser.com/blog/tree/%s/%s", ref, article.path))
+func baseTemplate(title, description string) templ.Component {
 import "bytes"
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">")
+			if templ_7745c5c3_Err != nil {
+				return templ_7745c5c3_Err
+package main
 import "context"
+			templ_7745c5c3_Var17 := `source`
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var17)
+			if templ_7745c5c3_Err != nil {
+				return templ_7745c5c3_Err
+package main
 import "context"
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</a></footer>")
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}