From d8eb1fda902e74caf84d71a830e13e453dbb0caa Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Fri, 16 Aug 2019 15:10:51 +0300 Subject: [PATCH 1/2] Docs option for projects combobox --- .../docs/app/VoloDocs.Web/Pages/Index.cshtml.cs | 4 ++-- modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs | 2 +- .../Areas/Documents/TagHelpers/TreeTagHelper.cs | 8 ++++---- .../{DocsUrlOptions.cs => DocsOptions.cs} | 8 +++++++- modules/docs/src/Volo.Docs.Web/DocsWebModule.cs | 6 +++--- .../Markdown/MarkdownDocumentToHtmlConverter.cs | 10 +++++----- .../Volo.Docs.Web/Pages/Documents/Index.cshtml.cs | 8 ++++---- .../Pages/Documents/Project/Index.cshtml | 2 +- .../Pages/Documents/Project/Index.cshtml.cs | 14 +++++++++++--- 9 files changed, 38 insertions(+), 24 deletions(-) rename modules/docs/src/Volo.Docs.Web/{DocsUrlOptions.cs => DocsOptions.cs} (70%) diff --git a/modules/docs/app/VoloDocs.Web/Pages/Index.cshtml.cs b/modules/docs/app/VoloDocs.Web/Pages/Index.cshtml.cs index 9404233493..48c810f7e1 100644 --- a/modules/docs/app/VoloDocs.Web/Pages/Index.cshtml.cs +++ b/modules/docs/app/VoloDocs.Web/Pages/Index.cshtml.cs @@ -8,9 +8,9 @@ namespace VoloDocs.Web.Pages { public class IndexModel : PageModel { - private readonly DocsUrlOptions _urlOptions; + private readonly DocsOptions _urlOptions; - public IndexModel(IOptions urlOptions) + public IndexModel(IOptions urlOptions) { _urlOptions = urlOptions.Value; } diff --git a/modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs b/modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs index b87f3b12f7..77dbaff275 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..7e3cf53830 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 DocsOptions _options; 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; + _options = 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 = _options.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/DocsOptions.cs similarity index 70% rename from modules/docs/src/Volo.Docs.Web/DocsUrlOptions.cs rename to modules/docs/src/Volo.Docs.Web/DocsOptions.cs index 67c11864ff..d8bf9f62a9 100644 --- a/modules/docs/src/Volo.Docs.Web/DocsUrlOptions.cs +++ b/modules/docs/src/Volo.Docs.Web/DocsOptions.cs @@ -2,7 +2,7 @@ namespace Volo.Docs { - public class DocsUrlOptions + public class DocsOptions { 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 ShowProjectsComboboxInUi = 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..35574a2d51 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..b0fc185e29 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 DocsOptions _options; public MarkdownDocumentToHtmlConverter(IMarkdownConverter markdownConverter, - IOptions urlOptions) + IOptions urlOptions) { _markdownConverter = markdownConverter; - _urlOptions = urlOptions.Value; + _options = 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, + _options.RoutePrefix, languageCode, projectShortName, version, @@ -101,7 +101,7 @@ namespace Volo.Docs.Markdown return string.Format( MdLinkFormat, displayText, - _urlOptions.RoutePrefix, + _options.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..f958d3d409 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 DocsOptions _options; public IndexModel( IProjectAppService projectAppService, - IOptions urlOptions) + IOptions urlOptions) { _projectAppService = projectAppService; - _urlOptions = urlOptions.Value; + _options = urlOptions.Value; } public async Task OnGetAsync() { - DocumentsUrlPrefix = _urlOptions.RoutePrefix; + DocumentsUrlPrefix = _options.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..8d72e75fe7 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,18 +52,20 @@ 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 DocsOptions _options; public IndexModel( IDocumentAppService documentAppService, IDocumentToHtmlConverterFactory documentToHtmlConverterFactory, IProjectAppService projectAppService, - IOptions options) + IOptions options) { _documentAppService = documentAppService; _documentToHtmlConverterFactory = documentToHtmlConverterFactory; @@ -74,6 +76,7 @@ namespace Volo.Docs.Pages.Documents.Project public async Task OnGetAsync() { DocumentsUrlPrefix = _options.RoutePrefix; + ShowProjectsCombobox = _options.ShowProjectsComboboxInUi; if (IsDocumentCultureDifferentThanCurrent()) { @@ -81,7 +84,12 @@ namespace Volo.Docs.Pages.Documents.Project } await SetProjectAsync(); - await SetProjectsAsync(); + + if (ShowProjectsCombobox) + { + await SetProjectsAsync(); + } + await SetVersionAsync(); await SetLanguageList(); From 63ff62415b1edda5f7570255e4f01fad1bfc1a73 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Fri, 16 Aug 2019 16:16:56 +0300 Subject: [PATCH 2/2] =?UTF-8?q?renaming=20DocsOptions=20to=20DocsUiOptions?= =?UTF-8?q?=20and=20ShowProjectsComboboxInU=C4=B1=20to=20ShowProjectsCombo?= =?UTF-8?q?box?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/docs/app/VoloDocs.Web/Pages/Index.cshtml.cs | 10 +++++----- modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs | 2 +- .../Areas/Documents/TagHelpers/TreeTagHelper.cs | 8 ++++---- .../Volo.Docs.Web/{DocsOptions.cs => DocsUiOptions.cs} | 4 ++-- modules/docs/src/Volo.Docs.Web/DocsWebModule.cs | 2 +- .../Markdown/MarkdownDocumentToHtmlConverter.cs | 10 +++++----- .../src/Volo.Docs.Web/Pages/Documents/Index.cshtml.cs | 8 ++++---- .../Pages/Documents/Project/Index.cshtml.cs | 10 +++++----- 8 files changed, 27 insertions(+), 27 deletions(-) rename modules/docs/src/Volo.Docs.Web/{DocsOptions.cs => DocsUiOptions.cs} (90%) diff --git a/modules/docs/app/VoloDocs.Web/Pages/Index.cshtml.cs b/modules/docs/app/VoloDocs.Web/Pages/Index.cshtml.cs index 48c810f7e1..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 DocsOptions _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 77dbaff275..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 7e3cf53830..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 DocsOptions _options; + 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) { - _options = 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 = _options.RoutePrefix; + var prefix = _uiOptions.RoutePrefix; return prefix + LanguageCode + "/" + ProjectName + "/" + Version + "/" + pathWithoutFileExtension; } diff --git a/modules/docs/src/Volo.Docs.Web/DocsOptions.cs b/modules/docs/src/Volo.Docs.Web/DocsUiOptions.cs similarity index 90% rename from modules/docs/src/Volo.Docs.Web/DocsOptions.cs rename to modules/docs/src/Volo.Docs.Web/DocsUiOptions.cs index d8bf9f62a9..4b4ab6a3b4 100644 --- a/modules/docs/src/Volo.Docs.Web/DocsOptions.cs +++ b/modules/docs/src/Volo.Docs.Web/DocsUiOptions.cs @@ -2,7 +2,7 @@ namespace Volo.Docs { - public class DocsOptions + public class DocsUiOptions { private string _routePrefix = "documents"; @@ -19,7 +19,7 @@ namespace Volo.Docs /// Allows user to see a combobox in user interface for swapping across projects /// Default value: True; /// - public bool ShowProjectsComboboxInUi = true; + public bool ShowProjectsCombobox = true; private string GetFormattedRoutePrefix() { diff --git a/modules/docs/src/Volo.Docs.Web/DocsWebModule.cs b/modules/docs/src/Volo.Docs.Web/DocsWebModule.cs index 35574a2d51..f128aacfd1 100644 --- a/modules/docs/src/Volo.Docs.Web/DocsWebModule.cs +++ b/modules/docs/src/Volo.Docs.Web/DocsWebModule.cs @@ -42,7 +42,7 @@ namespace Volo.Docs Configure(options => { var docsOptions = context.Services - .GetRequiredServiceLazy>() + .GetRequiredServiceLazy>() .Value.Value; var routePrefix = docsOptions.RoutePrefix; diff --git a/modules/docs/src/Volo.Docs.Web/Markdown/MarkdownDocumentToHtmlConverter.cs b/modules/docs/src/Volo.Docs.Web/Markdown/MarkdownDocumentToHtmlConverter.cs index b0fc185e29..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 DocsOptions _options; + private readonly DocsUiOptions _uiOptions; public MarkdownDocumentToHtmlConverter(IMarkdownConverter markdownConverter, - IOptions urlOptions) + IOptions urlOptions) { _markdownConverter = markdownConverter; - _options = 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, - _options.RoutePrefix, + _uiOptions.RoutePrefix, languageCode, projectShortName, version, @@ -101,7 +101,7 @@ namespace Volo.Docs.Markdown return string.Format( MdLinkFormat, displayText, - _options.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 f958d3d409..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 DocsOptions _options; + private readonly DocsUiOptions _uiOptions; public IndexModel( IProjectAppService projectAppService, - IOptions urlOptions) + IOptions urlOptions) { _projectAppService = projectAppService; - _options = urlOptions.Value; + _uiOptions = urlOptions.Value; } public async Task OnGetAsync() { - DocumentsUrlPrefix = _options.RoutePrefix; + DocumentsUrlPrefix = _uiOptions.RoutePrefix; var listResult = await _projectAppService.GetListAsync(); 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 8d72e75fe7..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 @@ -59,24 +59,24 @@ namespace Volo.Docs.Pages.Documents.Project private readonly IDocumentAppService _documentAppService; private readonly IDocumentToHtmlConverterFactory _documentToHtmlConverterFactory; private readonly IProjectAppService _projectAppService; - private readonly DocsOptions _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; - ShowProjectsCombobox = _options.ShowProjectsComboboxInUi; + DocumentsUrlPrefix = _uiOptions.RoutePrefix; + ShowProjectsCombobox = _uiOptions.ShowProjectsCombobox; if (IsDocumentCultureDifferentThanCurrent()) {