all repos — searchix @ 6b2a0fdd4e56796db8a921f26d9838b4b66a455e

Search engine for NixOS, nix-darwin, home-manager and NUR users

internal/components/packageDetail.go (view raw)

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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package components

import (
	"go.alanpearce.eu/searchix/internal/nix"

	g "go.alanpearce.eu/gomponents"
	. "go.alanpearce.eu/gomponents/html"
)

func licenseName(l nix.License) string {
	if l.FullName != "" {
		return l.FullName
	}

	return l.Name
}

func PackageDetail(pkg nix.Package) g.Node {
	return g.Group([]g.Node{
		H2(
			g.If(pkg.Broken,
				Del(g.Text(pkg.Attribute)),
				g.Text(pkg.Attribute),
			),
		),
		g.If(pkg.LongDescription != "",
			pkg.LongDescription,
			P(g.Text(pkg.Description)),
		),
		Dl(
			g.If(pkg.MainProgram != "",
				g.Group([]g.Node{
					Dt(g.Text("Main Program")),
					Dd(Code(g.Text(pkg.MainProgram))),
				}),
			),
			g.If(len(pkg.Programs) > 0,
				g.Group([]g.Node{
					Dt(g.Text("Programs")),
					Dd(
						Ul(
							g.Map(pkg.Programs, func(p string) g.Node {
								return Li(Code(g.Text(p)))
							}),
						),
					),
				}),
			),
			g.If(len(pkg.Homepages) > 0,
				g.Group([]g.Node{
					Dt(g.Text("Homepage")),
					Dd(
						Ul(
							g.Map(pkg.Homepages, func(u string) g.Node {
								return Li(A(Href(u), g.Text(u)))
							}),
						),
					),
				}),
			),
			g.If(pkg.Version != "",
				g.Group([]g.Node{
					Dt(g.Text("Version")),
					Dd(g.Text(pkg.Version)),
				}),
			),
			g.If(len(pkg.Licenses) > 0,
				g.Group([]g.Node{
					Dt(g.Text("License")),
					Dd(
						Ul(
							g.Map(pkg.Licenses, func(l nix.License) g.Node {
								return Li(
									g.If(l.URL != "",
										A(Href(l.URL), g.Text(licenseName(l))),
										g.Text(licenseName(l)),
									),
									g.If(l.AppendixURL != "",
										A(Href(l.AppendixURL), g.Text("Appendix")),
									),
								)
							}),
						),
					),
				}),
			),
			g.If(len(pkg.Maintainers) > 0,
				g.Group([]g.Node{
					Dt(g.Text("Maintainers")),
					Dd(
						Ul(
							g.Map(pkg.Maintainers, func(m nix.Maintainer) g.Node {
								return Li(
									g.If(
										m.Github != "",
										A(
											Href(joinPath("https://github.com", m.Github)),
											g.Text(m.Name),
										),
										g.Text(m.Name),
									),
								)
							}),
						),
					),
				}),
			),
			g.If(len(pkg.Platforms) > 0,
				g.Group([]g.Node{
					Dt(g.Text("Platforms")),
					Dd(
						Ul(
							g.Map(pkg.Platforms, func(plat string) g.Node {
								return Li(g.Text(plat))
							}),
						),
					),
				}),
			),
			g.If(pkg.Definition != "",
				g.Group([]g.Node{
					Dt(g.Text("Defined")),
					Dd(A(Href(pkg.Definition), g.Text("Source"))),
				}),
			),
		),
	})
}

func PackageDetailPage(tdata TemplateData, pkg nix.Package) g.Node {
	return Page(tdata, PackageDetail(pkg))
}