8000 fix #102 related to subcribing, upgrade to .NET 9, add Comment management UI by sbwalker · Pull Request #103 · oqtane/oqtane.blogs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix #102 related to subcribing, upgrade to .NET 9, add Comment management UI #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions Client/Comments.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
@using Oqtane.Blogs.Services
@using Oqtane.Blogs.Models
@using Oqtane.Blogs.Shared
@namespace Oqtane.Blogs
@inherits ModuleBase
@inject IBlogCommentService BlogCommentService
@inject IStringLocalizer<Edit> Localizer
@inject IStringLocalizer<SharedResources> SharedLocalizer

@if (_comments == null)
{
<p><em>@SharedLocalizer["Loading"]</em></p>
}
else
{
@if (_comments.Count == 0)
{
<p>@Localizer["NoComments"]</p>
}
else
{
<Pager Items="@_comments">
<Header>
<th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th>
<th>@Localizer["Title"]</th>
<th>@Localizer["Author"]</th>
<th>@Localizer["Submitted"]</th>
<th>@Localizer["Published"]</th>
</Header>
<Row>
<td><button type="button" class="btn btn-primary" @ () => await UpdateComment(context))">@(context.IsPublished ? Localizer["Unpublish"] : Localizer["Publish"])</button></td>
<td><ActionDialog Header="Delete Comment" Message="@Localizer["DeleteComment.Message"]" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" () => await DeleteComment(context))" ResourceKey="DeleteComment" /></td>
<td>@context.Blog.Title</td>
<td>@context.Name &lt;@context.Email&gt;</td>
<td>@context.CreatedOn.ToShortDateString()</td>
<td>@context.IsPublished.ToString()</td>
</Row>
<Detail>
<td colspan="2">&nbsp;</td>
<td colspan="4">@((MarkupString)context.Comment)</td>
</Detail>
</Pager>
}
}

@code {
private List<BlogComment> _comments;

public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit;

protected override async Task OnParametersSetAsync()
{
await GetComments();
}

private async Task GetComments()
{
_comments = await BlogCommentService.GetBlogCommentsAsync(-1, ModuleState.ModuleId);
}

private async Task UpdateComment(BlogComment comment)
{
try
{
if (comment.IsPublished)
{
comment.IsPublished = false;
}
else
{
comment.IsPublished = true;
}
await BlogCommentService.UpdateBlogCommentAsync(comment, ModuleState.ModuleId);
await logger.LogInformation("Blog Comment Updated {BlogComment}", comment);
await GetComments();
StateHasChanged();
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Updating Blog Comment {BlogComment} {Error}", comment, ex.Message);
AddModuleMessage(Localizer["Error.UpdateComment"], MessageType.Error);
}
}

private async Task DeleteComment(BlogComment comment)
{
try
{
await BlogCommentService.DeleteBlogCommentAsync(comment.BlogCommentId, comment.BlogId, ModuleState.ModuleId);
await logger.LogInformation("Blog Comment Deleted {BlogComment}", comment);
await GetComments();
StateHasChanged();
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Deleting Blog Comment {BlogComment} {Error}", comment, ex.Message);
AddModuleMessage(Localizer["Error.DeleteComment"], MessageType.Error);
}
}
}
20 changes: 5 additions & 15 deletions Client/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@
{
<NavLink class="btn btn-secondary ms-2" href="@NavigateUrl(PageState.Page.Path, Utilities.AddUrlParameters(_blog.BlogId))">@SharedLocalizer["Cancel"]</NavLink>
}
if (_blogEditor)
{
<ActionDialog Header="Delete Comment" Message="Are You Sure You Wish To Delete This Comment?" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" ResourceKey="DeleteComment" />
}
}
</div>
</div>
Expand Down Expand Up @@ -126,6 +122,10 @@ else
{
<div class="text-center mb-2">
<ActionLink Action="Add" Security="SecurityAccessLevel.Edit" ReturnUrl="@PageState.Route.PathAndQuery" ResourceKey="AddBlog" Text="Add Blog" />
@if (_comments == "True")
{
<ActionLink Action="Comments" Security="SecurityAccessLevel.Edit" ReturnUrl="@PageState.Route.PathAndQuery" ResourceKey="Comments" Text="Manage Comments" Class="btn btn-secondary ms-1" />
}
</div>
}

Expand Down Expand Up @@ -259,7 +259,7 @@ else
{
_blogEditor = UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, ModuleState.PermissionList) && PageState.EditMode;

if (PageState.QueryString.ContainsKey("guid") && PageState.QueryString.ContainsKey("action"))
if (string.IsNullOrEmpty(_subscriptionEmail) && PageState.QueryString.ContainsKey("guid") && PageState.QueryString.ContainsKey("action"))
{
if (PageState.QueryString["action"] == "unsubscribe")
{
Expand Down Expand Up @@ -288,16 +288,6 @@ else
}
}

if (PageState.QueryString.ContainsKey("comment") && PageState.QueryString.ContainsKey("delete") && _blogEditor)
{
var blogComment = await BlogCommentService.GetBlogCommentAsync(int.Parse(PageState.QueryString["comment"]), int.Parse(UrlParameters["id"]), ModuleState.ModuleId);
if (blogComment != null)
{
await BlogCommentService.DeleteBlogCommentAsync(int.Parse(PageState.QueryString["comment"]), int.Parse(UrlParameters["id"]), ModuleState.ModuleId);
AddModuleMessage("Blog Comment Deleted", MessageType.Success);
}
}

if (PageState.QueryString.ContainsKey("category") && int.TryParse(PageState.QueryString["category"], out int categoryId))
{
_categoryName = (await BlogCategoryService.GetBlogCategorySourcesAsync(ModuleState.ModuleId)).FirstOrDefault(i => i.BlogCategorySourceId == categoryId)?.Name ?? string.Empty;
Expand Down
4 changes: 2 additions & 2 deletions Client/ModuleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public class ModuleInfo : IModule
{
Name = "Blog",
Description = "Blog",
Version = "5.2.2",
ReleaseVersions = "1.0.0,1.0.1,1.0.3,1.0.4,1.0.5,1.0.6,5.0.0,5.0.1,5.0.2,5.0.3,5.1.0,5.2.0,5.2.1,5.2.2",
Version = "6.0.0",
ReleaseVersions = "1.0.0,1.0.1,1.0.3,1.0.4,1.0.5,1.0.6,5.0.0,5.0.1,5.0.2,5.0.3,5.1.0,5.2.0,5.2.1,5.2.2,6.0.0",
ServerManagerType = "Oqtane.Blogs.Manager.BlogManager, Oqtane.Blogs.Server.Oqtane",
Dependencies = "Oqtane.Blogs.Shared.Oqtane",
SettingsType = "Oqtane.Blogs.Settings, Oqtane.Blogs.Client.Oqtane",
Expand Down
25 changes: 15 additions & 10 deletions Client/Oqtane.Blogs.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Version>5.2.2</Version>
<TargetFramework>net9.0</TargetFramework>
<Version>6.0.0</Version>
<Authors>Shaun Walker</Authors>
<Company>.NET Foundation</Company>
<Description>A Blog Module for the Oqtane Framework</Description>
Expand All @@ -12,21 +12,26 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="8.0.7" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="8.0.7" />
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Localization" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0" />
<PackageReference Include="System.Net.Http.Json" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Shared\Oqtane.Blogs.Shared.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Oqtane.Client" Version="5.2.0" />
<PackageReference Include="Oqtane.Shared" Version="5.2.0" />
<PackageReference Include="Oqtane.Client" Version="6.0.1" />
<PackageReference Include="Oqtane.Shared" Version="6.0.1" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Resources\Oqtane.Blogs.Comments.resx">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>

<PropertyGroup>
Expand Down
156 changes: 156 additions & 0 deletions Client/Resources/Oqtane.Blogs.Comments.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema

Version 2.0

The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.

Example:

... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>

There are any number of "resheader" rows that contain simple
name/value pairs.

Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.

The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:

Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.

mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Author" xml:space="preserve">
<value>Author</value>
</data>
<data name="Submitted" xml:space="preserve">
<value>Submitted</value>
</data>
<data name="NoComments" xml:space="preserve">
<value>No Comments Exist For This Blog Module Instance</value>
</data>
<data name="Publish" xml:space="preserve">
<value>Publish</value>
</data>
<data name="Published" xml:space="preserve">
<value>Published</value>
</data>
<data name="Title" xml:space="preserve">
<value>Title</value>
</data>
<data name="Unpublish" xml:space="preserve">
<value>Unpublish</value>
</data>
<data name="DeleteComment.Message" xml:space="preserve">
<value>Are You Sure You Wish To Delete This Comment?</value>
</data>
<data name="DeleteComment.Text" xml:space="preserve">
<value>Delete</value>
</data>
<data name="DeleteComment.Header" xml:space="preserve">
<value>Delete Comment</value>
</data>
<data name="Error.UpdateComment" xml:space="preserve">
<value>Error Updating Blog Comment</value>
</data>
<data name="Error.DeleteComment" xml:space="preserve">
<value>Error Deleting Blog Comment</value>
</data>
</root>
2 changes: 1 addition & 1 deletion Client/Widgets/ModuleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ModuleInfo : IModule
{
Name = "Blog Widgets",
Description = "Blog Widgets",
Version = "5.2.2",
Version = "6.0.0",
Dependencies = "Oqtane.Blogs.Shared.Oqtane",
SettingsType = "Oqtane.Blogs.Widgets.Settings, Oqtane.Blogs.Client.Oqtane",
PackageName = "Oqtane.Blogs.Widgets"
Expand Down
2 changes: 1 addition & 1 deletion Package/Oqtane.Blogs.Package.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
</PropertyGroup>

Expand Down
Loading
0