Browse Source

Merge pull request #2797 from abpframework/Docs-NotFoundPage

Docs not found page
pull/2902/head
Yunus Emre Kalkan 7 years ago
committed by GitHub
parent
commit
a1efa5bcfd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      modules/docs/src/Volo.Docs.Web/DocsWebModule.cs
  2. 22
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml
  3. 17
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs
  4. 53
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/DocumentNotFoundComponent/Default.cshtml
  5. 15
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/DocumentNotFoundComponent/DocumentNotFoundPageModel.cs
  6. 26
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/DocumentNotFoundComponent/DocumentNotFoundViewComponent.cs
  7. 1
      modules/docs/src/Volo.Docs.Web/Volo.Docs.Web.csproj

8
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.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; 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.Packages.Prismjs;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AutoMapper; using Volo.Abp.AutoMapper;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
@ -18,7 +20,11 @@ namespace Volo.Docs
{ {
[DependsOn( [DependsOn(
typeof(DocsHttpApiModule), typeof(DocsHttpApiModule),
typeof(AbpAspNetCoreMvcUiBootstrapModule) typeof(AbpAutoMapperModule),
typeof(AbpAspNetCoreMvcUiBootstrapModule),
typeof(AbpAspNetCoreMvcUiThemeSharedModule),
typeof(AbpAspNetCoreMvcUiPackagesModule),
typeof(AbpAspNetCoreMvcUiBundlingModule)
)] )]
public class DocsWebModule : AbpModule public class DocsWebModule : AbpModule
{ {

22
modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml

@ -5,6 +5,7 @@
@using Volo.Abp.AspNetCore.Mvc.UI.Packages.Clipboard @using Volo.Abp.AspNetCore.Mvc.UI.Packages.Clipboard
@using Volo.Abp.AspNetCore.Mvc.UI.Packages.MalihuCustomScrollbar @using Volo.Abp.AspNetCore.Mvc.UI.Packages.MalihuCustomScrollbar
@using Volo.Abp.AspNetCore.Mvc.UI.Packages.Popper @using Volo.Abp.AspNetCore.Mvc.UI.Packages.Popper
@using Volo.Docs.Pages.Documents.Shared.DocumentNotFoundComponent
@using Volo.Abp.AspNetCore.Mvc.UI.Packages.Prismjs @using Volo.Abp.AspNetCore.Mvc.UI.Packages.Prismjs
@using Volo.Abp.AspNetCore.Mvc.UI.Theming @using Volo.Abp.AspNetCore.Mvc.UI.Theming
@using Volo.Docs @using Volo.Docs
@ -39,7 +40,9 @@
<abp-script src="/Pages/Documents/Project/index.js" /> <abp-script src="/Pages/Documents/Project/index.js" />
</abp-script-bundle> </abp-script-bundle>
} }
<div class="docs-page" data-spy="scroll" data-target="#docs-sticky-index"> @if (Model.DocumentFound)
{
<div class="docs-page" data-spy="scroll" data-target="#docs-sticky-index">
<div class="row justify-content-end"> <div class="row justify-content-end">
<div class="col-md-3 docs-sidebar dark-sidebar"> <div class="col-md-3 docs-sidebar dark-sidebar">
<div class="docs-sidebar-wrapper"> <div class="docs-sidebar-wrapper">
@ -303,5 +306,18 @@
} }
</div> </div>
</div> </div>
}
else
{
@(await Component.InvokeAsync<DocumentNotFoundViewComponent>(new
{
model = new DocumentNotFoundPageModel
{
ProjectName = Model.ProjectName,
DocumentName = Model.DocumentName,
LanguageCode = Model.LanguageCode,
Version = Model.Version,
}
}))
}

17
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)] [BindProperty(SupportsGet = true)]
public string LanguageCode { get; set; } public string LanguageCode { get; set; }
public bool DocumentFound { get; set; } = true;
public string DefaultLanguageCode { get; set; } public string DefaultLanguageCode { get; set; }
public ProjectDto Project { get; set; } public ProjectDto Project { get; set; }
@ -86,6 +88,21 @@ namespace Volo.Docs.Pages.Documents.Project
} }
public async Task<IActionResult> OnGetAsync() public async Task<IActionResult> OnGetAsync()
{
try
{
return await SetPageAsync();
}
catch (DocumentNotFoundException exception)
{
Logger.LogWarning(exception.Message);
DocumentFound = false;
return Page();
}
}
private async Task<IActionResult> SetPageAsync()
{ {
DocumentsUrlPrefix = _uiOptions.RoutePrefix; DocumentsUrlPrefix = _uiOptions.RoutePrefix;
ShowProjectsCombobox = _uiOptions.ShowProjectsCombobox; ShowProjectsCombobox = _uiOptions.ShowProjectsCombobox;

53
modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/DocumentNotFoundComponent/Default.cshtml

@ -0,0 +1,53 @@
@using Volo.Docs.Pages.Documents.Shared.DocumentNotFoundComponent
@model DocumentNotFoundPageModel
@{
}
<div class="row position-relative vh-100" style="background: #e8e8e8;">
<div class="center">
<span class="notfound-404">404</span>
<h1>
<strong>"@Model.DocumentName"</strong> not found in <strong>@Model.ProjectName</strong> documents, with <strong>@Model.Version</strong> version and <strong>@Model.LanguageCode</strong> language.
</h1>
<br />
<a href="@(Model.DocumentsUrlPrefix + Model.LanguageCode + "/" +Model.ProjectName + "/" + Model.Version)" class="btn btn-primary px-4">
Go Back
</a>
</div>
</div>
<style>
h1 {
font-size: 1.75em;
line-height: 1.75;
color: #777;
font-weight: normal;
}
h1 strong {
color: #222;
}
.center {
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
.notfound-404 {
font-size: 300px;
font-weight: 700;
line-height: 1.25;
margin: 0px;
color: #fff;
text-transform: uppercase;
display: block;
margin-bottom: -150px;
z-index: -1;
position: relative;
}
</style>

15
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; }
}
}

26
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<DocsUiOptions> options)
{
_options = options.Value;
}
public IViewComponentResult Invoke(DocumentNotFoundPageModel model, string defaultErrorMessageKey)
{
model.DocumentsUrlPrefix = _options.RoutePrefix;
return View("~/Pages/Documents/Shared/DocumentNotFoundComponent/Default.cshtml", model);
}
}
}

1
modules/docs/src/Volo.Docs.Web/Volo.Docs.Web.csproj

@ -18,6 +18,7 @@
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bundling\Volo.Abp.AspNetCore.Mvc.UI.Bundling.csproj" /> <ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bundling\Volo.Abp.AspNetCore.Mvc.UI.Bundling.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.csproj" /> <ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Packages\Volo.Abp.AspNetCore.Mvc.UI.Packages.csproj" /> <ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Packages\Volo.Abp.AspNetCore.Mvc.UI.Packages.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj" />
<ProjectReference Include="..\Volo.Docs.HttpApi\Volo.Docs.HttpApi.csproj" /> <ProjectReference Include="..\Volo.Docs.HttpApi\Volo.Docs.HttpApi.csproj" />
<PackageReference Include="Markdig.Signed" Version="0.18.0" /> <PackageReference Include="Markdig.Signed" Version="0.18.0" />
<PackageReference Include="Scriban" Version="2.1.1" /> <PackageReference Include="Scriban" Version="2.1.1" />

Loading…
Cancel
Save