From 247db3a6f41438ef38214137fe02dc78c6e3f823 Mon Sep 17 00:00:00 2001 From: Codeberg Date: Tue, 2 Feb 2021 01:41:25 +0100 Subject: [PATCH] address issue #2 --- Makefile | 19 ++++++------------- README.md | 14 ++++++++++++++ main.go | 6 +++++- 3 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 README.md diff --git a/Makefile b/Makefile index 2075382..f27b5d6 100755 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ export GOROOT := ${BUILDDIR}/go export GOPATH := ${BUILDDIR}/gitea 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 TARGETS = ${GOPATH}/bin/avatar @@ -16,20 +16,13 @@ all : ${TARGETS} ${GOPATH}/bin/avatar : main.go ${GOROOT}/bin/go go build -o $@ $< - -deployment : deploy-avatar - -deploy-avatar : ${GOPATH}/bin/avatar - -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 +${GOROOT}/bin/go : + mkdir -p ${GOROOT}/Downloads + wget -c --no-verbose --directory-prefix=${GOROOT}/Downloads https://dl.google.com/go/${GOTAR} + tar xfz ${GOROOT}/Downloads/${GOTAR} -C ${BUILDDIR} clean : - ${MAKE} -C ${GOPATH}/src/code.gitea.io/gitea clean + rm -rf ${TARGETS} realclean : rm -rf ${BUILDDIR} diff --git a/README.md b/README.md new file mode 100644 index 0000000..74b8ad1 --- /dev/null +++ b/README.md @@ -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 +``` + + diff --git a/main.go b/main.go index 4372cd4..a8fd93d 100644 --- a/main.go +++ b/main.go @@ -22,7 +22,11 @@ func makeAvatar(seedString string) string { seed = bits.RotateLeft64(seed, 8) seed ^= uint64(c) } - return femaleAvatar(seed) + if seed & 1 == 0 { + return femaleAvatar(seed) + } else { + return maleAvatar(seed) + } } /**