-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
86 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
namespace CaptchaN.WebApi | ||
using CaptchaN.Abstractions; | ||
using CaptchaN.Factories; | ||
using Microsoft.AspNetCore.Http.HttpResults; | ||
using Microsoft.Extensions.Options; | ||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
builder.Services.Configure<PainterOption>(builder.Configuration.GetSection("CaptchaN")); | ||
builder.Services.AddCaptchaN() | ||
//.UseFontRandomer(new SystemFontRandomerFactory()); | ||
.UseFontRandomer(new DirectoryFontRandomerFactory() { FontDir = new(Path.Combine(builder.Environment.ContentRootPath, "Fonts")) }); | ||
|
||
var app = builder.Build(); | ||
|
||
app.MapGet("/captcha", async Task<FileContentHttpResult> (IOptions<PainterOption> painterOpt, ICodeTextGenerator codeTextGenerator, IPainter painter) => | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
CreateHostBuilder(args).Build().Run(); | ||
} | ||
var codeText = codeTextGenerator.Generate(4); | ||
var image = await painter.GenerateImageAsync(codeText, painterOpt.Value); | ||
return TypedResults.File(image, "image/jpeg; charset=UTF-8"); | ||
}); | ||
|
||
public static IHostBuilder CreateHostBuilder(string[] args) => | ||
Host.CreateDefaultBuilder(args) | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
webBuilder.UseStartup<Startup>(); | ||
}); | ||
} | ||
} | ||
app.Run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# CaptchaN.WebApi | ||
|
||
Before the first running, please create a directory called `Fonts` at the same level of `Controllers`, then put your font files `*.ttf` into `Fonts`. | ||
>在第一次运行前,请先创建一个与`Controllers`同级的文件夹,命名为`Fonts`,然后将你的`*.ttf`格式字体文件放入其中。 | ||
Before the first running, please create a directory called `Fonts` at the same level of `Program.cs`, then put your font files `*.ttf` into `Fonts`. | ||
>在第一次运行前,请先创建一个与`Program.cs`同级的文件夹,命名为`Fonts`,然后将你的`*.ttf`格式字体文件放入其中。 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,36 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<TargetFrameworks>net6.0;net8.0</TargetFrameworks> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
|
||
<LangVersion>latest</LangVersion> | ||
<PackageId>CaptchaN.DI.Microsoft</PackageId> | ||
<Title>CaptchaN.DI.Microsoft</Title> | ||
<Authors>LeaFrock</Authors> | ||
<Version>1.1.0</Version> | ||
<Version>3.0.0</Version> | ||
<Product>CaptchaN.DI.Microsoft</Product> | ||
<Description>CaptchaN DI for .NET default container.</Description> | ||
<Copyright>Copyright © LeaFrock 2022</Copyright> | ||
<Copyright>Copyright © LeaFrock 2023</Copyright> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<PackageTags>captcha;imagesharp</PackageTags> | ||
<PackageProjectUrl>https://github.com/LeaFrock/CaptchaN</PackageProjectUrl> | ||
<RepositoryUrl>https://github.com/LeaFrock/CaptchaN.git</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
<PackageReleaseNotes>Upgrade to ImageSharp 2.0</PackageReleaseNotes> | ||
<PackageReleaseNotes>Add support for .NET 8</PackageReleaseNotes> | ||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance> | ||
<PackageReadmeFile>README.md</PackageReadmeFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CaptchaN" Version="2.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\CaptchaN\CaptchaN.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\..\README.md" Pack="true" PackagePath="\"/> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<TargetFrameworks>net6.0;net8.0</TargetFrameworks> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
|
||
<LangVersion>latest</LangVersion> | ||
<PackageId>CaptchaN</PackageId> | ||
<Title>CaptchaN</Title> | ||
<Authors>LeaFrock</Authors> | ||
<Version>2.0.1</Version> | ||
<Version>3.0.0</Version> | ||
<Product>CaptchaN</Product> | ||
<Description>Core module of generating captcha images.</Description> | ||
<Copyright>Copyright © LeaFrock 2022</Copyright> | ||
<Copyright>Copyright © LeaFrock 2023</Copyright> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<PackageTags>captcha;imagesharp</PackageTags> | ||
<PackageProjectUrl>https://github.com/LeaFrock/CaptchaN</PackageProjectUrl> | ||
<RepositoryUrl>https://github.com/LeaFrock/CaptchaN.git</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
<PackageReleaseNotes>Upgrade to ImageSharp 2.1</PackageReleaseNotes> | ||
<PackageReleaseNotes>Add support for .NET 8</PackageReleaseNotes> | ||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance> | ||
<PackageReadmeFile>README.md</PackageReadmeFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta15" /> | ||
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.0.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\..\README.md" Pack="true" PackagePath="\"/> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.