Add views and begin database
This commit is contained in:
parent
348545949a
commit
a15db5fb31
68 changed files with 709 additions and 90 deletions
36
src/app/views/collection.zig
Normal file
36
src/app/views/collection.zig
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
const std = @import("std");
|
||||
const jetzig = @import("jetzig");
|
||||
|
||||
pub fn index(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn get(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn post(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
return request.render(.created);
|
||||
}
|
||||
|
||||
pub fn put(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn patch(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn delete(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
3
src/app/views/collection/get.zmpl
Normal file
3
src/app/views/collection/get.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
8
src/app/views/collection/index.zmpl
Normal file
8
src/app/views/collection/index.zmpl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<body>
|
||||
@partial partials/header
|
||||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
3
src/app/views/collection/patch.zmpl
Normal file
3
src/app/views/collection/patch.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
3
src/app/views/collection/post.zmpl
Normal file
3
src/app/views/collection/post.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
3
src/app/views/collection/put.zmpl
Normal file
3
src/app/views/collection/put.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
36
src/app/views/concerts.zig
Normal file
36
src/app/views/concerts.zig
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
const std = @import("std");
|
||||
const jetzig = @import("jetzig");
|
||||
|
||||
pub fn index(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn get(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn post(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
return request.render(.created);
|
||||
}
|
||||
|
||||
pub fn put(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn patch(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn delete(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
3
src/app/views/concerts/delete.zmpl
Normal file
3
src/app/views/concerts/delete.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
3
src/app/views/concerts/get.zmpl
Normal file
3
src/app/views/concerts/get.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
8
src/app/views/concerts/index.zmpl
Normal file
8
src/app/views/concerts/index.zmpl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<body>
|
||||
@partial partials/header
|
||||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
3
src/app/views/concerts/patch.zmpl
Normal file
3
src/app/views/concerts/patch.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
3
src/app/views/concerts/post.zmpl
Normal file
3
src/app/views/concerts/post.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
3
src/app/views/concerts/put.zmpl
Normal file
3
src/app/views/concerts/put.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
36
src/app/views/lists.zig
Normal file
36
src/app/views/lists.zig
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
const std = @import("std");
|
||||
const jetzig = @import("jetzig");
|
||||
|
||||
pub fn index(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn get(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn post(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
return request.render(.created);
|
||||
}
|
||||
|
||||
pub fn put(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn patch(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn delete(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
3
src/app/views/lists/delete.zmpl
Normal file
3
src/app/views/lists/delete.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
3
src/app/views/lists/get.zmpl
Normal file
3
src/app/views/lists/get.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
8
src/app/views/lists/index.zmpl
Normal file
8
src/app/views/lists/index.zmpl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<body>
|
||||
@partial partials/header
|
||||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
3
src/app/views/lists/patch.zmpl
Normal file
3
src/app/views/lists/patch.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
3
src/app/views/lists/post.zmpl
Normal file
3
src/app/views/lists/post.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
3
src/app/views/lists/put.zmpl
Normal file
3
src/app/views/lists/put.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
const std = @import("std");
|
||||
const jetzig = @import("jetzig");
|
||||
|
||||
pub const static_params = .{
|
||||
.index = .{
|
||||
//.{ .params = .{ .foo = "hi", .bar = "bye" } },
|
||||
//.{ .params = .{ .foo = "hello", .bar = "goodbye" } },
|
||||
},
|
||||
//.get = .{
|
||||
// .{ .id = "1", .params = .{ .foo = "hi", .bar = "bye" } },
|
||||
// .{ .id = "2", .params = .{ .foo = "hello", .bar = "goodbye" } },
|
||||
//},
|
||||
};
|
||||
|
||||
pub fn index(request: *jetzig.StaticRequest, data: *jetzig.Data) !jetzig.View {
|
||||
var root = try data.object();
|
||||
|
||||
const params = try request.params();
|
||||
|
||||
if (params.get("foo")) |foo| try root.put("foo", foo);
|
||||
if (params.get("foo") == null) try root.put("foo", data.string("no foo"));
|
||||
if (params.get("bar")) |bar| try root.put("bar", bar);
|
||||
if (params.get("bar") == null) try root.put("bar", data.string("no bar"));
|
||||
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
//pub fn get(id: []const u8, request: *jetzig.StaticRequest, data: *jetzig.Data) !jetzig.View {
|
||||
// var root = try data.object();
|
||||
//
|
||||
// const params = try request.params();
|
||||
//
|
||||
// if (std.mem.eql(u8, id, "1")) {
|
||||
// try root.put("id", data.string("id is '1'"));
|
||||
// }
|
||||
//
|
||||
// if (params.get("foo")) |foo| try root.put("foo", foo);
|
||||
// if (params.get("bar")) |bar| try root.put("bar", bar);
|
||||
//
|
||||
// return request.render(.created);
|
||||
//}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
<div>{{.foo}}</div>
|
||||
<div>{{.bar}}</div>
|
||||
7
src/app/views/partials/_header.zmpl
Normal file
7
src/app/views/partials/_header.zmpl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<a class="header-link" href="/">Zuletzt</a>
|
||||
<a class="header-link" href="/scrobbles">Scrobbles</a>
|
||||
<a class="header-link" href="/concerts">Concerts</a>
|
||||
<a class="header-link" href="/collection">Collection</a>
|
||||
<a class="header-link" href="/ratings">Ratings</a>
|
||||
<a class="header-link" href="/lists">Lists</a>
|
||||
<hr>
|
||||
36
src/app/views/ratings.zig
Normal file
36
src/app/views/ratings.zig
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
const std = @import("std");
|
||||
const jetzig = @import("jetzig");
|
||||
|
||||
pub fn index(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn get(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn post(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
return request.render(.created);
|
||||
}
|
||||
|
||||
pub fn put(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn patch(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn delete(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
3
src/app/views/ratings/delete.zmpl
Normal file
3
src/app/views/ratings/delete.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
3
src/app/views/ratings/get.zmpl
Normal file
3
src/app/views/ratings/get.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
8
src/app/views/ratings/index.zmpl
Normal file
8
src/app/views/ratings/index.zmpl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<body>
|
||||
@partial partials/header
|
||||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
3
src/app/views/ratings/patch.zmpl
Normal file
3
src/app/views/ratings/patch.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
3
src/app/views/ratings/post.zmpl
Normal file
3
src/app/views/ratings/post.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
3
src/app/views/ratings/put.zmpl
Normal file
3
src/app/views/ratings/put.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<b class="title text-[#123456]">Zuletzt</b>
|
||||
<a class="header-link" href="/artists">Artists</a>
|
||||
<a class="header-link" href="/albums">Albums</a>
|
||||
<a class="header-link" href="/tracks">Tracks</a>
|
||||
<a class="header-link" href="/stats">Stats</a>
|
||||
<hr>
|
||||
|
|
@ -4,11 +4,10 @@
|
|||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<link rel="stylesheet" href="/styles.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@partial root/header
|
||||
@partial root/top
|
||||
@partial partials/header
|
||||
@partial partials/top
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
36
src/app/views/scrobbles.zig
Normal file
36
src/app/views/scrobbles.zig
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
const std = @import("std");
|
||||
const jetzig = @import("jetzig");
|
||||
|
||||
pub fn index(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn get(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn post(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
return request.render(.created);
|
||||
}
|
||||
|
||||
pub fn put(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn patch(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn delete(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
3
src/app/views/scrobbles/delete.zmpl
Normal file
3
src/app/views/scrobbles/delete.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
3
src/app/views/scrobbles/get.zmpl
Normal file
3
src/app/views/scrobbles/get.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
8
src/app/views/scrobbles/index.zmpl
Normal file
8
src/app/views/scrobbles/index.zmpl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<body>
|
||||
@partial partials/header
|
||||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
3
src/app/views/scrobbles/patch.zmpl
Normal file
3
src/app/views/scrobbles/patch.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
3
src/app/views/scrobbles/post.zmpl
Normal file
3
src/app/views/scrobbles/post.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
3
src/app/views/scrobbles/put.zmpl
Normal file
3
src/app/views/scrobbles/put.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
const std = @import("std");
|
||||
const jetzig = @import("jetzig");
|
||||
|
||||
pub fn index(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
return request.render(.ok);
|
||||
}
|
||||
48
src/app/views/upload.zig
Normal file
48
src/app/views/upload.zig
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
const std = @import("std");
|
||||
const jetzig = @import("jetzig");
|
||||
const jetquery = @import("jetzig").jetquery;
|
||||
|
||||
pub fn index(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
try request.repo.insert(.Artist, .{
|
||||
.id = 123,
|
||||
.name = "wilco",
|
||||
.album_num = 10,
|
||||
.song_num = 200,
|
||||
.play_count = 2700,
|
||||
.avg_album_score = 10.0,
|
||||
.avg_song_score = 10.0,
|
||||
.url = "/wilco",
|
||||
.aliased = false,
|
||||
});
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn get(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn post(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
return request.render(.created);
|
||||
}
|
||||
|
||||
pub fn put(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn patch(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
||||
pub fn delete(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
_ = id;
|
||||
return request.render(.ok);
|
||||
}
|
||||
3
src/app/views/upload/delete.zmpl
Normal file
3
src/app/views/upload/delete.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
3
src/app/views/upload/get.zmpl
Normal file
3
src/app/views/upload/get.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
19
src/app/views/upload/index.zmpl
Normal file
19
src/app/views/upload/index.zmpl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<html>
|
||||
<body>
|
||||
@partial partials/header
|
||||
<div>
|
||||
<span>Upload Last.fm or Spotify history file here (in json format).</span>
|
||||
</div>
|
||||
<form action="/" enctype="multipart/form-data" method="POST">
|
||||
<label>Filename</label>
|
||||
<input type="text" name="description" />
|
||||
<label>File</label>
|
||||
<input type="file" name="upload" />
|
||||
<input type="submit" value="Submit" />
|
||||
<fieldset>
|
||||
<input type="radio" name="t" label="Last.fm">Last.fm</input>
|
||||
<input type="radio" name="t" label="Spotify">Spotify</input>
|
||||
</fieldset>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
3
src/app/views/upload/patch.zmpl
Normal file
3
src/app/views/upload/patch.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
3
src/app/views/upload/post.zmpl
Normal file
3
src/app/views/upload/post.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
3
src/app/views/upload/put.zmpl
Normal file
3
src/app/views/upload/put.zmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<span>Content goes here</span>
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue