catbase/plugins/fact/fact.templ

55 lines
1.4 KiB
Plaintext

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) {
<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>
for _, f := range facts {
@p.searchResult(f)
}
</tbody>
</table>
}
templ (p *FactoidPlugin) searchResult(fact *Factoid) {
<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>
</tr>
}