Skip to content

Commit

Permalink
Simplify page header
Browse files Browse the repository at this point in the history
  • Loading branch information
SeriaWei committed Oct 11, 2024
1 parent 53cf6aa commit 0152a9e
Show file tree
Hide file tree
Showing 26 changed files with 139 additions and 234 deletions.
8 changes: 2 additions & 6 deletions src/ZKEACMS.Article/Service/ArticleDetailWidgetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,8 @@ public override object Display(WidgetDisplayContext widgetDisplayContext)
return null;
}

var layout = widgetDisplayContext.PageLayout;
if (layout != null && layout.Page != null)
{
layout.Page.ConfigSEO(viewModel.Current.Title, viewModel.Current.MetaKeyWords, viewModel.Current.MetaDescription);
AddStructuredDataToPageHeader(viewModel.Current);
}
ApplicationContext.As<CMSApplicationContext>().CurrentPage.ConfigSEO(viewModel.Current.Title, viewModel.Current.MetaKeyWords, viewModel.Current.MetaDescription);
AddStructuredDataToPageHeader(viewModel.Current);
return viewModel;
}
private void AddStructuredDataToPageHeader(ArticleEntity article)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ public override object Display(WidgetDisplayContext widgetDisplayContext)
else
{
_articleService.IncreaseCount(article);
var layout = widgetDisplayContext.PageLayout;
if (layout != null && layout.Page != null)
{
layout.Page.ConfigSEO(article.Title, article.MetaKeyWords, article.MetaDescription);
}
ApplicationContext.As<CMSApplicationContext>().CurrentPage.ConfigSEO(article.Title, article.MetaKeyWords, article.MetaDescription);
}
viewModel.Current = article;

Expand Down
6 changes: 1 addition & 5 deletions src/ZKEACMS.Article/Service/ArticleTypeWidgetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@ public override object Display(WidgetDisplayContext widgetDisplayContext)
}
if (articleType != null && articleType.SEOTitle.IsNotNullAndWhiteSpace())
{
var layout = widgetDisplayContext.PageLayout;
if (layout != null && layout.Page != null)
{
layout.Page.ConfigSEO(articleType.SEOTitle, articleType.SEOKeyWord, articleType.SEODescription);
}
_articleTypeService.ApplicationContext.As<CMSApplicationContext>().CurrentPage.ConfigSEO(articleType.SEOTitle, articleType.SEOKeyWord, articleType.SEODescription);
}
return new ArticleTypeWidgetViewModel
{
Expand Down
6 changes: 1 addition & 5 deletions src/ZKEACMS.Product/Service/ProductCategoryWidgetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ public override object Display(WidgetDisplayContext widgetDisplayContext)
}
if (productCategory != null && productCategory.SEOTitle.IsNotNullAndWhiteSpace())
{
var layout = widgetDisplayContext.PageLayout;
if (layout != null && layout.Page != null)
{
layout.Page.ConfigSEO(productCategory.SEOTitle, productCategory.SEOKeyWord, productCategory.SEODescription);
}
ApplicationContext.As<CMSApplicationContext>().CurrentPage.ConfigSEO(productCategory.SEOTitle, productCategory.SEOKeyWord, productCategory.SEODescription);
}
return new ProductCategoryWidgetViewModel
{
Expand Down
9 changes: 3 additions & 6 deletions src/ZKEACMS.Product/Service/ProductDetailWidgetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,9 @@ public override object Display(WidgetDisplayContext widgetDisplayContext)
return null;
}

var layout = widgetDisplayContext.PageLayout;
if (layout != null && layout.Page != null)
{
layout.Page.ConfigSEO(product.SEOTitle ?? product.Title, product.SEOKeyWord, product.SEODescription);
AddStructuredDataToPageHeader(product);
}
ApplicationContext.As<CMSApplicationContext>().CurrentPage.ConfigSEO(product.SEOTitle ?? product.Title, product.SEOKeyWord, product.SEODescription);
AddStructuredDataToPageHeader(product);

return product;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Easy.Mvc.Authorize;
using Easy.Extend;
using System.Text.RegularExpressions;
using ZKEACMS.Filter;

namespace ZKEACMS.SectionWidget.Controllers
{
Expand Down Expand Up @@ -62,6 +63,7 @@ public JsonResult Delete(string Id)
return Json(true);
}

[Themed]
public ActionResult Play(string Id)
{
SectionContentVideo video = _sectionContentProviderService.GetContent(Id) as SectionContentVideo;
Expand Down
8 changes: 8 additions & 0 deletions src/ZKEACMS.WebHost/Views/Shared/Partial.PageHeader.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@
{
Script.Reqiured(item).AtFoot();
}
var favicon = applicationSettingService.Get(SettingKeys.Favicon, "~/favicon.ico");
}
@inject IApplicationSettingService applicationSettingService
<title>
@this.WorkContext().CurrentPage.Title
</title>
<meta name="keywords" content="@this.WorkContext().CurrentPage.MetaKeyWorlds" />
<meta name="description" content="@this.WorkContext().CurrentPage.MetaDescription" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8" />
<meta name="author" content="ZKEASOFT" />
<meta name="about" content="@ZKEACMS.Version.CurrentVersion" />
<meta name="website" content="http://www.zkea.net" />
<link rel="author" href="http://www.zkea.net" />
<link href="@Url.Content(favicon)" rel="shortcut icon" type="image/x-icon" />
@if (this.WorkContext().OuterChainPicture)
{
<meta name="referrer" content="same-origin" />
Expand Down
20 changes: 3 additions & 17 deletions src/ZKEACMS.WebHost/Views/Shared/_AdminLayout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,13 @@
Style.Reqiured("admin").AtHead();
Script.Reqiured("admin").AtHead();
List<AdminMenu> menus = adminMenuProvider.GetAdminMenus().ToList();
this.WorkContext().CurrentPage.Title = ZKEACMS.Version.CurrentVersion + " " + ZKEACMS.Version.Rank;
}
@inject IOptions<CultureOption> cultureOption
<!DOCTYPE html>
<html lang="@cultureOption.Value.Code">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8" />
<title>@(ZKEACMS.Version.CurrentVersion + " " + ZKEACMS.Version.Rank)</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
@if (this.WorkContext().OuterChainPicture)
{
<meta name="referrer" content="same-origin" />
}
@if (this.WorkContext().EnableResponsiveDesign)
{
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,maximum-scale=1.0" />
}
@StyleAtHead()
@ScriptAtHead()
@await Html.PartialAsync("Partial.PageHeader")
</head>
<body>
<div id="wrap">
Expand Down Expand Up @@ -143,7 +131,6 @@
</nav>
<div class="main-container">
<div class="site-map">

</div>
<div id="main-body">
@if (ViewContext.ModelState.GetFieldValidationState("Unknown") == ModelValidationState.Invalid)
Expand All @@ -157,7 +144,6 @@
</div>
</div>
</div>
@StyleAtFoot()
@ScriptAtFoot()
@await Html.PartialAsync("Partial.PageFooter")
</body>
</html>
20 changes: 3 additions & 17 deletions src/ZKEACMS.WebHost/Views/Shared/_CustomerCenterLayout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,14 @@
Style.Reqiured("Customer").AtHead();
Style.Reqiured("Easy").AtHead();
IEnumerable<AdminMenu> menu = userCenterLinkService.GetLinks();
this.WorkContext().CurrentPage.Title = ViewBag.Title;
}
@inject IUserCenterLinkService userCenterLinkService
@inject IOptions<CultureOption> cultureOption
<!DOCTYPE html>
<html lang="@cultureOption.Value.Code">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8" />
<title>@ViewBag.Title</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
@if (this.WorkContext().OuterChainPicture)
{
<meta name="referrer" content="same-origin" />
}
@if (this.WorkContext().EnableResponsiveDesign)
{
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,maximum-scale=1.0" />
}
@StyleAtHead()
@ScriptAtHead()
@await Html.PartialAsync("Partial.PageHeader")
</head>
<body class="customer-center">
<div id="container" class="container">
Expand Down Expand Up @@ -72,9 +60,7 @@
@RenderBody()
</section>
</div>

</div>
@StyleAtFoot()
@ScriptAtFoot()
@await Html.PartialAsync("Partial.PageFooter")
</body>
</html>
30 changes: 3 additions & 27 deletions src/ZKEACMS.WebHost/Views/Shared/_DesignLayout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,14 @@
Script.Reqiured("admin").AtFoot();
Script.Reqiured("code-editor").AtFoot();
Model.ContainerClass = Model.ContainerClass ?? "container";
this.WorkContext().CurrentPage.Title = $"[{L("Design")}]{Model.LayoutName}";
}
@model LayoutEntity
@inject IOptions<CultureOption> cultureOption
<!DOCTYPE html>
<html lang="@cultureOption.Value.Code">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="cache-control" content="no-store">
<meta http-equiv="expires" content="0">
<meta http-equiv="pragma" content="no-cache" />
@if (this.WorkContext().OuterChainPicture)
{
<meta name="referrer" content="same-origin" />
}
@if (this.WorkContext().EnableResponsiveDesign)
{
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,maximum-scale=1.0" />
}
<title>[@L("Design")]@Model.LayoutName</title>
@StyleAtHead()
@ScriptAtHead()
@await Html.PartialAsync("Partial.PageHeader")
</head>
<body class="front">
<form id="LayoutInfo" asp-controller="Layout" asp-action="SaveLayout" method="post">
Expand Down Expand Up @@ -121,11 +107,6 @@
</div>

@await Html.PartialAsync("Layout/Templates")
@if (!Model.Style.IsNullOrEmpty())
{
<link href="@Url.Content(Model.Style)" rel="stylesheet" />

}
<div class="zk-modal fade" id="question" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="zk-modal-dialog" role="document">
<div class="zk-modal-content">
Expand Down Expand Up @@ -211,11 +192,6 @@
</div>
</div>
</div>
@if (!Model.Script.IsNullOrEmpty())
{
<script type="text/javascript" src="@Url.Content(Model.Script)"></script>
}
@StyleAtFoot()
@ScriptAtFoot()
@await Html.PartialAsync("Partial.PageFooter")
</body>
</html>
3 changes: 1 addition & 2 deletions src/ZKEACMS.WebHost/Views/Shared/_DesignPageLayout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
{
return;
}
this.WorkContext().CurrentPage.Title = $"[{L("Design")}]{Model.Page.Title}";
}
@inject IOptions<CultureOption> cultureOption
<!DOCTYPE html>
<html lang="@cultureOption.Value.Code">
<head>
<title>[@L("Design")]@Model.Page.Title</title>
<link href="@Url.PathContent(Model.Page.Favicon)" rel="shortcut icon" type="image/x-icon" />
@await Html.PartialAsync("Partial.PageHeader")
</head>
<body class="front">
Expand Down
18 changes: 5 additions & 13 deletions src/ZKEACMS.WebHost/Views/Shared/_EmptyLayout.cshtml
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
@using Microsoft.AspNetCore.Hosting
@using Microsoft.Extensions.Hosting
@{
this.WorkContext().CurrentPage.Title = ViewBag.Title;
}
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
@if (this.WorkContext().OuterChainPicture)
{
<meta name="referrer" content="same-origin" />
}
@if (this.WorkContext().EnableResponsiveDesign)
{
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,maximum-scale=1.0" />
}
@StyleAtHead()
@ScriptAtHead()
@await Html.PartialAsync("Partial.PageHeader")
</head>
<body>
<div>
@RenderBody()
</div>
@StyleAtFoot()
@ScriptAtFoot()
@await Html.PartialAsync("Partial.PageFooter")
</body>
</html>
6 changes: 0 additions & 6 deletions src/ZKEACMS.WebHost/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
<!DOCTYPE html>
<html lang="@cultureOption.Value.Code">
<head>
<title>@Model.Page.Title</title>
<meta name="keywords" content="@Model.Page.MetaKeyWorlds" />
<meta name="description" content="@Model.Page.MetaDescription" />
<link href="@Url.PathContent(Model.Page.Favicon)" rel="shortcut icon" type="image/x-icon" />
@await Html.PartialAsync("Partial.PageHeader")
</head>
<body class="front">
Expand Down Expand Up @@ -97,11 +93,9 @@
</script>
}
}

<div>
@RenderBody()
</div>
@await Html.PartialAsync("Partial.PageFooter")
</body>

</html>
30 changes: 3 additions & 27 deletions src/ZKEACMS.WebHost/Views/Shared/_LayoutGeneric.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,16 @@
@using Microsoft.Extensions.Options
@using Easy.Options
@{
ThemeEntity theme = themeService.GetCurrentTheme();
if (theme == null)
{
Style.Reqiured("bootStrap").AtHead();
}
this.WorkContext().CurrentPage.Title = ViewBag.Title;
}
@inject IThemeService themeService
@inject IOptions<CultureOption> cultureOption
<!DOCTYPE html>
<html lang="@cultureOption.Value.Code">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8" />
<title>@ViewBag.Title</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
@if (this.WorkContext().OuterChainPicture)
{
<meta name="referrer" content="same-origin" />
}
@if (this.WorkContext().EnableResponsiveDesign)
{
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,maximum-scale=1.0" />
}
@StyleAtHead()
@ScriptAtHead()
@if (theme != null)
{
string themeFile = ApplicationContext.HostingEnvironment.IsDevelopment() ? theme.UrlDebugger : theme.Url;
<link type="text/css" async rel="stylesheet" href="@Url.Content(themeFile)" />
}
@await Html.PartialAsync("Partial.PageHeader")
</head>
<body>
@RenderBody()
@StyleAtFoot()
@ScriptAtFoot()
@await Html.PartialAsync("Partial.PageFooter")
</body>
</html>
Loading

0 comments on commit 0152a9e

Please sign in to comment.