diff --git a/modules/docs/app/VoloDocs.Web/Pages/Index.cshtml.cs b/modules/docs/app/VoloDocs.Web/Pages/Index.cshtml.cs index 9404233493..b127db4b3f 100644 --- a/modules/docs/app/VoloDocs.Web/Pages/Index.cshtml.cs +++ b/modules/docs/app/VoloDocs.Web/Pages/Index.cshtml.cs @@ -8,19 +8,19 @@ namespace VoloDocs.Web.Pages { public class IndexModel : PageModel { - private readonly DocsUrlOptions _urlOptions; + private readonly DocsUiOptions _urlUiOptions; - public IndexModel(IOptions urlOptions) + public IndexModel(IOptions urlOptions) { - _urlOptions = urlOptions.Value; + _urlUiOptions = urlOptions.Value; } public IActionResult OnGet() { //TODO: Create HomeController & Index instead of Page. Otherwise, we have an empty Index.cshtml file. - if (!_urlOptions.RoutePrefix.IsNullOrWhiteSpace()) + if (!_urlUiOptions.RoutePrefix.IsNullOrWhiteSpace()) { - return Redirect("." + _urlOptions.RoutePrefix); + return Redirect("." + _urlUiOptions.RoutePrefix); } return Page(); diff --git a/modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs b/modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs index b87f3b12f7..85738e6ff9 100644 --- a/modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs +++ b/modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs @@ -62,7 +62,7 @@ namespace VoloDocs.Web var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); - Configure(options => + Configure(options => { options.RoutePrefix = null; }); diff --git a/modules/docs/src/Volo.Docs.Web/Areas/Documents/TagHelpers/TreeTagHelper.cs b/modules/docs/src/Volo.Docs.Web/Areas/Documents/TagHelpers/TreeTagHelper.cs index 00189be260..afb61eadd3 100644 --- a/modules/docs/src/Volo.Docs.Web/Areas/Documents/TagHelpers/TreeTagHelper.cs +++ b/modules/docs/src/Volo.Docs.Web/Areas/Documents/TagHelpers/TreeTagHelper.cs @@ -13,7 +13,7 @@ namespace Volo.Docs.Areas.Documents.TagHelpers [HtmlTargetElement("ul", Attributes = "root-node")] public class TreeTagHelper : TagHelper { - private readonly DocsUrlOptions _urlOptions; + private readonly DocsUiOptions _uiOptions; private const string LiItemTemplateWithLink = @"
  • {2}{3}
  • "; @@ -41,9 +41,9 @@ namespace Volo.Docs.Areas.Documents.TagHelpers [HtmlAttributeName("language")] public string LanguageCode { get; set; } - public TreeTagHelper(IOptions urlOptions) + public TreeTagHelper(IOptions urlOptions) { - _urlOptions = urlOptions.Value; + _uiOptions = urlOptions.Value; } public override void Process(TagHelperContext context, TagHelperOutput output) @@ -142,7 +142,7 @@ namespace Volo.Docs.Areas.Documents.TagHelpers return "javascript:;"; } - var prefix = _urlOptions.RoutePrefix; + var prefix = _uiOptions.RoutePrefix; return prefix + LanguageCode + "/" + ProjectName + "/" + Version + "/" + pathWithoutFileExtension; } diff --git a/modules/docs/src/Volo.Docs.Web/DocsUrlOptions.cs b/modules/docs/src/Volo.Docs.Web/DocsUiOptions.cs similarity index 70% rename from modules/docs/src/Volo.Docs.Web/DocsUrlOptions.cs rename to modules/docs/src/Volo.Docs.Web/DocsUiOptions.cs index 67c11864ff..4b4ab6a3b4 100644 --- a/modules/docs/src/Volo.Docs.Web/DocsUrlOptions.cs +++ b/modules/docs/src/Volo.Docs.Web/DocsUiOptions.cs @@ -2,7 +2,7 @@ namespace Volo.Docs { - public class DocsUrlOptions + public class DocsUiOptions { private string _routePrefix = "documents"; @@ -15,6 +15,12 @@ namespace Volo.Docs set => _routePrefix = value; } + /// + /// Allows user to see a combobox in user interface for swapping across projects + /// Default value: True; + /// + public bool ShowProjectsCombobox = true; + private string GetFormattedRoutePrefix() { if (string.IsNullOrWhiteSpace(_routePrefix)) diff --git a/modules/docs/src/Volo.Docs.Web/DocsWebModule.cs b/modules/docs/src/Volo.Docs.Web/DocsWebModule.cs index ea2c3447e6..f128aacfd1 100644 --- a/modules/docs/src/Volo.Docs.Web/DocsWebModule.cs +++ b/modules/docs/src/Volo.Docs.Web/DocsWebModule.cs @@ -41,11 +41,11 @@ namespace Volo.Docs Configure(options => { - var urlOptions = context.Services - .GetRequiredServiceLazy>() + var docsOptions = context.Services + .GetRequiredServiceLazy>() .Value.Value; - var routePrefix = urlOptions.RoutePrefix; + var routePrefix = docsOptions.RoutePrefix; options.Conventions.AddPageRoute("/Documents/Project/Index", routePrefix + "{projectName}"); options.Conventions.AddPageRoute("/Documents/Project/Index", routePrefix + "{languageCode}/{projectName}"); diff --git a/modules/docs/src/Volo.Docs.Web/Markdown/MarkdownDocumentToHtmlConverter.cs b/modules/docs/src/Volo.Docs.Web/Markdown/MarkdownDocumentToHtmlConverter.cs index ed3f2802e2..0915be10c2 100644 --- a/modules/docs/src/Volo.Docs.Web/Markdown/MarkdownDocumentToHtmlConverter.cs +++ b/modules/docs/src/Volo.Docs.Web/Markdown/MarkdownDocumentToHtmlConverter.cs @@ -14,13 +14,13 @@ namespace Volo.Docs.Markdown public const string Type = "md"; private readonly IMarkdownConverter _markdownConverter; - private readonly DocsUrlOptions _urlOptions; + private readonly DocsUiOptions _uiOptions; public MarkdownDocumentToHtmlConverter(IMarkdownConverter markdownConverter, - IOptions urlOptions) + IOptions urlOptions) { _markdownConverter = markdownConverter; - _urlOptions = urlOptions.Value; + _uiOptions = urlOptions.Value; } private const string MdLinkFormat = "[{0}]({1}{2}/{3}/{4}{5}/{6})"; @@ -73,7 +73,7 @@ namespace Volo.Docs.Markdown return string.Format( MdLinkFormat, displayText, - _urlOptions.RoutePrefix, + _uiOptions.RoutePrefix, languageCode, projectShortName, version, @@ -101,7 +101,7 @@ namespace Volo.Docs.Markdown return string.Format( MdLinkFormat, displayText, - _urlOptions.RoutePrefix, + _uiOptions.RoutePrefix, languageCode, projectShortName, version, diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Index.cshtml.cs b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Index.cshtml.cs index 15697f466c..9e21ec22de 100644 --- a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Index.cshtml.cs +++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Index.cshtml.cs @@ -15,19 +15,19 @@ namespace Volo.Docs.Pages.Documents public IReadOnlyList Projects { get; set; } private readonly IProjectAppService _projectAppService; - private readonly DocsUrlOptions _urlOptions; + private readonly DocsUiOptions _uiOptions; public IndexModel( IProjectAppService projectAppService, - IOptions urlOptions) + IOptions urlOptions) { _projectAppService = projectAppService; - _urlOptions = urlOptions.Value; + _uiOptions = urlOptions.Value; } public async Task OnGetAsync() { - DocumentsUrlPrefix = _urlOptions.RoutePrefix; + DocumentsUrlPrefix = _uiOptions.RoutePrefix; var listResult = await _projectAppService.GetListAsync(); diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml index 23c46063cc..e0d8d9f02c 100644 --- a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml +++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml @@ -76,7 +76,7 @@
    - @if (Model.ProjectSelectItems.Count > 1) + @if (Model.ShowProjectsCombobox && Model.ProjectSelectItems.Count > 1) {
    diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs index 5e155b7389..c61f2c33c8 100644 --- a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs +++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs @@ -52,28 +52,31 @@ namespace Volo.Docs.Pages.Documents.Project public string DocumentsUrlPrefix { get; set; } + public bool ShowProjectsCombobox { get; set; } + public bool DocumentLanguageIsDifferent { get; set; } private readonly IDocumentAppService _documentAppService; private readonly IDocumentToHtmlConverterFactory _documentToHtmlConverterFactory; private readonly IProjectAppService _projectAppService; - private readonly DocsUrlOptions _options; + private readonly DocsUiOptions _uiOptions; public IndexModel( IDocumentAppService documentAppService, IDocumentToHtmlConverterFactory documentToHtmlConverterFactory, IProjectAppService projectAppService, - IOptions options) + IOptions options) { _documentAppService = documentAppService; _documentToHtmlConverterFactory = documentToHtmlConverterFactory; _projectAppService = projectAppService; - _options = options.Value; + _uiOptions = options.Value; } public async Task OnGetAsync() { - DocumentsUrlPrefix = _options.RoutePrefix; + DocumentsUrlPrefix = _uiOptions.RoutePrefix; + ShowProjectsCombobox = _uiOptions.ShowProjectsCombobox; if (IsDocumentCultureDifferentThanCurrent()) { @@ -81,7 +84,12 @@ namespace Volo.Docs.Pages.Documents.Project } await SetProjectAsync(); - await SetProjectsAsync(); + + if (ShowProjectsCombobox) + { + await SetProjectsAsync(); + } + await SetVersionAsync(); await SetLanguageList();