diff --git a/.gitignore b/.gitignore index 9f6d7b4..23cb6fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ zig-out/ -zig-cache/ +.zig-cache/ *.core static/ .jetzig -src/app/database/data.db-journal \ No newline at end of file +src/app/database/data.db-journal diff --git a/src/app/views/music.zig b/src/app/views/music.zig new file mode 100644 index 0000000..4dd0d07 --- /dev/null +++ b/src/app/views/music.zig @@ -0,0 +1,41 @@ +const std = @import("std"); +const jetzig = @import("jetzig"); + +pub const static_params = .{ + .index = .{ + //.{ .params = .{ .foo = "hi", .bar = "bye" } }, + //.{ .params = .{ .foo = "hello", .bar = "goodbye" } }, + }, + //.get = .{ + // .{ .id = "1", .params = .{ .foo = "hi", .bar = "bye" } }, + // .{ .id = "2", .params = .{ .foo = "hello", .bar = "goodbye" } }, + //}, +}; + +pub fn index(request: *jetzig.StaticRequest, data: *jetzig.Data) !jetzig.View { + var root = try data.object(); + + const params = try request.params(); + + if (params.get("foo")) |foo| try root.put("foo", foo); + if (params.get("foo") == null) try root.put("foo", data.string("no foo")); + if (params.get("bar")) |bar| try root.put("bar", bar); + if (params.get("bar") == null) try root.put("bar", data.string("no bar")); + + return request.render(.ok); +} + +//pub fn get(id: []const u8, request: *jetzig.StaticRequest, data: *jetzig.Data) !jetzig.View { +// var root = try data.object(); +// +// const params = try request.params(); +// +// if (std.mem.eql(u8, id, "1")) { +// try root.put("id", data.string("id is '1'")); +// } +// +// if (params.get("foo")) |foo| try root.put("foo", foo); +// if (params.get("bar")) |bar| try root.put("bar", bar); +// +// return request.render(.created); +//} \ No newline at end of file diff --git a/src/app/views/music/index.zmpl b/src/app/views/music/index.zmpl new file mode 100644 index 0000000..a14b357 --- /dev/null +++ b/src/app/views/music/index.zmpl @@ -0,0 +1,2 @@ +
{{.foo}}
+
{{.bar}}
\ No newline at end of file