all repos — elgit @ 4cb034adf2fd34dbaeae280c30d88601865dc7d8

fork of legit: web frontend for git, written in go

templates/file.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
package templates

import (
	"fmt"

	g "alin.ovh/gomponents"
	. "alin.ovh/gomponents/html"
)

// FilePage renders a file view page
func FilePage(data PageData) g.Node {
	return Page(data, []g.Node{
		RepoHeader(data),
		RenderNav(data),
		Main(
			P(g.Text(data.Path), g.Text(" ("), A(Href("?raw=true"), g.Text("view raw")), g.Text(")")),
			Div(Class("file-wrapper"),
				Table(
					TBody(
						Tr(
							Td(Class("line-numbers"),
								Pre(g.Map(data.LineCount, func(line int) g.Node {
									return g.Group([]g.Node{
										g.Text("\n"),
										A(
											ID(fmt.Sprintf("L%d", line)),
											Href(fmt.Sprintf("#L%d", line)),
											g.Text(fmt.Sprintf("%d", line)),
										)})
								})),
							),
							Td(Class("file-content"),
								Pre(g.Text(data.Content)),
							),
						),
					),
				),
			),
		),
	})
}