Skip to content

Commit

Permalink
Kentico Xperience 13 Refresh 1 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
skurekjakub committed Mar 17, 2021
1 parent 863fd29 commit e4ca843
Show file tree
Hide file tree
Showing 6 changed files with 221 additions and 161 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
LearningKitCore/App_Data/
.vs/

LearningKitCore/App_Data/
LearningKitCore/appsettings.json
LearningKitCore/node_modules/
LearningKitCore/bin/
Expand Down
223 changes: 126 additions & 97 deletions LearningKitCore/CodeSnippets/Razor/CodeSnippetsTagHelpers.cshtml
Original file line number Diff line number Diff line change
@@ -1,97 +1,126 @@
@*DocSection:PageBuilderScriptsTagHelper*@
@addTagHelper Kentico.Content.Web.Mvc.PageBuilderScriptsTagHelper, Kentico.Content.Web.Mvc

<page-builder-scripts />
@*EndDocSection:PageBuilderScriptsTagHelper*@

@*DocSection:PageBuilderStylesTagHelper*@
@addTagHelper Kentico.Content.Web.Mvc.PageBuilderStylesTagHelper, Kentico.Content.Web.Mvc

<page-builder-styles />
@*EndDocSection:PageBuilderStylesTagHelper*@

@*DocSection:EditableAreaTagHelperSimple*@
@addTagHelper Kentico.Content.Web.Mvc.EditableAreaTagHelper, Kentico.Content.Web.Mvc

<editable-area area-identifier="areaSimple" />
@*EndDocSection:EditableAreaTagHelperSimple*@

@*DocSection:EditableAreaTagHelperAdvanced*@
@addTagHelper Kentico.Content.Web.Mvc.EditableAreaTagHelper, Kentico.Content.Web.Mvc
@using Kentico.PageBuilder.Web.Mvc

@{
var options = new EditableAreaOptions
{
AllowedWidgets = new[] { "LearningKit.Widgets.NumberWidget",
"LearningKit.Widgets.SomeOtherWidget" },
AllowedSections = AllowedComponents.ALL
};
}

<editable-area area-identifier="areaConfigured" area-options="options" />
@*EndDocSection:EditableAreaTagHelperAdvanced*@

@*DocSection:WidgetZoneTagHelper*@
@addTagHelper Kentico.Content.Web.Mvc.WidgetZoneTagHelper, Kentico.Content.Web.Mvc

<widget-zone />
@*EndDocSection:WidgetZoneTagHelper*@

@*DocSection:PageDataTagHelper*@
@addTagHelper Kentico.Content.Web.Mvc.PageDataTagHelper, Kentico.Content.Web.Mvc

<form asp-controller="Controller" asp-action="HandlePost" id="form">

...

<page-data />

<input type="submit" value="Submit" />
</form>
@*EndDocSection:PageDataTagHelper*@

@*DocSection:ComponentPropertiesDataTagHelper*@
@addTagHelper Kentico.Content.Web.Mvc.ComponentPropertiesDataTagHelper, Kentico.Content.Web.Mvc

<form asp-controller="Controller" asp-action="HandlePost" id="form">

...

<component-properties-data />

<input type="submit" value="Submit" />
</form>
@*EndDocSection:ComponentPropertiesDataTagHelper*@

@*DocSection:StandaloneWidgetTagHelper*@
@addTagHelper Kentico.Content.Web.Mvc.StandaloneWidgetTagHelper, Kentico.Content.Web.Mvc
@using Kentico.Forms.Web.Mvc.Widgets
@using Kentico.Content.Web.Mvc

@{
var widgetProperties = new FormWidgetProperties()
{
SelectedForm = "FormCodeName"
};
}

@* Renders the system's default Form widget *@
<standalone-widget widget-type-identifier="@SystemComponentIdentifiers.FORM_WIDGET_IDENTIFIER" widget-properties="widgetProperties" />
@*EndDocSection:StandaloneWidgetTagHelper*@

@*DocSection:NestedWidgetTagHelper*@
@addTagHelper Kentico.Content.Web.Mvc.NestedWidgetTagHelper, Kentico.Content.Web.Mvc

@* In this example, the extended widget uses an extended FormWidgetProperties class *@
@model ComponentViewModel<ExtendedFormWidgetProperties>

@* Renders the system's default Form widget as the nested widget *@
<nested-widget widget-type-identifier="@SystemComponentIdentifiers.FORM_WIDGET_IDENTIFIER" widget-properties="Model.Properties" />
@*EndDocSection:NestedWidgetTagHelper*@

@*DocSection:FormZoneTagHelper*@
@addTagHelper Kentico.Content.Web.Mvc.FormZoneTagHelper, Kentico.Content.Web.Mvc

<form-zone />
@*EndDocSection:FormZoneTagHelper*@
@*DocSection:PageBuilderScriptsTagHelper*@
@addTagHelper Kentico.Content.Web.Mvc.PageBuilderScriptsTagHelper, Kentico.Content.Web.Mvc

<page-builder-scripts />
@*EndDocSection:PageBuilderScriptsTagHelper*@

@*DocSection:PageBuilderStylesTagHelper*@
@addTagHelper Kentico.Content.Web.Mvc.PageBuilderStylesTagHelper, Kentico.Content.Web.Mvc

<page-builder-styles />
@*EndDocSection:PageBuilderStylesTagHelper*@

@*DocSection:EditableAreaTagHelperSimple*@
@addTagHelper Kentico.Content.Web.Mvc.EditableAreaTagHelper, Kentico.Content.Web.Mvc

<editable-area area-identifier="areaSimple" />
@*EndDocSection:EditableAreaTagHelperSimple*@

@*DocSection:EditableAreaTagHelperAdvanced*@
@addTagHelper Kentico.Content.Web.Mvc.EditableAreaTagHelper, Kentico.Content.Web.Mvc
@using Kentico.PageBuilder.Web.Mvc

@{
var options = new EditableAreaOptions
{
AllowedWidgets = new[] { "LearningKit.Widgets.NumberWidget",
"LearningKit.Widgets.SomeOtherWidget" },
AllowedSections = AllowedComponents.ALL
};
}

<editable-area area-identifier="areaConfigured" area-options="options" />
@*EndDocSection:EditableAreaTagHelperAdvanced*@

@*DocSection:EditableAreaCacheConfiguration*@
@* widget-output-cache-expires-on *@
@* Sets the cached entry to expire on 5:02 PM on January 29, 2025. If the specified date is in the past, nothing gets cached. *@
<editable-area area-identifier="editableArea" area-widget-output-cache="true" widget-output-cache-expires-on="@new DateTime(2025,1,29,17,02,0)" />

@* widget-output-cache-expires-after *@
@* Contents are evicted after five minutes and cached again on subsequent requests. *@
<editable-area area-identifier="editableArea" area-widget-output-cache="true" widget-output-cache-expires-after="@TimeSpan.FromSeconds(300)" />

@* widget-output-cache-expires-sliding *@
@* Cached content is evicted if not accessed again within 120 seconds of the initial request. *@
<editable-area area-identifier="editableArea" area-widget-output-cache="true" widget-output-cache-expires-sliding="@TimeSpan.FromSeconds(120)" />
@*EndDocSection:EditableAreaCacheConfiguration*@

@*DocSection:WidgetZoneTagHelper*@
@addTagHelper Kentico.Content.Web.Mvc.WidgetZoneTagHelper, Kentico.Content.Web.Mvc

<widget-zone />
@*EndDocSection:WidgetZoneTagHelper*@

@*DocSection:PageDataTagHelper*@
@addTagHelper Kentico.Content.Web.Mvc.PageDataTagHelper, Kentico.Content.Web.Mvc

<form asp-controller="Controller" asp-action="HandlePost" id="form">

...

<page-data />

<input type="submit" value="Submit" />
</form>
@*EndDocSection:PageDataTagHelper*@

@*DocSection:ComponentPropertiesDataTagHelper*@
@addTagHelper Kentico.Content.Web.Mvc.ComponentPropertiesDataTagHelper, Kentico.Content.Web.Mvc

<form asp-controller="Controller" asp-action="HandlePost" id="form">

...

<component-properties-data />

<input type="submit" value="Submit" />
</form>
@*EndDocSection:ComponentPropertiesDataTagHelper*@

@*DocSection:StandaloneWidgetTagHelper*@
@addTagHelper Kentico.Content.Web.Mvc.StandaloneWidgetTagHelper, Kentico.Content.Web.Mvc
@using Kentico.Forms.Web.Mvc.Widgets
@using Kentico.Content.Web.Mvc

@{
var widgetProperties = new FormWidgetProperties()
{
SelectedForm = "FormCodeName"
};
}

@* Renders the system's default Form widget *@
<standalone-widget widget-type-identifier="@SystemComponentIdentifiers.FORM_WIDGET_IDENTIFIER" widget-properties="widgetProperties" />
@*EndDocSection:StandaloneWidgetTagHelper*@

@*DocSection:NestedWidgetTagHelper*@
@addTagHelper Kentico.Content.Web.Mvc.NestedWidgetTagHelper, Kentico.Content.Web.Mvc

@* In this example, the extended widget uses an extended FormWidgetProperties class *@
@model ComponentViewModel<ExtendedFormWidgetProperties>
@* Renders the system's default Form widget as the nested widget *@
<nested-widget widget-type-identifier="@SystemComponentIdentifiers.FORM_WIDGET_IDENTIFIER" widget-properties="Model.Properties" />
@*EndDocSection:NestedWidgetTagHelper*@

@*DocSection:FormZoneTagHelper*@
@addTagHelper Kentico.Content.Web.Mvc.FormZoneTagHelper, Kentico.Content.Web.Mvc

<form-zone />
@*EndDocSection:FormZoneTagHelper*@

@*DocSection:CacheDependencyTagHelper*@
@addTagHelper Kentico.Web.Mvc.Caching.CacheDependencyTagHelper, Kentico.Web.Mvc

@{
var userCacheKeys = new[] { "cms.user|all" };

var enabled = false;
}
<cache enabled="@enabled">
@* Clears the cached data whenever a user object is modified *@
<cache-dependency cache-keys="@userCacheKeys" enabled="@enabled" />

Time: @DateTime.Now
</cache>
@*EndDocSection:CacheDependencyTagHelper*@
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@using Kentico.Web.Mvc
@using Kentico.Forms.Web.Mvc

namespace LearningKitCore.Components.FormSections
{
public class TwoColumnFormSection
{
}
}
<div>
<div style="float:left; width:50%;">
@await Html.Kentico().FormZoneAsync()
</div>
<div style="float:left; width:50%;">
@await Html.Kentico().FormZoneAsync()
</div>
<div style="clear:both;" />
</div>
18 changes: 18 additions & 0 deletions LearningKitCore/Customizations/Caching/VaryByUserName.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;

using CMS.Membership;

using Kentico.PageBuilder.Web.Mvc;

namespace LearningKitCore.Customizations.Caching
{
public class VaryByUserName : ICacheVaryByOption
{
public string GetKey()
{
string userFirstName = MembershipContext.AuthenticatedUser?.FirstName ?? String.Empty;

return $"UserFirstName={userFirstName}";
}
}
}
2 changes: 1 addition & 1 deletion LearningKitCore/LearningKitCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Kentico.Xperience.AspNetCore.WebApp" Version="13.0.0" />
<PackageReference Include="Kentico.Xperience.AspNetCore.WebApp" Version="13.0.16" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="3.1.2" />
Expand Down
Loading

0 comments on commit e4ca843

Please sign in to comment.