Initial commit: Aeroflot Flights Web Angular 12 application

This commit is contained in:
2026-04-03 10:10:52 +03:00
commit 2342f2e66e
1311 changed files with 128350 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
@page
@model Aeroflot.Flights.Web.Pages.RobotsModel
@{
Layout = null;
this.Response.ContentType = "text/plain";
}
@Model.RobotsTxtRules
Sitemap: @Model.SitemapLink
+74
View File
@@ -0,0 +1,74 @@
using System.Text;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Configuration;
namespace Aeroflot.Flights.Web.Pages
{
[ResponseCache(CacheProfileName = "DefaultBoard")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:File name should match first type name", Justification = "Razor page model")]
public class RobotsModel : PageModel
{
private readonly IConfiguration configuration;
private readonly bool allowIndexing;
public RobotsModel(IConfiguration configuration)
{
this.configuration = configuration ?? throw new System.ArgumentNullException(nameof(configuration));
this.allowIndexing = configuration.GetValue<bool>("AllowIndexing", false);
}
public void OnGet()
{
}
public HtmlString RobotsTxtRules
{
get
{
StringBuilder sb = new StringBuilder();
if (!this.allowIndexing)
{
// disallow all
sb.AppendLine("User-agent: *");
sb.AppendLine("Disallow: /");
sb.AppendLine();
}
else
{
foreach (var agent in Models.Seo.UserAgents)
{
sb.AppendLine($"User-agent: {agent}");
sb.AppendLine("#obrd");
foreach (var lang in Models.Seo.LanguagePairs)
{
sb.AppendLine($"Allow: /{lang}/onlineboard");
}
sb.AppendLine("#schd");
foreach (var lang in Models.Seo.LanguagePairs)
{
sb.AppendLine($"Allow: /{lang}/schedule");
}
sb.AppendLine("#errors");
foreach (var lang in Models.Seo.LanguagePairs)
{
sb.AppendLine($"Disallow: /{lang}/error/*");
}
sb.AppendLine();
}
sb.AppendLine();
}
return new HtmlString(sb.ToString());
}
}
public string SitemapLink => "https://" + HttpContext.Request.Host + "/sitemap.xml";
}
}
+7
View File
@@ -0,0 +1,7 @@
@page
@model Aeroflot.Flights.Web.Pages.SitemapModel
@{
Layout = null;
this.Response.ContentType = "text/plain";
}
@Model.GetSitemap
+85
View File
@@ -0,0 +1,85 @@
using System;
using System.IO;
using System.Text;
using System.Xml;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Configuration;
namespace Aeroflot.Flights.Web.Pages
{
[ResponseCache(CacheProfileName = "DefaultBoard")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:File name should match first type name", Justification = "Razor page model")]
public class SitemapModel : PageModel
{
private static readonly XmlWriterSettings XmlWriterSettings = new XmlWriterSettings() { Encoding = Encoding.UTF8, Indent = true };
private readonly IConfiguration configuration;
private readonly bool allowIndexing;
public SitemapModel(IConfiguration configuration)
{
this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
this.allowIndexing = configuration.GetValue<bool>("AllowIndexing", false);
}
public HtmlString GetSitemap
{
get
{
var today = DateTime.Now.Date.ToString("yyyy-MM-dd");
StringBuilder sb = new StringBuilder();
using (var sw = new StringWriterWithEncoding(sb, Encoding.UTF8))
using (XmlWriter writer = XmlWriter.Create(sw, XmlWriterSettings))
{
writer.WriteStartElement("urlset", "http://www.sitemaps.org/schemas/sitemap/0.9");
if (this.allowIndexing)
{
foreach (var lang in Models.Seo.LanguagePairs)
{
//obrd
writer.WriteStartElement("url");
writer.WriteElementString("loc", "https://" + HttpContext.Request.Host + $"/{lang}/onlineboard");
writer.WriteElementString("lastmod", today);
writer.WriteEndElement();
//schedule
writer.WriteStartElement("url");
writer.WriteElementString("loc", "https://" + HttpContext.Request.Host + $"/{lang}/schedule");
writer.WriteElementString("lastmod", today);
writer.WriteEndElement();
}
}
writer.WriteEndElement();
writer.Flush();
}
return new HtmlString(sb.ToString());
}
}
public void OnGet()
{
}
public class StringWriterWithEncoding : StringWriter
{
private readonly Encoding encoding;
public StringWriterWithEncoding(StringBuilder sb, Encoding encoding)
: base(sb)
{
this.encoding = encoding;
}
public override Encoding Encoding
{
get
{
return this.encoding;
}
}
}
}
}