download patch
commit 2591f18b4ceeaa1f14d29757102ff0647b6a4106
Author: tri <tri@thac.loan>
Date: Mon Sep 29 11:32:10 2025 +0700
put web assets into web dir too
To avoid littering the repos root dir too much.
diff --git a/src/main.zig b/src/main.zig
index ed33bc6..dd974eb 100644
--- a/src/main.zig
+++ b/src/main.zig
const println = @import("utils.zig").println;
const git = @import("git.zig");
const html = @import("html.zig");
-const web_prefix = "-";
+const web_path = "-";
+const assets_path = web_path ++ "/-khoe-hang";
pub fn main() !u8 {
if (std.os.argv.len != 3) {
pub fn main() !u8 {
try writeHomePage(target_dir, repo_summaries.items);
+ var assets_dir = try target_dir.makeOpenPath(assets_path, .{});
inline for (.{ "style.css", "script.js" }) |asset_name| {
- try target_dir.writeFile(.{
- .sub_path = asset_name,
+ try assets_dir.writeFile(.{
.data = @embedFile("assets/" ++ asset_name),
+ .sub_path = asset_name,
});
}
pub fn writeHomePage(dir: fs.Dir, repos: []RepoSummary) !void {
\\ <meta charset="utf-8" />
\\ <title>Khoe</title>
\\ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- \\ <link rel="stylesheet" href="/style.css">
- \\ <script src="/script.js"></script>
+ \\ <link rel="stylesheet" href="/-/-khoe-hang/style.css">
+ \\ <script src="/-/-khoe-hang/script.js"></script>
\\ </head>
\\ <body>
\\ <header>
pub fn writeHomePage(dir: fs.Dir, repos: []RepoSummary) !void {
\\
,
.{
- web_prefix, // 0
+ web_path, // 0
repo.name, // 1
repo.commit_count, // 2
repo.last_commit_msg, // 3
pub fn writeRepoPage(args: RepoArgs) !void {
var buf: [1024]u8 = undefined;
var out_repo_dir = try target_dir.makeOpenPath(
- try std.fmt.bufPrint(&buf, "{s}/{s}", .{ web_prefix, repo_name }),
+ try std.fmt.bufPrint(&buf, "{s}/{s}", .{ web_path, repo_name }),
.{},
);
defer out_repo_dir.close();
pub fn writeRepoPage(args: RepoArgs) !void {
\\ <meta charset="utf-8" />
\\ <title>{0s} | Khoe</title>
\\ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- \\ <link rel="stylesheet" href="/style.css">
- \\ <script src="/script.js"></script>
+ \\ <link rel="stylesheet" href="/-/-khoe-hang/style.css">
+ \\ <script src="/-/-khoe-hang/script.js"></script>
\\ </head>
\\ <body>
\\ <header>