aboutsummaryrefslogtreecommitdiff
path: root/comments/src
diff options
context:
space:
mode:
Diffstat (limited to 'comments/src')
-rw-r--r--comments/src/main.zig16
1 files changed, 8 insertions, 8 deletions
diff --git a/comments/src/main.zig b/comments/src/main.zig
index a5008b8..165dff0 100644
--- a/comments/src/main.zig
+++ b/comments/src/main.zig
@@ -84,7 +84,7 @@ const Response = struct {
fn do(self: @This()) !void {
const wtr = std.io.getStdOut().writer();
if (self.status.phrase()) |phrase| {
- try std.fmt.format(wtr, "status: {} {s}\r\n", .{@intFromEnum(self.status), phrase});
+ try std.fmt.format(wtr, "status: {} {s}\r\n", .{ @intFromEnum(self.status), phrase });
} else {
try std.fmt.format(wtr, "status: {}\r\n", .{@intFromEnum(self.status)});
}
@@ -196,7 +196,7 @@ fn get_comment(res: *Response, ctx: Ctx, _: Params) Err!void {
}
const rr = @embedFile("templates/comments.html");
- const tt = comptime mustache.parseComptime(rr, .{}, .{});
+ const tt = mustache.parseText(res.allocator, rr, .{}, .{ .copy_strings = false }) catch unreachable;
res.transfer_encoding = .chunked;
try res.headers.append("content-type", "text/html");
try res.do();
@@ -204,7 +204,7 @@ fn get_comment(res: *Response, ctx: Ctx, _: Params) Err!void {
const data = struct {
comments: []const Comment,
};
- try mustache.render(tt, data{
+ try mustache.render(tt.success, data{
.comments = comments.items,
}, res.writer());
try res.finish();
@@ -243,7 +243,7 @@ fn post_comment(res: *Response, ctx: Ctx, _: Params) Err!void {
}
const ans = try stmt.read_column(0, []const u8);
if (!std.mem.eql(u8, ans, form_val.capcha_answer)) {
- std.log.err("bad capcha answer {s} expected {s}", .{form_val.capcha_answer, ans});
+ std.log.err("bad capcha answer {s} expected {s}", .{ form_val.capcha_answer, ans });
try constresponse(res, @embedFile("templates/capchainvalid.html"), std.http.Status.unauthorized);
return;
}
@@ -261,9 +261,9 @@ fn post_comment(res: *Response, ctx: Ctx, _: Params) Err!void {
// Send me an email
const rr = @embedFile("templates/notification.txt");
- const tt = comptime mustache.parseComptime(rr, .{}, .{});
+ const tt = mustache.parseText(res.allocator, rr, .{}, .{ .copy_strings = false }) catch unreachable;
const Data = struct { url: []const u8, author: []const u8, comment: []const u8 };
- const notification = try mustache.allocRender(res.allocator, tt, Data{
+ const notification = try mustache.allocRender(res.allocator, tt.success, Data{
.url = form_val.url,
.author = form_val.author,
.comment = form_val.comment,
@@ -306,7 +306,7 @@ fn get_form(res: *Response, ctx: Ctx, _: Params) Err!void {
const capcha = try stmt.read_struct(Capcha);
const rr = @embedFile("templates/form.html");
- const tt = comptime mustache.parseComptime(rr, .{}, .{});
+ const tt = mustache.parseText(res.allocator, rr, .{}, .{ .copy_strings = false }) catch unreachable;
res.transfer_encoding = .chunked;
try res.headers.append("content-type", "text/html");
@@ -317,7 +317,7 @@ fn get_form(res: *Response, ctx: Ctx, _: Params) Err!void {
capcha_question: []const u8,
url: []const u8,
};
- try mustache.render(tt, data{
+ try mustache.render(tt.success, data{
.capcha_id = capcha.id,
.capcha_question = capcha.question,
.url = url,