diff --git a/FastBlog.sln b/FastBlog.sln index 99e5211..30342a8 100644 --- a/FastBlog.sln +++ b/FastBlog.sln @@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugin1", "plugins\Plugin1\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugin2", "plugins\Plugin2\Plugin2.csproj", "{743460B8-3E15-41E9-A3DE-E6789AF682B5}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InventoryContact", "plugins\InventoryContact\InventoryContact.csproj", "{8FC78017-9E2F-44EC-AC76-84EAE3799BEA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -40,11 +42,16 @@ Global {743460B8-3E15-41E9-A3DE-E6789AF682B5}.Debug|Any CPU.Build.0 = Debug|Any CPU {743460B8-3E15-41E9-A3DE-E6789AF682B5}.Release|Any CPU.ActiveCfg = Release|Any CPU {743460B8-3E15-41E9-A3DE-E6789AF682B5}.Release|Any CPU.Build.0 = Release|Any CPU + {8FC78017-9E2F-44EC-AC76-84EAE3799BEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8FC78017-9E2F-44EC-AC76-84EAE3799BEA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8FC78017-9E2F-44EC-AC76-84EAE3799BEA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8FC78017-9E2F-44EC-AC76-84EAE3799BEA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {C9A19395-1E93-488F-AD10-2C7D2DB78EB0} = {D7A1C18D-CC03-4704-B5B7-2F8B1A04E279} {B8CDA182-8097-4EF5-8EE2-CB73AF4B58AC} = {D7A1C18D-CC03-4704-B5B7-2F8B1A04E279} {79DEDFD2-BEE7-48C1-B6D5-89A6C9A3EC05} = {5036CE06-EB58-41ED-9A0B-58372A72BEC7} {743460B8-3E15-41E9-A3DE-E6789AF682B5} = {5036CE06-EB58-41ED-9A0B-58372A72BEC7} + {8FC78017-9E2F-44EC-AC76-84EAE3799BEA} = {5036CE06-EB58-41ED-9A0B-58372A72BEC7} EndGlobalSection EndGlobal diff --git a/plugins/InventoryContact/Controllers/ContactsController.cs b/plugins/InventoryContact/Controllers/ContactsController.cs new file mode 100644 index 0000000..9c12cb0 --- /dev/null +++ b/plugins/InventoryContact/Controllers/ContactsController.cs @@ -0,0 +1,16 @@ + +using Microsoft.AspNetCore.Mvc; + +namespace InventoryContact.Controllers; + +[Route("c")] +public class ContactsController : Controller +{ + + [HttpGet] + [Route("{shortcode}")] + public IActionResult Index(string shortcode) + { + return new OkResult(); + } +} \ No newline at end of file diff --git a/plugins/InventoryContact/Db/Migrations/202504240143_InventoryContact_Init.cs b/plugins/InventoryContact/Db/Migrations/202504240143_InventoryContact_Init.cs new file mode 100644 index 0000000..98d8bee --- /dev/null +++ b/plugins/InventoryContact/Db/Migrations/202504240143_InventoryContact_Init.cs @@ -0,0 +1,29 @@ +using FluentMigrator; + +namespace InventoryContact.Db.Migrations; + +[Migration(202504240143, "Init direct contact plugin")] +public class DirectContact_Init : Migration +{ + public override void Up() + { + Create.Table("DcContactMeta") + .WithColumn("Id").AsInt32().PrimaryKey().Identity() + .WithColumn("Slug").AsString(32).Indexed("IX_DcContactMeta_Slug").Unique() + .WithColumn("SourceLocation").AsString() + .WithColumn("MessageItemName").AsString() + .WithColumn("CreatedAt").AsDateTime().WithDefault(SystemMethods.CurrentUTCDateTime); + + Create.Table("DcMessageLogs") + .WithColumn("Id").AsInt32().PrimaryKey().Identity() + .WithColumn("ContactMetaId").AsInt32().ForeignKey("DcContactMeta", "Id") + .WithColumn("DisplayName").AsString(32).Nullable() + .WithColumn("Text").AsString(512) + .WithColumn("ContactInformation").AsString(64).Nullable() + .WithColumn("CreatedAt").AsDateTime().WithDefault(SystemMethods.CurrentUTCDateTime); + } + + public override void Down() + { + } +} \ No newline at end of file diff --git a/plugins/InventoryContact/DirectContactPlugin.cs b/plugins/InventoryContact/DirectContactPlugin.cs new file mode 100644 index 0000000..7a47ee5 --- /dev/null +++ b/plugins/InventoryContact/DirectContactPlugin.cs @@ -0,0 +1,28 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using RainCrab.Plugins.AspNet; + +namespace InventoryContact; + +public class DirectContactPlugin : IWebPlugin +{ + public Task ConfigureAsync(WebPluginLoadContext loadContext) + { + var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); + if (environment is null) + { + throw new ApplicationException("ASPNETCORE_ENVIRONMENT is not defined"); + } + + loadContext.ApplicationBuilder.Configuration.AddJsonFile("Plugins/InventoryContact/pluginsettings.json"); + loadContext.ApplicationBuilder.Configuration.AddJsonFile($"Plugins/InventoryContact/pluginsettings.{environment}.json", true); + loadContext.ApplicationBuilder.Services.AddControllersWithViews() + .AddApplicationPart(typeof(DirectContactPlugin).Assembly); + return Task.CompletedTask; + } + + public Task ShutdownAsync(WebPluginLoadContext loadContext) + { + return Task.CompletedTask; + } +} \ No newline at end of file diff --git a/plugins/InventoryContact/InventoryContact.csproj b/plugins/InventoryContact/InventoryContact.csproj new file mode 100644 index 0000000..bc6b48b --- /dev/null +++ b/plugins/InventoryContact/InventoryContact.csproj @@ -0,0 +1,37 @@ + + + + net8.0 + enable + enable + true + true + true + 0.1.0 + + + + + runtime + + + + + + runtime + + + runtime + + + + + + + + + + + + + diff --git a/plugins/InventoryContact/InventoryContact.runtimeconfig.template.json b/plugins/InventoryContact/InventoryContact.runtimeconfig.template.json new file mode 100644 index 0000000..2a7fedf --- /dev/null +++ b/plugins/InventoryContact/InventoryContact.runtimeconfig.template.json @@ -0,0 +1,7 @@ +{ + "runtimeOptions": { + "additionalProbingPaths": [ + "../." + ] + } +} \ No newline at end of file diff --git a/plugins/InventoryContact/Views/Contacts/ContactPage.cshtml b/plugins/InventoryContact/Views/Contacts/ContactPage.cshtml new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/plugins/InventoryContact/Views/Contacts/ContactPage.cshtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/plugins/InventoryContact/inventoryContact.manifest.json b/plugins/InventoryContact/inventoryContact.manifest.json new file mode 100644 index 0000000..57a6eeb --- /dev/null +++ b/plugins/InventoryContact/inventoryContact.manifest.json @@ -0,0 +1,6 @@ +{ + "Id": "inventory-contact", + "Version": "0.1.0", + "Assembly": "InventoryContact.dll", + "Name": "InventoryContact" +} \ No newline at end of file diff --git a/src/FastBlog.Web/Controllers/BlogsController.cs b/src/FastBlog.Web/Controllers/BlogsController.cs index 761835c..6ad7717 100644 --- a/src/FastBlog.Web/Controllers/BlogsController.cs +++ b/src/FastBlog.Web/Controllers/BlogsController.cs @@ -76,7 +76,7 @@ public class BlogsController(BlogService service) : Controller [SimpleAuth] [HttpGet] [Route("edit/{id:int?}")] - public async ValueTask Edit(int? id) + public async ValueTask Edit(int? id, [FromQuery(Name = "fw")] bool fullWidth = false) { if (!id.HasValue) { @@ -92,7 +92,8 @@ public class BlogsController(BlogService service) : Controller FullWidth = false, ShowDetails = true, Slug = "blog-" + date.ToString("yyyy-MM-dd-HH-mm"), - Visible = false + Visible = false, + FullWidthEditor = fullWidth } ); } @@ -140,6 +141,7 @@ public class BlogsController(BlogService service) : Controller FullWidth = editBlog.FullWidthStr is not null, Visible = editBlog.VisibleStr is not null, SourceLocation = editBlog.SourceLocation + } }); @@ -175,7 +177,7 @@ public class BlogsController(BlogService service) : Controller Signature = editBlog.Signature, FullWidth = editBlog.FullWidthStr is not null, Visible = editBlog.VisibleStr is not null, - SourceLocation = editBlog.SourceLocation + SourceLocation = editBlog.SourceLocation, } }); } diff --git a/src/FastBlog.Web/Models/EditBlog.cs b/src/FastBlog.Web/Models/EditBlog.cs index 7b7603c..28edba8 100644 --- a/src/FastBlog.Web/Models/EditBlog.cs +++ b/src/FastBlog.Web/Models/EditBlog.cs @@ -19,4 +19,5 @@ public sealed class EditBlog public string? FullWidthStr { get; init; } public bool Visible { get; init; } public string? VisibleStr { get; init; } + public bool FullWidthEditor { get; init; } = false; } \ No newline at end of file diff --git a/src/FastBlog.Web/Views/Blogs/Edit.cshtml b/src/FastBlog.Web/Views/Blogs/Edit.cshtml index ee40214..8e38328 100644 --- a/src/FastBlog.Web/Views/Blogs/Edit.cshtml +++ b/src/FastBlog.Web/Views/Blogs/Edit.cshtml @@ -1,13 +1,14 @@ -@model EditBlog +@using FastBlog.Web.Helpers +@model EditBlog @{ ViewData["Title"] = "Edit Blog"; + string selfLink = Model.Id.HasValue ? "/blogs/edit/" + Model.Id : "/blogs/edit"; } - - + @if (Model.Id is null) { @@ -17,6 +18,17 @@ { Edit "@Model.Title" } + + + @if (Model.FullWidthEditor) + { + Split View + } + else + { + Full width + } +