about summary refs log tree commit diff stats
path: root/internal/components/packageDetail.templ
blob: 65c74aa3254a4eaa159e81abcc9021b19635da7d (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
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
package components

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

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

templ PackageDetail(pkg nix.Package) {
	<h2>
		if pkg.Broken {
			<del>{ pkg.Attribute }</del>
		} else {
			{ pkg.Attribute }
		}
	</h2>
	if pkg.LongDescription != "" {
		@markdown(pkg.LongDescription)
	} else {
		<p>{ pkg.Description }</p>
	}
	<dl>
		if pkg.MainProgram != "" {
			<dt>Main Program</dt>
			<dd>
				<code>{ pkg.MainProgram }</code>
			</dd>
		}
		if len(pkg.Homepages) > 0 {
			<dt>Homepage</dt>
			<dd>
				<ul>
					for _, u := range pkg.Homepages {
						<li>
							<a href={ templ.SafeURL(u) }>{ u }</a>
						</li>
					}
				</ul>
			</dd>
		}
		if pkg.Version != "" {
			<dt>Version</dt>
			<dd>{ pkg.Version }</dd>
		}
		if len(pkg.Licenses) > 0 {
			<dt>License</dt>
			<dd>
				<ul>
					for _, l := range pkg.Licenses {
						<li>
							if l.URL != "" {
								<a href={ templ.SafeURL(l.URL) }>{ licenseName(l) }</a>
							} else {
								{ licenseName(l) }
							}
							if l.AppendixURL != "" {
								<a href={ templ.SafeURL(l.AppendixURL) }>Appendix</a>
							}
						</li>
					}
				</ul>
			</dd>
		}
		if len(pkg.Maintainers) > 0 {
			<dt>Maintainers</dt>
			<dd>
				<ul>
					for _, m := range pkg.Maintainers {
						<li>
							if m.Github != "" {
								<a href={ joinPath("https://github.com", m.Github) }>{ m.Name }</a>
							} else {
								{ m.Name }
							}
						</li>
					}
				</ul>
			</dd>
		}
		if pkg.Definition != "" {
			<dt>Defined</dt>
			<dd>
				<a href={ templ.SafeURL(pkg.Definition) }>Source</a>
			</dd>
		}
	</dl>
}

templ PackageDetailPage(tdata TemplateData, pkg nix.Package) {
	@Page(tdata) {
		@PackageDetail(pkg)
	}
}