+1
-1
appview/db/label.go
+1
-1
appview/db/label.go
+15
-15
appview/pages/funcmap.go
+15
-15
appview/pages/funcmap.go
···
141
141
"relTimeFmt": humanize.Time,
142
142
"shortRelTimeFmt": func(t time.Time) string {
143
143
return humanize.CustomRelTime(t, time.Now(), "", "", []humanize.RelTimeMagnitude{
144
-
{time.Second, "now", time.Second},
145
-
{2 * time.Second, "1s %s", 1},
146
-
{time.Minute, "%ds %s", time.Second},
147
-
{2 * time.Minute, "1min %s", 1},
148
-
{time.Hour, "%dmin %s", time.Minute},
149
-
{2 * time.Hour, "1hr %s", 1},
150
-
{humanize.Day, "%dhrs %s", time.Hour},
151
-
{2 * humanize.Day, "1d %s", 1},
152
-
{20 * humanize.Day, "%dd %s", humanize.Day},
153
-
{8 * humanize.Week, "%dw %s", humanize.Week},
154
-
{humanize.Year, "%dmo %s", humanize.Month},
155
-
{18 * humanize.Month, "1y %s", 1},
156
-
{2 * humanize.Year, "2y %s", 1},
157
-
{humanize.LongTime, "%dy %s", humanize.Year},
158
-
{math.MaxInt64, "a long while %s", 1},
144
+
{D: time.Second, Format: "now", DivBy: time.Second},
145
+
{D: 2 * time.Second, Format: "1s %s", DivBy: 1},
146
+
{D: time.Minute, Format: "%ds %s", DivBy: time.Second},
147
+
{D: 2 * time.Minute, Format: "1min %s", DivBy: 1},
148
+
{D: time.Hour, Format: "%dmin %s", DivBy: time.Minute},
149
+
{D: 2 * time.Hour, Format: "1hr %s", DivBy: 1},
150
+
{D: humanize.Day, Format: "%dhrs %s", DivBy: time.Hour},
151
+
{D: 2 * humanize.Day, Format: "1d %s", DivBy: 1},
152
+
{D: 20 * humanize.Day, Format: "%dd %s", DivBy: humanize.Day},
153
+
{D: 8 * humanize.Week, Format: "%dw %s", DivBy: humanize.Week},
154
+
{D: humanize.Year, Format: "%dmo %s", DivBy: humanize.Month},
155
+
{D: 18 * humanize.Month, Format: "1y %s", DivBy: 1},
156
+
{D: 2 * humanize.Year, Format: "2y %s", DivBy: 1},
157
+
{D: humanize.LongTime, Format: "%dy %s", DivBy: humanize.Year},
158
+
{D: math.MaxInt64, Format: "a long while %s", DivBy: 1},
159
159
})
160
160
},
161
161
"longTimeFmt": func(t time.Time) string {
+30
appview/pages/funcmap_test.go
+30
appview/pages/funcmap_test.go
···
1
+
package pages
2
+
3
+
import (
4
+
"html/template"
5
+
"tangled.org/core/appview/config"
6
+
"tangled.org/core/idresolver"
7
+
"testing"
8
+
)
9
+
10
+
func TestPages_funcMap(t *testing.T) {
11
+
tests := []struct {
12
+
name string // description of this test case
13
+
// Named input parameters for receiver constructor.
14
+
config *config.Config
15
+
res *idresolver.Resolver
16
+
want template.FuncMap
17
+
}{
18
+
// TODO: Add test cases.
19
+
}
20
+
for _, tt := range tests {
21
+
t.Run(tt.name, func(t *testing.T) {
22
+
p := NewPages(tt.config, tt.res)
23
+
got := p.funcMap()
24
+
// TODO: update the condition below to compare got with tt.want.
25
+
if true {
26
+
t.Errorf("funcMap() = %v, want %v", got, tt.want)
27
+
}
28
+
})
29
+
}
30
+
}
-4
appview/pages/pages.go
-4
appview/pages/pages.go
+1
-1
appview/reporesolver/resolver.go
+1
-1
appview/reporesolver/resolver.go
···
212
212
func (f *ResolvedRepo) RolesInRepo(u *oauth.User) repoinfo.RolesInRepo {
213
213
if u != nil {
214
214
r := f.rr.enforcer.GetPermissionsInRepo(u.Did, f.Knot, f.DidSlashRepo())
215
-
return repoinfo.RolesInRepo{r}
215
+
return repoinfo.RolesInRepo{Roles: r}
216
216
} else {
217
217
return repoinfo.RolesInRepo{}
218
218
}