mirror of https://github.com/abpframework/abp.git
15 changed files with 287 additions and 83 deletions
@ -0,0 +1,50 @@ |
|||
using System.Collections.Generic; |
|||
using Newtonsoft.Json; |
|||
using Volo.Docs.Projects; |
|||
|
|||
namespace Volo.Docs.Documents |
|||
{ |
|||
public class DocumentWithDetailsDto |
|||
{ |
|||
public string Title { get; set; } |
|||
|
|||
public string Content { get; set; } |
|||
|
|||
public string Format { get; set; } |
|||
|
|||
public string EditLink { get; set; } |
|||
|
|||
public string RootUrl { get; set; } |
|||
|
|||
public string RawRootUrl { get; set; } |
|||
|
|||
public string Version { get; set; } |
|||
|
|||
public ProjectDto Project { get; set; } |
|||
} |
|||
|
|||
public class NavigationNode |
|||
{ |
|||
[JsonProperty("text")] |
|||
public string Text { get; set; } |
|||
|
|||
[JsonProperty("path")] |
|||
public string Path { get; set; } |
|||
|
|||
[JsonProperty("items")] |
|||
public List<NavigationNode> Items { get; set; } |
|||
} |
|||
|
|||
public class NavigationWithDetailsDto : DocumentWithDetailsDto |
|||
{ |
|||
[JsonProperty("items")] |
|||
public NavigationNode RootItem { get; set; } |
|||
|
|||
public void ConvertItems() |
|||
{ |
|||
RootItem = string.IsNullOrWhiteSpace(Content) ? |
|||
new NavigationNode() : |
|||
JsonConvert.DeserializeObject<NavigationNode>(Content); |
|||
} |
|||
} |
|||
} |
|||
@ -1,23 +0,0 @@ |
|||
using Volo.Docs.Projects; |
|||
|
|||
namespace Volo.Docs.Documents |
|||
{ |
|||
public class DocumentWithDetailsDto |
|||
{ |
|||
public string Title { get; set; } |
|||
|
|||
public string Content { get; set; } |
|||
|
|||
public string Format { get; set; } |
|||
|
|||
public string EditLink { get; set; } |
|||
|
|||
public string RootUrl { get; set; } |
|||
|
|||
public string RawRootUrl { get; set; } |
|||
|
|||
public string Version { get; set; } |
|||
|
|||
public ProjectDto Project { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using Volo.Docs.Pages.Documents.Project; |
|||
|
|||
namespace Volo.Docs |
|||
{ |
|||
public class DocsWebConsts |
|||
{ |
|||
public static VersionInfo DefaultVersion = new VersionInfo("Unstable", "master"); //can be *latest* as well.
|
|||
} |
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
using System.Linq; |
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.AspNetCore.Razor.TagHelpers; |
|||
using Volo.Docs.Documents; |
|||
|
|||
namespace Volo.Docs.Helpers.TagHelpers |
|||
{ |
|||
[HtmlTargetElement("ul", Attributes = "navigation-items")] |
|||
public class TreeTagHelper : TagHelper |
|||
{ |
|||
//private readonly IHttpContextAccessor _contextAccessor;
|
|||
private const string LiItemTemplate = @"<li><label class='tree-toggle nav-header'><span class='plus-icon'><i class='fa fa-chevron-down'></i></span></label><a href='{0}'>{1}</a>{2}</li>"; |
|||
private const string UlItemTemplate = @"<ul class='nav nav-list tree'>{0}</ul>"; |
|||
|
|||
//public TreeTagHelper(IHttpContextAccessor contextAccessor)
|
|||
//{
|
|||
// _contextAccessor = contextAccessor;
|
|||
//}
|
|||
|
|||
[HtmlAttributeName("navigation-items")] |
|||
public NavigationNode RootItem { get; set; } |
|||
|
|||
public override void Process(TagHelperContext context, TagHelperOutput output) |
|||
{ |
|||
var rootUl = string.Format(UlItemTemplate, GetNodeHtml(RootItem)); |
|||
|
|||
output.Content.AppendHtml(rootUl); |
|||
//output.Attributes.SetAttribute("item-count", test);
|
|||
} |
|||
|
|||
private static string GetNodeHtml(NavigationNode node) |
|||
{ |
|||
var childContent = ""; |
|||
|
|||
if (node.Items != null && node.Items.Any()) |
|||
{ |
|||
node.Items.ForEach(innerNode => |
|||
{ |
|||
childContent += string.Format(UlItemTemplate, GetNodeHtml(innerNode)); |
|||
}); |
|||
} |
|||
|
|||
var li = string.Format(LiItemTemplate, string.IsNullOrWhiteSpace(node.Path) ? "#" : node.Path, node.Text, childContent); |
|||
|
|||
return li; |
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
namespace Volo.Docs.Pages.Documents.Project |
|||
{ |
|||
public class VersionInfo |
|||
{ |
|||
public string DisplayText { get; set; } |
|||
|
|||
public string Version { get; set; } |
|||
|
|||
public bool IsSelected { get; set; } |
|||
|
|||
public VersionInfo(string displayText, string version, bool isSelected = false) |
|||
{ |
|||
DisplayText = displayText; |
|||
Version = version; |
|||
IsSelected = isSelected; |
|||
} |
|||
} |
|||
} |
|||
@ -1,4 +1,5 @@ |
|||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
|||
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI |
|||
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap |
|||
@addTagHelper *, Volo.Docs.Web |
|||
@addTagHelper *, Volo.Docs.Web |
|||
@addTagHelper *, Volo.Docs.Helpers |
|||
|
|||
Loading…
Reference in new issue