Пример #1
0
        private async Task SetDocumentAsync()
        {
            try
            {
                if (DocumentNameWithExtension.IsNullOrWhiteSpace())
                {
                    Document = await _documentAppService.GetDefaultAsync(ProjectName, Version, true);
                }
                else
                {
                    Document = await _documentAppService.GetByNameAsync(ProjectName, DocumentNameWithExtension, Version, true);
                }
            }
            catch (DocumentNotFoundException)
            {
                return;
            }

            var converter = _documentConverterFactory.Create(Document.Format ?? ProjectFormat);

            var content = converter.NormalizeLinks(Document.Content, Document.Project.ShortName, GetSpecificVersionOrLatest(), 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;
        }
Пример #2
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();
        }
Пример #3
0
        private async Task SetDocumentAsync()
        {
            Document = await _documentAppService.GetByNameAsync(ProjectName, DocumentNameWithExtension, Version, true);

            var converter = _documentConverterFactory.Create(Document.Format ?? ProjectFormat);
            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;
        }