diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml.cs index e6ac4303db..1b9f50993f 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml.cs @@ -1,13 +1,9 @@ -using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc.RazorPages; namespace Volo.CmsKit.Pages { - [Authorize] public class IndexModel : PageModel { - public void OnGet() - { - } + } } diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Public.cshtml b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Public.cshtml deleted file mode 100644 index 1846666943..0000000000 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Public.cshtml +++ /dev/null @@ -1,39 +0,0 @@ -@page -@using Localization.Resources.AbpUi -@using Microsoft.Extensions.Localization -@using Volo.CmsKit.Pages -@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Commenting -@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.ReactionSelection -@model PublicModel -@inject IStringLocalizer Localizer -

CMS Kit DEMO - Public

- - - - -

- Any fool can write code that a computer can understand. Good programmers write code that humans can understand. -

-
- Martin Fowler -
-
-
- @await Component.InvokeAsync(typeof(ReactionSelectionViewComponent), new { entityType = "publicQuote", entityId = "1" }) -
- @await Component.InvokeAsync(typeof(CommentingViewComponent), new { entityType = "publicQuote", entityId = "1", loginUrl = "Account/Login?ReturnUrl=%2Fpublic" }) -
- - - - -

- Writing code is very simple, but writing simple code is the hardest thing there is! -

-
- Halil ibrahim Kalkan (inspired from Johan Cruyff) -
-
-
- @await Component.InvokeAsync(typeof(CommentingViewComponent), new { entityType = "publicQuote", entityId = "2", loginUrl="Account/Login?ReturnUrl=%2Fpublic" }) -
diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Public.cshtml.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Public.cshtml.cs deleted file mode 100644 index 3ec2b2020a..0000000000 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Public.cshtml.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace Volo.CmsKit.Pages -{ - public class PublicModel : PageModel - { - public void OnGet() - { - } - } -} diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj index d500cbce2d..b048056470 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj @@ -47,13 +47,6 @@ - - true - PreserveNewest - - - public.cshtml - Public.cshtml diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitOptions.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitUiOptions.cs similarity index 59% rename from modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitOptions.cs rename to modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitUiOptions.cs index b04ae26fb6..718284e042 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitOptions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitUiOptions.cs @@ -8,9 +8,15 @@ namespace Volo.CmsKit.Web [NotNull] public ReactionIconDictionary ReactionIcons { get; } + /// + /// Default value: "/Account/Login". + /// + public string LoginUrl { get; set; } //TODO: Consider to move to the ABP Framework! + public CmsKitUiOptions() { ReactionIcons = new ReactionIconDictionary(); + LoginUrl = "/Account/Login"; } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingViewComponent.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingViewComponent.cs index eaa25b21cb..924add7a6c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingViewComponent.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingViewComponent.cs @@ -1,10 +1,12 @@ -using System.Collections.Generic; -using System.Linq; +using System; +using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Options; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; using Volo.CmsKit.Public.Comments; +using Volo.CmsKit.Web; namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Commenting { @@ -17,21 +19,25 @@ namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Commenting public class CommentingViewComponent : AbpViewComponent { public ICommentPublicAppService CommentPublicAppService { get; } + public CmsKitUiOptions Options { get; } public CommentingViewComponent( - ICommentPublicAppService commentPublicAppService) + ICommentPublicAppService commentPublicAppService, + IOptions options) { CommentPublicAppService = commentPublicAppService; + Options = options.Value; } public virtual async Task InvokeAsync( string entityType, - string entityId, - string loginUrl = null) //TODO: This can be a configuration (default: /Account/Login) rather than passing it to the component + string entityId) { var result = await CommentPublicAppService .GetListAsync(entityType, entityId); + var loginUrl = $"{Options.LoginUrl}?returnUrl={HttpContext.Request.Path.ToString()}&returnUrlHash=#cms-comment_{entityType}_{entityId}"; + var viewModel = new CommentingViewModel { EntityId = entityId, diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/Default.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/Default.cshtml index 26faec1ffa..5246f9a0f1 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/Default.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/Default.cshtml @@ -54,7 +54,7 @@ } else { - @L["LoginToReply"] + @L["LoginToReply"] } } @if (authorId == CurrentUser.Id)