aboutsummaryrefslogtreecommitdiffstats
path: root/web/command/html/home.go
blob: 490b2b8b091587b7c5895eb8861000c912af65b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package html

import (
	"fmt"

	"github.com/LMBishop/scrapbook/pkg/index"
	"github.com/LMBishop/scrapbook/pkg/site"
	. "maragu.dev/gomponents"
	. "maragu.dev/gomponents/html"
)

func HomePage(siteIndex *index.SiteIndex) Node {
	return page("All sites",
		H1(Text("All sites")),

		Div(
			Class("sites-table"),
			Group{
				Span(
					Class("header name"),
					Text("Site"),
				),
				Span(
					Class("header status"),
					Text("Status"),
				),
				Span(
					Class("header flags"),
					Text("Flags"),
				),
				Span(
					Class("header actions"),
					Text("Actions"),
				),
			},
			Map(siteIndex.GetSites(), func(site *site.Site) Node {
				return Group{
					Span(
						Class("name"),
						Span(Text(site.Name)),
						Span(Text(fmt.Sprintf("on %s", site.SiteConfig.Host))),
					),
					Span(
						Class("status"),
						Text(site.EvaluateSiteStatus()),
					),
					Span(
						Class("flags"),
						Text(site.ConvertFlagsToString()),
					),
					Span(
						Class("actions"),
						navButton("Details", fmt.Sprintf("/site/%s/", site.Name)),
					),
				}
			}),
		),

		navButton("Create new", "/create"),
	)
}