2020-07-20 01:34:14 +02:00
|
|
|
# Generates a simple web view of open TODOs in the depot.
|
|
|
|
#
|
|
|
|
# Only TODOs that match the form 'TODO($username)' are considered, and
|
|
|
|
# only for users that are known to us.
|
2021-04-10 18:05:16 +02:00
|
|
|
{ depot, lib, pkgs, ... }:
|
2020-07-20 01:34:14 +02:00
|
|
|
|
|
|
|
let
|
2021-04-10 18:05:16 +02:00
|
|
|
inherit (pkgs)
|
2020-07-20 01:34:14 +02:00
|
|
|
jq
|
|
|
|
ripgrep
|
2022-09-26 19:33:05 +02:00
|
|
|
runCommand
|
2021-12-27 02:25:27 +01:00
|
|
|
writeTextFile
|
2020-07-20 01:34:14 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
inherit (builtins)
|
|
|
|
elem
|
|
|
|
filter
|
|
|
|
fromJSON
|
|
|
|
head
|
|
|
|
readFile
|
2021-01-18 12:10:33 +01:00
|
|
|
map
|
2020-07-20 01:34:14 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
inherit (lib) concatStringsSep;
|
|
|
|
|
2021-12-27 02:25:27 +01:00
|
|
|
inherit (depot.nix.yants)
|
|
|
|
defun
|
|
|
|
int
|
|
|
|
string
|
|
|
|
struct
|
|
|
|
;
|
|
|
|
|
2021-01-18 12:10:33 +01:00
|
|
|
knownUsers = map (u: u.username) depot.ops.users;
|
2020-07-20 01:34:14 +02:00
|
|
|
|
|
|
|
todo = struct {
|
|
|
|
file = string;
|
|
|
|
line = int;
|
|
|
|
todo = string;
|
|
|
|
user = string;
|
|
|
|
};
|
|
|
|
|
2022-09-26 19:33:05 +02:00
|
|
|
allTodos = fromJSON (readFile (runCommand "depot-todos.json" { } ''
|
2021-04-12 22:26:55 +02:00
|
|
|
${ripgrep}/bin/rg --json 'TODO\(\w+\):.*$' ${depot.path} | \
|
2020-07-20 01:34:14 +02:00
|
|
|
${jq}/bin/jq -s -f ${./extract-todos.jq} > $out
|
|
|
|
''));
|
|
|
|
|
|
|
|
knownUserTodos = filter (todos: elem (head todos).user knownUsers) allTodos;
|
|
|
|
|
|
|
|
fileLink = defun [ todo string ] (t:
|
|
|
|
''<a style="color: inherit;"
|
|
|
|
href="https://cs.tvl.fyi/depot/-/blob/${t.file}#L${toString t.line}">
|
|
|
|
//${t.file}:${toString t.line}</a>'');
|
|
|
|
|
|
|
|
todoElement = defun [ todo string ] (t: ''
|
2021-04-01 16:23:45 +02:00
|
|
|
<p>${fileLink t}:</p>
|
2020-07-20 01:34:14 +02:00
|
|
|
<blockquote>${t.todo}</blockquote>
|
|
|
|
|
|
|
|
'');
|
|
|
|
|
|
|
|
userParagraph = todos:
|
2022-01-30 17:06:58 +01:00
|
|
|
let user = (head todos).user;
|
|
|
|
in ''
|
|
|
|
<p>
|
|
|
|
<h3>
|
|
|
|
<a style="color:inherit; text-decoration: none;"
|
|
|
|
name="${user}"
|
|
|
|
href="#${user}">${user}</a>
|
|
|
|
</h3>
|
|
|
|
${concatStringsSep "\n" (map todoElement todos)}
|
|
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
'';
|
2020-07-20 01:34:14 +02:00
|
|
|
|
2021-10-01 18:57:43 +02:00
|
|
|
staticUrl = "https://static.tvl.fyi/${depot.web.static.drvHash}";
|
|
|
|
|
2022-01-30 17:06:58 +01:00
|
|
|
in
|
|
|
|
writeTextFile {
|
2021-12-27 02:25:27 +01:00
|
|
|
name = "tvl-todos";
|
|
|
|
destination = "/index.html";
|
|
|
|
text = ''
|
2020-07-20 01:34:14 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<meta name="description" content="TVL's todo-list">
|
2021-10-01 18:57:43 +02:00
|
|
|
<link rel="stylesheet" type="text/css" media="all" href="${staticUrl}/tvl.css">
|
|
|
|
<link rel="icon" type="image/webp" href="${staticUrl}/favicon.webp">
|
2020-07-20 01:34:14 +02:00
|
|
|
<title>TVL's todo-list</title>
|
|
|
|
<style>
|
|
|
|
svg {
|
|
|
|
max-width: inherit;
|
|
|
|
height: auto;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body class="dark">
|
|
|
|
<header>
|
|
|
|
<h1><a class="blog-title" href="/">The Virus Lounge's todo-list</a> </h1>
|
|
|
|
<hr>
|
|
|
|
</header>
|
|
|
|
<main>
|
|
|
|
${concatStringsSep "\n" (map userParagraph knownUserTodos)}
|
|
|
|
</main>
|
|
|
|
<footer>
|
|
|
|
<p class="footer">
|
|
|
|
<a class="uncoloured-link" href="https://tvl.fyi">homepage</a>
|
|
|
|
|
|
|
|
|
<a class="uncoloured-link" href="https://cs.tvl.fyi/depot/-/blob/README.md">code</a>
|
|
|
|
|
|
|
|
|
<a class="uncoloured-link" href="https://cl.tvl.fyi">reviews</a>
|
|
|
|
</p>
|
|
|
|
<p class="lod">ಠ_ಠ</p>
|
|
|
|
</footer>
|
|
|
|
</body>
|
|
|
|
'';
|
2021-12-27 02:25:27 +01:00
|
|
|
}
|