Exemple #1
0
 private void SetLatestVersionBranchName(List <VersionInfoViewModel> versions)
 {
     if (!Project.ExtraProperties.ContainsKey("GithubVersionProviderSource") ||
         (GithubVersionProviderSource)(long)Project.ExtraProperties["GithubVersionProviderSource"] == GithubVersionProviderSource.Releases)
     {
         versions.First(v => !SemanticVersionHelper.IsPreRelease(v.Version)).Version = Project.LatestVersionBranchName;
     }
 }
Exemple #2
0
        public virtual async Task <IActionResult> OnGetAsync(string keyword)
        {
            if (!await _documentAppService.FullSearchEnabledAsync())
            {
                return(RedirectToPage("Index"));
            }

            KeyWord = keyword;

            Project = await _projectAppService.GetAsync(ProjectName);

            var output = await _projectAppService.GetVersionsAsync(Project.ShortName);

            var versions = output.Items.ToList();

            if (versions.Any() &&
                string.Equals(Version, DocsAppConsts.Latest, StringComparison.OrdinalIgnoreCase))
            {
                if ((!Project.ExtraProperties.ContainsKey("GithubVersionProviderSource") ||
                     (GithubVersionProviderSource)(long)Project.ExtraProperties["GithubVersionProviderSource"] == GithubVersionProviderSource.Releases) &&
                    !string.IsNullOrEmpty(Project.LatestVersionBranchName))
                {
                    Version = Project.LatestVersionBranchName;
                }
                else
                {
                    Version = (versions.FirstOrDefault(v => !SemanticVersionHelper.IsPreRelease(v.Name)) ?? versions.First()).Name;
                }
            }

            SearchOutputs = await _documentAppService.SearchAsync(new DocumentSearchInput
            {
                ProjectId    = Project.Id,
                Context      = KeyWord,
                LanguageCode = LanguageCode,
                Version      = Version
            });

            var highlightTag1 = Guid.NewGuid().ToString();
            var highlightTag2 = Guid.NewGuid().ToString();

            foreach (var searchOutput in SearchOutputs)
            {
                for (var i = 0; i < searchOutput.Highlight.Count; i++)
                {
                    searchOutput.Highlight[i] = _encoder
                                                .Encode(searchOutput.Highlight[i].Replace("<highlight>", highlightTag1)
                                                        .Replace("</highlight>", highlightTag2))
                                                .Replace(highlightTag1, "<highlight>").Replace(highlightTag2, "</highlight>");
                }
            }

            return(Page());
        }
Exemple #3
0
        private VersionInfoViewModel GetLatestVersionInfo(List <VersionInfoViewModel> versions)
        {
            if (Project.ExtraProperties.ContainsKey("GithubVersionProviderSource") &&
                (GithubVersionProviderSource)(long)Project.ExtraProperties["GithubVersionProviderSource"] == GithubVersionProviderSource.Branches)
            {
                var LatestVersionBranchNameWithoutPrefix = RemoveVersionPrefix(Project.LatestVersionBranchName);

                foreach (var version in versions)
                {
                    if (version.Version == LatestVersionBranchNameWithoutPrefix)
                    {
                        return(version);
                    }

                    version.DisplayText = $"{version.DisplayText} ({L["Preview"].Value})";
                    version.IsPreview   = true;
                }
            }

            return(versions.FirstOrDefault(v => !SemanticVersionHelper.IsPreRelease(v.Version)) ?? versions.First());
        }