2023-10-07 17:12:47 +01:00
|
|
|
package server
|
|
|
|
|
|
|
|
import "html/template"
|
|
|
|
|
|
|
|
var home = template.Must(template.New("home").Parse(`
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<link rel="stylesheet" href="/assets/simple.css">
|
|
|
|
<link rel="stylesheet" href="/assets/custom.css">
|
|
|
|
<script src="/assets/htmx.min.js"></script>
|
|
|
|
<title>Anagram and Word Search</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<header>
|
|
|
|
<h1>Anagram and Word Search</h1>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<main>
|
2023-10-08 14:25:57 +01:00
|
|
|
<form action="/search" method="post" hx-boost="true" hx-target="#results">
|
2023-10-07 17:12:47 +01:00
|
|
|
<div class="center">
|
|
|
|
<input type="text" name="pattern" required></input>
|
|
|
|
<button name="mode" value="match">Match</button>
|
|
|
|
<button name="mode" value="anagrams">Anagrams</button>
|
2023-10-08 14:25:57 +01:00
|
|
|
<button type="reset">Clear</button>
|
2023-10-07 17:12:47 +01:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<div id="results">
|
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
`))
|
|
|
|
|
2023-10-07 18:05:05 +01:00
|
|
|
type ResultParams struct {
|
|
|
|
Preamble string
|
|
|
|
Results []string
|
|
|
|
}
|
|
|
|
|
2023-10-07 17:12:47 +01:00
|
|
|
var results = template.Must(template.New("results").Parse(`
|
|
|
|
{{ with .Preamble }}
|
|
|
|
<p>{{ . }}</p>
|
|
|
|
{{ end }}
|
|
|
|
<ul>
|
|
|
|
{{ range .Results }}
|
|
|
|
<li>{{.}}</li>
|
|
|
|
{{ end }}
|
|
|
|
</ul>
|
|
|
|
`))
|