penguin/flatgit

flatgit showcase

commit 2aa1addd3026c867d96e22dc5baeb9b379aded7a

author斟酌 鵬兄 <tgckpg@gmail.com>
date2026-10-15T02:24:53Z
subjectFixed image overflow
commit 2aa1addd3026c867d96e22dc5baeb9b379aded7a
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2026-10-15T02:24:53Z

    Fixed image overflow
---
 Makefile                            | 2 +-
 build.env                           | 2 ++
 internal/buildinfo/buildinfo_gen.go | 4 ++--
 internal/render/markdown.go         | 2 ++
 internal/render/render.go           | 2 +-
 5 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 6ca22d2..c6c1e63 100644
--- a/Makefile
+++ b/Makefile
@@ -63,7 +63,7 @@ fmt:
 	gofmt -w ./cmd ./internal
 
 run: build
-	$(BIN_DIR)/flatgit daemon -c examples/tinyproxy.json
+	$(BIN_DIR)/flatgit daemon -c $(RUN_CONF)
 
 vet:
 	go vet ./...
diff --git a/build.env b/build.env
index 05dcac8..342e55b 100644
--- a/build.env
+++ b/build.env
@@ -2,3 +2,5 @@ IMAGE_NAME=penguinade/flatgit
 IMAGE_TAG=dev
 
 APT_PROXY=
+
+RUN_CONF := examples/tinyproxy.json
diff --git a/internal/buildinfo/buildinfo_gen.go b/internal/buildinfo/buildinfo_gen.go
index ebaf7fb..75754fe 100644
--- a/internal/buildinfo/buildinfo_gen.go
+++ b/internal/buildinfo/buildinfo_gen.go
@@ -2,6 +2,6 @@ package buildinfo
 
 const (
     Version     = "dev"
-    GitRevision = "e9582f881b4cc2462eb5e02b88174c52d5894805"
-    Timestamp   = "20261014.051221"
+    GitRevision = "393d1b05164d0fb560d2a32df47d91f8a959ec59"
+    Timestamp   = "20261015.022007"
 )
diff --git a/internal/render/markdown.go b/internal/render/markdown.go
index f79f1ac..bf4ab5f 100644
--- a/internal/render/markdown.go
+++ b/internal/render/markdown.go
@@ -29,6 +29,7 @@ func renderMarkdownSafe(src []byte, markdownPath, rawBase, blobBase string) ([]b
 			switch n := node.(type) {
 			case *ast.Image:
 				n.Destination = []byte(markdownImageURL(string(n.Destination), markdownPath, rawBase))
+				n.SetAttributeString("data-md", "img")
 			case *ast.Link:
 				n.Destination = []byte(markdownLinkURL(string(n.Destination), markdownPath, blobBase))
 			}
@@ -44,6 +45,7 @@ func renderMarkdownSafe(src []byte, markdownPath, rawBase, blobBase string) ([]b
 	}
 
 	policy := bluemonday.UGCPolicy()
+	policy.AllowAttrs("data-md").OnElements("img")
 	return policy.SanitizeBytes(buf.Bytes()), nil
 }
 
diff --git a/internal/render/render.go b/internal/render/render.go
index 948ea07..435bd53 100644
--- a/internal/render/render.go
+++ b/internal/render/render.go
@@ -355,7 +355,7 @@ type blobView struct {
 }
 
 func writeStatic(root string) error {
-	css := `body{max-width:1100px;margin:2rem auto;padding:0 1rem;font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;line-height:1.45}a{color:inherit}header{border-bottom:1px solid #ddd;margin-bottom:1rem}nav a{margin-right:1rem}.muted{color:#666}.mono,pre,code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}table{border-collapse:collapse;width:100%}td,th{border-bottom:1px solid #eee;padding:.35rem;text-align:left;vertical-align:top}pre{overflow:auto;background:#f6f6f6;padding:1rem;border:1px solid #eee}.pill{border:1px solid #ddd;border-radius:999px;padding:.1rem .45rem;font-size:.85em}`
+	css := `body{max-width:1100px;margin:2rem auto;padding:0 1rem;font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;line-height:1.45}a{color:inherit}header{border-bottom:1px solid #ddd;margin-bottom:1rem}nav a{margin-right:1rem}.muted{color:#666}.mono,pre,code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}table{border-collapse:collapse;width:100%}td,th{border-bottom:1px solid #eee;padding:.35rem;text-align:left;vertical-align:top}pre{overflow:auto;background:#f6f6f6;padding:1rem;border:1px solid #eee}.pill{border:1px solid #ddd;border-radius:999px;padding:.1rem .45rem;font-size:.85em}[data-md=img]{max-width:100%}`
 	return writeFile(filepath.Join(root, "style.css"), []byte(css), 0o644)
 }