Skip to content

Commit

Permalink
Merged PR 87: Updates from Upstream
Browse files Browse the repository at this point in the history
- update translations
- Localize email input in CommentForm
- Localize Captcha placeholder text
- update more translations
- Update Npgsql.EntityFrameworkCore.PostgreSQL to 8.0.8
- Add localization for Dublin Core Metadata terms
- Add "Pronouns" translations for multiple languages
- Localize sidebar and widget text in multiple languages
- update translations
- add translation
- add more translation
- update translations
- update translation
- update translations
- update translation
- update more translation
- Refactor dark mode CSS for timeline component
- support dark theme on sign in page
- admin: apply theme to page with ThemeSwitchReady
- refact dark theme style
- move more dark theme css
- complete darkmode.css migration
- move around rwd css
- fix rwd background color
- update dark theme
- Update admin.css
- Refactor BlogPage config settings for clarity
- Refactor caching logic and update ImageStorage settings
- Update SQL Server migration script URL in appsettings.json
- Update admin.css
- color fix
- support dark theme on Notification settings
- support dark theme on Subscription page
- support dark theme on image settings
- dark theme for advanced settings
- dark mode for CustomStyleSheet
- dark mode for content settings
- dark mode for general settings
- Update drop target styling in modals and add dark theme
- support dark mode for categories
- dark mode for BlogPage
- dark mode for EditPage
- Add localization for "Change Password" in multiple languages
- remove MFA option
- dark theme for menu settings
- dark mode for friendlink
- dark mode for mention
- dark mode for tags admin
- dark mode for post admin
- dark mode for draft
- Update RecycleBin.cshtml
- dark mode for comments admin
- Rename CSS class from mention-item-container to mention-item-entry
- partial support for dark mode on post editor
- upgrade tagify
- Refactor theme switching script inclusion
- Update EditPost.cshtml
- Update background color for image upload area
- Update Microsoft.Identity.Web to version 3.2.1
- Move .md-editor-image-upload-area CSS to admin.css
- bump version
- Refactor CSS imports and remove redundant styles
- Add custom styles for tag input container in admin panel
- Add dark theme support for tagify component in admin UI
- fix build warning
- code refact
- Remove Moonglade.Setup from LoadAssemblies method
- bump version
- fix LoadAssemblies
- Reorder assemblies and filter MediatR registrations
- Refactor service configuration and async app run
- Add new namespaces and improve RewriteOptions readability
- bump version to rc
- Add PrefersColorSchemeMiddleware and config setting
- patch .net
- bump version
- Add server-side handling for color scheme preference
- Update version numbers in Directory.Build.props
- Enable config-based dark mode and improve code readability
- Update PrefersColorScheme feature and configuration
- Update config key for PrefersColorScheme header name
- Add DI, anti-forgery token, and "Index Now" settings
- Update icons for ...
  • Loading branch information
saigkill committed Oct 15, 2024
2 parents 5eadd39 + c2d9c94 commit 602dfff
Show file tree
Hide file tree
Showing 84 changed files with 2,822 additions and 895 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/webapp-prod.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Azure Web App (PROD)

env:
AZURE_WEBAPP_NAME: moonglade-ediwang-us
AZURE_WEBAPP_NAME: ediwang
AZURE_WEBAPP_PACKAGE_PATH: '.'
DOTNET_VERSION: '8'

Expand Down Expand Up @@ -66,5 +66,5 @@ jobs:
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
clean: true
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE2 }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
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) 2024 [email protected]</Copyright>
<AssemblyVersion>14.10.0.0</AssemblyVersion>
<FileVersion>14.10.0.0</FileVersion>
<Version>14.10.0-beta.1</Version>
<AssemblyVersion>14.12.0.0</AssemblyVersion>
<FileVersion>14.12.0.0</FileVersion>
<Version>14.12.0-preview.2</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.1.0" />
<PackageReference Include="Microsoft.Identity.Web" Version="3.2.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Moonglade.Configuration\Moonglade.Configuration.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion src/Moonglade.Comments/Moonglade.Comments.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
<ProjectReference Include="..\Moonglade.Configuration\Moonglade.Configuration.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.9.1" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.10.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Moonglade.Core.CategoryFeature;
public class CreateCategoryCommand : IRequest
{
[Required]
[Display(Name = "Display Name")]
[Display(Name = "Display name")]
[MaxLength(64)]
public string DisplayName { get; set; }

Expand Down
46 changes: 23 additions & 23 deletions src/Moonglade.Core/PostFeature/CreatePostCommand.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System.Globalization;

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

using Moonglade.Configuration;
using Moonglade.Data;
using Moonglade.Data.Specifications;
using Moonglade.Utils;
using System.Globalization;

namespace Moonglade.Core.PostFeature;

Expand Down Expand Up @@ -35,26 +34,27 @@ public async Task<PostEntity> Handle(CreatePostCommand request, CancellationToke
abs = request.Payload.Abstract.Trim();
}

var post = new PostEntity
{
CommentEnabled = request.Payload.EnableComment,
Id = Guid.NewGuid(),
PostContent = request.Payload.EditorContent,
ContentAbstract = abs,
CreateTimeUtc = DateTime.UtcNow,
LastModifiedUtc = DateTime.UtcNow, // Fix draft orders
Slug = request.Payload.Slug.ToLower().Trim(),
Author = request.Payload.Author?.Trim(),
Title = request.Payload.Title.Trim(),
ContentLanguageCode = request.Payload.LanguageCode,
IsFeedIncluded = request.Payload.FeedIncluded,
PubDateUtc = request.Payload.IsPublished ? DateTime.UtcNow : null,
IsDeleted = false,
IsPublished = request.Payload.IsPublished,
IsFeatured = request.Payload.Featured,
HeroImageUrl = string.IsNullOrWhiteSpace(request.Payload.HeroImageUrl) ? null : Helper.SterilizeLink(request.Payload.HeroImageUrl),
IsOutdated = request.Payload.IsOutdated,
};
var utcNow = DateTime.UtcNow;
var post = new PostEntity
{
CommentEnabled = request.Payload.EnableComment,
Id = Guid.NewGuid(),
PostContent = request.Payload.EditorContent,
ContentAbstract = abs,
CreateTimeUtc = utcNow,
LastModifiedUtc = utcNow, // Fix draft orders
Slug = request.Payload.Slug.ToLower().Trim(),
Author = request.Payload.Author?.Trim(),
Title = request.Payload.Title.Trim(),
ContentLanguageCode = request.Payload.LanguageCode,
IsFeedIncluded = request.Payload.FeedIncluded,
PubDateUtc = request.Payload.IsPublished ? utcNow : null,
IsDeleted = false,
IsPublished = request.Payload.IsPublished,
IsFeatured = request.Payload.Featured,
HeroImageUrl = string.IsNullOrWhiteSpace(request.Payload.HeroImageUrl) ? null : Helper.SterilizeLink(request.Payload.HeroImageUrl),
IsOutdated = request.Payload.IsOutdated,
};

post.RouteLink = $"{post.PubDateUtc.GetValueOrDefault().ToString("yyyy/M/d", CultureInfo.InvariantCulture)}/{request.Payload.Slug}";

Expand Down
3 changes: 3 additions & 0 deletions src/Moonglade.Core/PostFeature/PostEditModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,7 @@ public class PostEditModel
public bool IsOutdated { get; set; }

public bool WarnSlugModification => PublishDate.HasValue && (DateTime.UtcNow - PublishDate.Value).Days > 3;

[HiddenInput]
public string LastModifiedUtc { get; set; }
}
24 changes: 24 additions & 0 deletions src/Moonglade.Core/PostFeature/UnpublishPostCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Edi.CacheAside.InMemory;
using Moonglade.Data;

namespace Moonglade.Core.PostFeature;

public record UnpublishPostCommand(Guid Id) : IRequest;

public class UnpublishPostCommandHandler(MoongladeRepository<PostEntity> repo, ICacheAside cache) : IRequestHandler<UnpublishPostCommand>
{
public async Task Handle(UnpublishPostCommand request, CancellationToken ct)
{
var post = await repo.GetByIdAsync(request.Id, ct);
if (null == post) return;

post.IsPublished = false;
post.PubDateUtc = null;
post.RouteLink = null;
post.LastModifiedUtc = DateTime.UtcNow;

await repo.UpdateAsync(post, ct);

cache.Remove(BlogCachePartition.Post.ToString(), request.Id.ToString());
}
}
27 changes: 14 additions & 13 deletions src/Moonglade.Core/PostFeature/UpdatePostCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ public UpdatePostCommandHandler(
_useMySqlWorkaround = dbType!.ToLower().Trim() == "mysql";
}

public async Task<PostEntity> Handle(UpdatePostCommand request, CancellationToken ct)
{
var (guid, postEditModel) = request;
var post = await _postRepo.GetByIdAsync(guid, ct);
if (null == post)
public async Task<PostEntity> Handle(UpdatePostCommand request, CancellationToken ct)
{
throw new InvalidOperationException($"Post {guid} is not found.");
}
var utcNow = DateTime.UtcNow;
var (guid, postEditModel) = request;
var post = await _postRepo.GetByIdAsync(guid, ct);
if (null == post)
{
throw new InvalidOperationException($"Post {guid} is not found.");
}

post.CommentEnabled = postEditModel.EnableComment;
post.PostContent = postEditModel.EditorContent;
Expand All @@ -74,11 +75,11 @@ public async Task<PostEntity> Handle(UpdatePostCommand request, CancellationToke
post.ContentAbstract = postEditModel.Abstract.Trim();
}

if (postEditModel.IsPublished && !post.IsPublished)
{
post.IsPublished = true;
post.PubDateUtc = DateTime.UtcNow;
}
if (postEditModel.IsPublished && !post.IsPublished)
{
post.IsPublished = true;
post.PubDateUtc = utcNow;
}

// #325: Allow changing publish date for published posts
if (postEditModel.ChangePublishDate && postEditModel.PublishDate is not null && post.PubDateUtc.HasValue)
Expand All @@ -91,7 +92,7 @@ public async Task<PostEntity> Handle(UpdatePostCommand request, CancellationToke
post.Author = postEditModel.Author?.Trim();
post.Slug = postEditModel.Slug.ToLower().Trim();
post.Title = postEditModel.Title.Trim();
post.LastModifiedUtc = DateTime.UtcNow;
post.LastModifiedUtc = utcNow;
post.IsFeedIncluded = postEditModel.FeedIncluded;
post.ContentLanguageCode = postEditModel.LanguageCode;
post.IsFeatured = postEditModel.Featured;
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="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.8" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Moonglade.Data\Moonglade.Data.csproj" />
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.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.10" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Moonglade.Data\Moonglade.Data.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion src/Moonglade.Email.Client/Moonglade.Email.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.9.1" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.10.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Moonglade.Configuration\Moonglade.Configuration.csproj" />
Expand Down
2 changes: 2 additions & 0 deletions src/Moonglade.ImageStorage/ImageStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public class ImageStorageSettings
{
public string[] AllowedExtensions { get; set; }

public int CacheMinutes { get; set; }

public string Provider { get; set; }

public string FileSystemPath { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/Moonglade.ImageStorage/Moonglade.ImageStorage.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="Azure.Storage.Blobs" Version="12.22.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.22.2" />
<PackageReference Include="Minio" Version="6.0.3" />
</ItemGroup>
</Project>
12 changes: 1 addition & 11 deletions src/Moonglade.ImageStorage/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,10 @@

namespace Moonglade.ImageStorage;

public class ImageStorageOptions
{
public string ContentRootPath { get; set; } = Directory.GetCurrentDirectory();
}

public static class ServiceCollectionExtensions
{
private static readonly ImageStorageOptions Options = new();

public static IServiceCollection AddImageStorage(
this IServiceCollection services, IConfiguration configuration, Action<ImageStorageOptions> options)
public static IServiceCollection AddImageStorage(this IServiceCollection services, IConfiguration configuration)
{
options(Options);

var section = configuration.GetSection(nameof(ImageStorage));
var settings = section.Get<ImageStorageSettings>();
services.Configure<ImageStorageSettings>(section);
Expand Down
19 changes: 15 additions & 4 deletions src/Moonglade.IndexNow.Client/IndexNowClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.Extensions.Logging;
using System.Net;
using System.Text;
using System.Text.Json;

namespace Moonglade.IndexNow.Client;

Expand All @@ -28,7 +29,14 @@ public async Task SendRequestAsync(Uri uri)
var client = httpClientFactory.CreateClient(pingTarget);

var requestBody = CreateRequestBody(uri);
var content = new StringContent(System.Text.Json.JsonSerializer.Serialize(requestBody), Encoding.UTF8, "application/json");

var jso = new JsonSerializerOptions
{
// Fix 422 issue, some search engines is fracking case sensitive!
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};

var content = new StringContent(JsonSerializer.Serialize(requestBody, jso), Encoding.UTF8, "application/json");

try
{
Expand All @@ -45,12 +53,15 @@ public async Task SendRequestAsync(Uri uri)
private IndexNowRequest CreateRequestBody(Uri uri)
{
// https://www.indexnow.org/documentation
return new IndexNowRequest
// "In this option 2, the location of a key file determines the set of URLs that can be included with this key. A key file located at http://example.com/catalog/key12457EDd.txt can include any URLs starting with http://example.com/catalog/ but cannot include URLs starting with http://example.com/help/."
// "URLs that are not considered valid in option 2 may not be considered for indexing. It is strongly recommended that you use Option 1 and place your file key at the root directory of your web server."
// This is why we should not set KeyLocation = $"https://{uri.Host}/xxxx.txt",

return new()
{
Host = uri.Host,
Key = _apiKey,
KeyLocation = $"https://{uri.Host}/indexnowkey.txt",
UrlList = new[] { uri.ToString() }
UrlList = [uri.ToString()]
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/Moonglade.IndexNow.Client/IndexNowMapHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static async Task Handle(HttpContext httpContext, IConfiguration configur
if (string.IsNullOrWhiteSpace(apiKey))
{
httpContext.Response.StatusCode = StatusCodes.Status404NotFound;
await httpContext.Response.WriteAsync("No indexnowkey.txt is present.", httpContext.RequestAborted);
await httpContext.Response.WriteAsync("No IndexNow API Key is present.", httpContext.RequestAborted);
}
else
{
Expand Down
1 change: 0 additions & 1 deletion src/Moonglade.IndexNow.Client/IndexNowRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ public class IndexNowRequest
{
public string Host { get; set; }
public string Key { get; set; }
public string KeyLocation { get; set; }
public string[] UrlList { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.9.1" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.10.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Moonglade.Utils\Moonglade.Utils.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
<ProjectReference Include="..\Moonglade.Utils\Moonglade.Utils.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.9.1" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.10.0" />
</ItemGroup>
</Project>
4 changes: 1 addition & 3 deletions src/Moonglade.Pingback/PingbackSender.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using Moonglade.Utils;

namespace Moonglade.Pingback;

public class PingbackSender(HttpClient httpClient,
IPingbackRequestor requestor,
IConfiguration configuration,
ILogger<PingbackSender> logger)
: IPingbackSender
{
Expand Down
3 changes: 1 addition & 2 deletions src/Moonglade.Web/Controllers/ImageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class ImageController(IBlogImageStorage imageStorage,
IBlogConfig blogConfig,
IMemoryCache cache,
IFileNameGenerator fileNameGen,
IConfiguration configuration,
IOptions<ImageStorageSettings> imageStorageSettings,
CannonService cannonService)
: ControllerBase
Expand Down Expand Up @@ -42,7 +41,7 @@ public async Task<IActionResult> Image([MaxLength(256)] string filename)

var image = await cache.GetOrCreateAsync(filename, async entry =>
{
entry.SlidingExpiration = TimeSpan.FromMinutes(int.Parse(configuration["CacheSlidingExpirationMinutes:Image"]!));
entry.SlidingExpiration = TimeSpan.FromMinutes(_imageStorageSettings.CacheMinutes);
var imageInfo = await imageStorage.GetAsync(filename);
return imageInfo;
});
Expand Down
Loading

0 comments on commit 602dfff

Please sign in to comment.