Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Wayne-KTCSZ committed Oct 12, 2024
1 parent fe88d39 commit 35401e8
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 42 deletions.
6 changes: 3 additions & 3 deletions src/ZKEACMS.Article/Service/ArticleDetailWidgetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public override object Display(WidgetDisplayContext widgetDisplayContext)
else
{
var latest = _articleService.GetLatestPublished();
if (ApplicationContext.CurrentAppContext().IsDesignMode || ApplicationContext.CurrentAppContext().IsPreViewMode)
if (ApplicationContext.Current().IsDesignMode || ApplicationContext.Current().IsPreViewMode)
{
viewModel.Current = latest;
}
Expand All @@ -113,7 +113,7 @@ public override object Display(WidgetDisplayContext widgetDisplayContext)
return null;
}

ApplicationContext.As<CMSApplicationContext>().CurrentPage.ConfigSEO(viewModel.Current.Title, viewModel.Current.MetaKeyWords, viewModel.Current.MetaDescription);
ApplicationContext.Current().CurrentPage.ConfigSEO(viewModel.Current.Title, viewModel.Current.MetaKeyWords, viewModel.Current.MetaDescription);
AddStructuredDataToPageHeader(viewModel.Current);
return viewModel;
}
Expand All @@ -127,7 +127,7 @@ private void AddStructuredDataToPageHeader(ArticleEntity article)
DateModified = article.LastUpdateDate,
Author = new Person[] { new Person { Name = article.CreatebyName } }
};
ApplicationContext.CurrentAppContext().CurrentPage.HeaderScripts.Add(new Page.ScriptTag()
ApplicationContext.Current().CurrentPage.HeaderScripts.Add(new Page.ScriptTag()
{
Type = "application/ld+json",
InnerScript = new HtmlString(JsonConverter.Serialize(structuredData))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public override object Display(WidgetDisplayContext widgetDisplayContext)
else
{
_articleService.IncreaseCount(article);
ApplicationContext.As<CMSApplicationContext>().CurrentPage.ConfigSEO(article.Title, article.MetaKeyWords, article.MetaDescription);
ApplicationContext.Current().CurrentPage.ConfigSEO(article.Title, article.MetaKeyWords, article.MetaDescription);
}
viewModel.Current = article;

Expand Down
2 changes: 1 addition & 1 deletion src/ZKEACMS.Article/Service/ArticleTypeWidgetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public override object Display(WidgetDisplayContext widgetDisplayContext)
}
if (articleType != null && articleType.SEOTitle.IsNotNullAndWhiteSpace())
{
_articleTypeService.ApplicationContext.As<CMSApplicationContext>().CurrentPage.ConfigSEO(articleType.SEOTitle, articleType.SEOKeyWord, articleType.SEODescription);
_articleTypeService.ApplicationContext.Current().CurrentPage.ConfigSEO(articleType.SEOTitle, articleType.SEOKeyWord, articleType.SEODescription);
}
return new ArticleTypeWidgetViewModel
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public override object Display(WidgetDisplayContext widgetDisplayContext)
}
if (productCategory != null && productCategory.SEOTitle.IsNotNullAndWhiteSpace())
{
ApplicationContext.As<CMSApplicationContext>().CurrentPage.ConfigSEO(productCategory.SEOTitle, productCategory.SEOKeyWord, productCategory.SEODescription);
ApplicationContext.Current().CurrentPage.ConfigSEO(productCategory.SEOTitle, productCategory.SEOKeyWord, productCategory.SEODescription);
}
return new ProductCategoryWidgetViewModel
{
Expand Down
6 changes: 3 additions & 3 deletions src/ZKEACMS.Product/Service/ProductDetailWidgetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public override object Display(WidgetDisplayContext widgetDisplayContext)
}
else
{
if (ApplicationContext.CurrentAppContext().IsDesignMode || ApplicationContext.CurrentAppContext().IsPreViewMode)
if (ApplicationContext.Current().IsDesignMode || ApplicationContext.Current().IsPreViewMode)
{
product = _productService.GetLatestPublished();
}
Expand All @@ -97,7 +97,7 @@ public override object Display(WidgetDisplayContext widgetDisplayContext)
return null;
}

ApplicationContext.As<CMSApplicationContext>().CurrentPage.ConfigSEO(product.SEOTitle ?? product.Title, product.SEOKeyWord, product.SEODescription);
ApplicationContext.Current().CurrentPage.ConfigSEO(product.SEOTitle ?? product.Title, product.SEOKeyWord, product.SEODescription);
AddStructuredDataToPageHeader(product);

return product;
Expand All @@ -112,7 +112,7 @@ private void AddStructuredDataToPageHeader(ProductEntity product)
Description = product.Description,
MPN = product.PartNumber
};
ApplicationContext.CurrentAppContext().CurrentPage.HeaderScripts.Add(new Page.ScriptTag()
ApplicationContext.Current().CurrentPage.HeaderScripts.Add(new Page.ScriptTag()
{
Type = "application/ld+json",
InnerScript = new HtmlString(JsonConverter.Serialize(structuredData))
Expand Down
39 changes: 19 additions & 20 deletions src/ZKEACMS.WebHost/Views/Shared/Partial.PageHeader.cshtml
Original file line number Diff line number Diff line change
@@ -1,54 +1,53 @@
@{
foreach (var item in this.WorkContext().CurrentPage.StyleSource)
@inject IApplicationSettingService applicationSettingService
@{
var currentPage = this.WorkContext().CurrentPage;
foreach (var item in currentPage.StyleNames)
{
Style.Reqiured(item).AtHead();
}
foreach (var item in this.WorkContext().CurrentPage.ScriptSource)
foreach (var item in currentPage.ScriptNames)
{
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" />
<title>@currentPage.Title</title>
<meta name="keywords" content="@currentPage.MetaKeyWorlds" />
<meta name="description" content="@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().EnableResponsiveDesign)
{
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,maximum-scale=1.0" />
}
@if (this.WorkContext().OuterChainPicture)
{
<meta name="referrer" content="same-origin" />
}
@foreach (var item in this.WorkContext().CurrentPage.Meta)
@foreach (var item in currentPage.Meta)
{
@item.Render()
}
@if (this.WorkContext().EnableResponsiveDesign)
{
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,maximum-scale=1.0" />
}
<link rel="author" href="http://www.zkea.net" />
<link href="@Url.Content(favicon)" rel="shortcut icon" type="image/x-icon" />
@StyleAtHead()
@ScriptAtHead()
@foreach (var item in this.WorkContext().CurrentPage.Header)
@foreach (var item in currentPage.Header)
{
@item
}
@foreach (var item in this.WorkContext().CurrentPage.StyleSheets)
@foreach (var item in currentPage.StyleSheets)
{
@item.Render()
}
@foreach (var item in this.WorkContext().CurrentPage.Style)
@foreach (var item in currentPage.Style)
{
@item.Render()
}
@foreach (var item in this.WorkContext().CurrentPage.HeaderScripts)
@foreach (var item in currentPage.HeaderScripts)
{
@item.Render()
}
2 changes: 1 addition & 1 deletion src/ZKEACMS/ApplicationContextAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public CMSApplicationContext Current
{
get
{
return current ?? (current = _serviceProvider.GetService<IApplicationContext>().CurrentAppContext());
return current ?? (current = _serviceProvider.GetService<IApplicationContext>().Current());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ZKEACMS/Common/Service/HeadWidgetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override object Display(WidgetDisplayContext widgetDisplayContext)
htmlContentBuilder.AppendHtmlLine("<!-- head:{0} -->".FormatWith(widgetDisplayContext.Widget.ID));
htmlContentBuilder.AppendHtmlLine((widgetDisplayContext.Widget as HeadWidget).Content);
htmlContentBuilder.AppendHtmlLine("<!-- end -->");
ApplicationContext.CurrentAppContext().CurrentPage.Header.Add(htmlContentBuilder);
ApplicationContext.Current().CurrentPage.Header.Add(htmlContentBuilder);
return base.Display(widgetDisplayContext);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ZKEACMS/Common/Service/NavigationWidgetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public override object Display(WidgetDisplayContext widgetDisplayContext)

string path = null;
IUrlHelper urlHelper = null;
if (ApplicationContext.CurrentAppContext().IsDesignMode)
if (ApplicationContext.Current().IsDesignMode)
{
var layout = widgetDisplayContext.PageLayout;
if (layout != null && layout.Page != null)
Expand Down
8 changes: 4 additions & 4 deletions src/ZKEACMS/Extend/ApplicationContextExtend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ public static class ApplicationContextExtend
{
public static T GetService<T>(this IApplicationContext applicationContext)
{
return applicationContext.CurrentAppContext().HttpContextAccessor.HttpContext.RequestServices.GetService<T>();
return applicationContext.Current().HttpContextAccessor.HttpContext.RequestServices.GetService<T>();
}
public static IEnumerable<T> GetServices<T>(this IApplicationContext applicationContext)
{
return applicationContext.CurrentAppContext().HttpContextAccessor.HttpContext.RequestServices.GetServices<T>();
return applicationContext.Current().HttpContextAccessor.HttpContext.RequestServices.GetServices<T>();
}
public static CMSApplicationContext CurrentAppContext(this IApplicationContext applicationContext)
public static CMSApplicationContext Current(this IApplicationContext applicationContext)
{
return applicationContext.As<CMSApplicationContext>();
}
}
}
}
2 changes: 1 addition & 1 deletion src/ZKEACMS/Extend/RazorPageExtend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static class RazorPageExtend
{
public static CMSApplicationContext WorkContext<T>(this Easy.Mvc.RazorPages.EasyRazorPage<T> page)
{
return page.ApplicationContext.CurrentAppContext();
return page.ApplicationContext.Current();
}
}
}
5 changes: 2 additions & 3 deletions src/ZKEACMS/Page/IPageContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ public interface IPageContext
List<StyleSheetTag> StyleSheets { get; }
List<IHtmlContent> Header { get; }
List<ScriptTag> HeaderScripts { get; }

List<ScriptTag> FooterScripts { get; }
List<IHtmlContent> BodyFooter { get; }
List<string> StyleSource { get; }
List<string> ScriptSource { get; }
List<string> StyleNames { get; }
List<string> ScriptNames { get; }
void ConfigSEO(string title, string keywords, string description);
}
}
4 changes: 2 additions & 2 deletions src/ZKEACMS/Page/PageContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class PageContext : IPageContext

public List<IHtmlContent> Header { get; } = new List<IHtmlContent>();
public List<IHtmlContent> BodyFooter { get; } = new List<IHtmlContent>();
public List<string> StyleSource { get; }= new List<string>();
public List<string> ScriptSource { get; } = new List<string>();
public List<string> StyleNames { get; }= new List<string>();
public List<string> ScriptNames { get; } = new List<string>();
public string MetaKeyWorlds { get; set; }
public string MetaDescription { get; set; }

Expand Down

0 comments on commit 35401e8

Please sign in to comment.