Compare commits
7 Commits
e5e3a73cae
...
81dcac4097
| Author | SHA1 | Date | |
|---|---|---|---|
| 81dcac4097 | |||
| e0dbc08072 | |||
| f0caf0b3fc | |||
| 900a782bad | |||
| 2a37762aa5 | |||
| a808d2efbc | |||
| 188cd15291 |
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@because/sandlot",
|
"name": "@because/sandlot",
|
||||||
"version": "0.0.16",
|
"version": "0.0.19",
|
||||||
"description": "Sandboxed, branch-based development with Claude",
|
"description": "Sandboxed, branch-based development with Claude",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,12 @@
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h1><code>{{BRANCH}}</code></h1>
|
<h1><code>{{BRANCH}}</code></h1>
|
||||||
{{PROMPT_SECTION}}
|
{{PROMPT_SECTION}}
|
||||||
|
<div style="margin: 12px 0;">
|
||||||
|
<label style="cursor:pointer; user-select:none; font-size:14px; color:#8b949e;">
|
||||||
|
<input type="checkbox" id="unified-toggle" style="cursor:pointer; vertical-align:middle; margin-right:6px;">
|
||||||
|
Unified
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<div class="meta">
|
<div class="meta">
|
||||||
{{LOG_SECTION}}
|
{{LOG_SECTION}}
|
||||||
{{STAT_SECTION}}
|
{{STAT_SECTION}}
|
||||||
|
|
@ -34,16 +40,49 @@
|
||||||
<script>
|
<script>
|
||||||
const diffString = {{DIFF_JSON}};
|
const diffString = {{DIFF_JSON}};
|
||||||
const targetElement = document.getElementById("diff");
|
const targetElement = document.getElementById("diff");
|
||||||
const configuration = {
|
const toggle = document.getElementById("unified-toggle");
|
||||||
drawFileList: true,
|
|
||||||
|
// Split raw diff into per-file chunks and classify each
|
||||||
|
function splitDiff(raw) {
|
||||||
|
const files = [];
|
||||||
|
const parts = raw.split(/^(?=diff --git )/m);
|
||||||
|
for (const part of parts) {
|
||||||
|
if (!part.trim()) continue;
|
||||||
|
const isNew = /^new file mode/m.test(part);
|
||||||
|
const isDeleted = /^deleted file mode/m.test(part);
|
||||||
|
files.push({ raw: part, isNew, isDeleted });
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
const files = splitDiff(diffString);
|
||||||
|
|
||||||
|
function renderAll(modifiedFormat) {
|
||||||
|
targetElement.innerHTML = "";
|
||||||
|
for (const file of files) {
|
||||||
|
const div = document.createElement("div");
|
||||||
|
targetElement.appendChild(div);
|
||||||
|
const format = (file.isNew || file.isDeleted) ? "line-by-line" : modifiedFormat;
|
||||||
|
const ui = new Diff2HtmlUI(div, file.raw, {
|
||||||
|
drawFileList: false,
|
||||||
matching: "lines",
|
matching: "lines",
|
||||||
outputFormat: "side-by-side",
|
outputFormat: format,
|
||||||
highlight: true,
|
highlight: true,
|
||||||
colorScheme: "dark",
|
colorScheme: "dark",
|
||||||
};
|
}, hljs);
|
||||||
const diff2htmlUi = new Diff2HtmlUI(targetElement, diffString, configuration);
|
ui.draw();
|
||||||
diff2htmlUi.draw();
|
ui.highlightCode();
|
||||||
diff2htmlUi.highlightCode();
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const saved = localStorage.getItem("sandlot-unified") === "1";
|
||||||
|
toggle.checked = saved;
|
||||||
|
renderAll(saved ? "line-by-line" : "side-by-side");
|
||||||
|
|
||||||
|
toggle.addEventListener("change", function () {
|
||||||
|
localStorage.setItem("sandlot-unified", this.checked ? "1" : "0");
|
||||||
|
renderAll(this.checked ? "line-by-line" : "side-by-side");
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user