/
index.go
123 lines (106 loc) · 3.28 KB
/
index.go
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
package main
import (
"fmt"
"html/template"
"github.com/distr1/distri"
)
var indexTmpl = template.Must(template.New("").Funcs(template.FuncMap{
"parseVersion": distri.ParseVersion,
"percentage": func(a, b int) string {
return fmt.Sprintf("%.2f%%", 100*float64(a)/float64(b))
},
}).Parse(`<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="google" content="notranslate">
<title>distri repo browser: {{ .Repo }}</title>
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
<link rel="stylesheet" href="/css/bootstrap-4.4.1.min.css" crossorigin="anonymous">
<style type="text/css">
td.upstreamversion {
max-width: 400px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
td.upstreamversion badge {
display: inline;
}
#repostats td {
text-align: right;
}
</style>
</head>
<body>
<div class="container">
<table width="40%" style="float: right; margin-top: 1em" id="repostats">
<tr>
<td>Total:</td>
<td>{{ len .Packages }} Packages</td>
</tr>
<tr>
<td>New upstream:</td>
<td>{{ .NewUpstreamCount }} Packages ({{ percentage .NewUpstreamCount (len .Packages) }})</td>
</tr>
<tr>
<td>Up-to-date:</td>
<td>{{ .UpToDateCount }} Packages ({{ percentage .UpToDateCount (len .Packages) }})</td>
</tr>
</table>
<h1>distri repo browser</h1>
<p>
Repository: <code>{{ .Repo }}</code><br>
</p>
<table width="100%" class="table table-striped table-hover table-sm">
<thead>
<tr>
<th>Package</th>
<th>Architecture</th>
<th>Upstream Version</th>
<th>distri Revision</th>
<th>Links</th>
</tr>
</thead>
{{ range $idx, $pkg := .Packages }}
{{ with $pv := parseVersion $pkg.Name }}
<tr>
<td>
{{ $pv.Pkg }}
{{ with $status := index $.UpstreamStatus $pv.Pkg }}
{{ if (and (ne $pv.Upstream "native") (or (eq $status.SourcePackage "") $status.Unreachable)) }}
<span class="badge badge-danger">unreachable</span>
{{ end }}
{{ end }}
</td>
<td>{{ $pv.Arch }}</td>
<td class="upstreamversion">
{{ $pv.Upstream }}
{{ with $status := index $.UpstreamStatus $pv.Pkg }}
{{ if (and (ne $status.SourcePackage "") (not $status.Unreachable) (ne $status.UpstreamVersion $pv.Upstream)) }}
<span class="badge badge-warning">upstream: {{ $status.UpstreamVersion }}</span>
{{ end }}
{{ if (and (ne $status.SourcePackage "") (not $status.Unreachable) (eq $status.UpstreamVersion $pv.Upstream)) }}
<span class="badge badge-success">up-to-date</span>
{{ end }}
{{ end }}
</td>
<td>{{ $pv.DistriRevision }}</td>
<td>
<!-- TODO: use correct branch from repo url -->
{{ with $branch := "master" }}
<a href="https://github.com/distr1/distri/blob/{{ $branch }}/pkgs/{{ $pv.Pkg }}/build.textproto">build file</a>
{{ end }}
</td>
</tr>
{{ end }}
{{ end }}
</table>
</div>
<script src="/js/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="/js/popper-1.16.0.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="/js/bootstrap-4.4.1.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>
</html>
`))