diff --git a/devenv.nix b/devenv.nix index d33d683..bf06c95 100644 --- a/devenv.nix +++ b/devenv.nix @@ -10,6 +10,7 @@ let in { # https://devenv.sh/basics/ + packages = with pkgs; [ tailwindcss_4 ]; # https://devenv.sh/languages/ languages.zig = { diff --git a/src/main.zig b/src/main.zig index 13048bf..53ca0d3 100644 --- a/src/main.zig +++ b/src/main.zig @@ -3,12 +3,60 @@ const webui = @import("webui"); const std = @import("std"); pub fn main() !void { - // create a new window - var nwin = webui.newWindow(); + const window = webui.newWindow(); - // show the content - try nwin.show("
Hello World ! "); + // Bind all events + _ = try window.bind("", events); + + const port = 8080; + const pathToRootPage = "/home/cholli/projects/website/src/server/"; + + webui.setPort(window, port) catch |err| { + std.debug.print("Could not reserve port {d} due to {any}", .{ port, err }); + webui.exit(); + return; + }; + + _ = webui.startServer(window, pathToRootPage) catch |err| { + std.debug.print("Could not start server due to: {any}", .{err}); + webui.exit(); + return; + }; // wait the window exit webui.wait(); } + +fn events(e: *webui.Event) void { + // This function gets called every time + // there is an event + + switch (e.event_type) { + .EVENT_CONNECTED => { + std.debug.print("Connected. \n", .{}); + }, + .EVENT_DISCONNECTED => { + std.debug.print("Disconnected. \n", .{}); + }, + .EVENT_MOUSE_CLICK => { + std.debug.print("Click. \n", .{}); + }, + .EVENT_NAVIGATION => { + + // get the url string + const url = e.getString(); + + // we use this to get widnow + var win = e.getWindow(); + + std.debug.print("Starting navigation to: {s}\n", .{url}); + + // Because we used `bind(MyWindow, "", events);` + // WebUI will block all `href` link clicks and sent here instead. + // We can then control the behaviour of links as needed. + + win.navigate(url); + }, + else => {}, + } +} diff --git a/src/server/index.html b/src/server/index.html new file mode 100644 index 0000000..446ac91 --- /dev/null +++ b/src/server/index.html @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + +A passionate developer trying to automate and codify as much as I can.
+ + See My Work + ++ I'm a developer with a passion for making my life easier by trying to only do things once. Professionally I + mostly worked with Java and C# and yaml, privately I work a lot with the nix-language, and try to dabble in zig + and rust. When I am not coding I try to sail and do wintersports whenever possible, or maybe you can find me on + a small bike trip in the mountains. +
+This is the main configuration flake for all my devices running nixos, the main + language used is nix
+ View Project +A brief description of the project. Built with Next.js and TypeScript.
+ View Project +A brief description of the project. Built with Vue.js and TailwindCSS.
+ View Project ++ Have a question or want to work together? Feel free to reach out! +
+ + Send Me an Email + +