Beispiel #1
0
        public void Postbuild(ImmutableList <FileModel> models, IHostService host)
        {
            foreach (var model in models)
            {
                if (model.Type == DocumentType.Article)
                {
                    string         transformedFilePathFromRoot = model.LocalPathFromRoot.Replace("/", "%2F");
                    List <Commits> gitCommits = GitHubApi.GetCommits(models, transformedFilePathFromRoot);

                    if (gitCommits != null)
                    {
                        var commits = gitCommits
                                      .GroupBy(x => x.Author.Login)
                                      .OrderByDescending(x => x.Count())
                                      .Select(x => x.FirstOrDefault())
                                      .Take(5);

                        var content = (Dictionary <string, object>)model.Content;

                        int index = 1;
                        foreach (var commit in commits)
                        {
                            content["gitPageContributor" + index + "Login"]     = commit.Author.Login;
                            content["gitPageContributor" + index + "AvatarUrl"] = commit.Author.AvatarUrl;
                            content["gitPageContributor" + index + "HtmlUrl"]   = commit.Author.HtmlUrl;
                            index++;
                        }

                        content["gitPageDate"] = System.DateTime.Parse(gitCommits[0].Commit.Author.Date).ToShortDateString();
                    }
                }
            }
        }
Beispiel #2
0
        public void Postbuild(ImmutableList <FileModel> models, IHostService host)
        {
            List <Contributor> gitContributors = GitHubApi.GetContributors(models);
            List <Commits>     gitCommits      = GitHubApi.GetCommits(models, "");

            if (gitContributors != null && gitCommits != null)
            {
                foreach (var model in models)
                {
                    if (model.Type == DocumentType.Article)
                    {
                        var content = (Dictionary <string, object>)model.Content;

                        for (var i = 1; i < 6; i++)
                        {
                            content["gitContributor" + i + "Contributions"] = gitContributors[i - 1].Contributions;
                            content["gitContributor" + i + "Login"]         = gitContributors[i - 1].Login;
                            content["gitContributor" + i + "AvatarUrl"]     = gitContributors[i - 1].AvatarUrl;
                            content["gitContributor" + i + "HtmlUrl"]       = gitContributors[i - 1].HtmlUrl;
                        }

                        var commits = gitCommits
                                      .GroupBy(x => x.Author.Login)
                                      .OrderByDescending(x => x.Count())
                                      .Select(x => x.FirstOrDefault())
                                      .Take(5);

                        int index = 1;
                        foreach (var commit in commits)
                        {
                            content["gitRecentContributor" + index + "Login"]     = commit.Author.Login;
                            content["gitRecentContributor" + index + "AvatarUrl"] = commit.Author.AvatarUrl;
                            content["gitRecentContributor" + index + "HtmlUrl"]   = commit.Author.HtmlUrl;
                            index++;
                        }
                    }
                }
            }
        }