Update standalone server
* Use embedded data sources * Optionally listen on a Unix domain socket * Server htmx and CSS from remote CDNs.
This commit is contained in:
parent
f15c6ba2f5
commit
0ecc755b66
10 changed files with 76 additions and 747 deletions
17
go.sum
17
go.sum
|
@ -353,7 +353,6 @@ cloud.google.com/go/functions v1.9.0/go.mod h1:Y+Dz8yGguzO3PpIjhLTbnqV1CWmgQ5Uwt
|
|||
cloud.google.com/go/functions v1.10.0/go.mod h1:0D3hEOe3DbEvCXtYOZHQZmD+SzYsi1YbI7dGvHfldXw=
|
||||
cloud.google.com/go/functions v1.12.0/go.mod h1:AXWGrF3e2C/5ehvwYo/GH6O5s09tOPksiKhz+hH8WkA=
|
||||
cloud.google.com/go/functions v1.13.0/go.mod h1:EU4O007sQm6Ef/PwRsI8N2umygGqPBS/IZQKBQBcJ3c=
|
||||
cloud.google.com/go/functions v1.15.1 h1:LtAyqvO1TFmNLcROzHZhV0agEJfBi+zfMZsF4RT/a7U=
|
||||
cloud.google.com/go/functions v1.15.1/go.mod h1:P5yNWUTkyU+LvW/S9O6V+V423VZooALQlqoXdoPz5AE=
|
||||
cloud.google.com/go/functions v1.15.3/go.mod h1:r/AMHwBheapkkySEhiZYLDBwVJCdlRwsm4ieJu35/Ug=
|
||||
cloud.google.com/go/functions v1.16.1 h1:0kcko/2AKwm4USnWcGs/W/k++PAYPA3dYaQw1y5Xg3M=
|
||||
|
@ -762,8 +761,6 @@ gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zum
|
|||
git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/GoogleCloudPlatform/functions-framework-go v1.8.0 h1:T6A2/y11ew21+jYVgM8d6MeLuzBCLIhjuYqPWamNM/8=
|
||||
github.com/GoogleCloudPlatform/functions-framework-go v1.8.0/go.mod h1:KpD6tyJWaVnELorVNG+GgBxCNZSVnyWDIZOtibAfAH0=
|
||||
github.com/GoogleCloudPlatform/functions-framework-go v1.8.1 h1:wMO6lE8uR68ReG+/XwSgjTm79o4xJ+Aj9pNnCMnQzPk=
|
||||
github.com/GoogleCloudPlatform/functions-framework-go v1.8.1/go.mod h1:kKqAKLm08tjDVs37IG/Dl4hC1/go4E85Udn1LeSdAEI=
|
||||
github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk=
|
||||
|
@ -790,7 +787,6 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR
|
|||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cloudevents/sdk-go/v2 v2.14.0 h1:Nrob4FwVgi5L4tV9lhjzZcjYqFVyJzsA56CwPaPfv6s=
|
||||
github.com/cloudevents/sdk-go/v2 v2.14.0/go.mod h1:xDmKfzNjM8gBvjaF8ijFjM1VYOVUEeUfapHMUX1T5To=
|
||||
github.com/cloudevents/sdk-go/v2 v2.15.2 h1:54+I5xQEnI73RBhWHxbI1XJcqOFOVJN85vb41+8mHUc=
|
||||
github.com/cloudevents/sdk-go/v2 v2.15.2/go.mod h1:lL7kSWAE/V8VI4Wh0jbL2v/jvqsm6tjmaQBSvxcv4uE=
|
||||
|
@ -907,8 +903,9 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
|||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||
|
@ -938,7 +935,6 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
|
|||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
|
||||
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
|
@ -1050,7 +1046,6 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
|||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
|
||||
|
@ -1078,15 +1073,12 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe
|
|||
go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
|
||||
go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
|
||||
go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
|
||||
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
|
||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
|
@ -1389,7 +1381,6 @@ golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
|||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
|
@ -1399,9 +1390,9 @@ golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxb
|
|||
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.1.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
|
||||
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
||||
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
div.center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div#results {
|
||||
height: 60dvh;
|
||||
}
|
||||
|
||||
div#results > ul {
|
||||
list-style-type: none;
|
||||
overflow-y: auto;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
span.small {
|
||||
font-size: x-small;
|
||||
}
|
1
standalone/assets/htmx.min.js
vendored
1
standalone/assets/htmx.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,685 +0,0 @@
|
|||
/* Global variables. */
|
||||
:root,
|
||||
::backdrop {
|
||||
/* Set sans-serif & mono fonts */
|
||||
--sans-font: -apple-system, BlinkMacSystemFont, "Avenir Next", Avenir,
|
||||
"Nimbus Sans L", Roboto, "Noto Sans", "Segoe UI", Arial, Helvetica,
|
||||
"Helvetica Neue", sans-serif;
|
||||
--mono-font: Consolas, Menlo, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
|
||||
--standard-border-radius: 5px;
|
||||
|
||||
/* Default (light) theme */
|
||||
--bg: #fff;
|
||||
--accent-bg: #f5f7ff;
|
||||
--text: #212121;
|
||||
--text-light: #585858;
|
||||
--border: #898EA4;
|
||||
--accent: #0d47a1;
|
||||
--code: #d81b60;
|
||||
--preformatted: #444;
|
||||
--marked: #ffdd33;
|
||||
--disabled: #efefef;
|
||||
}
|
||||
|
||||
/* Dark theme */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root,
|
||||
::backdrop {
|
||||
color-scheme: dark;
|
||||
--bg: #212121;
|
||||
--accent-bg: #2b2b2b;
|
||||
--text: #dcdcdc;
|
||||
--text-light: #ababab;
|
||||
--accent: #ffb300;
|
||||
--code: #f06292;
|
||||
--preformatted: #ccc;
|
||||
--disabled: #111;
|
||||
}
|
||||
/* Add a bit of transparency so light media isn't so glaring in dark mode */
|
||||
img,
|
||||
video {
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset box-sizing */
|
||||
*, *::before, *::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* Reset default appearance */
|
||||
textarea,
|
||||
select,
|
||||
input,
|
||||
progress {
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
}
|
||||
|
||||
html {
|
||||
/* Set the font globally */
|
||||
font-family: var(--sans-font);
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
|
||||
/* Make the body a nice central block */
|
||||
body {
|
||||
color: var(--text);
|
||||
background-color: var(--bg);
|
||||
font-size: 1.15rem;
|
||||
line-height: 1.5;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr min(45rem, 90%) 1fr;
|
||||
margin: 0;
|
||||
}
|
||||
body > * {
|
||||
grid-column: 2;
|
||||
}
|
||||
|
||||
/* Make the header bg full width, but the content inline with body */
|
||||
body > header {
|
||||
background-color: var(--accent-bg);
|
||||
border-bottom: 1px solid var(--border);
|
||||
text-align: center;
|
||||
padding: 0 0.5rem 2rem 0.5rem;
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
body > header h1 {
|
||||
max-width: 1200px;
|
||||
margin: 1rem auto;
|
||||
}
|
||||
|
||||
body > header p {
|
||||
max-width: 40rem;
|
||||
margin: 1rem auto;
|
||||
}
|
||||
|
||||
/* Add a little padding to ensure spacing is correct between content and header > nav */
|
||||
main {
|
||||
padding-top: 1.5rem;
|
||||
}
|
||||
|
||||
body > footer {
|
||||
margin-top: 4rem;
|
||||
padding: 2rem 1rem 1.5rem 1rem;
|
||||
color: var(--text-light);
|
||||
font-size: 0.9rem;
|
||||
text-align: center;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
/* Format headers */
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 2.6rem;
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 2rem;
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 1.44rem;
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 0.96rem;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 1.5rem 0;
|
||||
}
|
||||
|
||||
/* Prevent long strings from overflowing container */
|
||||
p, h1, h2, h3, h4, h5, h6 {
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
/* Fix line height when title wraps */
|
||||
h1,
|
||||
h2,
|
||||
h3 {
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
/* Reduce header size on mobile */
|
||||
@media only screen and (max-width: 720px) {
|
||||
h1 {
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 2.1rem;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.75rem;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
/* Format links & buttons */
|
||||
a,
|
||||
a:visited {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
button,
|
||||
.button,
|
||||
a.button, /* extra specificity to override a */
|
||||
input[type="submit"],
|
||||
input[type="reset"],
|
||||
input[type="button"],
|
||||
label[type="button"] {
|
||||
border: 1px solid var(--accent);
|
||||
background-color: var(--accent);
|
||||
color: var(--bg);
|
||||
padding: 0.5rem 0.9rem;
|
||||
text-decoration: none;
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
.button[aria-disabled="true"],
|
||||
input:disabled,
|
||||
textarea:disabled,
|
||||
select:disabled,
|
||||
button[disabled] {
|
||||
cursor: not-allowed;
|
||||
background-color: var(--disabled);
|
||||
border-color: var(--disabled);
|
||||
color: var(--text-light);
|
||||
}
|
||||
|
||||
input[type="range"] {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Set the cursor to '?' on an abbreviation and style the abbreviation to show that there is more information underneath */
|
||||
abbr[title] {
|
||||
cursor: help;
|
||||
text-decoration-line: underline;
|
||||
text-decoration-style: dotted;
|
||||
}
|
||||
|
||||
button:enabled:hover,
|
||||
.button:not([aria-disabled="true"]):hover,
|
||||
input[type="submit"]:enabled:hover,
|
||||
input[type="reset"]:enabled:hover,
|
||||
input[type="button"]:enabled:hover,
|
||||
label[type="button"]:hover {
|
||||
filter: brightness(1.4);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.button:focus-visible,
|
||||
button:focus-visible:where(:enabled),
|
||||
input:enabled:focus-visible:where(
|
||||
[type="submit"],
|
||||
[type="reset"],
|
||||
[type="button"]
|
||||
) {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 1px;
|
||||
}
|
||||
|
||||
/* Format navigation */
|
||||
header > nav {
|
||||
font-size: 1rem;
|
||||
line-height: 2;
|
||||
padding: 1rem 0 0 0;
|
||||
}
|
||||
|
||||
/* Use flexbox to allow items to wrap, as needed */
|
||||
header > nav ul,
|
||||
header > nav ol {
|
||||
align-content: space-around;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* List items are inline elements, make them behave more like blocks */
|
||||
header > nav ul li,
|
||||
header > nav ol li {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
header > nav a,
|
||||
header > nav a:visited {
|
||||
margin: 0 0.5rem 1rem 0.5rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--standard-border-radius);
|
||||
color: var(--text);
|
||||
display: inline-block;
|
||||
padding: 0.1rem 1rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
header > nav a:hover,
|
||||
header > nav a.current,
|
||||
header > nav a[aria-current="page"] {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Reduce nav side on mobile */
|
||||
@media only screen and (max-width: 720px) {
|
||||
header > nav a {
|
||||
border: none;
|
||||
padding: 0;
|
||||
text-decoration: underline;
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Consolidate box styling */
|
||||
aside, details, pre, progress {
|
||||
background-color: var(--accent-bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--standard-border-radius);
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
aside {
|
||||
font-size: 1rem;
|
||||
width: 30%;
|
||||
padding: 0 15px;
|
||||
margin-inline-start: 15px;
|
||||
float: right;
|
||||
}
|
||||
*[dir="rtl"] aside {
|
||||
float: left;
|
||||
}
|
||||
|
||||
/* Make aside full-width on mobile */
|
||||
@media only screen and (max-width: 720px) {
|
||||
aside {
|
||||
width: 100%;
|
||||
float: none;
|
||||
margin-inline-start: 0;
|
||||
}
|
||||
}
|
||||
|
||||
article, fieldset, dialog {
|
||||
border: 1px solid var(--border);
|
||||
padding: 1rem;
|
||||
border-radius: var(--standard-border-radius);
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
article h2:first-child,
|
||||
section h2:first-child {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
section {
|
||||
border-top: 1px solid var(--border);
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 2rem 1rem;
|
||||
margin: 3rem 0;
|
||||
}
|
||||
|
||||
/* Don't double separators when chaining sections */
|
||||
section + section,
|
||||
section:first-child {
|
||||
border-top: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
section:last-child {
|
||||
border-bottom: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
details {
|
||||
padding: 0.7rem 1rem;
|
||||
}
|
||||
|
||||
summary {
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
padding: 0.7rem 1rem;
|
||||
margin: -0.7rem -1rem;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
details[open] > summary + * {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
details[open] > summary {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
details[open] > :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
/* Format tables */
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
margin: 1.5rem 0;
|
||||
}
|
||||
|
||||
td,
|
||||
th {
|
||||
border: 1px solid var(--border);
|
||||
text-align: start;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: var(--accent-bg);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
tr:nth-child(even) {
|
||||
/* Set every other cell slightly darker. Improves readability. */
|
||||
background-color: var(--accent-bg);
|
||||
}
|
||||
|
||||
table caption {
|
||||
font-weight: bold;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
/* Format forms */
|
||||
textarea,
|
||||
select,
|
||||
input,
|
||||
button,
|
||||
.button {
|
||||
font-size: inherit;
|
||||
font-family: inherit;
|
||||
padding: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
border-radius: var(--standard-border-radius);
|
||||
box-shadow: none;
|
||||
max-width: 100%;
|
||||
display: inline-block;
|
||||
}
|
||||
textarea,
|
||||
select,
|
||||
input {
|
||||
color: var(--text);
|
||||
background-color: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
label {
|
||||
display: block;
|
||||
}
|
||||
textarea:not([cols]) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Add arrow to drop-down */
|
||||
select:not([multiple]) {
|
||||
background-image: linear-gradient(45deg, transparent 49%, var(--text) 51%),
|
||||
linear-gradient(135deg, var(--text) 51%, transparent 49%);
|
||||
background-position: calc(100% - 15px), calc(100% - 10px);
|
||||
background-size: 5px 5px, 5px 5px;
|
||||
background-repeat: no-repeat;
|
||||
padding-inline-end: 25px;
|
||||
}
|
||||
*[dir="rtl"] select:not([multiple]) {
|
||||
background-position: 10px, 15px;
|
||||
}
|
||||
|
||||
/* checkbox and radio button style */
|
||||
input[type="checkbox"],
|
||||
input[type="radio"] {
|
||||
vertical-align: middle;
|
||||
position: relative;
|
||||
width: min-content;
|
||||
}
|
||||
|
||||
input[type="checkbox"] + label,
|
||||
input[type="radio"] + label {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
input[type="radio"] {
|
||||
border-radius: 100%;
|
||||
}
|
||||
|
||||
input[type="checkbox"]:checked,
|
||||
input[type="radio"]:checked {
|
||||
background-color: var(--accent);
|
||||
}
|
||||
|
||||
input[type="checkbox"]:checked::after {
|
||||
/* Creates a rectangle with colored right and bottom borders which is rotated to look like a check mark */
|
||||
content: " ";
|
||||
width: 0.18em;
|
||||
height: 0.32em;
|
||||
border-radius: 0;
|
||||
position: absolute;
|
||||
top: 0.05em;
|
||||
left: 0.17em;
|
||||
background-color: transparent;
|
||||
border-right: solid var(--bg) 0.08em;
|
||||
border-bottom: solid var(--bg) 0.08em;
|
||||
font-size: 1.8em;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
input[type="radio"]:checked::after {
|
||||
/* creates a colored circle for the checked radio button */
|
||||
content: " ";
|
||||
width: 0.25em;
|
||||
height: 0.25em;
|
||||
border-radius: 100%;
|
||||
position: absolute;
|
||||
top: 0.125em;
|
||||
background-color: var(--bg);
|
||||
left: 0.125em;
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
/* Makes input fields wider on smaller screens */
|
||||
@media only screen and (max-width: 720px) {
|
||||
textarea,
|
||||
select,
|
||||
input {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set a height for color input */
|
||||
input[type="color"] {
|
||||
height: 2.5rem;
|
||||
padding: 0.2rem;
|
||||
}
|
||||
|
||||
/* do not show border around file selector button */
|
||||
input[type="file"] {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
/* Misc body elements */
|
||||
hr {
|
||||
border: none;
|
||||
height: 1px;
|
||||
background: var(--border);
|
||||
margin: 1rem auto;
|
||||
}
|
||||
|
||||
mark {
|
||||
padding: 2px 5px;
|
||||
border-radius: var(--standard-border-radius);
|
||||
background-color: var(--marked);
|
||||
color: black;
|
||||
}
|
||||
|
||||
mark a {
|
||||
color: #0d47a1;
|
||||
}
|
||||
|
||||
img,
|
||||
video {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
border-radius: var(--standard-border-radius);
|
||||
}
|
||||
|
||||
figure {
|
||||
margin: 0;
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
figcaption {
|
||||
text-align: center;
|
||||
font-size: 0.9rem;
|
||||
color: var(--text-light);
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
margin-inline-start: 2rem;
|
||||
margin-inline-end: 0;
|
||||
margin-block: 2rem;
|
||||
padding: 0.4rem 0.8rem;
|
||||
border-inline-start: 0.35rem solid var(--accent);
|
||||
color: var(--text-light);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
cite {
|
||||
font-size: 0.9rem;
|
||||
color: var(--text-light);
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
dt {
|
||||
color: var(--text-light);
|
||||
}
|
||||
|
||||
/* Use mono font for code elements */
|
||||
code,
|
||||
pre,
|
||||
pre span,
|
||||
kbd,
|
||||
samp {
|
||||
font-family: var(--mono-font);
|
||||
color: var(--code);
|
||||
}
|
||||
|
||||
kbd {
|
||||
color: var(--preformatted);
|
||||
border: 1px solid var(--preformatted);
|
||||
border-bottom: 3px solid var(--preformatted);
|
||||
border-radius: var(--standard-border-radius);
|
||||
padding: 0.1rem 0.4rem;
|
||||
}
|
||||
|
||||
pre {
|
||||
padding: 1rem 1.4rem;
|
||||
max-width: 100%;
|
||||
overflow: auto;
|
||||
color: var(--preformatted);
|
||||
}
|
||||
|
||||
/* Fix embedded code within pre */
|
||||
pre code {
|
||||
color: var(--preformatted);
|
||||
background: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Progress bars */
|
||||
/* Declarations are repeated because you */
|
||||
/* cannot combine vendor-specific selectors */
|
||||
progress {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
progress:indeterminate {
|
||||
background-color: var(--accent-bg);
|
||||
}
|
||||
|
||||
progress::-webkit-progress-bar {
|
||||
border-radius: var(--standard-border-radius);
|
||||
background-color: var(--accent-bg);
|
||||
}
|
||||
|
||||
progress::-webkit-progress-value {
|
||||
border-radius: var(--standard-border-radius);
|
||||
background-color: var(--accent);
|
||||
}
|
||||
|
||||
progress::-moz-progress-bar {
|
||||
border-radius: var(--standard-border-radius);
|
||||
background-color: var(--accent);
|
||||
transition-property: width;
|
||||
transition-duration: 0.3s;
|
||||
}
|
||||
|
||||
progress:indeterminate::-moz-progress-bar {
|
||||
background-color: var(--accent-bg);
|
||||
}
|
||||
|
||||
dialog {
|
||||
max-width: 40rem;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
dialog::backdrop {
|
||||
background-color: var(--bg);
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 720px) {
|
||||
dialog {
|
||||
max-width: 100%;
|
||||
margin: auto 1em;
|
||||
}
|
||||
}
|
||||
|
||||
/* Superscript & Subscript */
|
||||
/* Prevent scripts from affecting line-height. */
|
||||
sup, sub {
|
||||
vertical-align: baseline;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
sup {
|
||||
top: -0.4em;
|
||||
}
|
||||
|
||||
sub {
|
||||
top: 0.3em;
|
||||
}
|
||||
|
||||
/* Classes for notices */
|
||||
.notice {
|
||||
background: var(--accent-bg);
|
||||
border: 2px solid var(--border);
|
||||
border-radius: 5px;
|
||||
padding: 1.5rem;
|
||||
margin: 2rem 0;
|
||||
}
|
BIN
standalone/data/anagram.bin
Normal file
BIN
standalone/data/anagram.bin
Normal file
Binary file not shown.
BIN
standalone/data/match.bin
Normal file
BIN
standalone/data/match.bin
Normal file
Binary file not shown.
|
@ -1,43 +1,72 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"embed"
|
||||
"encoding/gob"
|
||||
"flag"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/ray1729/wordsearch/anagram"
|
||||
"github.com/ray1729/wordsearch/match"
|
||||
"github.com/ray1729/wordsearch/standalone/server"
|
||||
)
|
||||
|
||||
var matchDB match.DB
|
||||
//go:embed data/*
|
||||
var fs embed.FS
|
||||
|
||||
var anagramDB anagram.DB
|
||||
var matchDB match.DB
|
||||
|
||||
func initializeDB() error {
|
||||
anagrams, err := fs.Open("data/anagram.bin")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer anagrams.Close()
|
||||
if err := gob.NewDecoder(anagrams).Decode(&anagramDB); err != nil {
|
||||
return err
|
||||
}
|
||||
matches, err := fs.Open("data/match.bin")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer matches.Close()
|
||||
if err := gob.NewDecoder(matches).Decode(&matchDB); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
f, err := os.Open("wordlist.txt")
|
||||
if err != nil {
|
||||
log.Fatalf("Error opening word list: %v", err)
|
||||
}
|
||||
defer f.Close()
|
||||
matchDB = match.New()
|
||||
anagramDB = anagram.New()
|
||||
sc := bufio.NewScanner(f)
|
||||
for sc.Scan() {
|
||||
s := sc.Text()
|
||||
matchDB.Add(s)
|
||||
anagramDB.Add(s)
|
||||
}
|
||||
if err := sc.Err(); err != nil {
|
||||
log.Fatalf("Error loading databases: %v", err)
|
||||
if err := initializeDB(); err != nil {
|
||||
log.Fatalf("error initializing databases: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
s := server.New("./assets", matchDB, anagramDB)
|
||||
address := ":8000"
|
||||
log.Printf("Listening on %s", address)
|
||||
if err := http.ListenAndServe(address, s); err != nil {
|
||||
var listenAddr = flag.String("listen", ":8000", "Address or port to listen on, prefix with unix: to listen on a Unix domain socket")
|
||||
flag.Parse()
|
||||
|
||||
server := http.Server{
|
||||
Handler: server.New(matchDB, anagramDB),
|
||||
}
|
||||
|
||||
var listener net.Listener
|
||||
var err error
|
||||
if strings.HasPrefix(*listenAddr, "unix:") {
|
||||
listener, err = net.Listen("unix", strings.TrimPrefix(*listenAddr, "unix:"))
|
||||
} else {
|
||||
listener, err = net.Listen("tcp", *listenAddr)
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatalf("Error listening on %s: %v", *listenAddr, err)
|
||||
}
|
||||
log.Printf("Listening on %s", *listenAddr)
|
||||
|
||||
if err := server.Serve(listener); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,9 +11,8 @@ import (
|
|||
"github.com/ray1729/wordsearch/match"
|
||||
)
|
||||
|
||||
func New(assetsPath string, matchDB match.DB, anagramDB anagram.DB) http.Handler {
|
||||
func New(matchDB match.DB, anagramDB anagram.DB) http.Handler {
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir(assetsPath))))
|
||||
mux.HandleFunc("/search", searchHandler(matchDB, anagramDB))
|
||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
renderTemplate(w, home, nil)
|
||||
|
|
|
@ -8,9 +8,23 @@ var home = template.Must(template.New("home").Parse(`
|
|||
<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>
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
<script src="https://unpkg.com/htmx.org@1.9.12"></script>
|
||||
<style>
|
||||
div.center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div#results {
|
||||
height: 60dvh;
|
||||
}
|
||||
|
||||
div#results > ul {
|
||||
list-style-type: none;
|
||||
overflow-y: auto;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
<title>Anagram and Word Search</title>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -19,7 +33,7 @@ var home = template.Must(template.New("home").Parse(`
|
|||
</header>
|
||||
|
||||
<main>
|
||||
<form action="/search" method="post" hx-boost="true" hx-target="#results">
|
||||
<form action="/search" method="post" hx-boost="true" hx-target="#results" hx-push-url="false">
|
||||
<div class="center">
|
||||
<input id="pattern" type="text" name="pattern" required autofocus></input>
|
||||
<button name="mode" value="match">Match</button>
|
||||
|
@ -51,9 +65,8 @@ var results = template.Must(template.New("results").Parse(`
|
|||
{{ end }}
|
||||
<ul>
|
||||
{{ range .Results }}
|
||||
<li>{{.}}
|
||||
<a href="https://dicoweb.gnu.org.ua/?q={{.}}&db=gcide&define=1" target="defn"><span class="small">GCIDE</span></a>
|
||||
<a href="https://dicoweb.gnu.org.ua/?q={{.}}&db=WordNet&define=1" target="defn"><span class="small">WordNet</span></a>
|
||||
<li>
|
||||
<a href="https://dicoweb.gnu.org.ua/?q={{.}}&db=gcide&define=1" target="defn">{{.}}</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
|
|
Loading…
Reference in a new issue