done with RSS
This commit is contained in:
parent
d0a8d8d969
commit
bca22601e1
@ -25,8 +25,8 @@
|
||||
// internet connectivity.
|
||||
.dependencies = .{
|
||||
.jetzig = .{
|
||||
.url = "https://github.com/jetzig-framework/jetzig/archive/1feb18fb74e626fe068ec67532318640a9cb83be.tar.gz",
|
||||
.hash = "jetzig-0.0.0-IpAgLfMzDwDyAqZ05btcLDd9dfE_bxUbfOI_Wx7a19ed",
|
||||
.url = "https://github.com/jetzig-framework/jetzig/archive/bb724b48f62605ca63dca5bb21805b2ed1683557.tar.gz",
|
||||
.hash = "jetzig-0.0.0-IpAgLf5aDwCfevsEIt-MOj1YUZI0IdhNCCuEBYXQcEkc",
|
||||
},
|
||||
.uuid = .{
|
||||
.url = "git+https://github.com/r4gus/uuid-zig#9d66e23e32cd7208d1becb4fd9352f8a27f89551",
|
||||
|
@ -21,17 +21,17 @@
|
||||
@else
|
||||
<a href="/login" class="text-blue-500 hover:underline ml-4">Login</a>
|
||||
@end
|
||||
<a href="git.yuzucchii.xyz" class="text-blue-500 hover:underline ml-4">Gitea instance</a>
|
||||
<a href="chat.yuzucchii.xyz" class="text-blue-500 hover:underline ml-4">IRC</a>
|
||||
<a href="https://git.yuzucchii.xyz" class="text-blue-500 hover:underline ml-4" rel="noopener">Gitea instance</a>
|
||||
<a href="https://chat.yuzucchii.xyz" class="text-blue-500 hover:underline ml-4" rel="noopener">IRC</a>
|
||||
<a href="/rss" class="text-blue-500 hover:underline ml-4">RSS feed</a>
|
||||
<a href="searx.yuzucchii.xyz" class="text-blue-500 hover:underline ml-4">SearX</a>
|
||||
<a href="yuzucchii.xyz/files" class="text-blue-500 hover:underline ml-4">Files</a>
|
||||
<a href="https://searx.yuzucchii.xyz" class="text-red-500 hover:underline ml-4">SearX</a>
|
||||
<a href="/files" class="text-red-500 hover:underline ml-4">Files</a>
|
||||
<a href="mailto:me@yuzucchii.xyz" class="text-blue-500 hover:underline ml-4">E-mail</a>
|
||||
<button
|
||||
id="copy-button"
|
||||
type="button"
|
||||
onclick="navigator.clipboard.writeText('mc.yuzucchii.xyz'); showCopiedMessage();"
|
||||
class="js-only text-blue-500 hover:underline ml-4 bg-transparent p-0 border-none cursor-pointer"
|
||||
class="js-only text-green-500 hover:underline ml-4 bg-transparent p-0 border-none cursor-pointer"
|
||||
>
|
||||
Minecraft server
|
||||
</button>
|
||||
|
@ -21,6 +21,7 @@ fn generateRss(items: []const RssItem, allocator: std.mem.Allocator) ![]u8 {
|
||||
\\<title>yuzucchii.xyz</title>
|
||||
\\<link>yuzucchii.xyz</link>
|
||||
\\<description>Personal blog of Yuzu with all kinds of different articles</description>
|
||||
\\<atom:link xmlns:atom="http://www.w3.org/2005/Atom" href="https://yuzucchii.xyz/rss.xml" rel="self" type="application/rss+xml"/>
|
||||
, .{});
|
||||
|
||||
for (items) |item| {
|
||||
@ -44,9 +45,7 @@ fn generateRss(items: []const RssItem, allocator: std.mem.Allocator) ![]u8 {
|
||||
|
||||
|
||||
// we'll send xml instead
|
||||
pub fn index(request: *jetzig.Request) !void {
|
||||
try request.headers.append("Content-Type", "application/rss+xml");
|
||||
|
||||
pub fn index(request: *jetzig.Request) !jetzig.View {
|
||||
const query = jetzig.database.Query(.Blog).orderBy(.{.created_at = .desc});
|
||||
|
||||
const blogs = try request.repo.all(query);
|
||||
@ -64,9 +63,14 @@ pub fn index(request: *jetzig.Request) !void {
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: wait until jetzig adds xml support
|
||||
_ = try generateRss(try items.toOwnedSlice(), request.allocator);
|
||||
const rss = generateRss(items.toOwnedSlice() catch {
|
||||
std.debug.print("lol", .{});
|
||||
return request.fail(.bad_request);
|
||||
}, request.allocator) catch {
|
||||
return request.fail(.bad_request);
|
||||
};
|
||||
|
||||
return request.render(.ok);
|
||||
request.response.content_type = "application/rss+xml";
|
||||
return request.renderText(rss, .ok);
|
||||
}
|
||||
|
1
src/app/views/rss/index.zmpl
Normal file
1
src/app/views/rss/index.zmpl
Normal file
@ -0,0 +1 @@
|
||||
<div></div>
|
@ -214,7 +214,7 @@ pub const jetzig_options = struct {
|
||||
};
|
||||
|
||||
pub fn init(app: *jetzig.App) !void {
|
||||
_ = app;
|
||||
app.route(.GET, "/rss.xml", @import("app/views/rss.zig"), .index);
|
||||
}
|
||||
|
||||
pub fn main() !void {
|
||||
|
Loading…
x
Reference in New Issue
Block a user