From 78c7f82ef8f934fabf0358807a3b5f6970850cd9 Mon Sep 17 00:00:00 2001 From: mappu Date: Mon, 12 Apr 2021 13:32:58 +1200 Subject: [PATCH] exclude 'build: success' badge from repos with 'article' topic --- pages.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pages.go b/pages.go index cbbc3a1..4702e30 100644 --- a/pages.go +++ b/pages.go @@ -174,8 +174,27 @@ func (this *Application) Repopage(w http.ResponseWriter, r *http.Request, repoNa lines := strings.Split(string(readme), "\n") + // Check if this repo has the 'article' tag + hasArticleTag := false + this.reposMut.RLock() + for _, rr := range this.reposCache { + if rr.Name != repoName { + continue + } + for _, topic := range rr.topics { + if topic == "article" { + hasArticleTag = true + break + } + } + } + this.reposMut.RUnlock() + // We add some extra badges based on special text entries - extraBadgesMd := ` ![](https://img.shields.io/badge/build-success-brightgreen)` + extraBadgesMd := `` + if !hasArticleTag { + extraBadgesMd += ` ![](https://img.shields.io/badge/build-success-brightgreen)` + } extraBadgesMd += ` [![](https://img.shields.io/badge/vcs-git-green?logo=git)](` + repoURL + `)` // Inject more badges to 3rd line; or, create badges on 3rd line if there are none already