srctree

Gregory Mullen parent f449f330 d9cb8ac5
fix template struct naming

src/endpoints/gist.zig added: 19, removed: 20, total 0
@@ -62,7 +62,7 @@ fn post(ctx: *Context) Error!void {
"public";
 
if (udata.new_file != null) {
const files = try ctx.alloc.alloc(Template.Structs.Gistfiles, udata.file_name.len + 1);
const files = try ctx.alloc.alloc(Template.Structs.GistFiles, udata.file_name.len + 1);
for (files[0 .. files.len - 1], udata.file_name, udata.file_blob) |*file, name, blob| {
file.* = .{
.name = name,
@@ -91,13 +91,13 @@ fn post(ctx: *Context) Error!void {
}
 
fn new(ctx: *Context) Error!void {
const files = [1]Template.Structs.Gistfiles{.{}};
const files = [1]Template.Structs.GistFiles{.{}};
return edit(ctx, &files);
}
 
fn edit(ctx: *Context, files: []const Template.Structs.Gistfiles) Error!void {
fn edit(ctx: *Context, files: []const Template.Structs.GistFiles) Error!void {
// TODO move this back into context somehow
var btns = [1]Template.Structs.Navbuttons{
var btns = [1]Template.Structs.NavButtons{
.{
.name = "inbox",
.url = "/inbox",
@@ -122,8 +122,8 @@ fn edit(ctx: *Context, files: []const Template.Structs.Gistfiles) Error!void {
return ctx.sendPage(&page);
}
 
fn toTemplate(a: Allocator, files: []const Gist.File) ![]Template.Structs.Gistfiles {
const out = try a.alloc(Template.Structs.Gistfiles, files.len);
fn toTemplate(a: Allocator, files: []const Gist.File) ![]Template.Structs.GistFiles {
const out = try a.alloc(Template.Structs.GistFiles, files.len);
for (files, out) |file, *o| {
o.* = .{
.file_name = try Bleach.sanitizeAlloc(a, file.name, .{}),
@@ -135,7 +135,7 @@ fn toTemplate(a: Allocator, files: []const Gist.File) ![]Template.Structs.Gistfi
 
fn view(ctx: *Context) Error!void {
// TODO move this back into context somehow
var btns = [1]Template.Structs.Navbuttons{.{ .name = "inbox", .url = "/inbox" }};
var btns = [1]Template.Structs.NavButtons{.{ .name = "inbox", .url = "/inbox" }};
 
if (ctx.uri.next()) |hash| {
if (hash.len != 64) return error.BadData;
 
src/endpoints/repos.zig added: 19, removed: 20, total 0
@@ -90,7 +90,7 @@ pub const RouteData = struct {
}
};
 
pub fn navButtons(ctx: *Context) ![2]Template.Structs.Navbuttons {
pub fn navButtons(ctx: *Context) ![2]Template.Structs.NavButtons {
const rd = RouteData.make(&ctx.uri) orelse unreachable;
if (!rd.exists()) unreachable;
var i_count: usize = 0;
@@ -105,7 +105,7 @@ pub fn navButtons(ctx: *Context) ![2]Template.Structs.Navbuttons {
dlt.raze(ctx.alloc);
}
 
const btns = [2]Template.Structs.Navbuttons{
const btns = [2]Template.Structs.NavButtons{
.{
.name = "issues",
.extra = try aPrint(ctx.alloc, "{}", .{i_count}),
@@ -220,7 +220,7 @@ fn sorter(_: void, l: []const u8, r: []const u8) bool {
return std.mem.lessThan(u8, l, r);
}
 
fn repoBlock(a: Allocator, name: []const u8, repo: Git.Repo) !Template.Structs.Repolist {
fn repoBlock(a: Allocator, name: []const u8, repo: Git.Repo) !Template.Structs.RepoList {
var desc: ?[]const u8 = try repo.description(a);
if (std.mem.startsWith(u8, desc.?, "Unnamed repository; edit this file")) {
desc = null;
@@ -302,7 +302,7 @@ fn list(ctx: *Context) Error!void {
;
}
 
const repos_compiled = try ctx.alloc.alloc(Template.Structs.Repolist, repos.items.len);
const repos_compiled = try ctx.alloc.alloc(Template.Structs.RepoList, repos.items.len);
for (repos.items, repos_compiled) |*repo, *compiled| {
defer repo.raze();
compiled.* = repoBlock(ctx.alloc, repo.repo_name orelse "unknown", repo.*) catch {
@@ -310,7 +310,7 @@ fn list(ctx: *Context) Error!void {
};
}
 
var btns = [1]Template.Structs.Navbuttons{.{
var btns = [1]Template.Structs.NavButtons{.{
.name = "inbox",
.extra = "0",
.url = "/inbox",
 
src/endpoints/repos/diffs.zig added: 19, removed: 20, total 0
@@ -72,7 +72,6 @@ const IssueCreateReq = struct {
// submit: bool,
// preview: bool,
//},
 
};
 
fn newPost(ctx: *Context) Error!void {
 
src/template-compiler.zig added: 19, removed: 20, total 0
@@ -237,7 +237,7 @@ pub fn makeStructName(in: []const u8) []const u8 {
if (next_upper) {
local.name[i] = std.ascii.toUpper(chr);
} else {
local.name[i] = std.ascii.toLower(chr);
local.name[i] = chr;
}
next_upper = false;
i += 1;
 
src/template.zig added: 19, removed: 20, total 0
@@ -572,7 +572,7 @@ pub fn makeStructName(comptime in: []const u8, comptime out: []u8) usize {
if (next_upper) {
out[i] = std.ascii.toUpper(chr);
} else {
out[i] = std.ascii.toLower(chr);
out[i] = chr;
}
next_upper = false;
i += 1;