const std = @import("std"); const jetzig = @import("jetzig"); pub const routes = @import("routes"); const zmd = @import("zmd"); const builtin = @import("builtin"); pub const static = @import("static"); // Override default settings in `jetzig.config` here: pub const jetzig_options = struct { pub const Schema = @import("Schema"); /// Middleware chain. Add any custom middleware here, or use middleware provided in /// `jetzig.middleware` (e.g. `jetzig.middleware.HtmxMiddleware`). pub const middleware: []const type = &.{ // htmx middleware skips layouts when `HX-Target` header is present and issues // `HX-Redirect` instead of a regular HTTP redirect when `request.redirect` is called. jetzig.middleware.HtmxMiddleware, // Demo middleware included with new projects. Remove once you are familiar with Jetzig's // middleware system. }; // Maximum bytes to allow in request body. pub const max_bytes_request_body: usize = std.math.pow(usize, 2, 32); // Maximum filesize for `public/` content. // pub const max_bytes_public_content: usize = std.math.pow(usize, 2, 20); // Maximum filesize for `static/` content (applies only to apps using `jetzig.http.StaticRequest`). // pub const max_bytes_static_content: usize = std.math.pow(usize, 2, 18); // Path relative to cwd() to serve public content from. Symlinks are not followed. // pub const public_content_path = "public"; // HTTP buffer. Must be large enough to store all headers. This should typically not be modified. // pub const http_buffer_size: usize = std.math.pow(usize, 2, 16); // Set custom fragments for rendering markdown templates. Any values will fall back to // defaults provided by Zmd (https://github.com/bobf/zmd/blob/main/src/zmd/html.zig). pub const markdown_fragments = struct { pub const root = .{ "
", "
", }; pub const h1 = .{ "

", "

", }; pub const h2 = .{ "

", "

", }; pub const h3 = .{ "

", "

", }; pub const paragraph = .{ "

", "

", }; pub const code = .{ "", "", }; pub const unordered_list = .{ "", }; pub const ordered_list = .{ "", }; pub fn block(allocator: std.mem.Allocator, node: zmd.Node) ![]const u8 { return try std.fmt.allocPrint(allocator, \\
{s}
, .{ node.meta, node.content }); } pub fn link(allocator: std.mem.Allocator, node: zmd.Node) ![]const u8 { return try std.fmt.allocPrint(allocator, \\{1s} , .{ node.href.?, node.title.? }); } }; }; pub fn main() !void { //var db = try sqlite.Db.init(.{ // .mode = sqlite.Db.Mode{ .File = "/home/swebb/Source/zuletzt/src/app/database/data.db" }, // .open_flags = .{ // .write = true, // .create = true, // }, // .threading_mode = .MultiThread, //}); //const create = // \\CREATE TABLE artists ('artist', 'plays') //; //const query = // \\INSERT INTO artists ('artist', 'plays') VALUES (?,?) //; //var build = try db.prepare(create); //defer build.deinit(); //try build.exec(.{},.{}); //var stmt = try db.prepare(query); //defer stmt.deinit(); //try stmt.exec(.{}, .{ // .artist = "Wilco", // .plays = 2500, //}); var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer std.debug.assert(gpa.deinit() == .ok); const allocator = gpa.allocator(); const app = try jetzig.init(allocator); defer app.deinit(); try app.start(routes, .{}); }