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
|
// Contains the model of a package version
package models
type UserPreferences struct {
General GeneralPreferences
Packages PackagesPreferences
Maintainers MaintainersPreferences
Useflags UseflagsPreferences
}
type GeneralPreferences struct {
LandingPageLayout string
}
type PackagesPreferences struct {
Overview PackagesOverviewPreferences
}
type PackagesOverviewPreferences struct {
Layout string
EAPI string
}
type MaintainersPreferences struct {
IncludeProjectPackages bool
ExcludedProjects []string
}
type UseflagsPreferences struct {
Layout string
}
var ArchesToShow = [...]string{"amd64", "x86", "alpha", "arm", "arm64", "hppa", "ia64", "ppc", "ppc64", "riscv", "sparc"}
var AllArches = [...]string{"alpha", "amd64", "arm", "arm64", "hppa", "ia64", "mips", "ppc", "ppc64", "riscv", "s390", "sparc", "x86"}
func GetDefaultUserPreferences() UserPreferences {
userPreferences := UserPreferences{}
userPreferences.General = GeneralPreferences{}
userPreferences.Packages = PackagesPreferences{}
userPreferences.Packages.Overview = PackagesOverviewPreferences{}
userPreferences.Maintainers = MaintainersPreferences{}
userPreferences.Useflags = UseflagsPreferences{}
userPreferences.General.LandingPageLayout = "classic"
userPreferences.Packages.Overview.Layout = "minimal"
userPreferences.Packages.Overview.EAPI = "none"
userPreferences.Useflags.Layout = "bubble"
userPreferences.Maintainers.IncludeProjectPackages = false
userPreferences.Maintainers.ExcludedProjects = []string{}
return userPreferences
}
func (u *UserPreferences) Sanitize() {
defaultUserPreferences := GetDefaultUserPreferences()
if !(u.General.LandingPageLayout == "classic" || u.General.LandingPageLayout == "full") {
u.General.LandingPageLayout = defaultUserPreferences.General.LandingPageLayout
}
if !(u.Packages.Overview.Layout == "minimal" || u.Packages.Overview.Layout == "full") {
u.Packages.Overview.Layout = defaultUserPreferences.Packages.Overview.Layout
}
if !(u.Packages.Overview.EAPI == "none" || u.Packages.Overview.EAPI == "column" || u.Packages.Overview.EAPI == "inline") {
u.Packages.Overview.EAPI = defaultUserPreferences.Packages.Overview.EAPI
}
if !(u.Useflags.Layout == "bubble" || u.Useflags.Layout == "search") {
u.Useflags.Layout = defaultUserPreferences.Useflags.Layout
}
}
|