Exemple #1
0
        public async Task OnGet()
        {
            var projectDto = await _projectAppService.FindByShortNameAsync(ProjectName);

            ProjectFormat = projectDto.Format;

            DocumentNameWithExtension = DocumentName + "." + projectDto.Format;

            var versions = await _documentAppService.GetVersions(projectDto.ShortName, projectDto.DefaultDocumentName,
                                                                 projectDto.ExtraProperties, projectDto.DocumentStoreType, DocumentNameWithExtension);

            Versions = versions.Select(v => new VersionInfo(v, v)).ToList();

            AddDefaultVersionIfNotContains();

            var latestVersion = Versions.Count == 1 ? Versions[0] : Versions[1];

            latestVersion.DisplayText = $"{latestVersion.Version} - latest";
            latestVersion.Version     = latestVersion.Version;


            var versionFromUrl = Versions.FirstOrDefault(v => v.Version == Version);

            if (versionFromUrl != null)
            {
                versionFromUrl.IsSelected = true;
            }
            else if (string.Equals(Version, "latest", StringComparison.InvariantCultureIgnoreCase))
            {
                latestVersion.IsSelected = true;
            }
            else
            {
                Versions.First().IsSelected = true;
            }

            if (Version == null)
            {
                Version = Versions.Single(x => x.IsSelected).Version;
            }

            Document = await _documentAppService.GetByNameAsync(ProjectName, DocumentNameWithExtension, Version, true);

            var converter = _documentConverterFactory.Create(Document.Format ?? projectDto.Format);
            var content   = converter.NormalizeLinks(Document.Content, Document.Project.ShortName, Document.Version, Document.LocalDirectory);

            content = converter.Convert(content);

            content          = HtmlNormalizer.ReplaceImageSources(content, Document.RawRootUrl, Document.LocalDirectory);
            content          = HtmlNormalizer.ReplaceCodeBlocksLanguage(content, "language-C#", "language-csharp"); //todo find a way to make it on client in prismJS configuration (eg: map C# => csharp)
            Document.Content = content;

            Navigation = await _documentAppService.GetNavigationDocumentAsync(ProjectName, Version, false);

            Navigation.ConvertItems();
        }
Exemple #2
0
        private async Task SetNavigationAsync()
        {
            try
            {
                Navigation = await _documentAppService.GetNavigationDocumentAsync(ProjectName, Version, false);
            }
            catch (DocumentNotFoundException) //TODO: What if called on a remote service which may return 404
            {
                return;
            }

            Navigation.ConvertItems();
        }
Exemple #3
0
        private async Task SetNavigationAsync()
        {
            Navigation = await _documentAppService.GetNavigationDocumentAsync(ProjectName, Version, false);

            Navigation.ConvertItems();
        }