Browse Source

Introduce LoginUrl option to CmsKitUiOptions & remove the public page.

pull/5163/head
Halil İbrahim Kalkan 6 years ago
parent
commit
c795d5864e
  1. 6
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml.cs
  2. 39
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Public.cshtml
  3. 11
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Public.cshtml.cs
  4. 7
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj
  5. 6
      modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitUiOptions.cs
  6. 16
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingViewComponent.cs
  7. 2
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/Default.cshtml

6
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()
{
}
}
}

39
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Public.cshtml

@ -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<AbpUiResource> Localizer
<h1>CMS Kit DEMO - Public</h1>
<abp-card class="mb-3">
<abp-card-body>
<abp-blockquote>
<p>
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
</p>
<footer>
Martin Fowler
</footer>
</abp-blockquote>
</abp-card-body>
@await Component.InvokeAsync(typeof(ReactionSelectionViewComponent), new { entityType = "publicQuote", entityId = "1" })
<hr />
@await Component.InvokeAsync(typeof(CommentingViewComponent), new { entityType = "publicQuote", entityId = "1", loginUrl = "Account/Login?ReturnUrl=%2Fpublic" })
</abp-card>
<abp-card class="mb-3">
<abp-card-body>
<abp-blockquote>
<p>
Writing code is very simple, but writing simple code is the hardest thing there is!
</p>
<footer>
Halil ibrahim Kalkan <small>(inspired from Johan Cruyff)</small>
</footer>
</abp-blockquote>
</abp-card-body>
@await Component.InvokeAsync(typeof(CommentingViewComponent), new { entityType = "publicQuote", entityId = "2", loginUrl="Account/Login?ReturnUrl=%2Fpublic" })
</abp-card>

11
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Public.cshtml.cs

@ -1,11 +0,0 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace Volo.CmsKit.Pages
{
public class PublicModel : PageModel
{
public void OnGet()
{
}
}
}

7
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj

@ -47,13 +47,6 @@
<Content Remove="Logs\**" />
<EmbeddedResource Remove="Logs\**" />
<None Remove="Logs\**" />
<Content Update="Pages\Public.cshtml">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Compile Update="Pages\Public.cshtml.cs">
<DependentUpon>public.cshtml</DependentUpon>
</Compile>
<Compile Update="Pages\Public.cshtml.cs">
<DependentUpon>Public.cshtml</DependentUpon>
</Compile>

6
modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitOptions.cs → modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitUiOptions.cs

@ -8,9 +8,15 @@ namespace Volo.CmsKit.Web
[NotNull]
public ReactionIconDictionary ReactionIcons { get; }
/// <summary>
/// Default value: "/Account/Login".
/// </summary>
public string LoginUrl { get; set; } //TODO: Consider to move to the ABP Framework!
public CmsKitUiOptions()
{
ReactionIcons = new ReactionIconDictionary();
LoginUrl = "/Account/Login";
}
}
}

16
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<CmsKitUiOptions> options)
{
CommentPublicAppService = commentPublicAppService;
Options = options.Value;
}
public virtual async Task<IViewComponentResult> 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,

2
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/Default.cshtml

@ -54,7 +54,7 @@
}
else
{
<a href="@Model.LoginUrl"> @L["LoginToReply"]</a>
<a href="@(Model.LoginUrl + "_" + id)"> @L["LoginToReply"]</a>
}
}
@if (authorId == CurrentUser.Id)

Loading…
Cancel
Save