Browse Source

closes #12355

pull/12356/head
Ebicoglu 5 years ago
parent
commit
f15ed95068
  1. 7
      modules/docs/src/Volo.Docs.Web/DocsWebModule.cs
  2. 110
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml
  3. 30
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs
  4. 4
      modules/docs/src/Volo.Docs.Web/Pages/Shared/Components/Head/Default.cshtml
  5. 15
      modules/docs/src/Volo.Docs.Web/Pages/Shared/Components/Head/HeadViewComponent.cs

7
modules/docs/src/Volo.Docs.Web/DocsWebModule.cs

@ -5,6 +5,7 @@ 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.Components.LayoutHook;
using Volo.Abp.AspNetCore.Mvc.UI.Packages; 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.AspNetCore.Mvc.UI.Theme.Shared;
@ -16,6 +17,7 @@ using Volo.Docs.Bundling;
using Volo.Docs.HtmlConverting; using Volo.Docs.HtmlConverting;
using Volo.Docs.Localization; using Volo.Docs.Localization;
using Volo.Docs.Markdown; using Volo.Docs.Markdown;
using Volo.Docs.Pages.Shared.Components.Head;
namespace Volo.Docs namespace Volo.Docs
{ {
@ -91,6 +93,11 @@ namespace Volo.Docs
{ {
options.DisableModule(DocsRemoteServiceConsts.ModuleName); options.DisableModule(DocsRemoteServiceConsts.ModuleName);
}); });
Configure<AbpLayoutHookOptions>(options =>
{
options.Add(LayoutHooks.Head.Last, typeof(HeadViewComponent));
});
} }
} }
} }

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

@ -11,38 +11,42 @@
@using Volo.Docs.Localization @using Volo.Docs.Localization
@using Volo.Docs.Pages.Documents.Project @using Volo.Docs.Pages.Documents.Project
@using Volo.Docs.Pages.Documents.Shared.ErrorComponent @using Volo.Docs.Pages.Documents.Shared.ErrorComponent
@using Volo.Docs.Pages.Shared.Components.Head
@inject IThemeManager ThemeManager @inject IThemeManager ThemeManager
@inject IPageLayout PageLayout @inject IPageLayout PageLayout
@inject IHtmlLocalizer<DocsResource> L @inject IHtmlLocalizer<DocsResource> L
@model IndexModel @model IndexModel
@{ @{
ViewBag.FluidLayout = true; ViewBag.FluidLayout = true;
Layout = ThemeManager.CurrentTheme.GetEmptyLayout(); Layout = ThemeManager.CurrentTheme.GetEmptyLayout();
PageLayout.Content.Title = Model.DocumentName?.Replace("-", " "); PageLayout.Content.Title = Model.DocumentName?.Replace("-", " ");
ViewBag.Description = Model.GetDescription(); ViewBag.Description = Model.GetDescription();
ViewBag.CanonicalUrl = Model.IsLatestVersion ? null : Model.GetFullUrlOfTheLatestDocument(); //issue #12355
} }
@section styles { @section styles {
<abp-style-bundle name="@typeof(IndexModel).FullName"> <abp-style-bundle name="@typeof(IndexModel).FullName">
<abp-style type="@typeof(PrismjsStyleBundleContributor)" /> <abp-style type="@typeof(PrismjsStyleBundleContributor)" />
<abp-style type="@typeof(MalihuCustomScrollbarPluginStyleBundleContributor)" /> <abp-style type="@typeof(MalihuCustomScrollbarPluginStyleBundleContributor)" />
<abp-style src="/Pages/Documents/Project/bootstrap-toc.css" /> <abp-style src="/Pages/Documents/Project/bootstrap-toc.css" />
<abp-style src="/Pages/Documents/Shared/Styles/vs.css" /> <abp-style src="/Pages/Documents/Shared/Styles/vs.css" />
<abp-style src="/Pages/Documents/Project/index.css"/> <abp-style src="/Pages/Documents/Project/index.css" />
</abp-style-bundle> </abp-style-bundle>
} }
@section scripts { @section scripts {
<abp-script-bundle name="@typeof(IndexModel).FullName"> <abp-script-bundle name="@typeof(IndexModel).FullName">
<abp-script type="@typeof(MalihuCustomScrollbarPluginScriptBundleContributor)" /> <abp-script type="@typeof(MalihuCustomScrollbarPluginScriptBundleContributor)" />
<abp-script type="@typeof(ClipboardScriptBundleContributor)" /> <abp-script type="@typeof(ClipboardScriptBundleContributor)" />
<abp-script type="@typeof(AnchorJsScriptBundleContributor)" /> <abp-script type="@typeof(AnchorJsScriptBundleContributor)" />
<abp-script type="@typeof(PrismjsScriptBundleContributor)" /> <abp-script type="@typeof(PrismjsScriptBundleContributor)" />
<abp-script type="@typeof(PopperJsScriptBundleContributor)" /> <abp-script type="@typeof(PopperJsScriptBundleContributor)" />
<abp-script src="/client-proxies/docs-proxy.js" /> <abp-script src="/client-proxies/docs-proxy.js" />
<abp-script src="/Pages/Documents/Project/bootstrap-toc.js" /> <abp-script src="/Pages/Documents/Project/bootstrap-toc.js" />
<abp-script src="/Pages/Documents/Shared/Scripts/vs.js" /> <abp-script src="/Pages/Documents/Shared/Scripts/vs.js" />
<abp-script src="/Pages/Documents/Project/index.js" /> <abp-script src="/Pages/Documents/Project/index.js" />
<abp-script src="/Pages/Documents/Shared/ErrorComponent/error.js" /> <abp-script src="/Pages/Documents/Shared/ErrorComponent/error.js" />
</abp-script-bundle> </abp-script-bundle>
} }
@if (Model.LoadSuccess) @if (Model.LoadSuccess)
{ {
@ -93,8 +97,8 @@
</span> </span>
<select asp-items="Model.ProjectSelectItems" <select asp-items="Model.ProjectSelectItems"
class="form-select" class="form-select"
onchange="window.location.pathname = this.value"> onchange="window.location.pathname = this.value">
</select> </select>
</div> </div>
</div> </div>
@ -112,11 +116,11 @@
<span class="input-group-text"> <span class="input-group-text">
<i class="fas fa-code-branch" aria-hidden="true" data-bs-toggle="tooltip" title="@L["Version"]"></i> <i class="fas fa-code-branch" aria-hidden="true" data-bs-toggle="tooltip" title="@L["Version"]"></i>
</span> </span>
<select asp-items="Model.VersionSelectItems" <select asp-items="Model.VersionSelectItems"
class="form-select" class="form-select"
onchange="if (this.value) { window.location.replace(this.value) }"> onchange="if (this.value) { window.location.replace(this.value) }">
</select> </select>
</div> </div>
</div> </div>
@ -131,11 +135,11 @@
<div class="version-select"> <div class="version-select">
<div class="input-group"> <div class="input-group">
@*<span class="input-group-text"> @*<span class="input-group-text">
<i class="fa fa-globe" aria-hidden="true" data-bs-toggle="tooltip" title="@L["Language"]"></i> <i class="fa fa-globe" aria-hidden="true" data-bs-toggle="tooltip" title="@L["Language"]"></i>
</span>*@ </span>*@
<select asp-items="Model.LanguageSelectListItems" <select asp-items="Model.LanguageSelectListItems"
class="form-select" class="form-select"
onchange="window.location.replace(this.value)"> onchange="window.location.replace(this.value)">
</select> </select>
</div> </div>
</div> </div>
@ -149,11 +153,11 @@
<div class="input-group"> <div class="input-group">
<span class="input-group-text"><i class="fa fa-filter"></i></span> <span class="input-group-text"><i class="fa fa-filter"></i></span>
<input class="form-control" <input class="form-control"
id="filter" id="filter"
type="search" type="search"
data-search-url="@Model." data-search-url="@Model."
placeholder="@L["FilterTopics"].Value" placeholder="@L["FilterTopics"].Value"
aria-label="Filter"> aria-label="Filter">
</div> </div>
</div> </div>
</div> </div>
@ -168,13 +172,13 @@
else else
{ {
<ul root-node="@Model.Navigation" <ul root-node="@Model.Navigation"
version="@(Model.LatestVersionInfo == null || Model.LatestVersionInfo.IsSelected ? DocsAppConsts.Latest : Model.Version)" version="@(Model.LatestVersionInfo == null || Model.LatestVersionInfo.IsSelected ? DocsAppConsts.Latest : Model.Version)"
project-name="@Model.ProjectName" project-name="@Model.ProjectName"
project-format="@Model.Project.Format" project-format="@Model.Project.Format"
selected-document-name="@Model.DocumentNameWithExtension" selected-document-name="@Model.DocumentNameWithExtension"
language="@Model.LanguageCode" language="@Model.LanguageCode"
id="sidebar-scroll" id="sidebar-scroll"
class="nav nav-list"></ul> class="nav nav-list"></ul>
} }
</div> </div>
@ -194,11 +198,11 @@
<span class="input-group-text"><i class="fa fa-search"></i></span> <span class="input-group-text"><i class="fa fa-search"></i></span>
<input class="form-control" <input class="form-control"
id="fullsearch" id="fullsearch"
type="search" type="search"
data-fullsearch-url="/search/@Model.LanguageCode/@Model.ProjectName/@Model.Version/" data-fullsearch-url="/search/@Model.LanguageCode/@Model.ProjectName/@Model.Version/"
placeholder="@L["FullSearch"].Value" placeholder="@L["FullSearch"].Value"
aria-label="Filter"> aria-label="Filter">
</div> </div>
</div> </div>
} }
@ -210,15 +214,15 @@
<span class="for-desktop me-3"> <span class="for-desktop me-3">
@(L["Contributors"].Value) @(L["Contributors"].Value)
</span> </span>
@foreach (var contributor in Model.Document.Contributors.OrderByDescending(c=> c.CommitCount).ToList()) @foreach (var contributor in Model.Document.Contributors.OrderByDescending(c => c.CommitCount).ToList())
{ {
<a href="@contributor.UserProfileUrl" target="_blank" class="cont-avatar"> <a href="@contributor.UserProfileUrl" target="_blank" class="cont-avatar">
<img src="@contributor.AvatarUrl" <img src="@contributor.AvatarUrl"
class="rounded-circle" class="rounded-circle"
alt="Avatar" alt="Avatar"
height="21" height="21"
width="21" width="21"
title="@contributor.Username" /> title="@contributor.Username" />
</a> </a>
} }
} }
@ -261,8 +265,8 @@
<div class="input-group"> <div class="input-group">
<span class="input-group-text" id="@("Section" + parameter.Name + "ComboboxAddonId")">@(parameter.DisplayName)</span> <span class="input-group-text" id="@("Section" + parameter.Name + "ComboboxAddonId")">@(parameter.DisplayName)</span>
<select class="doc-section-combobox form-select" <select class="doc-section-combobox form-select"
aria-describedby="@("Section" + parameter.Name + "ComboboxAddonId")" aria-describedby="@("Section" + parameter.Name + "ComboboxAddonId")"
id="@("Section" + parameter.Name + "ComboboxId")" data-key="@parameter.Name"> id="@("Section" + parameter.Name + "ComboboxId")" data-key="@parameter.Name">
@foreach (var value in parameter.Values) @foreach (var value in parameter.Values)
{ {
@if (value.Key == (Model.UserPreferences.ContainsKey(parameter.Name) ? Model.UserPreferences[parameter.Name] : null)) @if (value.Key == (Model.UserPreferences.ContainsKey(parameter.Name) ? Model.UserPreferences[parameter.Name] : null))

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

@ -78,6 +78,8 @@ namespace Volo.Docs.Pages.Documents.Project
public bool FullSearchEnabled { get; set; } public bool FullSearchEnabled { get; set; }
public bool IsLatestVersion => Version == LatestVersionInfo.Version;
private const int MaxDescriptionMetaTagLength = 200; private const int MaxDescriptionMetaTagLength = 200;
private readonly IDocumentAppService _documentAppService; private readonly IDocumentAppService _documentAppService;
private readonly IDocumentToHtmlConverterFactory _documentToHtmlConverterFactory; private readonly IDocumentToHtmlConverterFactory _documentToHtmlConverterFactory;
@ -100,6 +102,7 @@ namespace Volo.Docs.Pages.Documents.Project
_documentSectionRenderer = documentSectionRenderer; _documentSectionRenderer = documentSectionRenderer;
_uiOptions = options.Value; _uiOptions = options.Value;
LocalizationResourceType = typeof(DocsResource); LocalizationResourceType = typeof(DocsResource);
} }
@ -215,15 +218,21 @@ namespace Volo.Docs.Pages.Documents.Project
.Append("/").Append(LatestVersionInfo.IsSelected ? DocsAppConsts.Latest : Version).Append("/").Append(DocumentName).ToString(); .Append("/").Append(LatestVersionInfo.IsSelected ? DocsAppConsts.Latest : Version).Append("/").Append(DocumentName).ToString();
sb.Clear(); sb.Clear();
return Redirect(sb.Append("/Abp/Languages/Switch?culture=").Append(LanguageCode).Append("&uiCulture=") return Redirect(sb.Append("/Abp/Languages/Switch?culture=").Append(LanguageCode).Append("&uiCulture=")
.Append(LanguageCode).Append("&returnUrl=").Append(returnUrl).ToString()); .Append(LanguageCode).Append("&returnUrl=").Append(returnUrl).ToString());
} }
public string GetFullUrlOfTheLatestDocument()
{
return Request.Scheme + "://" + Request.Host.Value + Request.PathBase +
DocumentsUrlPrefix + LanguageCode + "/" + ProjectName + "/" +
DocsAppConsts.Latest + "/" + DocumentName;
}
private IActionResult RedirectToDefaultLanguage() private IActionResult RedirectToDefaultLanguage()
{ {
return RedirectToPage(new return RedirectToPage(new {
{
projectName = ProjectName, projectName = ProjectName,
version = (LatestVersionInfo.IsSelected ? DocsAppConsts.Latest : Version), version = (LatestVersionInfo.IsSelected ? DocsAppConsts.Latest : Version),
languageCode = DefaultLanguageCode, languageCode = DefaultLanguageCode,
@ -233,8 +242,7 @@ namespace Volo.Docs.Pages.Documents.Project
private IActionResult RedirectToDefaultDocument() private IActionResult RedirectToDefaultDocument()
{ {
return RedirectToPage(new return RedirectToPage(new {
{
projectName = ProjectName, projectName = ProjectName,
version = (LatestVersionInfo.IsSelected ? DocsAppConsts.Latest : Version), version = (LatestVersionInfo.IsSelected ? DocsAppConsts.Latest : Version),
documentName = "", documentName = "",
@ -332,7 +340,7 @@ namespace Volo.Docs.Pages.Documents.Project
private VersionInfoViewModel GetLatestVersionInfo(List<VersionInfoViewModel> versions) private VersionInfoViewModel GetLatestVersionInfo(List<VersionInfoViewModel> versions)
{ {
if (Project.ExtraProperties.ContainsKey("GithubVersionProviderSource") if (Project.ExtraProperties.ContainsKey("GithubVersionProviderSource")
&& (GithubVersionProviderSource) (long) Project.ExtraProperties["GithubVersionProviderSource"] == GithubVersionProviderSource.Branches) && (GithubVersionProviderSource)(long)Project.ExtraProperties["GithubVersionProviderSource"] == GithubVersionProviderSource.Branches)
{ {
var LatestVersionBranchNameWithoutPrefix = RemoveVersionPrefix(Project.LatestVersionBranchName); var LatestVersionBranchNameWithoutPrefix = RemoveVersionPrefix(Project.LatestVersionBranchName);
@ -372,9 +380,9 @@ namespace Volo.Docs.Pages.Documents.Project
private void SetLatestVersionBranchName(List<VersionInfoViewModel> versions) private void SetLatestVersionBranchName(List<VersionInfoViewModel> versions)
{ {
if (!Project.ExtraProperties.ContainsKey("GithubVersionProviderSource") if (!Project.ExtraProperties.ContainsKey("GithubVersionProviderSource")
|| (GithubVersionProviderSource) (long) Project.ExtraProperties["GithubVersionProviderSource"] == GithubVersionProviderSource.Releases) || (GithubVersionProviderSource)(long)Project.ExtraProperties["GithubVersionProviderSource"] == GithubVersionProviderSource.Releases)
{ {
versions.First(v=> !SemanticVersionHelper.IsPreRelease(v.Version)).Version = Project.LatestVersionBranchName; versions.First(v => !SemanticVersionHelper.IsPreRelease(v.Version)).Version = Project.LatestVersionBranchName;
} }
} }
@ -459,7 +467,7 @@ namespace Volo.Docs.Pages.Documents.Project
LanguageSelectListItems = new List<SelectListItem>(); LanguageSelectListItems = new List<SelectListItem>();
var sb = new StringBuilder(); var sb = new StringBuilder();
foreach (var language in LanguageConfig.Languages) foreach (var language in LanguageConfig.Languages)
{ {
LanguageSelectListItems.Add( LanguageSelectListItems.Add(
@ -641,8 +649,8 @@ namespace Volo.Docs.Pages.Documents.Project
} }
); );
} }
return await _documentAppService.GetAsync( return await _documentAppService.GetAsync(
new GetDocumentInput new GetDocumentInput
{ {

4
modules/docs/src/Volo.Docs.Web/Pages/Shared/Components/Head/Default.cshtml

@ -0,0 +1,4 @@
@if (ViewBag.CanonicalUrl != null)
{
<link rel="canonical" href="@ViewBag.CanonicalUrl" />
}

15
modules/docs/src/Volo.Docs.Web/Pages/Shared/Components/Head/HeadViewComponent.cs

@ -0,0 +1,15 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.DependencyInjection;
namespace Volo.Docs.Pages.Shared.Components.Head
{
public class HeadViewComponent : AbpViewComponent
{
public virtual IViewComponentResult Invoke()
{
return View("/Pages/Shared/Components/Head/Default.cshtml");
}
}
}
Loading…
Cancel
Save