Created
April 9, 2021 16:32
-
-
Save srakowski/0db55540e4a5d1f374c147ab82859394 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.EntityFrameworkCore; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.Hosting; | |
using Piranha; | |
using Piranha.AttributeBuilder; | |
using Piranha.AspNetCore.Identity.SQLite; | |
using Piranha.Data.EF.SQLite; | |
using Piranha.Manager.Editor; | |
using OrchardCore.Environment.Shell.Configuration; | |
using OrchardCore.Environment.Shell; | |
using OrchardCore.Modules; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.Routing; | |
using System; | |
using Microsoft.Extensions.FileProviders; | |
using System.IO; | |
using System.Reflection; | |
using System.Runtime.Loader; | |
namespace MultiCms.TenantSite | |
{ | |
public class Startup : OrchardCore.Modules.StartupBase | |
{ | |
private readonly string _tenant; | |
private readonly IShellConfiguration _configuration; | |
public Startup(ShellSettings shellSettings, IShellConfiguration configuration) | |
{ | |
_tenant = shellSettings.Name; | |
_configuration = configuration; | |
} | |
public override void ConfigureServices(IServiceCollection services) | |
{ | |
//services.AddMvc() | |
// .AddApplicationPart(typeof(Piranha.Api).Assembly) | |
// .AddApplicationPart(typeof(Piranha.Web.PostRouter).Assembly) | |
// .AddApplicationPart(typeof(Piranha.Manager.Module).Assembly); | |
services.AddPiranha(options => | |
{ | |
options.AddRazorRuntimeCompilation = true; | |
options.UseSiteRouting = false; | |
options.UseFileStorage(naming: Piranha.Local.FileStorageNaming.UniqueFolderNames); | |
options.UseImageSharp(); | |
options.UseManager(); | |
options.UseTinyMCE(); | |
options.UseMemoryCache(); | |
options.UseEF<SQLiteDb>(db => | |
db.UseSqlite($"Filename=./App_Data/Sites/{_tenant}/{_tenant}.db")); | |
options.UseIdentityWithSeed<IdentitySQLiteDb>(db => | |
db.UseSqlite($"Filename=./App_Data/Sites/{_tenant}/{_tenant}.db")); | |
/*** | |
* Here you can configure the different permissions | |
* that you want to use for securing content in the | |
* application. | |
options.UseSecurity(o => | |
{ | |
o.UsePermission("WebUser", "Web User"); | |
}); | |
*/ | |
}); | |
services.AddMvc(s => | |
{ | |
s.EnableEndpointRouting = false; | |
}); | |
} | |
public override void Configure(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider) | |
{ | |
var api = serviceProvider.GetService<IApi>(); | |
// Initialize Piranha | |
App.Init(api); | |
// Build content types | |
new ContentTypeBuilder(api) | |
.AddAssembly(typeof(Startup).Assembly) | |
.Build() | |
.DeleteOrphans(); | |
// Configure Tiny MCE | |
EditorConfig.FromFile("editorconfig.json"); | |
// Middleware setup | |
app.UsePiranha(options => | |
{ | |
options.UseManager(); | |
options.UseTinyMCE(); | |
options.UseIdentity(); | |
}); | |
app.UseMvc(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment