From 2159ed2cc629ae30d6bb020f67e301dedf779dd4 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Tue, 11 Feb 2025 21:33:48 +0800 Subject: [PATCH] repo_commit: Properly format patchsets --- handle_repo_commit.go | 1 + static/style.css | 31 ++++++++++++++++++++++++++++++- templates/repo_commit.html.tmpl | 37 ++++++++++++++++++++++++------------- diff --git a/handle_repo_commit.go b/handle_repo_commit.go index 3a6320158318a5468a2fc3c2122de486044cacdc..4660ff36df36999b0a3c1f638c7f9d7f74007387 100644 --- a/handle_repo_commit.go +++ b/handle_repo_commit.go @@ -45,6 +45,7 @@ return } data["patch"] = patch + // TODO: Remove unnecessary context usable_file_patches := make([]usable_file_patch, 0) for _, file_patch := range patch.FilePatches() { from, to := file_patch.Files() diff --git a/static/style.css b/static/style.css index e37ad0d4307e5052a40b50edae00e8fb0606f11f..c5d79ece6457c3d768329e20a648e4b63e918e5c 100644 --- a/static/style.css +++ b/static/style.css @@ -100,7 +100,7 @@ } .toggle-table-off + table > thead > tr > th > label, .toggle-table-on + table > thead > tr > th > label { width: 100%; display: inline-block; - padding: 3px 1px; + padding: 3px 0; cursor: pointer; } .toggle-table-off:checked + table > tbody { @@ -124,3 +124,32 @@ } .chunk-unknown { color: yellow; } +pre.chunk { + margin-top: 0; + margin-bottom: 0; +} +.toggle-on-wrapper { + border: var(--lighter-border-color) solid 1px; +} +.toggle-on-toggle { + display: none; +} +.toggle-on-header { + cursor: pointer; + display: block; + width: 100%; + border-bottom: var(--lighter-border-color) solid 1px; + background-color: var(--lighter-box-background-color); +} +.toggle-on-content { + display: none; +} +.toggle-on-toggle:checked + .toggle-on-header + .toggle-on-content { + display: block; +} +.file-patch + .file-patch { + margin-top: 0.5rem; +} +.file-header { + font-family: monospace; +} diff --git a/templates/repo_commit.html.tmpl b/templates/repo_commit.html.tmpl index edc4bc3c248167e88195916e7d35a4ca521570f9..5b6cb84afa2869f1b2d55ae06f70e23870a1ff62 100644 --- a/templates/repo_commit.html.tmpl +++ b/templates/repo_commit.html.tmpl @@ -41,21 +41,32 @@ -
+
+ {{ $parent_commit_object := .parent_commit_object }} + {{ $commit_object := .commit_object }} {{ range .file_patches }} -
- {{ .From.Path }} {{ .From.Mode }} → {{ .To.Path }} {{ .To.Mode }} - {{ range .Chunks }} - {{ if eq .Type 0 }} -
{{ .Content }}
- {{ else if eq .Type 1 }} -
{{ .Content }}
- {{ else if eq .Type 2 }} -
{{ .Content }}
- {{ else }} -
{{ .Content }}
+
+ + +
+ {{ range .Chunks }} + {{ if eq .Type 0 }} +
{{ .Content }}
+ {{ else if eq .Type 1 }} +
{{ .Content }}
+ {{ else if eq .Type 2 }} +
{{ .Content }}
+ {{ else }} +
{{ .Content }}
+ {{ end }} {{ end }} - {{ end }} +
{{ end }}
-- 2.48.1