- Search Nix Packages and options from NixOS, Darwin and Home-Manager -
- Source code - {{ end }} -From a1dfc548198a1326e71f1dd70303a5d3441f7a39 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 21 Jun 2024 13:02:08 +0200 Subject: refactor: switch to templ for HTML templates --- frontend/assets.go | 12 +++--- frontend/static/search.js | 4 +- frontend/static/style.css | 11 +++++ frontend/templates/blocks/error.gotmpl | 6 --- frontend/templates/blocks/option.gotmpl | 48 --------------------- frontend/templates/blocks/options.gotmpl | 25 ----------- frontend/templates/blocks/package.gotmpl | 69 ------------------------------- frontend/templates/blocks/packages.gotmpl | 30 -------------- frontend/templates/blocks/results.gotmpl | 21 ---------- frontend/templates/blocks/search.gotmpl | 37 ----------------- frontend/templates/index.gotmpl | 55 ------------------------ 11 files changed, 19 insertions(+), 299 deletions(-) delete mode 100644 frontend/templates/blocks/error.gotmpl delete mode 100644 frontend/templates/blocks/option.gotmpl delete mode 100644 frontend/templates/blocks/options.gotmpl delete mode 100644 frontend/templates/blocks/package.gotmpl delete mode 100644 frontend/templates/blocks/packages.gotmpl delete mode 100644 frontend/templates/blocks/results.gotmpl delete mode 100644 frontend/templates/blocks/search.gotmpl delete mode 100644 frontend/templates/index.gotmpl (limited to 'frontend') diff --git a/frontend/assets.go b/frontend/assets.go index 46369fa..7a90d80 100644 --- a/frontend/assets.go +++ b/frontend/assets.go @@ -12,8 +12,8 @@ import ( ) var Assets = &AssetCollection{ - Scripts: make(map[string]*Asset), - Stylesheets: make(map[string]*Asset), + Scripts: []*Asset{}, + Stylesheets: []*Asset{}, ByPath: make(map[string]*Asset), } @@ -25,8 +25,8 @@ type Asset struct { } type AssetCollection struct { - Scripts map[string]*Asset - Stylesheets map[string]*Asset + Scripts []*Asset + Stylesheets []*Asset ByPath map[string]*Asset } @@ -61,7 +61,7 @@ func hashScripts() error { if err != nil { return err } - Assets.Scripts[filename] = asset + Assets.Scripts = append(Assets.Scripts, asset) Assets.ByPath[asset.URL] = asset } @@ -78,7 +78,7 @@ func hashStyles() error { if err != nil { return err } - Assets.Stylesheets[filename] = asset + Assets.Stylesheets = append(Assets.Stylesheets, asset) Assets.ByPath[asset.URL] = asset } diff --git a/frontend/static/search.js b/frontend/static/search.js index e3777d7..df11d09 100644 --- a/frontend/static/search.js +++ b/frontend/static/search.js @@ -6,8 +6,8 @@ const results = document.getElementById("results"); let pagination = document.getElementById("pagination"); const resultsRange = new Range(); -resultsRange.setStartBefore(results.firstChild); -resultsRange.setEndAfter(results.lastChild); +resultsRange.setStart(results, 0); +resultsRange.setEnd(results, 0); const detailsRange = new Range(); detailsRange.setStartAfter(dialog.firstElementChild); diff --git a/frontend/static/style.css b/frontend/static/style.css index a202b89..7cdc6c8 100644 --- a/frontend/static/style.css +++ b/frontend/static/style.css @@ -169,3 +169,14 @@ td, th { padding: 0.25rem 0.5rem; } + +ul:only-child { + padding-inline-start: unset; + margin: unset; +} + +li { + display: inline-block; + margin-right: 1ex; + list-style: none; +} diff --git a/frontend/templates/blocks/error.gotmpl b/frontend/templates/blocks/error.gotmpl deleted file mode 100644 index 1352b2e..0000000 --- a/frontend/templates/blocks/error.gotmpl +++ /dev/null @@ -1,6 +0,0 @@ -{{- define "main" }} -
- {{ .Code }} - {{ .Message }} -
-{{- end }} diff --git a/frontend/templates/blocks/option.gotmpl b/frontend/templates/blocks/option.gotmpl deleted file mode 100644 index 2248708..0000000 --- a/frontend/templates/blocks/option.gotmpl +++ /dev/null @@ -1,48 +0,0 @@ -{{- define "main" }} - {{- with .Document }} -{{ . }}
{{ .Text }}
- {{- end }}
- {{ .Text }}
- {{- end }}
- Title | -Description | -
---|---|
- {{ .Name }} - | -- {{ markdown (firstSentence .Description) }} - - | -
{{ .Description }}
- {{- end }} -{{ . }}
- Attribute | -Name | -Description | -
---|---|---|
- {{- with .Attribute }} - {{ . }} - {{- end }} - | -- {{ .Name }} - | -- {{ .Description }} - | -
- Search Nix Packages and options from NixOS, Darwin and Home-Manager -
- Source code - {{ end }} -