mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 22:44:29 +01:00
* Move TagHelpers to Abstractions Makes them available for use in plugins. Also cleans up the tag helper references in the view code: As we have it in the root view imports, the individual directives in the views are superfluous. * Move CurrenciesSuggestionsTagHelper back To get rid of the Rating dependency in Abstractions.
26 lines
1.0 KiB
C#
26 lines
1.0 KiB
C#
using System.Text.Encodings.Web;
|
|
using Microsoft.AspNetCore.Mvc.Razor.TagHelpers;
|
|
using Microsoft.AspNetCore.Mvc.Routing;
|
|
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
|
using Microsoft.AspNetCore.Razor.TagHelpers;
|
|
|
|
namespace BTCPayServer.Abstractions.TagHelpers;
|
|
|
|
// Make sure that <svg><use href=/ are correctly working if rootpath is present
|
|
[HtmlTargetElement("use", Attributes = "href")]
|
|
public class SVGUse : UrlResolutionTagHelper
|
|
{
|
|
private readonly IFileVersionProvider _fileVersionProvider;
|
|
|
|
public SVGUse(IUrlHelperFactory urlHelperFactory, HtmlEncoder htmlEncoder, IFileVersionProvider fileVersionProvider) : base(urlHelperFactory, htmlEncoder)
|
|
{
|
|
_fileVersionProvider = fileVersionProvider;
|
|
}
|
|
public override void Process(TagHelperContext context, TagHelperOutput output)
|
|
{
|
|
var attr = output.Attributes["href"].Value.ToString();
|
|
attr = _fileVersionProvider.AddFileVersionToPath(ViewContext.HttpContext.Request.PathBase, attr);
|
|
output.Attributes.SetAttribute("href", attr);
|
|
}
|
|
}
|