initial commit

This commit is contained in:
Kukks
2023-01-16 10:31:48 +01:00
parent 136273406c
commit 25ccd99558
171 changed files with 10592 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
namespace BTCPayServer.Plugins.RockstarStylist
{
public class RockstarStyleProvider
{
private HttpClient _githubClient;
public RockstarStyleProvider(IHttpClientFactory httpClientFactory)
{
_githubClient = httpClientFactory.CreateClient();
_githubClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("btcpayserver", "1"));
}
public async Task<RockstarStyle[]> Get()
{
var response = JArray.Parse(await _githubClient.GetStringAsync("https://api.github.com/repos/btcpayserver/BTCPayThemes/contents"));
return response.Where(token => token.Value<string>("type") == "dir").Select(token => new RockstarStyle()
{
StyleName = token.Value<string>("name"),
CssUrl = $"https://btcpayserver.github.io/BTCPayThemes/{token.Value<string>("name")}/btcpay-checkout.custom.css",
PreviewUrl = $"https://btcpayserver.github.io/BTCPayThemes/{token.Value<string>("name")}"
}).ToArray();
}
}
public class RockstarStyle
{
public string StyleName { get; set; }
public string CssUrl { get; set; }
public string PreviewUrl { get; set; }
}
}