diff --git a/build.zig b/build.zig index 18f3429..19456fa 100644 --- a/build.zig +++ b/build.zig @@ -173,7 +173,7 @@ pub fn jetzigInit(b: *std.Build, exe: *std.Build.Step.Compile, options: JetzigIn if (!std.mem.eql(u8, ".zig", std.fs.path.extension(entry.path))) continue; const stat = try src_dir.statFile(entry.path); - const src_data = try src_dir.readFileAlloc(b.allocator, entry.path, stat.size); + const src_data = try src_dir.readFileAlloc(b.allocator, entry.path, @intCast(stat.size)); defer b.allocator.free(src_data); const relpath = try std.fs.path.join(b.allocator, &[_][]const u8{ "src", entry.path }); @@ -216,7 +216,7 @@ fn generateMarkdownFragments(b: *std.Build) ![]const u8 { } }; const stat = try file.stat(); - const source = try file.readToEndAllocOptions(b.allocator, stat.size, null, @alignOf(u8), 0); + const source = try file.readToEndAllocOptions(b.allocator, @intCast(stat.size), null, @alignOf(u8), 0); if (try getMarkdownFragmentsSource(b.allocator, source)) |markdown_fragments_source| { return try std.fmt.allocPrint(b.allocator, \\const std = @import("std"); diff --git a/build.zig.zon b/build.zig.zon index ebf6b63..2754e5e 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -3,12 +3,12 @@ .version = "0.0.0", .dependencies = .{ .zmd = .{ - .url = "https://github.com/jetzig-framework/zmd/archive/45a9ff0e3a55b4758163abad5a601bd3ef8127a8.tar.gz", - .hash = "122067a3107499e4b561a883a9f1e9f39662c4b87249a2e4e630279bd91ab7840230", + .url = "https://github.com/jetzig-framework/zmd/archive/557ab8a29c0f7b5d096070cde2858cf27da8b0f1.tar.gz", + .hash = "1220482f07f2bbaef335f20d6890c15a1e14739950b784232bc69182423520e058a5", }, .zmpl = .{ - .url = "https://github.com/jetzig-framework/zmpl/archive/9712b85e61f33879f388d5e1829856e326c53822.tar.gz", - .hash = "1220b185cf8316ae5ad6dd7d45bea278575391986b7d8233a9d9b2c342e339d65ac0", + .url = "https://github.com/jetzig-framework/zmpl/archive/046c05d376a4fe89d86c52596baa18137891cd87.tar.gz", + .hash = "1220d8890b1161e4356d2c59d4b88280566d55480dae840b6f5dae34bf852bef6b56", }, .args = .{ .url = "https://github.com/MasterQ32/zig-args/archive/01d72b9a0128c474aeeb9019edd48605fa6d95f7.tar.gz", diff --git a/cli/commands/generate.zig b/cli/commands/generate.zig index 059599d..fd7259f 100644 --- a/cli/commands/generate.zig +++ b/cli/commands/generate.zig @@ -42,19 +42,36 @@ pub fn run( var sub_args = std.ArrayList([]const u8).init(allocator); defer sub_args.deinit(); - const map = std.ComptimeStringMap(Generator, .{ - .{ "view", .view }, - .{ "partial", .partial }, - .{ "layout", .layout }, - .{ "job", .job }, - .{ "mailer", .mailer }, - .{ "middleware", .middleware }, - .{ "secret", .secret }, - }); - var available_buf = std.ArrayList([]const u8).init(allocator); defer available_buf.deinit(); - for (map.kvs) |kv| try available_buf.append(kv.key); + + // XXX: 0.12 Compatibility + const map = if (@hasDecl(std, "ComptimeStringMap")) blk: { + const inner_map = std.ComptimeStringMap(Generator, .{ + .{ "view", .view }, + .{ "partial", .partial }, + .{ "layout", .layout }, + .{ "job", .job }, + .{ "mailer", .mailer }, + .{ "middleware", .middleware }, + .{ "secret", .secret }, + }); + for (inner_map.kvs) |kv| try available_buf.append(kv.key); + break :blk inner_map; + } else if (@hasDecl(std, "StaticStringMap")) blk: { + const inner_map = std.StaticStringMap(Generator).initComptime(.{ + .{ "view", .view }, + .{ "partial", .partial }, + .{ "layout", .layout }, + .{ "job", .job }, + .{ "mailer", .mailer }, + .{ "middleware", .middleware }, + .{ "secret", .secret }, + }); + for (inner_map.keys()) |key| try available_buf.append(key); + break :blk inner_map; + } else unreachable; + const available_help = try std.mem.join(allocator, "|", available_buf.items); defer allocator.free(available_help); diff --git a/cli/compile.zig b/cli/compile.zig index b1bb2ef..1875896 100644 --- a/cli/compile.zig +++ b/cli/compile.zig @@ -45,7 +45,7 @@ pub fn initDataModule(build: *std.Build) !*std.Build.Module { const stat = try dir.statFile(path); const encoded = base64Encode( build.allocator, - try dir.readFileAlloc(build.allocator, path, stat.size), + try dir.readFileAlloc(build.allocator, path, @intCast(stat.size)), ); defer build.allocator.free(encoded); diff --git a/demo/src/app/views/quotes.zig b/demo/src/app/views/quotes.zig index 3626913..3ee13f6 100644 --- a/demo/src/app/views/quotes.zig +++ b/demo/src/app/views/quotes.zig @@ -37,7 +37,7 @@ const Quote = struct { fn randomQuote(allocator: std.mem.Allocator) !Quote { const path = "src/app/config/quotes.json"; const stat = try std.fs.cwd().statFile(path); - const json = try std.fs.cwd().readFileAlloc(allocator, path, stat.size); + const json = try std.fs.cwd().readFileAlloc(allocator, path, @intCast(stat.size)); const quotes = try std.json.parseFromSlice([]Quote, allocator, json, .{}); return quotes.value[std.crypto.random.intRangeLessThan(usize, 0, quotes.value.len)]; } diff --git a/demo/src/app/views/root/index.zmpl b/demo/src/app/views/root/index.zmpl index f5fc30b..1fb1e42 100644 --- a/demo/src/app/views/root/index.zmpl +++ b/demo/src/app/views/root/index.zmpl @@ -16,9 +16,3 @@
Take a look at the /demo/src/app/ directory to see how this application works.
Visit jetzig.dev to get started.
- -@markdown { - # Hello - - [foobar](https://www.google.com) -} diff --git a/src/GenerateMimeTypes.zig b/src/GenerateMimeTypes.zig index e1353e7..e908f1a 100644 --- a/src/GenerateMimeTypes.zig +++ b/src/GenerateMimeTypes.zig @@ -10,7 +10,7 @@ const JsonMimeType = struct { pub fn generateMimeModule(build: *std.Build) !*std.Build.Module { const file = try std.fs.openFileAbsolute(build.pathFromRoot("src/jetzig/http/mime/mimeData.json"), .{}); const stat = try file.stat(); - const json = try file.readToEndAlloc(build.allocator, stat.size); + const json = try file.readToEndAlloc(build.allocator, @intCast(stat.size)); defer build.allocator.free(json); const parsed_mime_types = try std.json.parseFromSlice( diff --git a/src/Routes.zig b/src/Routes.zig index 3540911..10a5b2e 100644 --- a/src/Routes.zig +++ b/src/Routes.zig @@ -296,7 +296,7 @@ const RouteSet = struct { fn generateRoutesForView(self: *Routes, dir: std.fs.Dir, path: []const u8) !RouteSet { const stat = try dir.statFile(path); - const source = try dir.readFileAllocOptions(self.allocator, path, stat.size, null, @alignOf(u8), 0); + const source = try dir.readFileAllocOptions(self.allocator, path, @intCast(stat.size), null, @alignOf(u8), 0); defer self.allocator.free(source); self.ast = try std.zig.Ast.parse(self.allocator, source, .zig); diff --git a/src/jetzig/markdown.zig b/src/jetzig/markdown.zig index d02ac86..397d943 100644 --- a/src/jetzig/markdown.zig +++ b/src/jetzig/markdown.zig @@ -33,7 +33,7 @@ pub fn render( else => err, }; }; - const markdown_content = std.fs.cwd().readFileAlloc(allocator, full_path, stat.size) catch |err| { + const markdown_content = std.fs.cwd().readFileAlloc(allocator, full_path, @intCast(stat.size)) catch |err| { switch (err) { error.FileNotFound => return null, else => return err,