-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
95 lines (76 loc) · 2.79 KB
/
Program.cs
File metadata and controls
95 lines (76 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using Microsoft.EntityFrameworkCore;
using Piranha;
using Piranha.AspNetCore.Identity.SQLite;
using Piranha.AttributeBuilder;
using Piranha.Data.EF.SQLite;
using Piranha.Local;
using Piranha.Manager.Editor;
using TAU.Website;
using TAU.Website.Data;
using TAU.Website.Models;
using TAU.Website.Models.Custom_Blocks;
using TAU.Website.Services;
var builder = WebApplication.CreateBuilder(args);
var connectionString = builder.Configuration.GetConnectionString("piranha");
builder.AddPiranha(options =>
{
/**
* This will enable automatic reload of .cshtml
* without restarting the application. However since
* this adds a slight overhead it should not be
* enabled in production.
*/
options.AddRazorRuntimeCompilation = true;
options.UseCms();
options.UseManager();
options.UseFileStorage(naming: FileStorageNaming.UniqueFolderNames);
options.UseImageSharp();
options.UseTinyMCE();
options.UseMemoryCache();
options.UseEF<SQLiteDb>(db => db.UseSqlite(connectionString));
options.UseIdentityWithSeed<IdentitySQLiteDb>(db => db.UseSqlite(connectionString));
/**
* 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");
});
*/
/**
* Here you can specify the login url for the front end
* application. This does not affect the login url of
* the manager interface.
options.LoginUrl = "login";
*/
});
builder.Services.Configure<GoogleReCaptchaConfig>(builder.Configuration.GetSection("GoogleReCaptcha"));
builder.Services.AddTransient(typeof(GoogleReCaptchaService));
builder.Services.AddTransient<INewsletterService, NewsletterService>();
builder.Services.AddTransient<IWhitePaperService, WhitePaperService>();
builder.Services.AddDbContext<TauDbContext>(options => options.UseSqlite(connectionString));
builder.Services.AddAutoMapper(typeof(Program));
builder.Services.AddControllersWithViews();
var app = builder.Build();
if (app.Environment.IsDevelopment()) app.UseDeveloperExceptionPage();
app.UsePiranha(options =>
{
// Initialize Piranha
App.Init(options.Api);
// Register custom components
App.Blocks.Register<NewsPaperBlock>();
App.Blocks.Register<WhitePaperBlock>();
App.Modules.Manager().Scripts.Add("~/whitePaper-block.js");
// Build content types
new ContentTypeBuilder(options.Api)
.AddAssembly(typeof(Program).Assembly)
.Build()
.DeleteOrphans();
// Configure Tiny MCE
EditorConfig.FromFile("editorconfig.json");
options.UseManager();
options.UseTinyMCE();
options.UseIdentity();
});
app.Run();