Example #1
0
        public async Task <IActionResult> Preview(string username, [FromQuery] UserStatsOptions options)
        {
            var userStats = await _githubService.GetUserStats(username);

            var rank    = _rankService.CalculateRank(userStats);
            var content = await _svgService.GetUserStatsImage(rank, options);


            return(File(content, "image/svg+xml; charset=utf-8"));
        }
Example #2
0
        public async Task <Stream> GetUserStatsImage(UserRank rank, UserStatsOptions options)
        {
            var svg  = new UserStatsCard(_degree, options);
            var file = await GetSvgFile(svg.GetCardName());


            var translations = await GetTranslations(options.Locale ?? "en");

            var styles = await GetStyle(options.Theme ?? "default");

            styles.Apply(options);

            return(svg.Svg(file, rank, styles, translations));
        }
Example #3
0
        public IActionResult Teste(string card, [FromQuery] UserStatsOptions options)
        {
            if (!System.IO.File.Exists(Path.Combine(_environment.ContentRootPath, @"svgs\user-stats", $"{card}.svg")))
            {
                return(BadRequest());
            }

            var coent = System.IO.File.ReadAllText(Path.Combine(_environment.ContentRootPath, @"svgs\user-stats", $"{card}.svg"));

            var usercard = new UserStatsCard(new RankDegree()
            {
                new(){ Rank = "S++", Points = 300000 },
                new(){ Rank = "S+", Points = 63000 },
                new(){ Rank = "S", Points = 28000 },
                new(){ Rank = "A++", Points = 21000 },
                new(){ Rank = "A+", Points = 14000 },
                new(){ Rank = "A", Points = 7000 },
                new(){ Rank = "💪", Points = 0 }
            }, options);
Example #4
0
 public UserStatsCard(RankDegree rankDegree, UserStatsOptions options)
 {
     _options   = options;
     RankDegree = rankDegree;
 }