diff --git a/.gitignore b/.gitignore index 9f6d7b4..1b3afe7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ zig-cache/ *.core static/ .jetzig -src/app/database/data.db-journal \ No newline at end of file +src/app/database/ \ No newline at end of file diff --git a/build.zig b/build.zig index 88fed1c..e488390 100644 --- a/build.zig +++ b/build.zig @@ -15,7 +15,7 @@ pub fn build(b: *std.Build) !void { // Example dependency: const iguanas_dep = b.dependency("iguanas", .{ .optimize = optimize, .target = target }); exe.root_module.addImport("iguanas", iguanas_dep.module("iguanas")); - + const sqlite = b.dependency("sqlite", .{ .target = target, .optimize = optimize, @@ -28,7 +28,7 @@ pub fn build(b: *std.Build) !void { // All dependencies **must** be added to imports above this line. - try jetzig.jetzigInit(b, exe, .{ .zmpl_version = .v2 }); + try jetzig.jetzigInit(b, exe, .{.zmpl_version = .v2}); b.installArtifact(exe); diff --git a/build.zig.zon b/build.zig.zon index ff7ee12..578092d 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -14,16 +14,20 @@ // `zig build --fetch` can be used to fetch all dependencies of a package, recursively. // Once all dependencies are fetched, `zig build` no longer requires // internet connectivity. - .dependencies = .{ .jetzig = .{ - .url = "https://github.com/jetzig-framework/jetzig/archive/88abe2243d87b28ad110c5fe9fe90b716a6c6583.tar.gz", - .hash = "12200d15cef72d4c37a01c930db53c3ffafdc05142462afddeab818701a0291327d1", - }, .iguanas = .{ - .url = "https://github.com/jetzig-framework/iguanas/archive/89c2abf29de0bc31054a9a6feac5a6a83bab0459.tar.gz", - .hash = "12202fd319a5ab4e124b00e8ddea474d07c19c4e005d77b6c29fc44860904ea01a5c", - }, .sqlite = .{ - .url = "https://github.com/vrischmann/zig-sqlite/archive/6af21bb.tar.gz", - .hash = "12202799861d92c7880d1a74f95be099752d7f0420a0c9628dc923ca2b1a22b7bda8", - } }, + .dependencies = .{ + .jetzig = .{ + .url = "https://github.com/jetzig-framework/jetzig/archive/68ca4d3bbad05880e6e38fc6d10e7a24e772081e.tar.gz", + .hash = "122047ebabab1dfe1bb7f96ffdac98410ffb4850b06dc6b1670ce74aaeaa49bdc08e", + }, + .iguanas = .{ + .url = "https://github.com/jetzig-framework/iguanas/archive/89c2abf29de0bc31054a9a6feac5a6a83bab0459.tar.gz", + .hash = "12202fd319a5ab4e124b00e8ddea474d07c19c4e005d77b6c29fc44860904ea01a5c", + }, + .sqlite = .{ + .url = "https://github.com/vrischmann/zig-sqlite/archive/6af21bb.tar.gz", + .hash = "12202799861d92c7880d1a74f95be099752d7f0420a0c9628dc923ca2b1a22b7bda8", + } + }, .paths = .{ // This makes *all* files, recursively, included in this package. It is generally // better to explicitly list the files and directories instead, to insure that diff --git a/public/styles.css b/public/styles.css index afdbce9..1755d47 100644 --- a/public/styles.css +++ b/public/styles.css @@ -3,23 +3,8 @@ * * */ - @import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap'); -.title { - font-family: 'Roboto'; +.message { + font-weight: bold; font-size: 3rem; - font-weight: 500; - margin-left: 20px; - margin-right: 40px; - margin-top: 20px; -} - -.header-link{ - font-family: 'Roboto'; - font-size: 1.5rem; - margin-right: 20px; -} - -#replaceMe{ - font-family:'Courier New'; } diff --git a/src/app/database/data.db b/src/app/database/data.db deleted file mode 100644 index fa37ab7..0000000 Binary files a/src/app/database/data.db and /dev/null differ diff --git a/src/app/lib/db.zig b/src/app/lib/db.zig deleted file mode 100644 index dd6f7bf..0000000 --- a/src/app/lib/db.zig +++ /dev/null @@ -1,22 +0,0 @@ -pub const addArtist = \\INSERT INTO artists ('artist', 'plays', 'url') VALUES (?,?) -; - -pub const addTrack = \\INSERT INTO tracks ('artist', 'track', 'album', 'plays', 'url') VALUES (?,?,?,?) -; - -pub const getArtist = \\SELECT artist, plays FROM artists WHERE artist == ? -; - -pub const getTrack = \\SELECT artist, track, album, plays FROM tracks WHERE track == ? -; - -pub const getTrackSearch = \\SELECT track, url, form FROM tracks WHERE track LIKE '%' || ? || '%' -; - -pub const getArtistSearch = \\SELECT artist, url, form FROM artists WHERE artist LIKE '%' || ? || '%' -; - -pub const getAlbumSearch = \\SELECT album, url, form FROM albums WHERE album LIKE '%' || ? || '%' -; - -pub const total_search = getArtistSearch ++ " UNION " ++ getAlbumSearch ++ " UNION " ++ getTrackSearch; \ No newline at end of file diff --git a/src/app/views/root.zig b/src/app/views/root.zig index d567fc5..0fa146c 100644 --- a/src/app/views/root.zig +++ b/src/app/views/root.zig @@ -1,4 +1,3 @@ -const std = @import("std"); const jetzig = @import("jetzig"); /// `src/app/views/root.zig` represents the root URL `/` @@ -19,7 +18,7 @@ pub fn index(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View { var root = try data.object(); // Add a string to the root object. - try root.put("welcome_message", data.string("Welcome to Jetzig!")); + try root.put("message", data.string("Welcome to Jetzig!")); // Request params have the same type as a `data.object()` so they can be inserted them // directly into the response data. Fetch `http://localhost:8080/?message=hello` to set the @@ -27,7 +26,9 @@ pub fn index(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View { // present. const params = try request.params(); - try root.put("message_param", params.get("message")); + if (params.get("message")) |value| { + try root.put("message_param", value); + } // Set arbitrary response headers as required. `content-type` is automatically assigned for // HTML, JSON responses. diff --git a/src/app/views/root/_content.zmpl b/src/app/views/root/_content.zmpl new file mode 100644 index 0000000..088ab6b --- /dev/null +++ b/src/app/views/root/_content.zmpl @@ -0,0 +1,20 @@ + +

+
+
+