|
|
|
@ -2,6 +2,7 @@ using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Globalization; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using System.Text.RegularExpressions; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Web; |
|
|
|
@ -70,6 +71,8 @@ namespace Volo.Docs.Pages.Documents.Project |
|
|
|
|
|
|
|
public DocumentRenderParameters UserPreferences { get; set; } = new DocumentRenderParameters(); |
|
|
|
|
|
|
|
public List<string> AlternativeOptionLinkQueries { get; set; } = new List<string>(); |
|
|
|
|
|
|
|
public bool FullSearchEnabled { get; set; } |
|
|
|
|
|
|
|
private const int MaxDescriptionMetaTagLength = 200; |
|
|
|
@ -441,6 +444,7 @@ namespace Volo.Docs.Pages.Documents.Project |
|
|
|
if (_uiOptions.SectionRendering) |
|
|
|
{ |
|
|
|
await SetDocumentPreferencesAsync(); |
|
|
|
SetAlternativeOptionLinksAsync(); |
|
|
|
SetUserPreferences(); |
|
|
|
|
|
|
|
var partialTemplates = await GetDocumentPartialTemplatesAsync(); |
|
|
|
@ -617,21 +621,21 @@ namespace Volo.Docs.Pages.Documents.Project |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var availableparameters = await _documentSectionRenderer.GetAvailableParametersAsync(Document.Content); |
|
|
|
var availableParameters = await _documentSectionRenderer.GetAvailableParametersAsync(Document.Content); |
|
|
|
|
|
|
|
DocumentPreferences = new DocumentParametersDto |
|
|
|
{ |
|
|
|
Parameters = new List<DocumentParameterDto>() |
|
|
|
}; |
|
|
|
|
|
|
|
if (availableparameters == null || !availableparameters.Any()) |
|
|
|
if (availableParameters == null || !availableParameters.Any()) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var parameter in projectParameters.Parameters) |
|
|
|
{ |
|
|
|
var availableParameter = availableparameters.GetOrDefault(parameter.Name); |
|
|
|
var availableParameter = availableParameters.GetOrDefault(parameter.Name); |
|
|
|
if (availableParameter != null) |
|
|
|
{ |
|
|
|
var newParameter = new DocumentParameterDto |
|
|
|
@ -654,6 +658,48 @@ namespace Volo.Docs.Pages.Documents.Project |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void SetAlternativeOptionLinksAsync() |
|
|
|
{ |
|
|
|
if (!DocumentPreferences?.Parameters?.Any() ?? true) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
AlternativeOptionLinkQueries = CollectAlternativeOptionLinksRecursively(); |
|
|
|
} |
|
|
|
|
|
|
|
private List<string> CollectAlternativeOptionLinksRecursively(int index = 0) |
|
|
|
{ |
|
|
|
if (index >= DocumentPreferences.Parameters.Count) |
|
|
|
{ |
|
|
|
return new List<string>(); |
|
|
|
} |
|
|
|
|
|
|
|
var option = DocumentPreferences.Parameters[index]; |
|
|
|
var queries = new List<string>(); |
|
|
|
|
|
|
|
foreach (var key in option.Values.Keys) |
|
|
|
{ |
|
|
|
var linkQuery = new StringBuilder($"{option.Name}={key}"); |
|
|
|
|
|
|
|
var restOfQueries = CollectAlternativeOptionLinksRecursively(index + 1); |
|
|
|
|
|
|
|
if (restOfQueries.Any()) |
|
|
|
{ |
|
|
|
foreach (var restOfQuery in restOfQueries) |
|
|
|
{ |
|
|
|
queries.Add($"{linkQuery}&{restOfQuery}"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
queries.Add($"{linkQuery}"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return queries; |
|
|
|
} |
|
|
|
|
|
|
|
public string GetDescription() |
|
|
|
{ |
|
|
|
if (Document == null || Document.Content.IsNullOrWhiteSpace()) |
|
|
|
|