2024-02-28 02:59:24 +00:00
|
|
|
package fact
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
templ (p *FactoidPlugin) factIndex() {
|
|
|
|
<div class="container">
|
|
|
|
<form
|
|
|
|
hx-post="/factoid/search"
|
|
|
|
hx-target="#results">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-10">
|
|
|
|
<input type="text"
|
|
|
|
name="query"
|
|
|
|
class="form-control"
|
|
|
|
placeholder="Query..."
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div class="col-1">
|
|
|
|
<button
|
|
|
|
class="btn btn-secondary"
|
|
|
|
>Search</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<div class="row" id="results">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
|
|
|
|
templ (p *FactoidPlugin) searchResults(facts []*Factoid) {
|
2024-02-28 03:19:25 +00:00
|
|
|
<table class="table">
|
|
|
|
<thead>
|
|
|
|
<tr class="d-flex">
|
|
|
|
<th class="col-2">Fact</th>
|
|
|
|
<th class="col-8">Tidbit</th>
|
|
|
|
<th class="col-1">Owner</th>
|
|
|
|
<th class="col-1">Count</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2024-02-28 02:59:24 +00:00
|
|
|
for _, f := range facts {
|
|
|
|
@p.searchResult(f)
|
|
|
|
}
|
2024-02-28 03:19:25 +00:00
|
|
|
</tbody>
|
2024-02-28 02:59:24 +00:00
|
|
|
</table>
|
|
|
|
}
|
|
|
|
|
|
|
|
templ (p *FactoidPlugin) searchResult(fact *Factoid) {
|
2024-02-28 03:19:25 +00:00
|
|
|
<tr class="d-flex">
|
|
|
|
<td class="col-2">{ fact.Fact }</td>
|
|
|
|
<td class="col-8">{ fact.Tidbit }</td>
|
|
|
|
<td class="col-1">{ fact.Owner }</td>
|
|
|
|
<td class="col-1">{ fmt.Sprint(fact.Count) }</td>
|
2024-02-28 02:59:24 +00:00
|
|
|
</tr>
|
|
|
|
}
|