Merge pull request #1650 from abpframework/Docs-option-for-projects-combobox

Docs option for projects combobox
pull/1725/head
Halil İbrahim Kalkan 6 years ago committed by GitHub
commit 9d7e3e1359
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,19 +8,19 @@ namespace VoloDocs.Web.Pages
{
public class IndexModel : PageModel
{
private readonly DocsUrlOptions _urlOptions;
private readonly DocsUiOptions _urlUiOptions;
public IndexModel(IOptions<DocsUrlOptions> urlOptions)
public IndexModel(IOptions<DocsUiOptions> 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();

@ -62,7 +62,7 @@ namespace VoloDocs.Web
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
Configure<DocsUrlOptions>(options =>
Configure<DocsUiOptions>(options =>
{
options.RoutePrefix = null;
});

@ -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 = @"<li class='{0}'><span class='plus-icon'><i class='fa fa-{1}'></i></span>{2}{3}</li>";
@ -41,9 +41,9 @@ namespace Volo.Docs.Areas.Documents.TagHelpers
[HtmlAttributeName("language")]
public string LanguageCode { get; set; }
public TreeTagHelper(IOptions<DocsUrlOptions> urlOptions)
public TreeTagHelper(IOptions<DocsUiOptions> 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;
}

@ -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;
}
/// <summary>
/// Allows user to see a combobox in user interface for swapping across projects
/// Default value: True;
/// </summary>
public bool ShowProjectsCombobox = true;
private string GetFormattedRoutePrefix()
{
if (string.IsNullOrWhiteSpace(_routePrefix))

@ -41,11 +41,11 @@ namespace Volo.Docs
Configure<RazorPagesOptions>(options =>
{
var urlOptions = context.Services
.GetRequiredServiceLazy<IOptions<DocsUrlOptions>>()
var docsOptions = context.Services
.GetRequiredServiceLazy<IOptions<DocsUiOptions>>()
.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}");

@ -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<DocsUrlOptions> urlOptions)
IOptions<DocsUiOptions> 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,

@ -15,19 +15,19 @@ namespace Volo.Docs.Pages.Documents
public IReadOnlyList<ProjectDto> Projects { get; set; }
private readonly IProjectAppService _projectAppService;
private readonly DocsUrlOptions _urlOptions;
private readonly DocsUiOptions _uiOptions;
public IndexModel(
IProjectAppService projectAppService,
IOptions<DocsUrlOptions> urlOptions)
IOptions<DocsUiOptions> urlOptions)
{
_projectAppService = projectAppService;
_urlOptions = urlOptions.Value;
_uiOptions = urlOptions.Value;
}
public async Task<IActionResult> OnGetAsync()
{
DocumentsUrlPrefix = _urlOptions.RoutePrefix;
DocumentsUrlPrefix = _uiOptions.RoutePrefix;
var listResult = await _projectAppService.GetListAsync();

@ -76,7 +76,7 @@
<div class="docs-tree-list">
@if (Model.ProjectSelectItems.Count > 1)
@if (Model.ShowProjectsCombobox && Model.ProjectSelectItems.Count > 1)
{
<div class="docs-version">
<div class="version-select">

@ -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<DocsUrlOptions> options)
IOptions<DocsUiOptions> options)
{
_documentAppService = documentAppService;
_documentToHtmlConverterFactory = documentToHtmlConverterFactory;
_projectAppService = projectAppService;
_options = options.Value;
_uiOptions = options.Value;
}
public async Task<IActionResult> 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();

Loading…
Cancel
Save