Skip to content

Commit

Permalink
Merge pull request #21689 from abpframework/Lazy-expandable
Browse files Browse the repository at this point in the history
Lazy expandable feature for documentation
  • Loading branch information
oykuermann authored Dec 25, 2024
2 parents 7d0aa3b + 7c85b2a commit dc3a6d5
Show file tree
Hide file tree
Showing 8 changed files with 445 additions and 22 deletions.
175 changes: 174 additions & 1 deletion docs/en/docs-nav.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
},
{
"text": "TODO Application",
"isLazyExpandable": true,
"path": "tutorials/todo",
"items": [
{
"text": "Overview",
Expand All @@ -75,6 +77,8 @@
},
{
"text": "Book Store Application",
"isLazyExpandable": true,
"path": "tutorials/book-store",
"items": [
{
"text": "Overview",
Expand Down Expand Up @@ -155,6 +159,8 @@
},
{
"text": "Modular Monolith Application",
"isLazyExpandable": true,
"path": "tutorials/modular-crm/index.md",
"items": [
{
"text": "Overview",
Expand Down Expand Up @@ -1893,7 +1899,170 @@
},
{
"text": "Microservice Solution",
"path": "solution-templates/microservice"
"isLazyExpandable": true,
"path": "solution-templates/microservice",
"items":[
{
"text": "Overview",
"path": "solution-templates/microservice"
},
{
"text": "Solution Structure",
"path": "solution-templates/microservice/solution-structure.md"
},
{
"text": "Main Components",
"items": [
{
"text": "Overview",
"path": "solution-templates/microservice/main-components"
},
{
"text": "Microservices",
"path": "solution-templates/microservice/microservices.md"
},
{
"text": "API Gateways",
"path": "solution-templates/microservice/api-gateways.md"
},
{
"text": "Web Applications",
"path": "solution-templates/microservice/web-applications.md"
},
{
"text": "Mobile Applications",
"path": "solution-templates/microservice/mobile-applications.md"
}
]
},
{
"text": "Built-In Features",
"items": [
{
"text": "Overview",
"path": "solution-templates/microservice/built-in-features.md"
},
{
"text": "Authentication",
"path": "solution-templates/microservice/authentication.md"
},
{
"text": "Database configurations",
"path": "solution-templates/microservice/database-configurations.md"
},
{
"text": "Logging (with Serilog and Elasticsearch)",
"path": "solution-templates/microservice/logging.md"
},
{
"text": "Monitoring (with Prometheus and Grafana)",
"path": "solution-templates/microservice/monitoring.md"
},
{
"text": "Swagger integration",
"path": "solution-templates/microservice/swagger.md"
},
{
"text": "Permission management",
"path": "solution-templates/microservice/permission-management.md"
},
{
"text": "Feature management",
"path": "solution-templates/microservice/feature-management.md"
},
{
"text": "Localization system",
"path": "solution-templates/microservice/localization-system.md"
},
{
"text": "Background Jobs",
"path": "solution-templates/microservice/background-jobs.md"
},
{
"text": "Background Workers",
"path": "solution-templates/microservice/background-workers.md"
},
{
"text": "Distributed Locking",
"path": "solution-templates/microservice/distributed-locking.md"
},
{
"text": "Distributed Cache",
"path": "solution-templates/microservice/distributed-cache.md"
},
{
"text": "Multi-Tenancy",
"path": "solution-templates/microservice/multi-tenancy.md"
},
{
"text": "BLOB Storing",
"path": "solution-templates/microservice/blob-storing.md"
},
{
"text": "CORS configuration",
"path": "solution-templates/microservice/cors-configuration.md"
}
]
},
{
"text": "Communication",
"items":[
{
"text": "Overview",
"path": "solution-templates/microservice/communication.md"
},
{
"text": "HTTP API Calls",
"path": "solution-templates/microservice/http-api-calls.md"
},
{
"text": "gRPC Calls",
"path": "solution-templates/microservice/grpc-calls.md"
},
{
"text": "Distributed Events",
"path": "solution-templates/microservice/distributed-events.md"
}
]
},
{
"text": "Helm Charts and Kubernetes",
"path": "solution-templates/microservice/helm-charts-and-kubernetes.md"
},
{
"text": "Guides",
"items": [
{
"text": "Overview",
"path": "solution-templates/microservice/guides.md"
},
{
"text": "Adding new microservices",
"path": "solution-templates/microservice/adding-new-microservices.md"
},
{
"text": "Adding new applications",
"path": "solution-templates/microservice/adding-new-applications.md"
},
{
"text": "Adding new API gateways",
"path": "solution-templates/microservice/adding-new-api-gateways.md"
},
{
"text": "Mono-repo vs multiple repository approaches",
"path": "solution-templates/microservice/mono-repo-vs-multiple-repository-approaches.md"
},
{
"text": "Authoring unit and integration tests",
"path": "solution-templates/microservice/authoring-unit-and-integration-tests.md"
},
{
"text": "How to use with ABP Suite",
"path": "solution-templates/microservice/how-to-use-with-abp-suite.md"
}
]
}
]
},
{
"text": "Application Module",
Expand Down Expand Up @@ -1981,6 +2150,8 @@
},
{
"text": "IdentityServer",
"isLazyExpandable": true,
"path": "modules/identity-server.md",
"items": [
{
"text": "Overview",
Expand All @@ -2003,6 +2174,8 @@
},
{
"text": "OpenIddict",
"isLazyExpandable": true,
"path": "modules/openiddict.md",
"items": [
{
"text": "Overview",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public class NavigationNode
[JsonPropertyName("items")]
public List<NavigationNode> Items { get; set; }

[JsonPropertyName("isLazyExpandable")]
public bool IsLazyExpandable { get; set; }

[JsonPropertyName("isIndex")]
public bool IsIndex { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using System;
using System.Threading.Tasks;
using Asp.Versioning;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Docs.Areas.Models.DocumentNavigation;
using Volo.Docs.Documents;
using Volo.Docs.Utils;

namespace Volo.Docs.Areas.Documents;

[RemoteService(Name = DocsRemoteServiceConsts.RemoteServiceName)]
[Area(DocsRemoteServiceConsts.ModuleName)]
[ControllerName("DocumentNavigation")]
[Route("/docs/document-navigation")]
public class DocumentNavigationController : AbpController
{
private readonly IDocumentAppService _documentAppService;
private readonly IDocsLinkGenerator _docsLinkGenerator;

public DocumentNavigationController(IDocumentAppService documentAppService, IDocsLinkGenerator docsLinkGenerator)
{
_documentAppService = documentAppService;
_docsLinkGenerator = docsLinkGenerator;
}

[HttpGet]
[Route("")]
public virtual async Task<NavigationNode> GetNavigationAsync(GetNavigationNodeWithLinkModel input)
{
var navigationNode = await _documentAppService.GetNavigationAsync(new GetNavigationDocumentInput
{
LanguageCode = input.LanguageCode,
Version = input.Version,
ProjectId = input.ProjectId
});

NormalPath(navigationNode, input);

return navigationNode;
}

protected virtual void NormalPath(NavigationNode node, GetNavigationNodeWithLinkModel input)
{
if (node.HasChildItems)
{
foreach (var item in node.Items)
{
NormalPath(item, input);
}
}

if (UrlHelper.IsExternalLink(node.Path))
{
return;
}

node.Path = RemoveFileExtensionFromPath(node.Path, input.ProjectFormat);
if (node.Path.IsNullOrWhiteSpace())
{
node.Path = "javascript:;";
return;
}

node.Path = _docsLinkGenerator.GenerateLink(input.ProjectName, input.LanguageCode, input.RouteVersion, node.Path);
}

private string RemoveFileExtensionFromPath(string path, string projectFormat)
{
if (path == null)
{
return null;
}

return path.EndsWith("." + projectFormat)
? path.Left(path.Length - projectFormat.Length - 1)
: path;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@ private string RenderNodeAsHtml(NavigationNode node)

var isAnyNodeOpenedInThisLevel = IsAnyNodeOpenedInThisLevel(node);

node.Items?.ForEach(innerNode =>
if (!node.IsLazyExpandable || isAnyNodeOpenedInThisLevel)
{
content += GetParentNode(innerNode, isAnyNodeOpenedInThisLevel);
});

node.Items?.ForEach(innerNode =>
{
content += GetParentNode(innerNode, isAnyNodeOpenedInThisLevel);
});
}

var result = node.IsEmpty ? content : GetLeafNode(node, content);

return result;
Expand Down Expand Up @@ -121,6 +124,11 @@ private string GetLeafNode(NavigationNode node, string content)
listItemCss += " selected-tree";
}

if (node.IsLazyExpandable)
{
listItemCss += " lazy-expand";
}

string listInnerItem;
if (node.Path.IsNullOrEmpty() && node.IsLeaf)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Validation;
using Volo.Docs.Language;
using Volo.Docs.Projects;

namespace Volo.Docs.Areas.Models.DocumentNavigation;

public class GetNavigationNodeWithLinkModel
{
public Guid ProjectId { get; set; }

[DynamicStringLength(typeof(ProjectConsts), nameof(ProjectConsts.MaxVersionNameLength))]
public string Version { get; set; }

[Required]
[DynamicStringLength(typeof(LanguageConsts), nameof(LanguageConsts.MaxLanguageCodeLength))]
public string LanguageCode { get; set; }

[Required]
public string ProjectName { get; set; }

[Required]
public string ProjectFormat { get; set; }

[Required]
public string RouteVersion { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@

@if (Model.LoadSuccess)
{
<script type="text/javascript">
var doc = doc || {};
doc.project = {
id: '@Model.Project.Id',
name: '@Model.Project.ShortName',
languageCode: '@Model.LanguageCode',
version: '@Model.Version',
format: '@Model.Project.Format',
routeVersion: '@(Model.LatestVersionInfo == null || Model.LatestVersionInfo.IsSelected ? DocsAppConsts.Latest : Model.Version)'
}
</script>
<abp-script-bundle name="@typeof(IndexModel).FullName">
<abp-script type="@typeof(MalihuCustomScrollbarPluginScriptBundleContributor)"/>
<abp-script type="@typeof(ClipboardScriptBundleContributor)"/>
Expand Down
Loading

0 comments on commit dc3a6d5

Please sign in to comment.