srctree

Gregory Mullen parent ec81f0e1 e0f0930f
fix diff alignment and persist with cookie

inlinesplit
src/endpoints/repos/commits.zig added: 46, removed: 34, total 12
@@ -39,7 +39,7 @@ pub fn patchVerse(a: Allocator, patch: *Patch.Patch) ![]Template.Context {
}
 
pub const PatchView = struct {
@"inline": ?bool = true,
@"inline": ?bool = null,
};
 
fn commitHtml(ctx: *Verse.Frame, sha: []const u8, repo_name: []const u8, repo: Git.Repo) Error!void {
@@ -133,8 +133,20 @@ fn commitHtml(ctx: *Verse.Frame, sha: []const u8, repo_name: []const u8, repo: G
}
} else |_| {}
 
var inline_html: bool = true;
const udata = ctx.request.data.query.validate(PatchView) catch return error.BadData;
const inline_html = udata.@"inline" orelse true;
if (udata.@"inline") |uinline| {
std.debug.print("unline {}\n", .{uinline});
inline_html = uinline;
ctx.cookie_jar.add(.{
.name = "diff-inline",
.value = if (uinline) "1" else "0",
}) catch @panic("OOM");
} else {
if (ctx.request.cookie_jar.get("diff-inline")) |cookie| {
inline_html = if (cookie.value.len > 0 and cookie.value[0] == '1') true else false;
}
}
 
var page = CommitPage.init(.{
.meta_head = meta_head,
 
static/main.css added: 46, removed: 34, total 12
@@ -455,38 +455,38 @@ patch, gist {
display: block;
text-align: left;
background: #333;
span {
white-space: pre;
&.split {
white-space: pre;
width: 100%;
.split {
display: flex;
span {
flex: auto;
margin: 0;
width: fit-content;
margin: 0;
min-width: 50%;
display: inline-block;
span {
margin: 0;
width: fit-content;
display: inline-block;
overflow: scroll;
overflow: scroll;
> div {
white-space: pre;
}
}
&.del { background: #5b0000 }
&.add { background: #003e00 }
:first-child {
margin: 0;
}
.block {
&:first-child {
margin-top: 0;
}
border-top: 1px solid #999;
border-bottom: 2px solid #222;
background: #569;
/* background: #4a4a91; might want to revert to this color */
display: block;
width: auto;
margin: 8px auto;
padding: 8px;
}
&.del { background: #5b0000 }
&.add { background: #003e00 }
:first-child {
margin: 0;
}
.block {
&:first-child {
margin-top: 0;
}
border-top: 1px solid #999;
border-bottom: 2px solid #222;
background: #569;
/* background: #4a4a91; might want to revert to this color */
display: block;
width: auto;
margin: 8px auto;
padding: 8px;
}
}
.buttons {
 
templates/_patch.html added: 46, removed: 34, total 12
@@ -1,8 +1,8 @@
<For Files>
<patch>
<header>
<Filename ORELSE No Filename found>
<strong><DiffStat ORELSE Diff Stat Missing></strong>
<Filename />
<strong><DiffStat /></strong>
</header>
<changes>
<Split DiffLines />