1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

feat: show users top languages

feat: language icons
This commit is contained in:
Ferdinand Mütsch
2022-10-05 23:36:57 +02:00
parent 7a07c9d4fc
commit 1989a69926
10 changed files with 77 additions and 15 deletions

View File

@@ -1,6 +1,9 @@
package view
import "github.com/muety/wakapi/models"
import (
"github.com/muety/wakapi/models"
"strings"
)
type LeaderboardViewModel struct {
User *models.User
@@ -39,3 +42,30 @@ func (s *LeaderboardViewModel) ColorModifier(item *models.LeaderboardItem, princ
}
return "default"
}
func (s *LeaderboardViewModel) LangIcon(lang string) string {
// https://icon-sets.iconify.design/mdi/
langs := map[string]string{
"c": "c",
"c++": "cpp",
"cpp": "cpp",
"go": "go",
"haskell": "haskell",
"html": "html5",
"java": "java",
"javascript": "javascript",
"kotlin": "kotlin",
"lua": "lua",
"php": "php",
"python": "python",
"r": "r",
"ruby": "ruby",
"rust": "rust",
"swift": "swift",
"typescript": "typescript",
}
if match, ok := langs[strings.ToLower(lang)]; ok {
return "mdi:language-" + match
}
return ""
}