Skip to content

Commit 309c5e1

Browse files
committed
add monsterid
1 parent 0a0b147 commit 309c5e1

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ require (
106106
gopkg.in/ini.v1 v1.66.4
107107
gopkg.in/yaml.v2 v2.4.0
108108
mvdan.cc/xurls/v2 v2.4.0
109+
src.techknowlogick.com/monster-id v0.0.0-20210202042845-b14361e87496
109110
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251
110111
xorm.io/builder v0.3.11
111112
xorm.io/xorm v1.3.2-0.20220714055524-c3bce556200f

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,6 +2430,8 @@ sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
24302430
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
24312431
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
24322432
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
2433+
src.techknowlogick.com/monster-id v0.0.0-20210202042845-b14361e87496 h1:c+syTOBF/T6w7vi7KoDpFHQsAxWrZBn2oJfLqylWqgo=
2434+
src.techknowlogick.com/monster-id v0.0.0-20210202042845-b14361e87496/go.mod h1:C4IzHjWw8+3/osm2FWUib2Ax2owZ1oKx4rzBZilBS8I=
24332435
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251 h1:mUcz5b3FJbP5Cvdq7Khzn6J9OCUQJaBwgBkCR+MOwSs=
24342436
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251/go.mod h1:FJGmPh3vz9jSos1L/F91iAgnC/aejc0wIIrF2ZwJxdY=
24352437
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=

modules/avatar/avatar.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616

1717
"code.gitea.io/gitea/modules/avatar/dicebear"
1818
"code.gitea.io/gitea/modules/avatar/identicon"
19+
"code.gitea.io/gitea/modules/avatar/monsterid"
1920
"code.gitea.io/gitea/modules/avatar/none"
2021
"code.gitea.io/gitea/modules/avatar/robot"
2122
"code.gitea.io/gitea/modules/setting"
@@ -67,6 +68,7 @@ var (
6768
identicon.Identicon{},
6869
none.None{},
6970
robot.Robot{},
71+
monsterid.Monster{},
7072
}
7173
)
7274

modules/avatar/monsterid/generate.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2022 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package monsterid
6+
7+
import (
8+
"image"
9+
10+
monster "src.techknowlogick.com/monster-id"
11+
)
12+
13+
// Monster is used to generate pseudo-random avatars
14+
type Monster struct{}
15+
16+
func (Monster) Name() string {
17+
return "monsterid"
18+
}
19+
20+
func (Monster) RandomUserImage(size int, data []byte) (image.Image, error) {
21+
return randomImageSize(size, data)
22+
}
23+
24+
func (Monster) RandomOrgImage(size int, data []byte) (image.Image, error) {
25+
return randomImageSize(size, data)
26+
}
27+
28+
func (Monster) RandomRepoImage(size int, data []byte) (image.Image, error) {
29+
return randomImageSize(size, data)
30+
}
31+
32+
func randomImageSize(size int, data []byte) (image.Image, error) {
33+
return monster.New(data), nil
34+
}

0 commit comments

Comments
 (0)