Skip to content

Commit 6a154d9

Browse files
Add HandleLeafDocumentAsync method and fix problems
1 parent e27b48c commit 6a154d9

File tree

7 files changed

+174
-83
lines changed

7 files changed

+174
-83
lines changed

docs/en/docs-nav.json

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -83,47 +83,59 @@
8383
{
8484
"text": "Overview",
8585
"path": "tutorials/book-store",
86-
"isIndex": true
86+
"isIndex": true,
87+
"isInSeries": true
8788
},
8889
{
8990
"text": "1: Creating the Server Side",
90-
"path": "tutorials/book-store/part-01.md"
91+
"path": "tutorials/book-store/part-01.md",
92+
"isInSeries": true
93+
9194
},
9295
{
9396
"text": "2: The Book List Page",
94-
"path": "tutorials/book-store/part-02.md"
97+
"path": "tutorials/book-store/part-02.md",
98+
"isInSeries": true
9599
},
96100
{
97101
"text": "3: Creating, Updating and Deleting Books",
98-
"path": "tutorials/book-store/part-03.md"
102+
"path": "tutorials/book-store/part-03.md",
103+
"isInSeries": true
99104
},
100105
{
101106
"text": "4: Integration Tests",
102-
"path": "tutorials/book-store/part-04.md"
107+
"path": "tutorials/book-store/part-04.md",
108+
"isInSeries": true
103109
},
104110
{
105111
"text": "5: Authorization",
106-
"path": "tutorials/book-store/part-05.md"
112+
"path": "tutorials/book-store/part-05.md",
113+
"isInSeries": true
107114
},
108115
{
109116
"text": "6: Authors: Domain Layer",
110-
"path": "tutorials/book-store/part-06.md"
117+
"path": "tutorials/book-store/part-06.md",
118+
"isInSeries": true
111119
},
112120
{
113121
"text": "7: Authors: Database Integration",
114-
"path": "tutorials/book-store/part-07.md"
122+
"path": "tutorials/book-store/part-07.md",
123+
"isInSeries": true
115124
},
116125
{
117126
"text": "8: Authors: Application Layer",
118-
"path": "tutorials/book-store/part-08.md"
127+
"path": "tutorials/book-store/part-08.md",
128+
"isInSeries": true
119129
},
120130
{
121131
"text": "9: Authors: User Interface",
122-
"path": "tutorials/book-store/part-09.md"
132+
"path": "tutorials/book-store/part-09.md",
133+
"isInSeries": true
123134
},
124135
{
125136
"text": "10: Book to Author Relation",
126-
"path": "tutorials/book-store/part-10.md"
137+
"path": "tutorials/book-store/part-10.md",
138+
"isInSeries": true
127139
}
128140
]
129141
},
@@ -135,27 +147,33 @@
135147
{
136148
"text": "Overview",
137149
"path": "tutorials/book-store-with-abp-suite",
138-
"isIndex": true
150+
"isIndex": true,
151+
"isInSeries": true
139152
},
140153
{
141154
"text": "1: Creating the Solution",
142-
"path": "tutorials/book-store-with-abp-suite/part-01.md"
155+
"path": "tutorials/book-store-with-abp-suite/part-01.md",
156+
"isInSeries": true
143157
},
144158
{
145159
"text": "2: Creating the Books",
146-
"path": "tutorials/book-store-with-abp-suite/part-02.md"
160+
"path": "tutorials/book-store-with-abp-suite/part-02.md",
161+
"isInSeries": true
147162
},
148163
{
149164
"text": "3: Creating the Authors",
150-
"path": "tutorials/book-store-with-abp-suite/part-03.md"
165+
"path": "tutorials/book-store-with-abp-suite/part-03.md",
166+
"isInSeries": true
151167
},
152168
{
153169
"text": "4: Book to Author Relation",
154-
"path": "tutorials/book-store-with-abp-suite/part-04.md"
170+
"path": "tutorials/book-store-with-abp-suite/part-04.md",
171+
"isInSeries": true
155172
},
156173
{
157174
"text": "5: Customizing the Generated Code",
158-
"path": "tutorials/book-store-with-abp-suite/part-05.md"
175+
"path": "tutorials/book-store-with-abp-suite/part-05.md",
176+
"isInSeries": true
159177
}
160178
]
161179
},
@@ -2070,19 +2088,23 @@
20702088
"items": [
20712089
{
20722090
"text": "Deploy to Azure Web App Service",
2073-
"path": "solution-templates/layered-web-application/deployment/azure-deployment/azure-deployment.md"
2091+
"path": "solution-templates/layered-web-application/deployment/azure-deployment/azure-deployment.md",
2092+
"isInSeries": true
20742093
},
20752094
{
20762095
"text": "Creating an Azure Web App Service Environment",
2077-
"path": "solution-templates/layered-web-application/deployment/azure-deployment/step1-create-azure-resources.md"
2096+
"path": "solution-templates/layered-web-application/deployment/azure-deployment/step1-create-azure-resources.md",
2097+
"isInSeries": true
20782098
},
20792099
{
20802100
"text": "Customizing the Configuration of Your ABP Application",
2081-
"path": "solution-templates/layered-web-application/deployment/azure-deployment/step2-configuration-application.md"
2101+
"path": "solution-templates/layered-web-application/deployment/azure-deployment/step2-configuration-application.md",
2102+
"isInSeries": true
20822103
},
20832104
{
20842105
"text": "Deploying Application With GitHub Actions",
2085-
"path": "solution-templates/layered-web-application/deployment/azure-deployment/step3-deployment-github-action.md"
2106+
"path": "solution-templates/layered-web-application/deployment/azure-deployment/step3-deployment-github-action.md",
2107+
"isInSeries": true
20862108
}
20872109
]
20882110
},

modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ public override void ConfigureServices(ServiceConfigurationContext context)
180180
options.BaseUrl = configuration["App:selfUrl"];
181181
options.IndexPagePath = "Index.md";
182182
options.CalculatePdfFileTitle = project => project.ShortName == "abp" ? "ABP Documentation" : null;
183+
options.DocumentContentNormalizer = content => content.Replace("<i class=\"fa fa-minus text-secondary\"></i>", "No").Replace("<i class=\"fa fa-check text-success\"></i>", "Yes");
183184
});
184185

185186
Configure<AbpBlobStoringOptions>(options =>

modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/NavigationNode.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public class NavigationNode
2727

2828
[JsonPropertyName("ignoreOnDownload")]
2929
public bool IgnoreOnDownload { get; set; }
30+
31+
[JsonPropertyName("isInSeries")]
32+
public bool IsInSeries { get; set; }
3033

3134
public bool IsLeaf => !HasChildItems;
3235

modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/DocsProjectPdfGeneratorOptions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public class DocsProjectPdfGeneratorOptions
4646
/// </summary>
4747
public Func<Project, string> CalculatePdfFileTitle { get; set; }
4848

49+
public Func<string, string> HtmlContentNormalizer { get; set; }
50+
51+
public Func<string, string> DocumentContentNormalizer { get; set; }
52+
4953
public DocsProjectPdfGeneratorOptions()
5054
{
5155
HtmlLayout = $@"

modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/IText/ITextHtmlToPdfRenderer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using iText.Kernel.Pdf.Action;
88
using Microsoft.Extensions.Options;
99
using Volo.Abp.DependencyInjection;
10+
using Volo.Docs.Utils;
1011
using ITextDocument = iText.Layout.Document;
1112

1213
namespace Volo.Docs.Projects.Pdf.IText;
@@ -56,7 +57,7 @@ private void BuildPdfOutlines(PdfOutline parentOutline, List<PdfDocument> pdfDoc
5657
var outline = parentOutline.AddOutline(pdfDocumentNode.Title);
5758
if (!pdfDocumentNode.Id.IsNullOrWhiteSpace())
5859
{
59-
outline.AddAction(PdfAction.CreateGoTo(pdfDocumentNode.Id));
60+
outline.AddAction(UrlHelper.IsExternalLink(pdfDocumentNode.Id) ? PdfAction.CreateURI(pdfDocumentNode.Id) : PdfAction.CreateGoTo(pdfDocumentNode.Id));
6061
}
6162

6263
if (pdfDocumentNode.HasChildren)

modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/Markdig/MarkdigPdfDocumentToHtmlConverter.cs

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,33 @@ protected virtual MarkdownPipeline GetPipeline(PdfDocument pdfDocument)
3636
{
3737
return new MarkdownPipelineBuilder()
3838
.UseAdvancedExtensions()
39+
.UseBootstrap()
3940
.Use(new AnchorLinkResolverExtension(pdfDocument))
4041
.Build();
4142
}
4243

4344
protected virtual string NormalizeContent(string content, PdfDocument pdfDocument, DocumentParams documentParams)
4445
{
4546
content = Regex.Replace(content, @"`{3,4}json\s*//\[doc-nav\][\s\S]*?`{3,4}", string.Empty, RegexOptions.IgnoreCase);
46-
47-
if (pdfDocument.RenderParameters.IsNullOrEmpty())
47+
content = SetContentTitle(content, pdfDocument, documentParams);
48+
if (Options.Value.DocumentContentNormalizer == null)
4849
{
4950
return content;
5051
}
5152

52-
var titleLine = content.Split(Environment.NewLine).FirstOrDefault(x => x.TrimStart().StartsWith("#"));
53-
if (titleLine == null)
54-
{
55-
return content;
56-
}
57-
58-
var paramValues = pdfDocument.RenderParameters.Select(x =>
59-
{
60-
var documentParam = documentParams.Parameters.FirstOrDefault(p => p.Name == x.Key);
61-
return $"{documentParam?.Values[x.Value] ?? x.Value}";
62-
});
63-
64-
var newTitle = $"{titleLine.Trim()} ({string.Join(", ", paramValues)})";
65-
return content.Replace(titleLine, newTitle);
53+
return Options.Value.DocumentContentNormalizer(content);
6654
}
6755

6856
protected virtual string NormalizeHtmlContent(string htmlContent, PdfDocument pdfDocument)
6957
{
7058
htmlContent = WrapHtmlWithPageDiv(htmlContent, pdfDocument);
71-
return ReplaceRelativeImageUrls(htmlContent, pdfDocument);
59+
htmlContent = ReplaceRelativeImageUrls(htmlContent, pdfDocument);
60+
if (Options.Value.HtmlContentNormalizer == null)
61+
{
62+
return htmlContent;
63+
}
64+
65+
return Options.Value.HtmlContentNormalizer(htmlContent);
7266
}
7367

7468
private string WrapHtmlWithPageDiv(string htmlContent, PdfDocument pdfDocument)
@@ -96,4 +90,27 @@ private string ReplaceRelativeImageUrls(string htmlContent, PdfDocument pdfDocum
9690

9791
}, RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.Multiline);
9892
}
93+
94+
private static string SetContentTitle(string content, PdfDocument pdfDocument, DocumentParams documentParams)
95+
{
96+
if (pdfDocument.RenderParameters.IsNullOrEmpty())
97+
{
98+
return content;
99+
}
100+
101+
var titleLine = content.Split(Environment.NewLine).FirstOrDefault(x => x.TrimStart().StartsWith("#"));
102+
if (titleLine == null)
103+
{
104+
return content;
105+
}
106+
107+
var paramValues = pdfDocument.RenderParameters.Select(x =>
108+
{
109+
var documentParam = documentParams.Parameters.FirstOrDefault(p => p.Name == x.Key);
110+
return $"{documentParam?.Values[x.Value] ?? x.Value}";
111+
});
112+
113+
var newTitle = $"{titleLine.Trim()} ({string.Join(", ", paramValues)})";
114+
return content.Replace(titleLine, newTitle);
115+
}
99116
}

0 commit comments

Comments
 (0)