2024-02-28 02:59:24 +00:00
|
|
|
package fact
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
templ (p *FactoidPlugin) factIndex() {
|
2024-02-28 15:28:51 +00:00
|
|
|
<div class="grid-container">
|
|
|
|
<div class="grid-x">
|
|
|
|
<div class="cell">
|
|
|
|
<h2>Factoid</h2>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-02-28 02:59:24 +00:00
|
|
|
<form
|
|
|
|
hx-post="/factoid/search"
|
|
|
|
hx-target="#results">
|
2024-02-28 15:28:51 +00:00
|
|
|
<div class="grid-x grid-margin-x">
|
|
|
|
<div class="cell auto">
|
2024-02-28 02:59:24 +00:00
|
|
|
<input type="text"
|
|
|
|
name="query"
|
|
|
|
class="form-control"
|
|
|
|
placeholder="Query..."
|
|
|
|
/>
|
|
|
|
</div>
|
2024-02-28 15:28:51 +00:00
|
|
|
<div class="cell small-1">
|
|
|
|
<button class="button">Search</button>
|
2024-02-28 02:59:24 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
2024-02-28 15:28:51 +00:00
|
|
|
<div class="grid-x" id="results">
|
2024-02-28 02:59:24 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
|
|
|
|
templ (p *FactoidPlugin) searchResults(facts []*Factoid) {
|
2024-02-28 03:19:25 +00:00
|
|
|
<table class="table">
|
|
|
|
<thead>
|
2024-02-28 15:28:51 +00:00
|
|
|
<tr>
|
|
|
|
<th>Fact</th>
|
|
|
|
<th>Tidbit</th>
|
|
|
|
<th>Owner</th>
|
|
|
|
<th>Count</th>
|
2024-02-28 03:19:25 +00:00
|
|
|
</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 15:28:51 +00:00
|
|
|
<tr>
|
|
|
|
<td>{ fact.Fact }</td>
|
|
|
|
<td>{ fact.Tidbit }</td>
|
|
|
|
<td>{ fact.Owner }</td>
|
|
|
|
<td>{ fmt.Sprint(fact.Count) }</td>
|
2024-02-28 02:59:24 +00:00
|
|
|
</tr>
|
|
|
|
}
|