Skip to content

Commit ebad9e3

Browse files
committed
bump to YAF 4.0.1
1 parent f5fa4b2 commit ebad9e3

13 files changed

Lines changed: 146 additions & 288 deletions

File tree

YAF.Website/Areas/Forums/Pages/Shared/_Layout.cshtml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@using Microsoft.AspNetCore.Http
22
@using YAF.Configuration
3-
@using YAF.Core.Services
43
@using YAF.Core.Context
54
@using YAF.Web.HtmlHelpers
65
@using YAF.Types.Interfaces
@@ -15,17 +14,8 @@
1514
@inject BoardContext Current
1615

1716
@{
18-
ViewBag.CdvVersion = Current.BoardSettings.CdvVersion;
19-
20-
#if DEBUG
21-
ViewBag.ForumJs = Current.CurrentForumPage.IsAdminPage ? "forumAdminExtensions" : "forumExtensions";
22-
ViewBag.ForumCss = Current.CurrentForumPage.IsAdminPage ? "forum-admin" : "forum";
23-
#else
24-
ViewBag.ForumJs = Current.CurrentForumPage.IsAdminPage ? "forumAdminExtensions.min" : "forumExtensions.min";
25-
ViewBag.ForumCss = Current.CurrentForumPage.IsAdminPage ? "forum-admin.min" : "forum.min";
26-
#endif
27-
28-
ViewBag.PageName = Current.CurrentForumPage.PageName.ToString();
17+
ViewBag.ForumCss = Current.CurrentForumPage.IsAdminPage ? "forum-admin.min" : "forum.min";
18+
ViewBag.PageName = Current.CurrentForumPage.PageName.ToString();
2919
}
3020

3121
<!DOCTYPE html>
@@ -285,7 +275,7 @@
285275
</footer>
286276
</main>
287277

288-
<script src="@(Current.Get<BoardInfo>().GetUrlToScripts($"{ViewBag.ForumJs}.js?v={ViewBag.CdvVersion}"))"></script>
278+
<script src="~/js/forumExtensions.min.js" asp-append-version="true"></script>
289279

290280

291281
@await RenderSectionAsync("Scripts", required: false)

YAF.Website/Areas/Forums/Pages/Shared/_LoginBox.cshtml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -81,36 +81,6 @@
8181
text-localized-tag="FORUM_LOGIN"></button>
8282
</div>
8383
</form>
84-
@if (Current.BoardSettings.AllowSingleSignOn)
85-
{
86-
<section>
87-
<form asp-controller="LoginBox" asp-action="Auth">
88-
<div class="d-grid gap-2">
89-
@{
90-
var loginProviders = (await SignInManager.GetExternalAuthenticationSchemesAsync()).ToList();
91-
if (loginProviders.HasItems())
92-
{
93-
@foreach (var provider in loginProviders)
94-
{
95-
<button type="submit"
96-
asp-route-auth="@provider.Name"
97-
button-style="None"
98-
button-size="Small"
99-
class="@Html.Raw($"btn btn-social btn-{provider.Name} me-1 mb-1")"
100-
icon="@provider.Name"
101-
icon-css-class="fab"
102-
text-localized-tag="AUTH_CONNECT"
103-
title-localized-tag="AUTH_CONNECT"
104-
text-param0="@provider.DisplayName"
105-
title-param0="@provider.DisplayName">
106-
</button>
107-
}
108-
}
109-
}
110-
</div>
111-
</form>
112-
</section>
113-
}
11484
</div>
11585
</div>
11686

YAF.Website/Pages/Downloads.cshtml.cs

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -307,37 +307,46 @@ public async Task OnGetAsync()
307307
{
308308
var githubClient = new GitHubClient(new ProductHeaderValue("YAF.NET"));
309309

310-
await this.GetDnnReleasesAsync(githubClient);
310+
var releases = new List<Release>();
311+
var sampleAppReleases = new List<Release>();
312+
313+
if (this.Get<IDataCache>().Get("ReleaseNetCore") == null)
314+
{
315+
releases = [.. await githubClient.Repository.Release.GetAll("YAFNET", "YAFNET")];
316+
}
317+
318+
if (this.Get<IDataCache>().Get("SampleApplicationRelease") == null)
319+
{
320+
sampleAppReleases = [.. await githubClient.Repository.Release.GetAll("YAFNET", "YAF.SampleWebApplication")];
321+
}
311322

312-
var sampleAppReleases = await githubClient.Repository.Release.GetAll("YAFNET", "YAF.SampleWebApplication");
323+
await this.GetDnnReleasesAsync(githubClient);
313324

314325
await this.GetSampleApplicationReleasesAsync(sampleAppReleases);
315326

316327
await this.GetSampleAppReleasesAsync(sampleAppReleases);
317328

318-
await this.GetMySqlReleasesAsync(githubClient);
329+
this.GetNetCoreReleases(releases);
319330

320-
await this.GetMsSqlReleasesAsync(githubClient);
331+
this.GetMySqlReleases(releases);
321332

322-
await this.GetSqliteReleasesAsync(githubClient);
333+
this.GetMsSqlReleases(releases);
323334

324-
await this.GetPostgreSqlReleasesAsync(githubClient);
335+
this.GetSqliteReleases(releases);
325336

326-
await this.GetNetCoreReleasesAsync(githubClient);
337+
this.GetPostgreSqlReleases(releases);
327338
}
328339

329340
/// <summary>
330341
/// Gets the net core releases.
331342
/// </summary>
332-
/// <param name="githubClient"></param>
333-
private async Task GetNetCoreReleasesAsync(GitHubClient githubClient)
343+
/// <param name="releases">All yaf releases</param>
344+
private void GetNetCoreReleases(List<Release> releases)
334345
{
335346
Release release;
336347

337348
if (this.Get<IDataCache>().Get("ReleaseNetCore") == null)
338349
{
339-
var releases = await githubClient.Repository.Release.GetAll("YAFNET", "YAFNET");
340-
341350
release = releases.First(r => r.TagName.StartsWith("v4") && !r.Prerelease);
342351

343352
this.Get<IDataCache>().Set("ReleaseNetCore", release);
@@ -366,14 +375,14 @@ private async Task GetNetCoreReleasesAsync(GitHubClient githubClient)
366375
/// <summary>
367376
/// Gets my SQL releases.
368377
/// </summary>
369-
/// <param name="githubClient"></param>
370-
private async Task GetMySqlReleasesAsync(GitHubClient githubClient)
378+
/// <param name="releases">All yaf releases</param>
379+
private void GetMySqlReleases(List<Release> releases)
371380
{
372381
Release release;
373382

374383
if (this.Get<IDataCache>().Get("Release") == null)
375384
{
376-
release = await githubClient.Repository.Release.GetLatest("YAFNET", "YAFNET");
385+
release = releases.First(r => r.TagName.StartsWith("v3") && !r.Prerelease);
377386
this.Get<IDataCache>().Set("Release", release);
378387
}
379388
else
@@ -393,14 +402,14 @@ private async Task GetMySqlReleasesAsync(GitHubClient githubClient)
393402
/// <summary>
394403
/// Gets the ms SQL releases.
395404
/// </summary>
396-
/// <param name="githubClient"></param>
397-
private async Task GetMsSqlReleasesAsync(GitHubClient githubClient)
405+
/// <param name="releases">All yaf releases</param>
406+
private void GetMsSqlReleases(List<Release> releases)
398407
{
399408
Release release;
400409

401410
if (this.Get<IDataCache>().Get("Release") == null)
402411
{
403-
release = await githubClient.Repository.Release.GetLatest("YAFNET", "YAFNET");
412+
release = releases.First(r => r.TagName.StartsWith("v3") && !r.Prerelease);
404413
this.Get<IDataCache>().Set("Release", release);
405414
}
406415
else
@@ -417,14 +426,14 @@ private async Task GetMsSqlReleasesAsync(GitHubClient githubClient)
417426
/// <summary>
418427
/// Gets the sqlite releases.
419428
/// </summary>
420-
/// <param name="githubClient"></param>
421-
private async Task GetSqliteReleasesAsync(GitHubClient githubClient)
429+
/// <param name="releases">All yaf releases</param>
430+
private void GetSqliteReleases(List<Release> releases)
422431
{
423432
Release release;
424433

425434
if (this.Get<IDataCache>().Get("Release") == null)
426435
{
427-
release = await githubClient.Repository.Release.GetLatest("YAFNET", "YAFNET");
436+
release = releases.First(r => r.TagName.StartsWith("v3") && !r.Prerelease);
428437
this.Get<IDataCache>().Set("Release", release);
429438
}
430439
else
@@ -441,14 +450,14 @@ private async Task GetSqliteReleasesAsync(GitHubClient githubClient)
441450
/// <summary>
442451
/// Gets the postgre SQL releases.
443452
/// </summary>
444-
/// <param name="githubClient"></param>
445-
private async Task GetPostgreSqlReleasesAsync(GitHubClient githubClient)
453+
/// <param name="releases">All yaf releases</param>
454+
private void GetPostgreSqlReleases(List<Release> releases)
446455
{
447456
Release release;
448457

449458
if (this.Get<IDataCache>().Get("Release") == null)
450459
{
451-
release = await githubClient.Repository.Release.GetLatest("YAFNET", "YAFNET");
460+
release = releases.First(r => r.TagName.StartsWith("v3") && !r.Prerelease);
452461
this.Get<IDataCache>().Set("Release", release);
453462
}
454463
else

YAF.Website/Pages/Shared/_Layout.cshtml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
@using Microsoft.AspNetCore.Mvc.TagHelpers
2-
@using YAF.Core.Context
1+
@using YAF.Core.Context
32
@using YAF.Core.Extensions
43

54
@inject BoardContext Current
@@ -109,7 +108,7 @@
109108
</div>
110109
</footer>
111110
</main>
112-
<script src="@(Current.Get<BoardInfo>().GetUrlToScripts("forumExtensions.min.js"))" asp-append-version="true"></script>
111+
<script src="~/js/forumExtensions.min.js" asp-append-version="true"></script>
113112

114113
@if (!Current.IsGuest)
115114
{

YAF.Website/Pages/Shared/_LoginBox.cshtml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -81,36 +81,6 @@
8181
text-localized-tag="FORUM_LOGIN"></button>
8282
</div>
8383
</form>
84-
@if (Current.BoardSettings.AllowSingleSignOn)
85-
{
86-
<section>
87-
<form asp-controller="LoginBox" asp-action="Auth">
88-
<div class="d-grid gap-2">
89-
@{
90-
var loginProviders = (await SignInManager.GetExternalAuthenticationSchemesAsync()).ToList();
91-
if (loginProviders.HasItems())
92-
{
93-
@foreach (var provider in loginProviders)
94-
{
95-
<button type="submit"
96-
asp-route-auth="@provider.Name"
97-
button-style="None"
98-
button-size="Small"
99-
class="@Html.Raw($"btn btn-social btn-{provider.Name} me-1 mb-1")"
100-
icon="@provider.Name"
101-
icon-css-class="fab"
102-
text-localized-tag="AUTH_CONNECT"
103-
title-localized-tag="AUTH_CONNECT"
104-
text-param0="@provider.DisplayName"
105-
title-param0="@provider.DisplayName">
106-
</button>
107-
}
108-
}
109-
}
110-
</div>
111-
</form>
112-
</section>
113-
}
11484
</div>
11585
</div>
11686

YAF.Website/Program.cs

Lines changed: 82 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,91 @@
2222
* under the License.
2323
*/
2424

25+
using Autofac;
26+
using Autofac.Extensions.DependencyInjection;
27+
28+
using System.Net;
29+
30+
using Microsoft.AspNetCore.Rewrite;
31+
32+
using YAF.Core.Context;
2533
using YAF.Core.Extensions;
34+
using YAF.Core.Hubs;
35+
using YAF.Core.Middleware;
36+
using YAF.RazorPages;
37+
38+
var builder = WebApplication.CreateBuilder(args);
2639

27-
namespace YAF.Website;
40+
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
2841

29-
/// <summary>
30-
/// Class Program.
31-
/// </summary>
32-
public class Program
42+
builder.Host.ConfigureYafLogging();
43+
44+
builder.Host.ConfigureContainer<ContainerBuilder>(containerBuilder =>
3345
{
34-
/// <summary>
35-
/// Defines the entry point of the application.
36-
/// </summary>
37-
/// <param name="args">
38-
/// The arguments.
39-
/// </param>
40-
/// <returns>
41-
/// The <see cref="Task"/>.
42-
/// </returns>
43-
public static Task Main(string[] args)
44-
{
45-
var host = Host.CreateDefaultBuilder(args).UseAutofacServiceProviderFactory()
46-
.ConfigureYafLogging()
47-
.ConfigureWebHostDefaults(webHostBuilder => webHostBuilder.UseStartup<Startup>()).Build();
46+
containerBuilder.RegisterYafModules();
47+
});
48+
49+
builder.Services.AddRazorPages(options =>
50+
{
51+
options.Conventions.AddAreaPageRoute("Forums", "/SiteMap", "/Sitemap.xml");
52+
}).AddYafRazorPages(builder.Environment);
53+
54+
builder.Services.AddYafCore(builder.Configuration);
55+
56+
var app = builder.Build();
57+
58+
if (app.Environment.IsDevelopment())
59+
{
60+
app.UseDeveloperExceptionPage();
61+
}
62+
else
63+
{
64+
app.UseExceptionHandler("/Forums/Error");
65+
66+
app.UseHsts();
67+
}
68+
69+
app.Use(async (context, next) =>
70+
{
71+
var path = context.Request.Path.ToString();
4872

49-
return host.RunAsync();
73+
if (path.Contains("/RegisterV", StringComparison.InvariantCultureIgnoreCase))
74+
{
75+
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
76+
return;
5077
}
51-
}
78+
79+
await next();
80+
});
81+
82+
app.RegisterAutofac();
83+
84+
app.UseAntiXssMiddleware();
85+
86+
using (var iisUrlRewriteStreamReader = File.OpenText(Path.Combine(app.Environment.ContentRootPath, "IISUrlRewrite.xml")))
87+
{
88+
var options = new RewriteOptions().AddIISUrlRewrite(iisUrlRewriteStreamReader);
89+
app.UseRewriter(options);
90+
}
91+
92+
app.UseStaticFiles();
93+
94+
app.UseSession();
95+
96+
app.UseYafCore(BoardContext.Current.ServiceLocator);
97+
98+
app.UseRobotsTxt(app.Environment);
99+
100+
app.MapRazorPages();
101+
102+
app.MapAreaControllerRoute(
103+
name: "default",
104+
areaName: "Forums",
105+
pattern: "{controller=Home}/{action=Index}/{id?}");
106+
107+
app.MapControllers();
108+
109+
app.MapHub<NotificationHub>("/NotificationHub");
110+
app.MapHub<ChatHub>("/ChatHub");
111+
112+
await app.RunAsync();

0 commit comments

Comments
 (0)