diff --git a/src/main/controllers/web.zig b/src/main/controllers/web.zig index 9cdec8a..183c3ce 100644 --- a/src/main/controllers/web.zig +++ b/src/main/controllers/web.zig @@ -4,6 +4,7 @@ pub const routes = .{ index, about, login, + global_timeline, }; const index = struct { @@ -54,3 +55,18 @@ const login = struct { try res.status(.see_other); } }; + +const global_timeline = struct { + pub const path = "/timelines/global"; + pub const method = .GET; + + pub fn handler(req: anytype, res: anytype, srv: anytype) !void { + _ = req; + const timeline = try srv.globalTimeline(.{}); + + try res.template(.ok, @embedFile("./web/timelines/global.tmpl.html"), .{ + .notes = timeline.items, + .community = srv.community, + }); + } +}; diff --git a/src/main/controllers/web/timelines/global.tmpl.html b/src/main/controllers/web/timelines/global.tmpl.html new file mode 100644 index 0000000..e3394c8 --- /dev/null +++ b/src/main/controllers/web/timelines/global.tmpl.html @@ -0,0 +1,20 @@ + + + + + { .community.name } + + +
+

{ .community.name }

+
+ {#for .notes |$note| =} +
+
@{$note.author.username}
+
+ {$note.content} +
+
+ {/for =} + +