From fc5fd2edd9b8282497e33a18300eab694d8a89c6 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/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 ------------------------
10 files changed, 13 insertions(+), 293 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/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 }}
- {{ .Name }}
- {{ markdown .Description }}
-
- {{- with .Type }}
- - Type
- {{ . }}
- {{- end }}
- {{- with .Default }}
- {{- if or .Text .Markdown }}
- - Default
- -
- {{- if .Markdown }}
- {{ markdown .Markdown }}
- {{- else }}
-
{{ .Text }}
- {{- end }}
-
- {{- end }}
- {{- end }}
- {{- with .Example }}
- {{- if or .Text .Markdown }}
- - Example
- -
- {{- if .Markdown }}
- {{ markdown .Markdown }}
- {{- else }}
-
{{ .Text }}
- {{- end }}
-
- {{- end }}
- {{- end }}
- {{- with .RelatedPackages }}
- - Related Packages
- - {{ . }}
- {{- end }}
- {{- with .Declarations }}
- - Declared
- {{- range . }}
- -
- {{ .Name }}
-
- {{- end }}
- {{- end }}
-
- {{- end }}
-{{- end }}
diff --git a/frontend/templates/blocks/options.gotmpl b/frontend/templates/blocks/options.gotmpl
deleted file mode 100644
index 5a08bae..0000000
--- a/frontend/templates/blocks/options.gotmpl
+++ /dev/null
@@ -1,25 +0,0 @@
-{{- define "hits" }}
-
-
-
- Title |
- Description |
-
-
-
- {{- range . }}
- {{- with .Data }}
-
-
- {{ .Name }}
- |
-
- {{ markdown (firstSentence .Description) }}
-
- |
-
- {{- end }}
- {{- end }}
-
-
-{{- end }}
diff --git a/frontend/templates/blocks/package.gotmpl b/frontend/templates/blocks/package.gotmpl
deleted file mode 100644
index a42a8b1..0000000
--- a/frontend/templates/blocks/package.gotmpl
+++ /dev/null
@@ -1,69 +0,0 @@
-{{- define "main" }}
- {{- with .Document }}
-
- {{- if .Broken }}
- {{ .Attribute }}
- {{- else }}
- {{ .Attribute }}
- {{- end }}
-
- {{- if .LongDescription }}
- {{ markdown .LongDescription }}
- {{- else }}
- {{ .Description }}
- {{- end }}
-
- {{- with .MainProgram }}
- - Main Program
- -
-
{{ . }}
-
- {{- end }}
- {{- with .Homepages }}
- - Homepage
- -
- {{- range . }}
- {{ . }}
- {{- end }}
-
- {{- end }}
- {{- with .Version }}
- - Version
- - {{ . }}
- {{- end }}
- {{- with .Licenses }}
- - License
- -
- {{- range . }}
- {{- if .URL }}
- {{ or .FullName .Name }}
- {{- else }}
- {{ or .FullName .Name }}
- {{- end }}
- {{- with .AppendixURL }}
- Appendix
- {{- end }}
- {{- end }}
-
- {{- end }}
- {{- with .Maintainers }}
- - Maintainer{{ if gt (len .) 1 }}s{{ end }}
- -
- {{- range . }}
- {{- if .Github }}
- {{ .Name }}
- {{- else }}
- {{ .Name }}
- {{- end }}
- {{- end }}
-
- {{- end }}
- {{- with .Definition }}
- - Defined
- -
- Source
-
- {{- end }}
-
- {{- end }}
-{{- end }}
diff --git a/frontend/templates/blocks/packages.gotmpl b/frontend/templates/blocks/packages.gotmpl
deleted file mode 100644
index cce97a0..0000000
--- a/frontend/templates/blocks/packages.gotmpl
+++ /dev/null
@@ -1,30 +0,0 @@
-{{- define "hits" }}
-
-
-
- Attribute |
- Name |
- Description |
-
-
-
- {{- range . }}
- {{- with .Data }}
-
-
- {{- with .Attribute }}
- {{ . }}
- {{- end }}
- |
-
- {{ .Name }}
- |
-
- {{ .Description }}
- |
-
- {{- end }}
- {{- end }}
-
-
-{{- end }}
diff --git a/frontend/templates/blocks/results.gotmpl b/frontend/templates/blocks/results.gotmpl
deleted file mode 100644
index ef6e1f1..0000000
--- a/frontend/templates/blocks/results.gotmpl
+++ /dev/null
@@ -1,21 +0,0 @@
-{{- define "results" }}
- {{- with .Results }}
- {{- if gt .Total 0 }}
- {{ block "hits" .Hits }}
- {{ end }}
-
- {{- else }}
- Nothing found
- {{- end }}
- {{- end }}
-{{- end }}
diff --git a/frontend/templates/blocks/search.gotmpl b/frontend/templates/blocks/search.gotmpl
deleted file mode 100644
index 93ae545..0000000
--- a/frontend/templates/blocks/search.gotmpl
+++ /dev/null
@@ -1,37 +0,0 @@
-{{- define "main" }}
-
-
- {{- if .Results }}
- {{ block "results" . }}{{ end }}
- {{- end }}
-
-
-{{- end }}
-
-{{- define "head" }}
- {{- with (index .Assets.Scripts "static/search.js") }}
-
- {{- end }}
-{{- end }}
diff --git a/frontend/templates/index.gotmpl b/frontend/templates/index.gotmpl
deleted file mode 100644
index 7732dc8..0000000
--- a/frontend/templates/index.gotmpl
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
-
- Searchix
- {{- range .Assets.Stylesheets }}
-
- {{- end }}
- {{ block "head" . }}
- {{ end }}
- {{ .ExtraHeadHTML }}
- {{- range $key, $value := .Sources }}
-
- {{- end }}
-
-
-
-
- {{ block "main" . }}
-
- Search Nix Packages and options from NixOS, Darwin and Home-Manager
-
- Source code
- {{ end }}
-
-
-
-
--
cgit 1.4.1