예제 #1
0
        private async Task SetDocumentAsync()
        {
            if (DocumentName.IsNullOrWhiteSpace())
            {
                DocumentName = Project.DefaultDocumentName;
            }

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

            try
            {
                if (DocumentNameWithExtension.IsNullOrWhiteSpace())
                {
                    Document = await _documentAppService.GetDefaultAsync(
                        new GetDefaultDocumentInput
                    {
                        ProjectId    = Project.Id,
                        LanguageCode = LanguageCode,
                        Version      = Version
                    }
                        );
                }
                else
                {
                    Document = await _documentAppService.GetAsync(
                        new GetDocumentInput
                    {
                        ProjectId    = Project.Id,
                        Name         = DocumentNameWithExtension,
                        LanguageCode = LanguageCode,
                        Version      = Version
                    }
                        );
                }
            }
            catch (DocumentNotFoundException)
            {
                Document = await _documentAppService.GetDefaultAsync(
                    new GetDefaultDocumentInput
                {
                    ProjectId    = Project.Id,
                    LanguageCode = LanguageCode,
                    Version      = Version
                }
                    );
            }

            LanguageCode = Document.CurrentLanguageCode;

            ConvertDocumentContentToHtml();
        }
예제 #2
0
 private async Task <DocumentWithDetailsDto> GetSpecificDocumentOrDefaultAsync(string languageCode)
 {
     if (DocumentName.IsNullOrWhiteSpace())
     {
         return(await _documentAppService.GetDefaultAsync(
                    new GetDefaultDocumentInput
         {
             ProjectId = Project.Id,
             LanguageCode = languageCode,
             Version = Version
         }
                    ));
     }
     else
     {
         return(await _documentAppService.GetAsync(
                    new GetDocumentInput
         {
             ProjectId = Project.Id,
             Name = DocumentNameWithExtension,
             LanguageCode = languageCode,
             Version = Version
         }
                    ));
     }
 }
예제 #3
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;
        }
예제 #4
0
        private async Task SetDocumentAsync()
        {
            if (DocumentName.IsNullOrWhiteSpace())
            {
                DocumentName = Project.DefaultDocumentName;
            }

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

            try
            {
                if (DocumentNameWithExtension.IsNullOrWhiteSpace())
                {
                    Document = await _documentAppService.GetDefaultAsync(
                        new GetDefaultDocumentInput
                    {
                        ProjectId = Project.Id,
                        Version   = Version
                    }
                        );
                }
                else
                {
                    Document = await _documentAppService.GetAsync(
                        new GetDocumentInput
                    {
                        ProjectId = Project.Id,
                        Name      = DocumentNameWithExtension,
                        Version   = Version
                    }
                        );
                }
            }
            catch (DocumentNotFoundException)
            {
                //TODO: Handle it!
                throw;
            }

            ConvertDocumentContentToHtml();
        }