diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..3dd49fd
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "btcpayserver"]
+ path = btcpayserver
+ url = https://github.com/btcpayserver/btcpayserver
diff --git a/BTCPay.Plugins.Template/BTCPayServer.Plugins.Template.csproj b/BTCPay.Plugins.Template/BTCPayServer.Plugins.Template.csproj
new file mode 100644
index 0000000..efd2d86
--- /dev/null
+++ b/BTCPay.Plugins.Template/BTCPayServer.Plugins.Template.csproj
@@ -0,0 +1,35 @@
+
+
+ net6.0
+ 10
+
+
+
+
+ BTCPay Server Plugin Template
+ A template for your own BTCPay Server plugin.
+ BTCPay Server
+ 1.0.0
+
+
+
+
+ true
+ false
+ true
+
+
+
+
+
+ StaticWebAssetsEnabled=false
+ false
+ runtime;native;build;buildTransitive;contentFiles
+
+
+
+
+
+
+
+
diff --git a/Controllers/UIPluginController.cs b/BTCPay.Plugins.Template/Controllers/UIPluginController.cs
similarity index 87%
rename from Controllers/UIPluginController.cs
rename to BTCPay.Plugins.Template/Controllers/UIPluginController.cs
index 4a279d9..8ef926f 100644
--- a/Controllers/UIPluginController.cs
+++ b/BTCPay.Plugins.Template/Controllers/UIPluginController.cs
@@ -13,9 +13,9 @@ namespace BTCPayServer.Plugins.Template;
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Cookie, Policy = Policies.CanViewProfile)]
public class UIPluginController : Controller
{
- private readonly PluginService _PluginService;
+ private readonly MyPluginService _PluginService;
- public UIPluginController(PluginService PluginService)
+ public UIPluginController(MyPluginService PluginService)
{
_PluginService = PluginService;
}
diff --git a/Data/PluginDbContext.cs b/BTCPay.Plugins.Template/Data/MyPluginDbContext.cs
similarity index 93%
rename from Data/PluginDbContext.cs
rename to BTCPay.Plugins.Template/Data/MyPluginDbContext.cs
index dd34314..7dc0b1f 100644
--- a/Data/PluginDbContext.cs
+++ b/BTCPay.Plugins.Template/Data/MyPluginDbContext.cs
@@ -9,11 +9,11 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace BTCPayServer.Plugins.Template;
-public class PluginDbContext : DbContext
+public class MyPluginDbContext : DbContext
{
private readonly bool _designTime;
- public PluginDbContext(DbContextOptions options, bool designTime = false)
+ public MyPluginDbContext(DbContextOptions options, bool designTime = false)
: base(options)
{
_designTime = designTime;
diff --git a/Data/PluginData.cs b/BTCPay.Plugins.Template/Data/PluginData.cs
similarity index 100%
rename from Data/PluginData.cs
rename to BTCPay.Plugins.Template/Data/PluginData.cs
diff --git a/Migrations/20201117154419_Init.cs b/BTCPay.Plugins.Template/Migrations/20201117154419_Init.cs
similarity index 96%
rename from Migrations/20201117154419_Init.cs
rename to BTCPay.Plugins.Template/Migrations/20201117154419_Init.cs
index f223784..83950bf 100644
--- a/Migrations/20201117154419_Init.cs
+++ b/BTCPay.Plugins.Template/Migrations/20201117154419_Init.cs
@@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace BTCPayServer.Plugins.Template.Migrations
{
- [DbContext(typeof(PluginDbContext))]
+ [DbContext(typeof(MyPluginDbContext))]
[Migration("20201117154419_Init")]
public partial class Init : Migration
{
diff --git a/Migrations/PluginDbContextModelSnapshot.cs b/BTCPay.Plugins.Template/Migrations/MyPluginDbContextModelSnapshot.cs
similarity index 90%
rename from Migrations/PluginDbContextModelSnapshot.cs
rename to BTCPay.Plugins.Template/Migrations/MyPluginDbContextModelSnapshot.cs
index b325dcf..0c6a2a1 100644
--- a/Migrations/PluginDbContextModelSnapshot.cs
+++ b/BTCPay.Plugins.Template/Migrations/MyPluginDbContextModelSnapshot.cs
@@ -7,8 +7,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace BTCPayServer.Plugins.Template.Migrations
{
- [DbContext(typeof(PluginDbContext))]
- partial class PluginDbContextModelSnapshot : ModelSnapshot
+ [DbContext(typeof(MyPluginDbContext))]
+ partial class MyPluginDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
diff --git a/Plugin.cs b/BTCPay.Plugins.Template/Plugin.cs
similarity index 57%
rename from Plugin.cs
rename to BTCPay.Plugins.Template/Plugin.cs
index 2841f90..9f9dd22 100644
--- a/Plugin.cs
+++ b/BTCPay.Plugins.Template/Plugin.cs
@@ -8,20 +8,21 @@ namespace BTCPayServer.Plugins.Template;
public class Plugin : BaseBTCPayServerPlugin
{
- public override string Identifier { get; } = "BTCPayServer.Plugins.Template";
- public override string Name { get; } = "Plugin Template";
- public override string Description { get; } = "This is the plugin description";
+ public override IBTCPayServerPlugin.PluginDependency[] Dependencies { get; } = new[]
+ {
+ new IBTCPayServerPlugin.PluginDependency { Identifier = nameof(BTCPayServer), Condition = ">=1.7.4" }
+ };
public override void Execute(IServiceCollection services)
{
services.AddSingleton(new UIExtension("TemplatePluginHeaderNav", "header-nav"));
services.AddHostedService();
services.AddHostedService();
- services.AddSingleton();
- services.AddSingleton();
- services.AddDbContext((provider, o) =>
+ services.AddSingleton();
+ services.AddSingleton();
+ services.AddDbContext((provider, o) =>
{
- PluginDbContextFactory factory = provider.GetRequiredService();
+ MyPluginDbContextFactory factory = provider.GetRequiredService();
factory.ConfigureBuilder(o);
});
}
diff --git a/PluginMigrationRunner.cs b/BTCPay.Plugins.Template/PluginMigrationRunner.cs
similarity index 78%
rename from PluginMigrationRunner.cs
rename to BTCPay.Plugins.Template/PluginMigrationRunner.cs
index 4b2d7fd..de4424b 100644
--- a/PluginMigrationRunner.cs
+++ b/BTCPay.Plugins.Template/PluginMigrationRunner.cs
@@ -9,15 +9,17 @@ namespace BTCPayServer.Plugins.Template;
public class PluginMigrationRunner : IHostedService
{
- private readonly PluginDbContextFactory _PluginDbContextFactory;
- private readonly PluginService _PluginService;
+ private readonly MyPluginDbContextFactory _PluginDbContextFactory;
+ private readonly MyPluginService _PluginService;
private readonly ISettingsRepository _settingsRepository;
- public PluginMigrationRunner(PluginDbContextFactory PluginDbContextFactory, ISettingsRepository settingsRepository,
- PluginService PluginService)
+ public PluginMigrationRunner(
+ ISettingsRepository settingsRepository,
+ MyPluginDbContextFactory PluginDbContextFactory,
+ MyPluginService PluginService)
{
- _PluginDbContextFactory = PluginDbContextFactory;
_settingsRepository = settingsRepository;
+ _PluginDbContextFactory = PluginDbContextFactory;
_PluginService = PluginService;
}
@@ -25,16 +27,16 @@ public class PluginMigrationRunner : IHostedService
{
PluginDataMigrationHistory settings = await _settingsRepository.GetSettingAsync() ??
new PluginDataMigrationHistory();
- await using PluginDbContext ctx = _PluginDbContextFactory.CreateContext();
+ await using var ctx = _PluginDbContextFactory.CreateContext();
await ctx.Database.MigrateAsync(cancellationToken);
-
+
// settings migrations
if (!settings.UpdatedSomething)
{
settings.UpdatedSomething = true;
await _settingsRepository.UpdateSetting(settings);
}
-
+
// test record
await _PluginService.AddTestDataRecord();
}
diff --git a/Resources/img/screengrab.png b/BTCPay.Plugins.Template/Resources/img/screengrab.png
similarity index 100%
rename from Resources/img/screengrab.png
rename to BTCPay.Plugins.Template/Resources/img/screengrab.png
diff --git a/Services/ApplicationPartsLogger.cs b/BTCPay.Plugins.Template/Services/ApplicationPartsLogger.cs
similarity index 100%
rename from Services/ApplicationPartsLogger.cs
rename to BTCPay.Plugins.Template/Services/ApplicationPartsLogger.cs
diff --git a/BTCPay.Plugins.Template/Services/MyPluginDbContextFactory.cs b/BTCPay.Plugins.Template/Services/MyPluginDbContextFactory.cs
new file mode 100644
index 0000000..8059b55
--- /dev/null
+++ b/BTCPay.Plugins.Template/Services/MyPluginDbContextFactory.cs
@@ -0,0 +1,33 @@
+using BTCPayServer.Abstractions.Contracts;
+using BTCPayServer.Abstractions.Models;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Design;
+using Microsoft.Extensions.Options;
+
+namespace BTCPayServer.Plugins.Template;
+
+public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory
+{
+ public MyPluginDbContext CreateDbContext(string[] args)
+ {
+ DbContextOptionsBuilder builder = new DbContextOptionsBuilder();
+
+ builder.UseSqlite("Data Source=temp.db");
+
+ return new MyPluginDbContext(builder.Options, true);
+ }
+}
+
+public class MyPluginDbContextFactory : BaseDbContextFactory
+{
+ public MyPluginDbContextFactory(IOptions options) : base(options, "BTCPayServer.Plugins.Template")
+ {
+ }
+
+ public override MyPluginDbContext CreateContext()
+ {
+ DbContextOptionsBuilder builder = new DbContextOptionsBuilder();
+ ConfigureBuilder(builder);
+ return new MyPluginDbContext(builder.Options);
+ }
+}
diff --git a/Services/PluginService.cs b/BTCPay.Plugins.Template/Services/MyPluginService.cs
similarity index 63%
rename from Services/PluginService.cs
rename to BTCPay.Plugins.Template/Services/MyPluginService.cs
index 991d8ad..401b43f 100644
--- a/Services/PluginService.cs
+++ b/BTCPay.Plugins.Template/Services/MyPluginService.cs
@@ -6,18 +6,18 @@ using Microsoft.EntityFrameworkCore;
namespace BTCPayServer.Plugins.Template.Services;
-public class PluginService
+public class MyPluginService
{
- private readonly PluginDbContextFactory _PluginDbContextFactory;
+ private readonly MyPluginDbContextFactory _PluginDbContextFactory;
- public PluginService(PluginDbContextFactory PluginDbContextFactory)
+ public MyPluginService(MyPluginDbContextFactory PluginDbContextFactory)
{
_PluginDbContextFactory = PluginDbContextFactory;
}
public async Task AddTestDataRecord()
{
- await using PluginDbContext context = _PluginDbContextFactory.CreateContext();
+ await using var context = _PluginDbContextFactory.CreateContext();
await context.PluginRecords.AddAsync(new PluginData { Timestamp = DateTimeOffset.UtcNow });
await context.SaveChangesAsync();
@@ -25,7 +25,7 @@ public class PluginService
public async Task> Get()
{
- await using PluginDbContext context = _PluginDbContextFactory.CreateContext();
+ await using var context = _PluginDbContextFactory.CreateContext();
return await context.PluginRecords.ToListAsync();
}
diff --git a/Views/PluginNavPages.cs b/BTCPay.Plugins.Template/Views/PluginNavPages.cs
similarity index 100%
rename from Views/PluginNavPages.cs
rename to BTCPay.Plugins.Template/Views/PluginNavPages.cs
diff --git a/Views/Shared/TemplatePluginHeaderNav.cshtml b/BTCPay.Plugins.Template/Views/Shared/TemplatePluginHeaderNav.cshtml
similarity index 100%
rename from Views/Shared/TemplatePluginHeaderNav.cshtml
rename to BTCPay.Plugins.Template/Views/Shared/TemplatePluginHeaderNav.cshtml
diff --git a/Views/UIPlugin/Index.cshtml b/BTCPay.Plugins.Template/Views/UIPlugin/Index.cshtml
similarity index 100%
rename from Views/UIPlugin/Index.cshtml
rename to BTCPay.Plugins.Template/Views/UIPlugin/Index.cshtml
diff --git a/Views/_ViewImports.cshtml b/BTCPay.Plugins.Template/Views/_ViewImports.cshtml
similarity index 100%
rename from Views/_ViewImports.cshtml
rename to BTCPay.Plugins.Template/Views/_ViewImports.cshtml
diff --git a/BTCPayServer.Plugins.Template.csproj b/BTCPayServer.Plugins.Template.csproj
deleted file mode 100644
index 32e5fb9..0000000
--- a/BTCPayServer.Plugins.Template.csproj
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
- net6.0
- true
- false
- true
- 1.0.0
-
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
diff --git a/LICENSE b/LICENSE
index d03fbac..b2bef0f 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2017-2023 btcpayserver
+Copyright (c) 2023 BTCPay Server
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/Services/PluginDbContextFactory.cs b/Services/PluginDbContextFactory.cs
deleted file mode 100644
index 7414a0e..0000000
--- a/Services/PluginDbContextFactory.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using BTCPayServer.Abstractions.Contracts;
-using BTCPayServer.Abstractions.Models;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Design;
-using Microsoft.Extensions.Options;
-
-namespace BTCPayServer.Plugins.Template;
-
-public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory
-{
- public PluginDbContext CreateDbContext(string[] args)
- {
- DbContextOptionsBuilder builder = new DbContextOptionsBuilder();
-
- builder.UseSqlite("Data Source=temp.db");
-
- return new PluginDbContext(builder.Options, true);
- }
-}
-
-public class PluginDbContextFactory : BaseDbContextFactory
-{
- public PluginDbContextFactory(IOptions options) : base(options, "BTCPayServer.Plugins.Template")
- {
- }
-
- public override PluginDbContext CreateContext()
- {
- DbContextOptionsBuilder builder = new DbContextOptionsBuilder();
- ConfigureBuilder(builder);
- return new PluginDbContext(builder.Options);
- }
-}
diff --git a/btcpayserver b/btcpayserver
new file mode 160000
index 0000000..5089ec9
--- /dev/null
+++ b/btcpayserver
@@ -0,0 +1 @@
+Subproject commit 5089ec98262a05ffb955d918828e53de93e0894b