aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--comments/.gitignore1
-rw-r--r--comments/build.zig.zon5
-rw-r--r--converter/build.zig36
-rw-r--r--converter/build.zig.zon13
-rw-r--r--converter/src/main.zig70
-rw-r--r--converter/src/root.zig10
7 files changed, 4 insertions, 132 deletions
diff --git a/.gitignore b/.gitignore
index e4fec02..bfe2f94 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@ public/
.env
zig-cache/
zig-out/
+.zig-cache
diff --git a/comments/.gitignore b/comments/.gitignore
index 4c82b07..f9a280a 100644
--- a/comments/.gitignore
+++ b/comments/.gitignore
@@ -1,2 +1,3 @@
zig-cache
zig-out
+.zig-cache
diff --git a/comments/build.zig.zon b/comments/build.zig.zon
index 54d1e35..5740fa1 100644
--- a/comments/build.zig.zon
+++ b/comments/build.zig.zon
@@ -10,9 +10,8 @@
.hash = "1220b42673da5f313d4ce816e41de2f17e4b7ebbae1669904b9c17a385d9997e72ed",
//.path = "../../smtp-zig"
}, .mustache = .{
- // TODO revert to balati when https://github.com/batiati/mustache-zig/pull/21 is merged
- .url = "https://github.com/MFAshby/mustache-zig/archive/refs/heads/master.tar.gz",
- .hash = "1220910fce41f46c0f652c3bfe19ca83940b1b26e046d8bdb901e3a9fd0f2b480b1b",
+ .url = "https://github.com/batiati/mustache-zig/archive/ae5ecc1522da983dc39bb0d8b27f5d1b1d7956e3.tar.gz",
+ .hash = "1220ac9e3316ce71ad9cd66c7f215462bf5c187828b50bb3d386549bf6af004e3bb0",
//.path = "../../mustache-zig"
}, .zigwebserver = .{
.url = "https://code.mfashby.net/zigwebserver/snapshot/zigwebserver-main.tar.xz",
diff --git a/converter/build.zig b/converter/build.zig
deleted file mode 100644
index f1563cf..0000000
--- a/converter/build.zig
+++ /dev/null
@@ -1,36 +0,0 @@
-const std = @import("std");
-
-pub fn build(b: *std.Build) void {
- const target = b.standardTargetOptions(.{});
- const optimize = b.standardOptimizeOption(.{});
-
- const exe = b.addExecutable(.{
- .name = "converter",
- .root_source_file = .{ .path = "src/main.zig" },
- .target = target,
- .optimize = optimize,
- });
- const ziggy = b.dependency("ziggy", .{});
- exe.root_module.addImport("ziggy", ziggy.module("ziggy"));
-
- b.installArtifact(exe);
-
- const run_cmd = b.addRunArtifact(exe);
- run_cmd.step.dependOn(b.getInstallStep());
-
- if (b.args) |args| {
- run_cmd.addArgs(args);
- }
- const run_step = b.step("run", "Run the app");
- run_step.dependOn(&run_cmd.step);
-
- const exe_unit_tests = b.addTest(.{
- .root_source_file = .{ .path = "src/main.zig" },
- .target = target,
- .optimize = optimize,
- });
-
- const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
- const test_step = b.step("test", "Run unit tests");
- test_step.dependOn(&run_exe_unit_tests.step);
-}
diff --git a/converter/build.zig.zon b/converter/build.zig.zon
deleted file mode 100644
index 1d3de63..0000000
--- a/converter/build.zig.zon
+++ /dev/null
@@ -1,13 +0,0 @@
-.{
- .name = "converter",
- .version = "0.0.0",
- .dependencies = .{
- .ziggy = .{
- .url = "https://github.com/kristoff-it/ziggy/archive/refs/heads/main.tar.gz",
- .hash = "1220037474a924385b0d2ccb0e5c416c595f43f93a3450d55f8b6d5ad6f3ba091ca5",
- }
- },
- .paths = .{
- "",
- },
-}
diff --git a/converter/src/main.zig b/converter/src/main.zig
deleted file mode 100644
index edaf51f..0000000
--- a/converter/src/main.zig
+++ /dev/null
@@ -1,70 +0,0 @@
-const std = @import("std");
-const ziggy = @import("ziggy");
-
-const Page = struct {
- title: ?[]const u8 = null,
- author: ?[]const u8 = null,
- date: ?[]const u8 = null,
- layout: ?[]const u8 = null,
- // draft: ?bool = null,
- // params: ?struct {
- // comments: bool,
- // } = null,
-};
-
-pub fn main() !void {
- const a = std.heap.page_allocator;
- var args = std.process.args();
- if (!args.skip()) @panic("errors kipping program name?");
- const contentdirname = args.next() orelse return error.NoDir;
- const contentdir = try std.fs.cwd().openDir(contentdirname, .{ .iterate = true });
- var walker = try contentdir.walk(a);
- while (try walker.next()) |we| {
- if (std.mem.endsWith(u8, we.basename, ".md")) {
- std.log.info("converting file {s}", .{we.basename});
- const file = try we.dir.readFileAlloc(a, we.basename, 1_000_000);
- const start = (std.mem.indexOf(u8, file, "---\n") orelse return error.NoFrontmatter) + 4;
- const end = (std.mem.lastIndexOf(u8, file, "---\n") orelse return error.NoFrontMatter);
-
- var childproc = std.process.Child.init(&.{ "yq", "-o", "json" }, a);
- childproc.stdin_behavior = .Pipe;
- childproc.stdout_behavior = .Pipe;
- childproc.stderr_behavior = .Pipe;
- std.log.info("spawn", .{});
- try childproc.spawn();
- std.log.info("writeAll", .{});
- try childproc.stdin.?.writeAll(file[start..end]);
- childproc.stdin.?.close();
- childproc.stdin = null;
-
- var stdout = std.ArrayList(u8).init(a);
- var stderr = std.ArrayList(u8).init(a);
- std.log.info("collectOutput", .{});
- try childproc.collectOutput(&stdout, &stderr, 1_000_000);
- std.log.info("got output {s}", .{stdout.items});
- std.log.info("wait", .{});
- const term = try childproc.wait();
- if (term.Exited != 0) {
- return error.ProcessError;
- }
- const fm_json = try stdout.toOwnedSlice();
- // Now parse it and add missing fields
- const fm_json_parsed_value = try std.json.parseFromSlice(Page, a, fm_json, .{
- .ignore_unknown_fields = true,
- });
- defer fm_json_parsed_value.deinit();
- var fm_json_parsed = fm_json_parsed_value.value;
- fm_json_parsed.title = fm_json_parsed.title orelse "";
- fm_json_parsed.author = fm_json_parsed.author orelse "Martin Ashby";
- fm_json_parsed.date = fm_json_parsed.date orelse "1900-01-01T00:00:00Z";
- fm_json_parsed.layout = fm_json_parsed.layout orelse "single.html";
-
- var out = std.ArrayList(u8).init(a);
- defer out.deinit();
- try ziggy.stringify(fm_json_parsed, .{.whitespace = .space_2}, out.writer());
- const newfile = try std.mem.concat(a, u8, &.{ "---\n", out.items, "\n", file[end..] });
- try we.dir.writeFile(we.basename, newfile);
- }
- }
- std.log.info("done!", .{});
-}
diff --git a/converter/src/root.zig b/converter/src/root.zig
deleted file mode 100644
index ecfeade..0000000
--- a/converter/src/root.zig
+++ /dev/null
@@ -1,10 +0,0 @@
-const std = @import("std");
-const testing = std.testing;
-
-export fn add(a: i32, b: i32) i32 {
- return a + b;
-}
-
-test "basic add functionality" {
- try testing.expect(add(3, 7) == 10);
-}