blob: 8571f6b119badbcfd9a92de4719ff6474a42c0ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
When the db library is /dbLib/ {
set db [__db]
Wish the web server handles route "/statements" with handler {
set l [list]
# You need to use the Simple form so it doesn't auto-claimize it.
set results [QuerySimple! false /...terms/]
foreach result $results { dict with result {
set childMatchRefs [$dbLib childMatches $db $__ref]
set childMatchInfo [join [lmap childMatchRef $childMatchRefs {
set childStatementRefs [$dbLib childStatements $db $childMatchRef]
subst {
\[ $childMatchRef ($childStatementRefs) \]
}
}] " "]
lappend l [subst {
<li>
<details>
<summary style="[expr {
[lsearch -exact $terms error] != -1
? "color: red"
: ""}]">
$__ref ([$dbLib statementParentCount $db $__ref]): <code>[htmlEscape [string range $terms 0 100]]</code> ($childMatchInfo)</summary>
<pre>[htmlEscape $terms]</pre>
</details>
</li>
}]
} }
html [subst {
<html>
<head>
<link rel="stylesheet" href="/style.css">
<title>Statements</title>
</head>
<h1>Statements</h1>
<ul>[join $l "\n"]</ul>
</html>
}]
}
}
|