SixLabors / ImageSharp.Web

:globe_with_meridians: High Performance Image Processing Middleware for ASP.NET- Core.
https://sixlabors.com/products/imagesharp-web/
Other
423 stars 101 forks source link

Introduce Taghelper #290

Closed JimBobSquarePants closed 1 year ago

JimBobSquarePants commented 2 years ago

Prerequisites

Description

Adds a new ImageSharpTaghelper that greatly simplifies URL generation (including automatic generation of HMAC keys). The TagHelper is designed to be inheritable allowing the addition of custom commands.

Example usage (note, the syntax highlighter here does not do the TagHelper justice. The property values are all strong typed)

<img src="sixlabors.imagesharp.web.png"
     width="300"
     height="200"
     imagesharp-width="600"
     imagesharp-height="400"
     imagesharp-rmode="ResizeMode.Pad"
     imagesharp-rcolor="Color.LimeGreen" />

The TagHelper will only intitialize when both the following criteria are met:

  1. The TagHelper is explicitly referenced in _ViewImports.cshtml via @addTagHelper *, SixLabors.ImageSharp.Web
  2. The src and imagesharp- prefixed HTML attributes are declared.
codecov[bot] commented 2 years ago

Codecov Report

Merging #290 (e057f93) into main (35e1ae2) will increase coverage by 0%. The diff coverage is 87%.

@@         Coverage Diff          @@
##           main   #290    +/-   ##
====================================
  Coverage    85%    85%            
====================================
  Files        77     83     +6     
  Lines      2199   2375   +176     
  Branches    313    346    +33     
====================================
+ Hits       1871   2026   +155     
- Misses      235    245    +10     
- Partials     93    104    +11     
Flag Coverage Δ
unittests 85% <87%> (+<1%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/ImageSharp.Web/Middleware/ImageContext.cs 80% <ø> (ø)
...rc/ImageSharp.Web/RequestAuthorizationUtilities.cs 86% <50%> (ø)
src/ImageSharp.Web/CaseHandlingUriBuilder.cs 88% <71%> (ø)
...rc/ImageSharp.Web/TagHelpers/HmacTokenTagHelper.cs 74% <74%> (ø)
src/ImageSharp.Web/TagHelpers/ImageTagHelper.cs 91% <91%> (ø)
...DependencyInjection/ServiceCollectionExtensions.cs 100% <100%> (ø)
src/ImageSharp.Web/Format.cs 100% <100%> (ø)
src/ImageSharp.Web/FormatCommand.cs 100% <100%> (ø)
src/ImageSharp.Web/HMACUtilities.cs 86% <100%> (ø)
.../ImageSharp.Web/Middleware/ImageSharpMiddleware.cs 81% <100%> (-1%) :arrow_down:
... and 2 more

... and 1 file with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more