diff --git a/build.zig b/build.zig index d1eca1b..f7f33bf 100644 --- a/build.zig +++ b/build.zig @@ -16,7 +16,7 @@ pub fn build(b: *std.Build) void { const optimize = b.standardOptimizeOption(.{}); const lib = b.addStaticLibrary(.{ - .name = "jungle_zig", + .name = "aoc_zig", // In this case the main source file is merely a path, however, in more // complicated build scripts, this could be a generated file. .root_source_file = b.path("src/root.zig"), @@ -30,7 +30,7 @@ pub fn build(b: *std.Build) void { b.installArtifact(lib); const exe = b.addExecutable(.{ - .name = "jungle_zig", + .name = "aoc_zig", .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, diff --git a/build.zig.zon b/build.zig.zon index 87d9ad1..97beeb9 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,5 +1,5 @@ .{ - .name = "jungle_zig", + .name = "aoc_zig", // This is a [Semantic Version](https://semver.org/). // In a future version of Zig it will be used for package deduplication. .version = "0.0.0", diff --git a/src/main.zig b/src/main.zig index 2ac6ea1..236241d 100644 --- a/src/main.zig +++ b/src/main.zig @@ -19,7 +19,7 @@ const Allocator = std.mem.Allocator; // r.sendBody("404 - File not found") catch return; //} -pub const JungleRouter = struct { +pub const WebRouter = struct { const Self = @This(); allocator: Allocator, @@ -83,9 +83,10 @@ pub fn main() !void { .not_found = not_found, }); defer router.deinit(); - var jungle_router = JungleRouter.init(allocator); - try router.handle_func("/", &jungle_router, &JungleRouter.index); - try router.handle_func("/home", &jungle_router, &JungleRouter.home); + var web_router = WebRouter.init(allocator); + try router.handle_func("/home", &web_router, &WebRouter.home); + try router.handle_func("/index", &web_router, &WebRouter.index); + try router.handle_func("/", &web_router, &WebRouter.index); var listener = zap.HttpListener.init(.{ .port = 3000, .on_request = router.on_request_handler(), .log = true, .max_clients = 100000, .public_folder = "src/public" }); try listener.listen(); diff --git a/src/public/index.html b/src/public/index.html index 9d8467a..35aedb2 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -1,29 +1,52 @@ - - - - mskor - - - + + + + Newcastle AOC + + + - -
-

mskor

-
- -
-
- -
-
+ + +
+ pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{ + .thread_safe = true, + }){}; + const allocator = gpa.allocator(); + var router = zap.Router.init(allocator, .{ + .not_found = not_found, + }); + defer router.deinit(); + var web_router = WebRouter.init(allocator); + try router.handle_func("/home", &web_router, &WebRouter.home); + try router.handle_func("/index", &web_router, &WebRouter.index); + try router.handle_func("/", &web_router, &WebRouter.index); + var listener = zap.HttpListener.init(.{ .port = 3000, .on_request = router.on_request_handler(), .log = true, .max_clients = 100000, .public_folder = "src/public" }); + try listener.listen(); + + std.debug.print("Listening on 0.0.0.0:3000\n", .{}); + + zap.start(.{ + .threads = 2, + .workers = 1, // 1 worker enables sharing state between threads + }); + } +
diff --git a/src/public/logo.png b/src/public/logo.png new file mode 100644 index 0000000..73812b2 Binary files /dev/null and b/src/public/logo.png differ diff --git a/src/public/style.css b/src/public/style.css index 139f60b..63ff5a4 100644 --- a/src/public/style.css +++ b/src/public/style.css @@ -1,4 +1,4 @@ -html { +body { max-width:70%; margin:40px auto; font-size:18px; @@ -9,7 +9,7 @@ html { a { text-decoration:none; - color:MediumSeaGreen; + color:Black; } td { @@ -27,6 +27,24 @@ img { height:100%; } +#header { + position:relative; + padding:5px; + background-color:#123; + top:0px; +} + +#header img { + float:left; + display:block; + width:25%; + height:25%; + top:0px; + object-fit:scale-down; +} + + + @media (prefers-color-scheme:dark) { body { background-color:#222;