Browse Source
Merge pull request #22899 from abpframework/liangshiwei/docs-patch
Improve PDF file generation
pull/22903/head
maliming
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
14 additions and
12 deletions
-
modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs
-
modules/docs/app/VoloDocs.Web/appsettings.json
-
modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/ProjectPdfGenerator.cs
-
modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml
|
|
|
@ -177,8 +177,8 @@ namespace VoloDocs.Web |
|
|
|
|
|
|
|
Configure<DocsProjectPdfGeneratorOptions>(options => |
|
|
|
{ |
|
|
|
options.BaseUrl = configuration["App:selfUrl"]; |
|
|
|
options.IndexPagePath = "Index.md"; |
|
|
|
options.BaseUrl = configuration["App:SelfUrl"]; |
|
|
|
options.IndexPagePath = "index.md"; |
|
|
|
options.CalculatePdfFileTitle = project => project.ShortName == "abp" ? "ABP Documentation" : null; |
|
|
|
options.DocumentContentNormalizer = content => content.Replace("<i class=\"fa fa-minus text-secondary\"></i>", "No").Replace("<i class=\"fa fa-check text-success\"></i>", "Yes"); |
|
|
|
}); |
|
|
|
|
|
|
|
@ -1,6 +1,6 @@ |
|
|
|
{ |
|
|
|
"App": { |
|
|
|
"selfUrl": "https://localhost:5001" |
|
|
|
"SelfUrl": "https://localhost:5001" |
|
|
|
}, |
|
|
|
"Kestrel": { |
|
|
|
"EndPoints": { |
|
|
|
|
|
|
|
@ -326,19 +326,21 @@ public class ProjectPdfGenerator : IProjectPdfGenerator, ITransientDependency |
|
|
|
version = string.IsNullOrWhiteSpace(version) ? project.LatestVersionBranchName : version; |
|
|
|
|
|
|
|
Document document = null; |
|
|
|
|
|
|
|
Exception firstException = null; |
|
|
|
foreach (var name in GetPossibleNames(documentName, project.Format)) |
|
|
|
|
|
|
|
var possibleNames = GetPossibleNames(documentName, project.Format); |
|
|
|
document = await DocumentRepository.FindAsync(project.Id, possibleNames, languageCode, version); |
|
|
|
if (document != null) |
|
|
|
{ |
|
|
|
return document; |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var name in possibleNames) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
document = await DocumentRepository.FindAsync(project.Id, documentName, version, languageCode); |
|
|
|
if (document != null) |
|
|
|
{ |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
document = await DocumentSource.GetDocumentAsync(project, name, languageCode, version); |
|
|
|
await DocumentRepository.InsertAsync(document, true); |
|
|
|
break; |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
|
|
|
|
@ -294,7 +294,7 @@ |
|
|
|
@if (Model.HasDownloadPdfPermission) |
|
|
|
{ |
|
|
|
<div class="docs-sidebar-footer"> |
|
|
|
<a href="@Url.Content($"~/api/docs/documents/pdf?ProjectId={Model.Project.Id}&Version={(Model.LatestVersionInfo == null || Model.LatestVersionInfo.IsSelected ? DocsAppConsts.Latest : Model.Version)}&LanguageCode={Model.LanguageCode}")" target="_blank" class="download-pdf-btn"> |
|
|
|
<a href="@Url.Content($"~/api/docs/documents/pdf?ProjectId={Model.Project.Id}&Version={(Model.LatestVersionInfo.IsSelected ? Model.LatestVersionInfo.Version : Model.Version)}&LanguageCode={Model.LanguageCode ?? Model.DefaultLanguageCode}")" target="_blank" class="download-pdf-btn"> |
|
|
|
<i class="fa fa-download"></i> @L["DownloadPDF"] |
|
|
|
</a> |
|
|
|
</div> |
|
|
|
|