diff --git a/INSTALLATION.md b/INSTALLATION.md index 8dd81a05..37327a0b 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -13,12 +13,11 @@ ## Download the repository -* `go get github.com/animenotifier/notify.moe` +* `go get github.com/animenotifier/notify.moe/...` ## Build all * `cd $GOPATH/src/github.com/animenotifier/notify.moe` -* `make tools` to install [pack](https://github.com/aerogo/pack) & [run](https://github.com/aerogo/run) * `make all` ## Browser diff --git a/makefile b/makefile index 4a3923dc..bf190197 100644 --- a/makefile +++ b/makefile @@ -9,6 +9,9 @@ BUILDPATCHES=@./patches/build.sh BUILDBOTS=@./bots/build.sh TSCMD=@tsc IPTABLES=@sudo iptables +PACK:=$(shell command -v pack 2> /dev/null) +RUN:=$(shell command -v run 2> /dev/null) +GOIMPORTS:=$(shell command -v goimports 2> /dev/null) # Determine the name of the platform OSNAME= @@ -42,20 +45,36 @@ test: $(GOTEST) github.com/animenotifier/notify.moe -v -cover bench: $(GOTEST) -bench . +pack: + go get -u github.com/aerogo/pack + go install github.com/aerogo/pack +run: + go get -u github.com/aerogo/run + go install github.com/aerogo/run +goimports: + go get -u golang.org/x/tools/cmd/goimports + go install golang.org/x/tools/cmd/goimports tools: ifeq ($(OSNAME),OSX) brew install coreutils endif - go get -u golang.org/x/tools/cmd/goimports - go get -u github.com/aerogo/pack - go get -u github.com/aerogo/run - go install github.com/aerogo/pack - go install github.com/aerogo/run +ifndef GOIMPORTS + @make goimports +endif +ifndef PACK + @make pack +endif +ifndef RUN + @make run +endif versions: @go version + $(TSCMD) --version assets: $(TSCMD) @pack +deps: + @go get -v ./... depslist: $(GOCMD) list -f {{.Deps}} | sed -e 's/\[//g' -e 's/\]//g' | tr " " "\n" clean: @@ -75,6 +94,6 @@ endif ifeq ($(OSNAME),OSX) @/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --ignore-certificate-errors endif -all: assets server bots jobs patches +all: tools assets server bots jobs patches -.PHONY: bots jobs patches ports +.PHONY: tools assets server bots jobs patches ports clean versions diff --git a/middleware/UserInfo.go b/middleware/UserInfo.go index fdd331b1..86aa78fb 100644 --- a/middleware/UserInfo.go +++ b/middleware/UserInfo.go @@ -68,6 +68,15 @@ func updateUserInfo(ctx *aero.Context, user *arn.User) { // Updates the location of the user. func updateUserLocation(user *arn.User, newIP string) { user.IP = newIP + + if arn.APIKeys.IPInfoDB.ID == "" { + if arn.IsProduction() { + color.Red("IPInfoDB key not defined") + } + + return + } + locationAPI := "https://api.ipinfodb.com/v3/ip-city/?key=" + arn.APIKeys.IPInfoDB.ID + "&ip=" + user.IP + "&format=json" response, err := client.Get(locationAPI).End() diff --git a/pages/login/login.pixy b/pages/login/login.pixy index 9dd819be..c12948d4 100644 --- a/pages/login/login.pixy +++ b/pages/login/login.pixy @@ -1,9 +1,11 @@ component Login(target string) .login-buttons.mountable - a.login-button.login-button-google(href="/auth/google", target=target, data-ajax="false") - Icon("google") - span Sign in via Google + if arn.APIKeys.Google.Secret != "" + a.login-button.login-button-google(href="/auth/google", target=target, data-ajax="false") + Icon("google") + span Sign in via Google - a.login-button.login-button-facebook(href="/auth/facebook", target=target, data-ajax="false") - Icon("facebook") - span Sign in via Facebook \ No newline at end of file + if arn.APIKeys.Facebook.Secret != "" + a.login-button.login-button-facebook(href="/auth/facebook", target=target, data-ajax="false") + Icon("facebook") + span Sign in via Facebook \ No newline at end of file diff --git a/patches/delete-anilist-mappings/delete-custom-anime.go b/patches/delete-anilist-mappings/delete-custom-anime.go deleted file mode 100644 index b9fa6232..00000000 --- a/patches/delete-anilist-mappings/delete-custom-anime.go +++ /dev/null @@ -1,16 +0,0 @@ -package main - -import ( - "github.com/animenotifier/arn" -) - -func main() { - defer arn.Node.Close() - - for anime := range arn.StreamAnime() { - providerID := anime.GetMapping("anilist/anime") - arn.DB.Delete("AniListToAnime", providerID) - anime.RemoveMapping("anilist/anime", providerID) - anime.Save() - } -} diff --git a/patches/import-anilist-user/import-anilist-user.go b/patches/import-anilist-user/import-anilist-user.go deleted file mode 100644 index db9d3bbe..00000000 --- a/patches/import-anilist-user/import-anilist-user.go +++ /dev/null @@ -1,40 +0,0 @@ -package main - -import ( - "fmt" - - "github.com/animenotifier/anilist" - "github.com/animenotifier/arn" - "github.com/fatih/color" -) - -var userName = "Akyoto" -var allAnime []*arn.Anime - -func init() { - allAnime = arn.AllAnime() -} - -func main() { - user, _ := arn.GetUserByNick(userName) - animeList, err := anilist.GetAnimeList(user.Accounts.AniList.Nick) - arn.PanicOnError(err) - - importList(animeList.Lists.Watching) - importList(animeList.Lists.Completed) -} - -func importList(animeListItems []*anilist.AnimeListItem) { - imported := []*arn.Anime{} - - for _, item := range animeListItems { - anime := arn.FindAniListAnime(item.Anime, allAnime) - - if anime != nil { - fmt.Println(item.Anime.TitleRomaji, "=>", anime.Title.Romaji) - imported = append(imported, anime) - } - } - - color.Green("%d / %d", len(imported), len(animeListItems)) -}