Browse Source

Docs module: contributors order & skip contributors if nav doc

pull/819/head
Yunus Emre Kalkan 7 years ago
parent
commit
f16fa50350
  1. 21
      modules/docs/src/Volo.Docs.Domain/Volo/Docs/GitHub/Documents/GithubDocumentStore.cs

21
modules/docs/src/Volo.Docs.Domain/Volo/Docs/GitHub/Documents/GithubDocumentStore.cs

@ -29,6 +29,7 @@ namespace Volo.Docs.GitHub.Documents
var rawRootUrl = CalculateRawRootUrl(rootUrl); var rawRootUrl = CalculateRawRootUrl(rootUrl);
var rawDocumentUrl = rawRootUrl + documentName; var rawDocumentUrl = rawRootUrl + documentName;
var commitHistoryUrl = project.GetGitHubUrlForCommitHistory() + documentName; var commitHistoryUrl = project.GetGitHubUrlForCommitHistory() + documentName;
var isNavigationDocument = documentName == project.NavigationDocumentName;
var editLink = rootUrl.ReplaceFirst("/tree/", "/blob/") + documentName; var editLink = rootUrl.ReplaceFirst("/tree/", "/blob/") + documentName;
var localDirectory = ""; var localDirectory = "";
var fileName = documentName; var fileName = documentName;
@ -48,7 +49,7 @@ namespace Volo.Docs.GitHub.Documents
Format = project.Format, Format = project.Format,
LocalDirectory = localDirectory, LocalDirectory = localDirectory,
FileName = fileName, FileName = fileName,
Contributors = await GetContributors(commitHistoryUrl, token), Contributors = !isNavigationDocument ? await GetContributors(commitHistoryUrl, token): new List<DocumentContributor>(),
Version = version, Version = version,
Content = await DownloadWebContentAsStringAsync(rawDocumentUrl, token) Content = await DownloadWebContentAsStringAsync(rawDocumentUrl, token)
}; };
@ -118,7 +119,7 @@ namespace Volo.Docs.GitHub.Documents
{ {
try try
{ {
var urlStartingAfterFirstSlash = url.Substring(url.IndexOf("github.com/",StringComparison.OrdinalIgnoreCase) + "github.com/".Length); var urlStartingAfterFirstSlash = url.Substring(url.IndexOf("github.com/", StringComparison.OrdinalIgnoreCase) + "github.com/".Length);
return urlStartingAfterFirstSlash.Substring(0, urlStartingAfterFirstSlash.IndexOf('/')); return urlStartingAfterFirstSlash.Substring(0, urlStartingAfterFirstSlash.IndexOf('/'));
} }
catch (Exception) catch (Exception)
@ -200,18 +201,16 @@ namespace Volo.Docs.GitHub.Documents
{ {
var author = commit["author"]; var author = commit["author"];
if (contributors.All(c => c.Username != (string) author["login"])) contributors.Add(new DocumentContributor
{ {
contributors.Add(new DocumentContributor Username = (string)author["login"],
{ UserProfileUrl = (string)author["html_url"],
Username = (string)author["login"], AvatarUrl = (string)author["avatar_url"]
UserProfileUrl = (string)author["html_url"], });
AvatarUrl = (string)author["avatar_url"]
});
}
} }
contributors.Reverse(); contributors = contributors.GroupBy(c => c.Username).OrderByDescending(c=>c.Count())
.Select( c => c.FirstOrDefault()).ToList();
} }
catch (Exception ex) catch (Exception ex)
{ {

Loading…
Cancel
Save