Skip to content

Commit

Permalink
v14.18.0 (#853)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdiWang authored Jan 23, 2025
2 parents a58d4a7 + cde6ce2 commit 3f833e2
Show file tree
Hide file tree
Showing 90 changed files with 1,389 additions and 1,172 deletions.
11 changes: 10 additions & 1 deletion Deployment/mssql-migration.sql
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,16 @@ BEGIN
ALTER TABLE [dbo].[BlogConfiguration] DROP CONSTRAINT [PK_BlogConfiguration];
END

ALTER TABLE [dbo].[BlogConfiguration] ADD CONSTRAINT [PK_BlogConfiguration_CfgKey] PRIMARY KEY CLUSTERED ([CfgKey] ASC);
IF NOT EXISTS (
SELECT 1
FROM sys.key_constraints kc
INNER JOIN sys.tables t ON kc.parent_object_id = t.object_id
WHERE kc.type = 'PK'
AND t.name = 'BlogConfiguration'
)
BEGIN
ALTER TABLE [dbo].[BlogConfiguration] ADD CONSTRAINT [PK_BlogConfiguration_CfgKey] PRIMARY KEY CLUSTERED ([CfgKey] ASC);
END

IF EXISTS (
SELECT 1
Expand Down
6 changes: 3 additions & 3 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<Authors>Edi Wang</Authors>
<Company>edi.wang</Company>
<Copyright>(C) 2025 [email protected]</Copyright>
<AssemblyVersion>14.17.0</AssemblyVersion>
<FileVersion>14.17.0</FileVersion>
<Version>14.17.0</Version>
<AssemblyVersion>14.18.0</AssemblyVersion>
<FileVersion>14.18.0</FileVersion>
<Version>14.18.0</Version>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Moonglade.Auth/Moonglade.Auth.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ItemGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Identity.Web" Version="3.5.0" />
<PackageReference Include="Microsoft.Identity.Web" Version="3.6.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Moonglade.Configuration\Moonglade.Configuration.csproj" />
Expand Down
7 changes: 7 additions & 0 deletions src/Moonglade.Comments/CommentProviderGateAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.DependencyInjection;
using Moonglade.Configuration;
using Moonglade.Utils;

namespace Moonglade.Comments;

Expand All @@ -11,6 +12,12 @@ public class CommentProviderGateAttribute : ActionFilterAttribute
{
public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
if (Helper.GetAppDomainData<bool>("IsReadonlyMode"))
{
await HandleDisabledComment(context).ConfigureAwait(false);
return;
}

var config = context.HttpContext.RequestServices.GetService<IBlogConfig>();

if (config != null &&
Expand Down
2 changes: 1 addition & 1 deletion src/Moonglade.Core/PageFeature/DeletePageCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public async Task<OperationCode> Handle(DeletePageCommand request, CancellationT
var page = await repo.GetByIdAsync(request.Id, ct);
if (page == null) return OperationCode.ObjectNotFound;

if (page.CssId != null)
if (!string.IsNullOrWhiteSpace(page.CssId))
{
await mediator.Send(new DeleteStyleSheetCommand(new(page.CssId)), ct);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.12" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Moonglade.Data\Moonglade.Data.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion src/Moonglade.Data/Moonglade.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="Ardalis.Specification" Version="8.0.0" />
<PackageReference Include="Ardalis.Specification.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="MediatR" Version="12.4.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.12" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Moonglade.Utils\Moonglade.Utils.csproj" />
Expand Down
3 changes: 2 additions & 1 deletion src/Moonglade.Theme/ThemeFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public static IEnumerable<BlogThemeEntity> GetSystemThemes()
CreateTheme(105, "Metal Blue", "#4E5967"),
CreateTheme(106, "Mars Green", "#008C8C"),
CreateTheme(107, "Prussian Blue", "#003153"),
CreateTheme(108, "Hermes Orange", "#E85827")
CreateTheme(108, "Hermes Orange", "#E85827"),
CreateTheme(109, "Burgundy Red", "#800020"),
};
}

Expand Down
16 changes: 16 additions & 0 deletions src/Moonglade.Utils/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ public static string AppVersion
}
}

public static void SetAppDomainData(string key, object value)
{
AppDomain.CurrentDomain.SetData(key, value);
}

public static T GetAppDomainData<T>(string key, T defaultValue = default(T))
{
object data = AppDomain.CurrentDomain.GetData(key);
if (data == null)
{
return defaultValue;
}

return (T)data;
}

public static bool IsNonStableVersion()
{
string pattern = @"\b(preview|beta|rc|debug|alpha|test|canary|nightly)\b";
Expand Down
2 changes: 1 addition & 1 deletion src/Moonglade.Utils/Moonglade.Utils.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Markdig" Version="0.39.1" />
<PackageReference Include="Markdig" Version="0.40.0" />
<PackageReference Include="Edi.ChinaDetector" Version="1.3.251" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions src/Moonglade.Web/Controllers/AssetsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public async Task<IActionResult> Avatar(ICacheAside cache)

[Authorize]
[HttpPost("avatar")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status409Conflict)]
[TypeFilter(typeof(ClearBlogCache), Arguments = [BlogCachePartition.General, "avatar"])]
Expand Down Expand Up @@ -109,6 +110,7 @@ public async Task<IActionResult> SiteIconOrigin()

[Authorize]
[HttpPost("siteicon")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status409Conflict)]
public async Task<IActionResult> UpdateSiteIcon([FromBody] string base64Img)
Expand Down
3 changes: 3 additions & 0 deletions src/Moonglade.Web/Controllers/CategoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public async Task<IActionResult> List()
}

[HttpPost]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status201Created)]
public async Task<IActionResult> Create(CreateCategoryCommand command)
{
Expand All @@ -44,6 +45,7 @@ public async Task<IActionResult> Create(CreateCategoryCommand command)
}

[HttpPut("{id:guid}")]
[ReadonlyMode]
[ApiConventionMethod(typeof(DefaultApiConventions), nameof(DefaultApiConventions.Put))]
public async Task<IActionResult> Update([NotEmpty] Guid id, UpdateCategoryCommand command)
{
Expand All @@ -55,6 +57,7 @@ public async Task<IActionResult> Update([NotEmpty] Guid id, UpdateCategoryComman
}

[HttpDelete("{id:guid}")]
[ReadonlyMode]
[ApiConventionMethod(typeof(DefaultApiConventions), nameof(DefaultApiConventions.Delete))]
public async Task<IActionResult> Delete([NotEmpty] Guid id)
{
Expand Down
3 changes: 3 additions & 0 deletions src/Moonglade.Web/Controllers/FriendLinkController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Moonglade.Web.Controllers;
public class FriendLinkController(IMediator mediator) : ControllerBase
{
[HttpPost]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status201Created)]
public async Task<IActionResult> Create(EditLinkRequest request)
{
Expand Down Expand Up @@ -37,6 +38,7 @@ public async Task<IActionResult> List()
}

[HttpPut("{id:guid}")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Update([NotEmpty] Guid id, EditLinkRequest request)
{
Expand All @@ -45,6 +47,7 @@ public async Task<IActionResult> Update([NotEmpty] Guid id, EditLinkRequest requ
}

[HttpDelete("{id:guid}")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Delete([NotEmpty] Guid id)
{
Expand Down
1 change: 1 addition & 0 deletions src/Moonglade.Web/Controllers/ImageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public async Task<IActionResult> Image([MaxLength(256)] string filename)
}

[Authorize]
[ReadonlyMode]
[HttpPost, IgnoreAntiforgeryToken]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
Expand Down
4 changes: 4 additions & 0 deletions src/Moonglade.Web/Controllers/MentionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class MentionController(
IMediator mediator) : ControllerBase
{
[HttpPost("/webmention")]
[ReadonlyMode]
[IgnoreAntiforgeryToken]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
Expand Down Expand Up @@ -55,6 +56,7 @@ private IActionResult HandleWebmentionFailure(WebmentionStatus status)
}

[HttpPost("/pingback")]
[ReadonlyMode]
[IgnoreAntiforgeryToken]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
Expand Down Expand Up @@ -87,6 +89,7 @@ private async void SendMentionEmailAction(MentionEntity mention)
}

[Authorize]
[ReadonlyMode]
[HttpDelete("{pingbackId:guid}")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Delete([NotEmpty] Guid pingbackId)
Expand All @@ -96,6 +99,7 @@ public async Task<IActionResult> Delete([NotEmpty] Guid pingbackId)
}

[Authorize]
[ReadonlyMode]
[HttpDelete("clear")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Clear()
Expand Down
3 changes: 3 additions & 0 deletions src/Moonglade.Web/Controllers/PageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Moonglade.Web.Controllers;
public class PageController(ICacheAside cache, IMediator mediator) : Controller
{
[HttpPost]
[ReadonlyMode]
[TypeFilter(typeof(ClearBlogCache), Arguments = [BlogCacheType.SiteMap])]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<IActionResult> Create(EditPageRequest model)
Expand All @@ -20,6 +21,7 @@ public async Task<IActionResult> Create(EditPageRequest model)
}

[HttpPut("{id:guid}")]
[ReadonlyMode]
[TypeFilter(typeof(ClearBlogCache), Arguments = [BlogCacheType.SiteMap])]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<IActionResult> Edit([NotEmpty] Guid id, EditPageRequest model)
Expand All @@ -31,6 +33,7 @@ public async Task<IActionResult> Edit([NotEmpty] Guid id, EditPageRequest model)
}

[HttpDelete("{id:guid}")]
[ReadonlyMode]
[ApiConventionMethod(typeof(DefaultApiConventions), nameof(DefaultApiConventions.Delete))]
public async Task<IActionResult> Delete([NotEmpty] Guid id)
{
Expand Down
6 changes: 6 additions & 0 deletions src/Moonglade.Web/Controllers/PostController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class PostController(
CannonService cannonService) : ControllerBase
{
[HttpPost("createoredit")]
[ReadonlyMode]
[TypeFilter(typeof(ClearBlogCache), Arguments =
[
BlogCacheType.SiteMap |
Expand Down Expand Up @@ -92,6 +93,7 @@ await mediator.Send(new CreatePostCommand(model)) :
BlogCacheType.Subscription
])]
[HttpPost("{postId:guid}/restore")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Restore([NotEmpty] Guid postId)
{
Expand All @@ -105,6 +107,7 @@ public async Task<IActionResult> Restore([NotEmpty] Guid postId)
BlogCacheType.Subscription
])]
[HttpDelete("{postId:guid}/recycle")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Delete([NotEmpty] Guid postId)
{
Expand All @@ -114,6 +117,7 @@ public async Task<IActionResult> Delete([NotEmpty] Guid postId)

[TypeFilter(typeof(ClearBlogCache), Arguments = [BlogCacheType.Subscription | BlogCacheType.SiteMap])]
[HttpDelete("{postId:guid}/destroy")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> DeleteFromRecycleBin([NotEmpty] Guid postId)
{
Expand All @@ -123,6 +127,7 @@ public async Task<IActionResult> DeleteFromRecycleBin([NotEmpty] Guid postId)

[TypeFilter(typeof(ClearBlogCache), Arguments = [BlogCacheType.Subscription | BlogCacheType.SiteMap])]
[HttpDelete("recyclebin")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> EmptyRecycleBin()
{
Expand All @@ -132,6 +137,7 @@ public async Task<IActionResult> EmptyRecycleBin()

[TypeFilter(typeof(ClearBlogCache), Arguments = [BlogCacheType.Subscription | BlogCacheType.SiteMap])]
[HttpPut("{postId:guid}/unpublish")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Unpublish([NotEmpty] Guid postId)
{
Expand Down
11 changes: 11 additions & 0 deletions src/Moonglade.Web/Controllers/SettingsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public IActionResult SetLanguage(string culture, string returnUrl)
}

[HttpPost("general")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> General(GeneralSettings model, ITimeZoneResolver timeZoneResolver)
{
Expand All @@ -54,6 +55,7 @@ public async Task<IActionResult> General(GeneralSettings model, ITimeZoneResolve
}

[HttpPost("content")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Content(ContentSettings model)
{
Expand All @@ -64,6 +66,7 @@ public async Task<IActionResult> Content(ContentSettings model)
}

[HttpPost("comment")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Comment(CommentSettings model)
{
Expand All @@ -74,6 +77,7 @@ public async Task<IActionResult> Comment(CommentSettings model)
}

[HttpPost("notification")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Notification(NotificationSettings model)
{
Expand All @@ -100,6 +104,7 @@ public async Task<IActionResult> TestEmail()
}

[HttpPost("subscription")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Subscription(FeedSettings model)
{
Expand All @@ -110,6 +115,7 @@ public async Task<IActionResult> Subscription(FeedSettings model)
}

[HttpPost("watermark")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> Image(ImageSettings model, IBlogImageStorage imageStorage)
Expand Down Expand Up @@ -153,6 +159,7 @@ public async Task<IActionResult> Image(ImageSettings model, IBlogImageStorage im
}

[HttpPost("advanced")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Advanced(AdvancedSettings model)
{
Expand All @@ -163,6 +170,7 @@ public async Task<IActionResult> Advanced(AdvancedSettings model)
}

[HttpPost("social-link")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> SocialLink(SocialLinkSettingsJsonModel model)
{
Expand Down Expand Up @@ -216,6 +224,7 @@ public async Task<IActionResult> SocialLink(SocialLinkSettingsJsonModel model)
}

[HttpPost("appearance")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[TypeFilter(typeof(ClearBlogCache), Arguments = [BlogCachePartition.General, "theme"])]
Expand All @@ -234,6 +243,7 @@ public async Task<IActionResult> Appearance(AppearanceSettings model)
}

[HttpPost("custom-menu")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> CustomMenu(CustomMenuSettingsJsonModel model)
Expand Down Expand Up @@ -267,6 +277,7 @@ public IActionResult GeneratePassword([FromServices] IPasswordGenerator password
}

[HttpPut("password/local")]
[ReadonlyMode]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status409Conflict)]
public async Task<IActionResult> UpdateLocalAccountPassword(UpdateLocalAccountPasswordRequest request)
Expand Down
Loading

0 comments on commit 3f833e2

Please sign in to comment.