mirror of https://github.com/abpframework/abp.git
40 changed files with 366 additions and 84 deletions
@ -0,0 +1,29 @@ |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.VirtualFileSystem; |
|||
using Volo.CmsKit.Reactions; |
|||
using Volo.CmsKit.Web.Icons; |
|||
|
|||
namespace Volo.CmsKit.Web |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpAspNetCoreMvcUiThemeSharedModule), |
|||
typeof(CmsKitDomainSharedModule) |
|||
)] |
|||
public class CmsKitCommonWebModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<CmsKitUiOptions>(options => |
|||
{ |
|||
options.ReactionIcons[StandardReactions.Smile] = new LocalizableIconDictionary("/cms-kit/icons/smile.png"); |
|||
options.ReactionIcons[StandardReactions.ThumbsUp] = new LocalizableIconDictionary("/cms-kit/icons/thumbsup.png"); |
|||
}); |
|||
|
|||
Configure<AbpVirtualFileSystemOptions>(options => |
|||
{ |
|||
options.FileSets.AddEmbedded<CmsKitCommonWebModule>(); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using JetBrains.Annotations; |
|||
using Volo.CmsKit.Web.Reactions; |
|||
|
|||
namespace Volo.CmsKit.Web |
|||
{ |
|||
public class CmsKitUiOptions |
|||
{ |
|||
[NotNull] |
|||
public ReactionIconDictionary ReactionIcons { get; } |
|||
|
|||
public CmsKitUiOptions() |
|||
{ |
|||
ReactionIcons = new ReactionIconDictionary(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,36 @@ |
|||
using System.Collections.Generic; |
|||
using System.Diagnostics.CodeAnalysis; |
|||
using System.Globalization; |
|||
using Volo.Abp; |
|||
|
|||
namespace Volo.CmsKit.Web.Icons |
|||
{ |
|||
public class LocalizableIconDictionary : Dictionary<string, string> |
|||
{ |
|||
[NotNull] |
|||
public string Default |
|||
{ |
|||
get => _default; |
|||
set => _default = Check.NotNullOrWhiteSpace(value, nameof(value)); |
|||
} |
|||
private string _default; |
|||
|
|||
public LocalizableIconDictionary([NotNull] string defaultIcon) |
|||
{ |
|||
Default = defaultIcon; |
|||
} |
|||
|
|||
public string GetLocalizedIconOrDefault(string cultureName = null) |
|||
{ |
|||
cultureName ??= CultureInfo.CurrentUICulture.Name; |
|||
|
|||
var localizedIcon = this.GetOrDefault(cultureName); |
|||
if (localizedIcon != null) |
|||
{ |
|||
return localizedIcon; |
|||
} |
|||
|
|||
return Default; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.CmsKit.Web.Icons; |
|||
|
|||
namespace Volo.CmsKit.Web.Reactions |
|||
{ |
|||
public class ReactionIconDictionary : Dictionary<string, LocalizableIconDictionary> |
|||
{ |
|||
public string GetLocalizedIcon(string name, string cultureName = null) |
|||
{ |
|||
var icon = this.GetOrDefault(name); |
|||
if (icon == null) |
|||
{ |
|||
throw new AbpException($"No icon defined for the reaction with name '{name}'"); |
|||
} |
|||
|
|||
return icon.GetLocalizedIconOrDefault(cultureName); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
|||
|
|||
<Import Project="..\..\..\..\common.props" /> |
|||
<Import Project="..\..\..\..\configureawait.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netcoreapp3.1</TargetFramework> |
|||
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
|||
<IsPackable>true</IsPackable> |
|||
<OutputType>Library</OutputType> |
|||
<RootNamespace>Volo.CmsKit.Web</RootNamespace> |
|||
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj" /> |
|||
<ProjectReference Include="..\Volo.CmsKit.Domain.Shared\Volo.CmsKit.Domain.Shared.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="3.1.5" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<EmbeddedResource Include="wwwroot\**\*.*" /> |
|||
<Content Remove="wwwroot\**\*.*" /> |
|||
<EmbeddedResource Include="Pages\**\*.css" /> |
|||
<Content Remove="Pages\**\*.css" /> |
|||
<EmbeddedResource Include="Pages\**\*.js" /> |
|||
<Content Remove="Pages\**\*.js" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
@ -0,0 +1,8 @@ |
|||
namespace Volo.CmsKit.Reactions |
|||
{ |
|||
public class StandardReactions |
|||
{ |
|||
public const string Smile = "SM"; |
|||
public const string ThumbsUp = "TU"; |
|||
} |
|||
} |
|||
@ -1,12 +1,20 @@ |
|||
using Volo.Abp.Modularity; |
|||
using Volo.CmsKit.Reactions; |
|||
|
|||
namespace Volo.CmsKit |
|||
{ |
|||
[DependsOn( |
|||
typeof(CmsKitDomainSharedModule) |
|||
)] |
|||
)] |
|||
public class CmsKitDomainModule : AbpModule |
|||
{ |
|||
|
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<CmsKitOptions>(options => |
|||
{ |
|||
options.Reactions.AddOrReplace(StandardReactions.Smile); |
|||
options.Reactions.AddOrReplace(StandardReactions.ThumbsUp); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,9 +0,0 @@ |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Volo.CmsKit.Reactions |
|||
{ |
|||
public class LocalizableIconDictionary : Dictionary<string, string> |
|||
{ |
|||
public string Default { get; set; } |
|||
} |
|||
} |
|||
@ -1,9 +1,13 @@ |
|||
using System.Collections.Generic; |
|||
using Volo.Abp.Localization; |
|||
|
|||
namespace Volo.CmsKit.Reactions |
|||
{ |
|||
public class ReactionDefinitionDictionary : Dictionary<string, ReactionDefinition> |
|||
{ |
|||
|
|||
public void AddOrReplace(string name, ILocalizableString displayName = null) |
|||
{ |
|||
this[name] = new ReactionDefinition(name, displayName); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,8 +1,8 @@ |
|||
using Volo.Abp.Application; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.Authorization; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.CmsKit.Public |
|||
namespace Volo.CmsKit |
|||
{ |
|||
[DependsOn( |
|||
typeof(CmsKitDomainSharedModule), |
|||
@ -0,0 +1,9 @@ |
|||
namespace Volo.CmsKit.Reactions |
|||
{ |
|||
public class GetAvailableReactionsDto |
|||
{ |
|||
public string EntityType { get; set; } |
|||
|
|||
public string EntityId { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace Volo.CmsKit.Reactions |
|||
{ |
|||
public interface IReactionPublicAppService : IApplicationService |
|||
{ |
|||
Task<ListResultDto<ReactionDto>> GetAvailableReactions( |
|||
GetAvailableReactionsDto getAvailableReactionsDto |
|||
); |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using JetBrains.Annotations; |
|||
|
|||
namespace Volo.CmsKit.Reactions |
|||
{ |
|||
public class ReactionDto |
|||
{ |
|||
[NotNull] |
|||
public string Name { get; set; } |
|||
|
|||
[CanBeNull] |
|||
public string DisplayName { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace Volo.CmsKit.Reactions |
|||
{ |
|||
public class ReactionPublicAppService : ApplicationService, IReactionPublicAppService |
|||
{ |
|||
public Task<ListResultDto<ReactionDto>> GetAvailableReactions( |
|||
GetAvailableReactionsDto getAvailableReactionsDto) |
|||
{ |
|||
return Task.FromResult( |
|||
new ListResultDto<ReactionDto>(new List<ReactionDto>() |
|||
{ |
|||
new ReactionDto {Name = StandardReactions.ThumbsUp}, |
|||
new ReactionDto {Name = StandardReactions.Smile, DisplayName = "Smile :)"} |
|||
}) |
|||
); |
|||
} |
|||
} |
|||
} |
|||
@ -1,9 +0,0 @@ |
|||
@page |
|||
@using Microsoft.Extensions.Localization |
|||
@using Volo.CmsKit.Localization |
|||
@model Volo.CmsKit.Public.Web.Pages.Public.IndexModel |
|||
@inject IStringLocalizer<CmsKitResource> L |
|||
@{ |
|||
} |
|||
<h1>Public</h1> |
|||
<p>@L["SamplePageMessage"]</p> |
|||
@ -1,9 +0,0 @@ |
|||
namespace Volo.CmsKit.Public.Web.Pages.Public |
|||
{ |
|||
public class IndexModel : PublicPageModel |
|||
{ |
|||
public void OnGet() |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -1,2 +1,8 @@ |
|||
@model Volo.CmsKit.Web.Pages.CmsKit.Shared.Components.ReactionSelectionViewModel |
|||
<p>TEST!</p> |
|||
<p>EntityType: @Model.EntityType</p> |
|||
<p>EntityId: @Model.EntityId</p> |
|||
@foreach (var reaction in Model.Reactions) |
|||
{ |
|||
<img width="20" height="20" src="@reaction.Icon"/> |
|||
} |
|||
|
|||
@ -1,17 +1,56 @@ |
|||
using System.Threading.Tasks; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.Extensions.Options; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.CmsKit.Reactions; |
|||
|
|||
namespace Volo.CmsKit.Web.Pages.CmsKit.Shared.Components |
|||
{ |
|||
public class ReactionSelectionViewComponent : AbpViewComponent |
|||
{ |
|||
public virtual async Task<IViewComponentResult> InvokeAsync(string entityType = null, string entityId = null) |
|||
protected IReactionPublicAppService ReactionPublicAppService { get; } |
|||
protected CmsKitUiOptions Options { get; } |
|||
|
|||
public ReactionSelectionViewComponent( |
|||
IReactionPublicAppService reactionPublicAppService, |
|||
IOptions<CmsKitUiOptions> options) |
|||
{ |
|||
ReactionPublicAppService = reactionPublicAppService; |
|||
Options = options.Value; |
|||
} |
|||
|
|||
public virtual async Task<IViewComponentResult> InvokeAsync( |
|||
string entityType = null, |
|||
string entityId = null) |
|||
{ |
|||
return View( |
|||
"~/Pages/CmsKit/Shared/Components/Default.cshtml", |
|||
new ReactionSelectionViewModel() |
|||
); |
|||
var result = await ReactionPublicAppService.GetAvailableReactions( |
|||
new GetAvailableReactionsDto |
|||
{ |
|||
EntityType = entityType, |
|||
EntityId = entityId |
|||
} |
|||
); |
|||
|
|||
var viewModel = new ReactionSelectionViewModel |
|||
{ |
|||
EntityType = entityType, |
|||
EntityId = entityId, |
|||
Reactions = new List<ReactionViewModel>() |
|||
}; |
|||
|
|||
foreach (var reactionDto in result.Items) |
|||
{ |
|||
viewModel.Reactions.Add( |
|||
new ReactionViewModel |
|||
{ |
|||
Name = reactionDto.Name, |
|||
DisplayName = reactionDto.DisplayName, |
|||
Icon = Options.ReactionIcons.GetLocalizedIcon(reactionDto.Name) |
|||
}); |
|||
} |
|||
|
|||
return View("~/Pages/CmsKit/Shared/Components/Default.cshtml", viewModel); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,7 +1,14 @@ |
|||
namespace Volo.CmsKit.Web.Pages.CmsKit.Shared.Components |
|||
using System.Collections.Generic; |
|||
using Volo.CmsKit.Reactions; |
|||
|
|||
namespace Volo.CmsKit.Web.Pages.CmsKit.Shared.Components |
|||
{ |
|||
public class ReactionSelectionViewModel |
|||
{ |
|||
public string EntityType { get; set; } |
|||
|
|||
public string EntityId { get; set; } |
|||
|
|||
public List<ReactionViewModel> Reactions { get; set; } |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,16 @@ |
|||
using JetBrains.Annotations; |
|||
|
|||
namespace Volo.CmsKit.Web.Pages.CmsKit.Shared.Components |
|||
{ |
|||
public class ReactionViewModel |
|||
{ |
|||
[NotNull] |
|||
public string Name { get; set; } |
|||
|
|||
[CanBeNull] |
|||
public string DisplayName { get; set; } |
|||
|
|||
[NotNull] |
|||
public string Icon { get; set; } |
|||
} |
|||
} |
|||
Loading…
Reference in new issue