From 9a2e84de688fe61cb033f264a2aab63ee8493087 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Mon, 10 Feb 2020 14:26:10 +0300 Subject: [PATCH 1/2] Create DocumentNotFoundPage https://github.com/volosoft/volo/issues/751 --- modules/docs/Volo.Docs.sln | 4 +- .../docs/src/Volo.Docs.Web/DocsWebModule.cs | 8 +- .../Pages/Documents/Project/Index.cshtml | 436 +++++++++--------- .../Pages/Documents/Project/Index.cshtml.cs | 17 + .../DocumentNotFoundComponent/Default.cshtml | 11 + .../DocumentNotFoundPageModel.cs | 15 + .../DocumentNotFoundViewComponent.cs | 26 ++ .../src/Volo.Docs.Web/Volo.Docs.Web.csproj | 1 + 8 files changed, 305 insertions(+), 213 deletions(-) create mode 100644 modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/DocumentNotFoundComponent/Default.cshtml create mode 100644 modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/DocumentNotFoundComponent/DocumentNotFoundPageModel.cs create mode 100644 modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/DocumentNotFoundComponent/DocumentNotFoundViewComponent.cs diff --git a/modules/docs/Volo.Docs.sln b/modules/docs/Volo.Docs.sln index 74e748ac9b..1c32767baa 100644 --- a/modules/docs/Volo.Docs.sln +++ b/modules/docs/Volo.Docs.sln @@ -57,9 +57,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VoloDocs.Web", "app\VoloDoc EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VoloDocs.Migrator", "app\VoloDocs.Migrator\VoloDocs.Migrator.csproj", "{8A5E5001-C017-44A8-ADDA-DC66C102556E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Docs.MongoDB", "src\Volo.Docs.MongoDB\Volo.Docs.MongoDB.csproj", "{DBE846CD-1BED-4F2C-ABF2-94F6240BCB9B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Docs.MongoDB", "src\Volo.Docs.MongoDB\Volo.Docs.MongoDB.csproj", "{DBE846CD-1BED-4F2C-ABF2-94F6240BCB9B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Docs.MongoDB.Tests", "test\Volo.Docs.MongoDB.Tests\Volo.Docs.MongoDB.Tests.csproj", "{C5E2A2A3-D54D-4C2E-97BA-EA50A49ED7AD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Docs.MongoDB.Tests", "test\Volo.Docs.MongoDB.Tests\Volo.Docs.MongoDB.Tests.csproj", "{C5E2A2A3-D54D-4C2E-97BA-EA50A49ED7AD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/modules/docs/src/Volo.Docs.Web/DocsWebModule.cs b/modules/docs/src/Volo.Docs.Web/DocsWebModule.cs index 13f29184a9..5b7309a310 100644 --- a/modules/docs/src/Volo.Docs.Web/DocsWebModule.cs +++ b/modules/docs/src/Volo.Docs.Web/DocsWebModule.cs @@ -5,7 +5,9 @@ using Microsoft.Extensions.Options; using Volo.Abp.AspNetCore.Mvc.Localization; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; using Volo.Abp.AspNetCore.Mvc.UI.Bundling; +using Volo.Abp.AspNetCore.Mvc.UI.Packages; using Volo.Abp.AspNetCore.Mvc.UI.Packages.Prismjs; +using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AutoMapper; using Volo.Abp.Modularity; using Volo.Abp.VirtualFileSystem; @@ -18,7 +20,11 @@ namespace Volo.Docs { [DependsOn( typeof(DocsHttpApiModule), - typeof(AbpAspNetCoreMvcUiBootstrapModule) + typeof(AbpAutoMapperModule), + typeof(AbpAspNetCoreMvcUiBootstrapModule), + typeof(AbpAspNetCoreMvcUiThemeSharedModule), + typeof(AbpAspNetCoreMvcUiPackagesModule), + typeof(AbpAspNetCoreMvcUiBundlingModule) )] public class DocsWebModule : AbpModule { 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 bebf083381..3af95c420d 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 @@ -7,6 +7,7 @@ @using Volo.Abp.AspNetCore.Mvc.UI.Packages.Popper @using Volo.Abp.AspNetCore.Mvc.UI.Packages.Prismjs @using Volo.Abp.AspNetCore.Mvc.UI.Theming +@using Volo.Docs.Pages.Documents.Shared.DocumentNotFoundComponent @using Volo.Docs @using Volo.Docs.Localization @using Volo.Docs.Pages.Documents.Project @@ -39,268 +40,283 @@ } -
-
-
-
+@if (Model.DocumentFound) +{ +
+
+
+
-
- -
- -
+
+ +
-
- @if (Model.VersionSelectItems.Any()) - { -
-
-
-
-
- -
+
- + @if (Model.ShowProjectsCombobox && Model.ProjectSelectItems.Count > 1) + { +
+
+
+
+
+ +
} - @if (Model.LanguageSelectListItems.Count > 1) - { -
-
-
-
-
- +
+ @if (Model.VersionSelectItems.Any()) + { +
+
+
+
+
+ +
+ +
-
-
- } -
+ } -
-
-
-
- + @if (Model.LanguageSelectListItems.Count > 1) + { +
+
+
+
+
+ +
+ +
+
+
- - -
+ }
-
+
+
+
+
+ +
- @if (Model.Navigation == null || Model.Navigation.Content.IsNullOrEmpty()) - { -
- @L["NavigationDocumentNotFound"] + +
+
- } - else - { - - } -
- -
-
- @if (Model.Document != null) - { -
- +
-
-
-
- @if (Model.Document.Contributors != null && Model.Document.Contributors.Count > 0) - { -
- @(L["Contributors"].Value + " :") - @foreach (var contributor in Model.Document.Contributors) - { - - - - } -
- } + @if (Model.Document != null) + { +
+ -
-
+
+
+
+ @if (Model.Document.Contributors != null && Model.Document.Contributors.Count > 0) + { +
+ @(L["Contributors"].Value + " :") + @foreach (var contributor in Model.Document.Contributors) + { + + + + } +
+ } - @if (Model.DocumentLanguageIsDifferent) + @if (Model.DocumentPreferences != null && Model.DocumentPreferences.Parameters != null && Model.DocumentPreferences.Parameters.Any()) { - - @L["DocumentNotFoundInSelectedLanguage"] - +
+ + +

+ + @L["MultipleVersionDocumentInfo"] +

+
+
+ + @foreach (var parameter in Model.DocumentPreferences.Parameters) + { + +
+
+ @(parameter.DisplayName) +
+ +
+
+ } +
+
} - @Html.Raw(Model.Document.Content) -
+
+ +
+
+ + @if (Model.DocumentLanguageIsDifferent) + { + + @L["DocumentNotFoundInSelectedLanguage"] + + } + @Html.Raw(Model.Document.Content) +
-
-
-
+
-
+
-
@L["InThisDocument"]
- +
@L["InThisDocument"]
+ -
-
- } - else - { -
-

@L["DocumentNotFound"]

+ } + else + { +
+

@L["DocumentNotFound"]

- - - @L["BackToWebsite"] - -
- } + + + @L["BackToWebsite"] + +
+ } +
-
- +} +else +{ + @(await Component.InvokeAsync(new + { + model = new DocumentNotFoundPageModel + { + ProjectName = Model.ProjectName, + DocumentName = Model.DocumentName, + LanguageCode = Model.LanguageCode, + Version = Model.Version, + } + })) +} 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 82b58ad117..e3802b2b36 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 @@ -33,6 +33,8 @@ namespace Volo.Docs.Pages.Documents.Project [BindProperty(SupportsGet = true)] public string LanguageCode { get; set; } + public bool DocumentFound { get; set; } = true; + public string DefaultLanguageCode { get; set; } public ProjectDto Project { get; set; } @@ -86,6 +88,21 @@ namespace Volo.Docs.Pages.Documents.Project } public async Task OnGetAsync() + { + try + { + return await SetPageAsync(); + } + catch (DocumentNotFoundException exception) + { + Logger.LogWarning(exception.Message); + + DocumentFound = false; + return Page(); + } + } + + private async Task SetPageAsync() { DocumentsUrlPrefix = _uiOptions.RoutePrefix; ShowProjectsCombobox = _uiOptions.ShowProjectsCombobox; diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/DocumentNotFoundComponent/Default.cshtml b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/DocumentNotFoundComponent/Default.cshtml new file mode 100644 index 0000000000..ade6e18529 --- /dev/null +++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/DocumentNotFoundComponent/Default.cshtml @@ -0,0 +1,11 @@ +@using Volo.Docs.Pages.Documents.Shared.DocumentNotFoundComponent +@model DocumentNotFoundPageModel +@{ +} + +

"@Model.DocumentName" not found in "@Model.ProjectName" documents, with "@Model.Version" version and "@Model.LanguageCode" language

+
+ + click here to return. + + diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/DocumentNotFoundComponent/DocumentNotFoundPageModel.cs b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/DocumentNotFoundComponent/DocumentNotFoundPageModel.cs new file mode 100644 index 0000000000..72b2b97584 --- /dev/null +++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/DocumentNotFoundComponent/DocumentNotFoundPageModel.cs @@ -0,0 +1,15 @@ +namespace Volo.Docs.Pages.Documents.Shared.DocumentNotFoundComponent +{ + public class DocumentNotFoundPageModel + { + public string ProjectName { get; set; } + + public string LanguageCode { get; set; } + + public string Version { get; set; } + + public string DocumentName { get; set; } + + public string DocumentsUrlPrefix { get; set; } + } +} diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/DocumentNotFoundComponent/DocumentNotFoundViewComponent.cs b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/DocumentNotFoundComponent/DocumentNotFoundViewComponent.cs new file mode 100644 index 0000000000..7aeed9beee --- /dev/null +++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/DocumentNotFoundComponent/DocumentNotFoundViewComponent.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Options; +using Volo.Abp.AspNetCore.Mvc; + +namespace Volo.Docs.Pages.Documents.Shared.DocumentNotFoundComponent +{ + public class DocumentNotFoundViewComponent : AbpViewComponent + { + private readonly DocsUiOptions _options; + + public DocumentNotFoundViewComponent(IOptions options) + { + _options = options.Value; + } + public IViewComponentResult Invoke(DocumentNotFoundPageModel model, string defaultErrorMessageKey) + { + model.DocumentsUrlPrefix = _options.RoutePrefix; + + return View("~/Pages/Documents/Shared/DocumentNotFoundComponent/Default.cshtml", model); + } + } +} diff --git a/modules/docs/src/Volo.Docs.Web/Volo.Docs.Web.csproj b/modules/docs/src/Volo.Docs.Web/Volo.Docs.Web.csproj index 2e89e9b255..ed9cf98af8 100644 --- a/modules/docs/src/Volo.Docs.Web/Volo.Docs.Web.csproj +++ b/modules/docs/src/Volo.Docs.Web/Volo.Docs.Web.csproj @@ -18,6 +18,7 @@ + From 52b1940ac50faf197344829079c339b125671087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arma=C4=9Fan=20=C3=9Cnl=C3=BC?= <36102404+armgnunlu@users.noreply.github.com> Date: Mon, 10 Feb 2020 17:33:31 +0300 Subject: [PATCH 2/2] Resolved #2796 --- .../Pages/Documents/Project/Index.cshtml | 1 - .../DocumentNotFoundComponent/Default.cshtml | 52 +++++++++++++++++-- 2 files changed, 47 insertions(+), 6 deletions(-) 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 3af95c420d..a6b1e1538f 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 @@ -46,7 +46,6 @@
-