ugly fucking global timeline endpoint
This commit is contained in:
parent
6748f065ef
commit
1b379513f7
2 changed files with 36 additions and 0 deletions
|
@ -4,6 +4,7 @@ pub const routes = .{
|
||||||
index,
|
index,
|
||||||
about,
|
about,
|
||||||
login,
|
login,
|
||||||
|
global_timeline,
|
||||||
};
|
};
|
||||||
|
|
||||||
const index = struct {
|
const index = struct {
|
||||||
|
@ -54,3 +55,18 @@ const login = struct {
|
||||||
try res.status(.see_other);
|
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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
20
src/main/controllers/web/timelines/global.tmpl.html
Normal file
20
src/main/controllers/web/timelines/global.tmpl.html
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<title>{ .community.name }</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<h1>{ .community.name }</h1>
|
||||||
|
</header>
|
||||||
|
{#for .notes |$note| =}
|
||||||
|
<section>
|
||||||
|
<header>@{$note.author.username}</header>
|
||||||
|
<div>
|
||||||
|
{$note.content}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{/for =}
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in a new issue