Compare commits
2 Commits
47069f5ece
...
95b3ac9695
Author | SHA1 | Date | |
---|---|---|---|
95b3ac9695 | |||
70c7cfe8d2 |
@ -1,3 +1,9 @@
|
|||||||
|
using NetBarcode;
|
||||||
|
using SixLabors.ImageSharp;
|
||||||
|
using SixLabors.ImageSharp.Formats.Png;
|
||||||
|
using SixLabors.ImageSharp.Processing;
|
||||||
|
using Type = System.Type;
|
||||||
|
|
||||||
namespace OliverBooth.Data.Web;
|
namespace OliverBooth.Data.Web;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -16,4 +22,16 @@ internal sealed class Book : IBook
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string Title { get; }
|
public string Title { get; }
|
||||||
}
|
|
||||||
|
public string GetBarcode()
|
||||||
|
{
|
||||||
|
var barcode = new Barcode(Isbn, NetBarcode.Type.EAN13);
|
||||||
|
using var image = barcode.GetImage();
|
||||||
|
int width = image.Width;
|
||||||
|
int height = image.Height;
|
||||||
|
image.Mutate(i => i.Pad(width + 10, height + 10, Color.White));
|
||||||
|
image.Mutate(i => i.Resize(i.GetCurrentSize() / 4 * 3));
|
||||||
|
|
||||||
|
return image.ToBase64String(PngFormat.Instance);
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,5 @@
|
|||||||
|
using SixLabors.ImageSharp;
|
||||||
|
|
||||||
namespace OliverBooth.Data.Web;
|
namespace OliverBooth.Data.Web;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -28,4 +30,11 @@ public interface IBook
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The title of the book.</value>
|
/// <value>The title of the book.</value>
|
||||||
string Title { get; }
|
string Title { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generates the barcode for this book.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The EAN-13 barcode encoded as PNG in Base64.</returns>
|
||||||
|
/// <remarks>This value should be disposed.</remarks>
|
||||||
|
string GetBarcode();
|
||||||
}
|
}
|
@ -1,7 +1,8 @@
|
|||||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
EXPOSE 443
|
EXPOSE 443
|
||||||
|
RUN apt install -y libc6-dev libgdiplus
|
||||||
|
|
||||||
FROM node:20-alpine as build-deps
|
FROM node:20-alpine as build-deps
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
@ -11,7 +12,7 @@ RUN npm i
|
|||||||
COPY . ./
|
COPY . ./
|
||||||
RUN gulp
|
RUN gulp
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
COPY --from=build-deps /src/OliverBooth/wwwroot /src/OliverBooth/wwwroot
|
COPY --from=build-deps /src/OliverBooth/wwwroot /src/OliverBooth/wwwroot
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY ["OliverBooth/OliverBooth.csproj", "OliverBooth/"]
|
COPY ["OliverBooth/OliverBooth.csproj", "OliverBooth/"]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
@ -9,25 +9,26 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Alexinea.Extensions.Configuration.Toml" Version="7.0.0"/>
|
<PackageReference Include="Alexinea.Extensions.Configuration.Toml" Version="7.0.0"/>
|
||||||
<PackageReference Include="AspNetCore.ReCaptcha" Version="1.7.0" />
|
<PackageReference Include="AspNetCore.ReCaptcha" Version="1.7.0"/>
|
||||||
<PackageReference Include="BCrypt.Net-Core" Version="1.6.0"/>
|
<PackageReference Include="BCrypt.Net-Core" Version="1.6.0"/>
|
||||||
<PackageReference Include="Humanizer.Core" Version="2.14.1"/>
|
<PackageReference Include="Humanizer.Core" Version="2.14.1"/>
|
||||||
<PackageReference Include="MailKit" Version="4.1.0"/>
|
<PackageReference Include="MailKit" Version="4.3.0"/>
|
||||||
<PackageReference Include="MailKitSimplified.Sender" Version="2.5.2"/>
|
<PackageReference Include="MailKitSimplified.Sender" Version="2.8.0"/>
|
||||||
<PackageReference Include="Markdig" Version="0.32.0"/>
|
<PackageReference Include="Markdig" Version="0.34.0"/>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.10"/>
|
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0"/>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.10"/>
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.0"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="7.0.10"/>
|
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.0"/>
|
||||||
|
<PackageReference Include="NetBarcode" Version="1.7.0"/>
|
||||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0"/>
|
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0"/>
|
||||||
<PackageReference Include="Serilog" Version="3.0.1"/>
|
<PackageReference Include="Serilog" Version="3.1.1"/>
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0"/>
|
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0"/>
|
||||||
<PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0"/>
|
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0"/>
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0"/>
|
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1"/>
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0"/>
|
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0"/>
|
||||||
<PackageReference Include="SmartFormat.NET" Version="3.2.2"/>
|
<PackageReference Include="SmartFormat.NET" Version="3.3.0"/>
|
||||||
<PackageReference Include="X10D" Version="3.2.2"/>
|
<PackageReference Include="X10D" Version="3.3.1"/>
|
||||||
<PackageReference Include="X10D.Hosting" Version="3.2.2"/>
|
<PackageReference Include="X10D.Hosting" Version="3.3.1"/>
|
||||||
<PackageReference Include="ZString" Version="2.5.0"/>
|
<PackageReference Include="ZString" Version="2.5.1"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
@page
|
@page
|
||||||
|
@using NetBarcode
|
||||||
@using OliverBooth.Data.Web
|
@using OliverBooth.Data.Web
|
||||||
|
@using SixLabors.ImageSharp
|
||||||
|
@using SixLabors.ImageSharp.Formats.Png
|
||||||
|
@using SixLabors.ImageSharp.Processing
|
||||||
|
@using Type = NetBarcode.Type
|
||||||
@model OliverBooth.Pages.Books
|
@model OliverBooth.Pages.Books
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Reading List";
|
ViewData["Title"] = "Reading List";
|
||||||
@ -33,7 +38,7 @@
|
|||||||
@book.Title.Trim()
|
@book.Title.Trim()
|
||||||
</td>
|
</td>
|
||||||
<td>@book.Author.Trim()</td>
|
<td>@book.Author.Trim()</td>
|
||||||
<td>@book.Isbn.Trim()</td>
|
<td style="font-family: monospace">@book.Isbn.Trim()<br><img src="@book.GetBarcode()" alt="@book.Isbn"></td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -58,7 +63,7 @@
|
|||||||
@book.Title.Trim()
|
@book.Title.Trim()
|
||||||
</td>
|
</td>
|
||||||
<td>@book.Author.Trim()</td>
|
<td>@book.Author.Trim()</td>
|
||||||
<td>@book.Isbn.Trim()</td>
|
<td style="font-family: monospace">@book.Isbn.Trim()<br><img src="@book.GetBarcode()" alt="@book.Isbn"></td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -83,7 +88,7 @@
|
|||||||
@book.Title.Trim()
|
@book.Title.Trim()
|
||||||
</td>
|
</td>
|
||||||
<td>@book.Author.Trim()</td>
|
<td>@book.Author.Trim()</td>
|
||||||
<td>@book.Isbn.Trim()</td>
|
<td style="font-family: monospace">@book.Isbn.Trim()<br><img src="@book.GetBarcode()" alt="@book.Isbn"></td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
Loading…
Reference in New Issue
Block a user