address issue #2

This commit is contained in:
Codeberg 2021-02-02 01:41:25 +01:00
parent 4f12f14411
commit 247db3a6f4
3 changed files with 25 additions and 14 deletions

View File

@ -6,7 +6,7 @@ export GOROOT := ${BUILDDIR}/go
export GOPATH := ${BUILDDIR}/gitea export GOPATH := ${BUILDDIR}/gitea
export PATH := ${GOROOT}/bin:${GOPATH}/bin:${PATH} export PATH := ${GOROOT}/bin:${GOPATH}/bin:${PATH}
GOTAR = go1.12.1.$(shell uname | tr [:upper:] [:lower:])-amd64.tar.gz GOTAR = go1.15.6.$(shell uname | tr [:upper:] [:lower:])-amd64.tar.gz
ORIGIN = ssh://prlgc.com/git/gogs-gitea ORIGIN = ssh://prlgc.com/git/gogs-gitea
TARGETS = ${GOPATH}/bin/avatar TARGETS = ${GOPATH}/bin/avatar
@ -16,20 +16,13 @@ all : ${TARGETS}
${GOPATH}/bin/avatar : main.go ${GOROOT}/bin/go ${GOPATH}/bin/avatar : main.go ${GOROOT}/bin/go
go build -o $@ $< go build -o $@ $<
${GOROOT}/bin/go :
deployment : deploy-avatar mkdir -p ${GOROOT}/Downloads
wget -c --no-verbose --directory-prefix=${GOROOT}/Downloads https://dl.google.com/go/${GOTAR}
deploy-avatar : ${GOPATH}/bin/avatar tar xfz ${GOROOT}/Downloads/${GOTAR} -C ${BUILDDIR}
-ssh root@${HOSTNAME_FQDN} systemctl stop avatar
scp $< root@${HOSTNAME_FQDN}:/usr/local/bin/
scp -r etc/* root@${HOSTNAME_FQDN}:/etc/
ssh root@${HOSTNAME_FQDN} systemctl daemon-reload
ssh root@${HOSTNAME_FQDN} systemctl enable avatar
ssh root@${HOSTNAME_FQDN} systemctl start avatar
ssh root@${HOSTNAME_FQDN} systemctl status avatar
clean : clean :
${MAKE} -C ${GOPATH}/src/code.gitea.io/gitea clean rm -rf ${TARGETS}
realclean : realclean :
rm -rf ${BUILDDIR} rm -rf ${BUILDDIR}

14
README.md Normal file
View File

@ -0,0 +1,14 @@
# Golang port of DiceBear Avatars, which in turn were inspired by 8biticon avatars
## Build & Run
```shell
# will build the binary into ${BUILDDIR}. The golang compiler is fetched and installed into $PWD/gitea/bin/
make BUILDDIR=$PWD
# Create a random avatar and write it to /tmp/avatar.svg
$PWD/gitea/bin/avatar my-special-seed-string > /tmp/avatar.svg
# Open SVG file with default image viewer
xdg-open /tmp/avatar.svg
```

View File

@ -22,7 +22,11 @@ func makeAvatar(seedString string) string {
seed = bits.RotateLeft64(seed, 8) seed = bits.RotateLeft64(seed, 8)
seed ^= uint64(c) seed ^= uint64(c)
} }
return femaleAvatar(seed) if seed & 1 == 0 {
return femaleAvatar(seed)
} else {
return maleAvatar(seed)
}
} }
/** /**