示例#1
0
        private async Task <IReadOnlyList <Release> > GetReleasesAsync(Project project)
        {
            var url       = project.GetGitHubUrl();             //https://github.com/52ABP/Documents/tree/{version}/src/mvc/"
            var ownerName = GetOwnerNameFromUrl(url);           //52ABP

            var repositoryName = GetRepositoryNameFromUrl(url); //Documents

            var releases = await _githubRepositoryManager.GetReleasesAsync(ownerName, repositoryName, project.GetGitHubAccessTokenOrNull());

            return(releases);
        }
示例#2
0
        public async Task <DocumentResource> GetResource(Project project, string resourceName, string version)
        {
            var rawRootUrl = CalculateRawRootUrl(project.GetGitHubUrl(version));
            var content    = await DownloadWebContentAsByteArrayAsync(
                rawRootUrl + resourceName,
                project.GetGitHubAccessTokenOrNull(),
                project.GetGithubUserAgentOrNull()
                );

            return(new DocumentResource(content));
        }
示例#3
0
        public virtual async Task <Document> GetDocumentAsync(Project project, string documentName, string version)
        {
            var token                = project.GetGitHubAccessTokenOrNull();
            var rootUrl              = project.GetGitHubUrl(version);
            var rawRootUrl           = CalculateRawRootUrl(rootUrl);
            var rawDocumentUrl       = rawRootUrl + documentName;
            var commitHistoryUrl     = project.GetGitHubUrlForCommitHistory() + documentName;
            var userAgent            = project.GetGithubUserAgentOrNull();
            var isNavigationDocument = documentName == project.NavigationDocumentName;
            var editLink             = rootUrl.ReplaceFirst("/tree/", "/blob/") + documentName;
            var localDirectory       = "";
            var fileName             = documentName;

            if (documentName.Contains("/"))
            {
                localDirectory = documentName.Substring(0, documentName.LastIndexOf('/'));
                fileName       = documentName.Substring(documentName.LastIndexOf('/') + 1);
            }
            var contributors = new List <DocumentContributor>();

            if (!isNavigationDocument)
            {
                contributors = await GetContributors(commitHistoryUrl, token, userAgent);
            }


            var document =
                new Document
            {
                Title          = documentName,
                EditLink       = editLink,
                RootUrl        = rootUrl,
                RawRootUrl     = rawRootUrl,
                Format         = project.Format,
                LocalDirectory = localDirectory,
                FileName       = fileName,
                //Contributors = new List<DocumentContributor>(),
                Contributors = contributors,
                Version      = version,
                Content      = await DownloadWebContentAsStringAsync(rawDocumentUrl, token, userAgent)
            };


            return(document);
        }