Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Release Into master #906

Open
wants to merge 170 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
5ccb682
update
chenzhitong Sep 9, 2021
92f0252
new hero page
chenzhitong Sep 9, 2021
fe6d299
Update ConverterHelper.cs
chenzhitong Sep 15, 2021
e4bcf4e
resume
chenzhitong Sep 16, 2021
faddf8c
update
chenzhitong Sep 16, 2021
2c4c3a9
Update Index.cshtml
chenzhitong Sep 16, 2021
a5d781a
style / site map
chenzhitong Sep 16, 2021
1006d54
Update Index.cshtml
chenzhitong Sep 16, 2021
0a19c3a
Update Index.cshtml
chenzhitong Sep 16, 2021
d50d0e6
onegate
chenzhitong Sep 17, 2021
84d51f9
update
chenzhitong Sep 23, 2021
28fa0d8
Update ResumeController.cs
chenzhitong Sep 24, 2021
ffce6e4
update
chenzhitong Sep 24, 2021
73ed7e5
Update Views.JoinUS.Index.zh.resx
chenzhitong Sep 28, 2021
adce713
Grants pages & Neon wallet
chenzhitong Oct 12, 2021
7fc2f7c
update
chenzhitong Oct 12, 2021
bba82e1
Update _OverviewPartial.cshtml
chenzhitong Oct 12, 2021
9599d57
update
chenzhitong Oct 13, 2021
06ef970
update resume
chenzhitong Oct 20, 2021
ce88b15
Update Index.cshtml
chenzhitong Oct 20, 2021
602c865
update logo
chenzhitong Nov 15, 2021
a2baa85
Merge branch 'master' into release
chenzhitong Nov 15, 2021
41191db
fixed error link and code
chenzhitong Nov 15, 2021
8325cd1
.net 6
chenzhitong Nov 24, 2021
3f2dce0
Update Index.cshtml
chenzhitong Nov 24, 2021
419a47d
grants 1/2
chenzhitong Dec 10, 2021
2769e00
grants 2/2
chenzhitong Dec 10, 2021
9186d77
update
chenzhitong Dec 10, 2021
1263060
logo
chenzhitong Dec 10, 2021
5a6039b
update
chenzhitong Dec 10, 2021
b177964
Update _GeneralGrantsPartial.cshtml
chenzhitong Dec 13, 2021
db77c18
fixed bug
chenzhitong Dec 14, 2021
78bd1a2
typo
chenzhitong Dec 22, 2021
ed30c90
Update Index.cshtml
chenzhitong Dec 22, 2021
f630410
typo
chenzhitong Feb 21, 2022
2698be6
github status update (#887)
zackha Mar 25, 2022
0f2e559
Feature/polaris (#889)
apisit Mar 25, 2022
698b839
remove timeline.svg
chenzhitong Mar 25, 2022
3a6fc40
add Timeline.svg
chenzhitong Mar 25, 2022
d4630cc
chinese
chenzhitong Mar 25, 2022
f7d508a
Update Views.Home.Index.zh.resx
chenzhitong Mar 25, 2022
39cca65
revert appsetting.json
chenzhitong Mar 26, 2022
4da68da
Add ndapp link (#892)
apisit Apr 13, 2022
2a6bc11
Neo Brand Manual V1.1.pdf
chenzhitong Apr 14, 2022
5adbdc8
Neo Brand Manual V1.2.pdf
chenzhitong Apr 27, 2022
3b5ba2f
Portfolio (1/3)
chenzhitong May 9, 2022
dcde493
Portfolio (2/3)
chenzhitong May 9, 2022
03972c4
Portfolio (3/3)
chenzhitong May 10, 2022
24deac2
Update _EarlyAdoptionPartial.cshtml
chenzhitong May 10, 2022
b8a94ef
update to Neo 3.3.0
chenzhitong Jun 9, 2022
384e03d
Update Index.cshtml
chenzhitong Jun 9, 2022
4b33a5f
update
chenzhitong Jun 14, 2022
2954375
合约脚本转脚本哈希和地址
chenzhitong Jul 26, 2022
113a481
update
chenzhitong Aug 22, 2022
1f6c388
Update/grantshares (#894)
apisit Aug 23, 2022
3496610
Update Index.cshtml
chenzhitong Aug 29, 2022
f3d5a51
add onegate explorer
chenzhitong Sep 1, 2022
ed05e76
ban IP
chenzhitong Sep 7, 2022
211aa7e
ban IP
chenzhitong Sep 7, 2022
b52ae3b
beautify 403 page
chenzhitong Sep 8, 2022
345354d
Update JoinUSController.cs
chenzhitong Sep 9, 2022
e65492d
Add neon mobile
chenzhitong Sep 19, 2022
8235fe9
Hello NeoWorld.
chenzhitong Sep 22, 2022
7bea09d
Update JoinUSController.cs
chenzhitong Sep 27, 2022
94bdcf2
usa campus tour hero (#896)
apisit Oct 4, 2022
802296f
Update ConverterController.cs
chenzhitong Oct 9, 2022
80ca9e5
update
chenzhitong Oct 14, 2022
2dc9d00
.net7.0
chenzhitong Nov 9, 2022
9053014
Update JoinUSController.cs
chenzhitong Nov 10, 2022
c111f0e
Resume list optimization
chenzhitong Dec 5, 2022
a20665a
Update Index.cshtml
chenzhitong Dec 5, 2022
d20ce79
n3docker
chenzhitong Dec 15, 2022
b5cc943
reCAPTCHA
chenzhitong Jan 3, 2023
a9f8c87
back to grantshare (#898)
apisit Jan 11, 2023
53a7833
Update NuGet
chenzhitong Jan 11, 2023
e317b97
Developer Portal
chenzhitong Feb 14, 2023
0e88d23
Modify links
chenzhitong Feb 21, 2023
e2fec5b
update
chenzhitong Mar 16, 2023
3ac6223
update
chenzhitong Mar 16, 2023
292bc57
update
chenzhitong Mar 16, 2023
3d6fa64
CCAntiAttackMiddleware
chenzhitong May 23, 2023
c176052
Merge branch 'release' of https://github.com/neo-project/neo.org into…
chenzhitong May 23, 2023
5cd2e39
MaxRequestsPerMinute
chenzhitong May 30, 2023
3ab044a
429 Page
chenzhitong May 30, 2023
4d33cf4
New CDN
chenzhitong Jun 26, 2023
bbf9717
update
chenzhitong Jun 26, 2023
2137dd9
update CCAntiAttackMiddleware
chenzhitong Jun 26, 2023
8e38a3d
fixed bug
chenzhitong Jun 26, 2023
932e276
fixed bug
chenzhitong Jun 26, 2023
4b17424
fixed bug
chenzhitong Jun 26, 2023
284d504
update
chenzhitong Jun 26, 2023
912ac98
update
chenzhitong Jun 27, 2023
44dbff0
update
chenzhitong Jul 4, 2023
3df5582
fixed bug
chenzhitong Jul 4, 2023
2eeaa2d
update
chenzhitong Jul 4, 2023
7bb5f2b
fixed bug
chenzhitong Jul 5, 2023
f7376a0
u
chenzhitong Jul 5, 2023
2fb313d
hackathon
chenzhitong Jul 5, 2023
2188e78
s
chenzhitong Jul 5, 2023
445592c
s
chenzhitong Jul 5, 2023
2cd6e36
Update Index.cshtml
chenzhitong Jul 5, 2023
2c0a619
Update Index.cshtml
chenzhitong Jul 5, 2023
5aae92c
Update Index.cshtml
chenzhitong Jul 5, 2023
95cfc3b
Update Index.cshtml
chenzhitong Jul 6, 2023
4cb9b67
update
chenzhitong Jul 7, 2023
3704a74
update
chenzhitong Jul 7, 2023
1149487
update
chenzhitong Jul 7, 2023
d0acc2e
s
chenzhitong Jul 7, 2023
a5969ca
s
chenzhitong Jul 7, 2023
d84b78b
update readme
chenzhitong Jul 11, 2023
56930d9
update readme
chenzhitong Jul 11, 2023
f08d8c4
update
chenzhitong Oct 23, 2023
8258af2
neo 3.6
chenzhitong Oct 24, 2023
9f49baf
datatables
chenzhitong Oct 24, 2023
9e63f90
Nexo
chenzhitong Oct 24, 2023
513a83a
fixed bug
chenzhitong Oct 25, 2023
56f5ee6
update
chenzhitong Oct 27, 2023
ceaa2f2
remove tailwind
chenzhitong Oct 27, 2023
8f67f02
update GitHubStatus
chenzhitong Nov 1, 2023
c5d64bb
sidechain
chenzhitong Nov 13, 2023
da47982
sidechain2
chenzhitong Nov 13, 2023
6fa8ef6
link
chenzhitong Nov 13, 2023
57ee3a1
update
chenzhitong Nov 13, 2023
0cac77d
update
chenzhitong Nov 13, 2023
89af9cf
Some fixes (#900)
alvarodh5 Nov 14, 2023
b33fd7f
remove 404 links
chenzhitong Nov 24, 2023
0f35f2b
Merge branch 'release' of https://github.com/neo-project/neo.org into…
chenzhitong Nov 24, 2023
4a7cc92
Add neo-express
chenzhitong Nov 24, 2023
d1978b1
update neo-express logo
chenzhitong Nov 27, 2023
04023fd
update
chenzhitong Nov 27, 2023
85184f5
remove n3t4
chenzhitong Nov 29, 2023
1e93a6c
update
chenzhitong Dec 1, 2023
ae1a398
.net 8.0
chenzhitong Dec 5, 2023
0926387
fixed bug
chenzhitong Dec 5, 2023
16530f3
update
chenzhitong Dec 5, 2023
c8aaafb
update
chenzhitong Dec 8, 2023
752ea41
update
chenzhitong Dec 8, 2023
9f82005
remove John deVadoss
chenzhitong Dec 11, 2023
65492ac
remove unused files
chenzhitong Dec 11, 2023
a803735
fixed bug
chenzhitong Dec 13, 2023
6655ee2
upgrade tinymce
chenzhitong Dec 13, 2023
5c3d27c
grantshares
chenzhitong Dec 18, 2023
efe6557
update
chenzhitong Dec 29, 2023
2c3c1f3
update
chenzhitong Jan 10, 2024
ba1de6f
update
chenzhitong Jan 10, 2024
1988484
fixed bug
chenzhitong Feb 21, 2024
fe9fba7
update
chenzhitong Apr 15, 2024
41f156e
Hide subscription information
chenzhitong Apr 16, 2024
9c75881
update
chenzhitong May 14, 2024
1ea3e81
WIFToHexPrivateKey
chenzhitong May 14, 2024
ac43545
update
chenzhitong May 15, 2024
df73b0b
load draft
chenzhitong May 15, 2024
da68a40
update
chenzhitong Jun 4, 2024
a80d405
neo 3.7.5
chenzhitong Jun 13, 2024
f07c760
update
chenzhitong Jun 13, 2024
8c7d6a5
remove neo tracker
chenzhitong Jun 14, 2024
d1bb1df
update wallet
chenzhitong Jun 14, 2024
3fb1897
update
chenzhitong Jun 17, 2024
d1673e7
neox
chenzhitong Jul 23, 2024
b9139bf
Update NuGet
chenzhitong Aug 21, 2024
512dc0a
Update NuGet
chenzhitong Aug 21, 2024
45f2efe
update
chenzhitong Sep 12, 2024
53dc906
update
chenzhitong Sep 12, 2024
83efa1f
update
chenzhitong Sep 24, 2024
39c4800
AsTransferScript
chenzhitong Oct 8, 2024
132025a
Vote, CheckSig, CheckMultiSig
chenzhitong Oct 17, 2024
3322c20
Script hash to to Base64 string
chenzhitong Oct 17, 2024
ddfd40f
line
chenzhitong Oct 17, 2024
011d0a6
Update ConverterHelper.cs
chenzhitong Oct 17, 2024
dd020e7
Update ConverterHelper.cs
chenzhitong Oct 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,4 @@ NeoWeb/CandidateBackgrounder/
NeoWeb/validators.json
NeoWeb/wwwroot/css/*.css
SendGridTest/Program.cs
.DS_Store
.DS_Store
4 changes: 2 additions & 2 deletions NeoWeb.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29324.140
# Visual Studio Version 17
VisualStudioVersion = 17.8.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NeoWeb", "NeoWeb\NeoWeb.csproj", "{EFDED9C5-0650-4FA2-B532-FCD2ADDCC7F9}"
EndProject
Expand Down
23 changes: 13 additions & 10 deletions NeoWeb/.editorconfig
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# 若要了解有关 .editorconfig 的详细信息,请参阅 https://aka.ms/editorconfigdocs
root = true

# All files
[*]
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
end_of_line = lf
# 若要了解有关 .editorconfig 的详细信息,请参阅 https://aka.ms/editorconfigdocs
root = true

# All files
[*]
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
end_of_line = lf

# SYSLIB1045: 转换为“GeneratedRegexAttribute”。
dotnet_diagnostic.SYSLIB1045.severity = none
82 changes: 82 additions & 0 deletions NeoWeb/CCAntiAttackMiddleware.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace NeoWeb
{
public class CCAntiAttackMiddleware(RequestDelegate next)
{
private readonly List<RequestItem> _requestList = [];
private readonly List<BlockItem> _blockList = [];

private const int MaxRequestsPerMinute = 10;
private const int BlockDurationMinutes = 10;

public async Task Invoke(HttpContext context)
{
var ipAddress = context.Connection.RemoteIpAddress?.ToString();
if (!string.IsNullOrEmpty(ipAddress) && System.IO.File.ReadAllLines("whitelist.txt").All(p => p != ipAddress))
{
CleanUpExpiredRequestsAndBlocks();

var block = _blockList.FirstOrDefault(p => p?.IP == ipAddress);
var requestsPerMinute = _requestList.Count(p => p?.IP == ipAddress);

if (block is not null)
{
await HandleBlockedRequest(context, block);
return;
}

if (requestsPerMinute > MaxRequestsPerMinute * 2 /*Request & Response*/)
{
await HandleExceededRequestLimit(context, ipAddress);
return;
}

_requestList.Add(new RequestItem { IP = ipAddress, DateTime = DateTime.UtcNow });
}

await next(context);
}

private void CleanUpExpiredRequestsAndBlocks()
{
var utcNow = DateTime.UtcNow;
_requestList.RemoveAll(p => p == null || p?.DateTime < utcNow.AddMinutes(-1));
_blockList.RemoveAll(p => p == null || p?.DateTime < utcNow);
}

private static async Task HandleBlockedRequest(HttpContext context, BlockItem block)
{
context.Response.StatusCode = 429; // Too Many Requests
context.Response.Headers.Append("Retry-After", block.DateTime.ToString("R"));
context.Response.ContentType = "text/html";
await context.Response.WriteAsync(string.Format(System.IO.File.ReadAllText("wwwroot/429.html"), (int)(block.DateTime - DateTime.UtcNow).TotalSeconds, block.IP, block.DateTime.ToString("R")));
}

private async Task HandleExceededRequestLimit(HttpContext context, string ipAddress)
{
var blockTime = DateTime.UtcNow.AddMinutes(BlockDurationMinutes);
_blockList.Add(new BlockItem { IP = ipAddress, DateTime = blockTime });
context.Response.StatusCode = 429; // Too Many Requests
context.Response.Headers.Append("Retry-After", blockTime.ToString("R"));
context.Response.ContentType = "text/html";
await context.Response.WriteAsync(string.Format(System.IO.File.ReadAllText("wwwroot/429.html"), (int)(blockTime - DateTime.UtcNow).TotalSeconds, ipAddress, blockTime.ToString("R")));
}
}

public class RequestItem
{
public string IP { get; set; }
public DateTime DateTime { get; set; } //访问时间
}

public class BlockItem
{
public string IP { get; set; }
public DateTime DateTime { get; set; } //阻止访问的截止时间
}
}
43 changes: 43 additions & 0 deletions NeoWeb/ClientIpCheckActionFilter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System.Linq;

namespace NeoWeb
{
public class ClientIpCheckActionFilter : ActionFilterAttribute
{
public ClientIpCheckActionFilter(string fileName)
{
if (Helper.Banlist.Count > 0) return;
var temp = System.IO.File.ReadAllLines(fileName).ToList();
foreach (var item in temp)
{
var start = item.Split('\t')[0].IPToInteger();
var end = item.Split('\t')[1].IPToInteger();
Helper.Banlist.Add(new IPZone(start, end));
}
}

public override void OnActionExecuting(ActionExecutingContext context)
{
var remoteIp = context.HttpContext.Connection.RemoteIpAddress;

remoteIp = remoteIp.IsIPv4MappedToIPv6 ? remoteIp.MapToIPv4() : remoteIp;
var ipInteger = remoteIp.IPToInteger();

if (Helper.Banlist.Any(p => ipInteger > p.Start && ipInteger < p.End))
{
context.Result = new ViewResult() { ViewName = "403", StatusCode = 403 };
return;
}

base.OnActionExecuting(context);
}
}

public class IPZone(long start, long end)
{
public long Start { get; set; } = start;
public long End { get; set; } = end;
}
}
1 change: 1 addition & 0 deletions NeoWeb/Controllers/AboutController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace NeoWeb.Controllers
{
[ServiceFilter(typeof(ClientIpCheckActionFilter))]
public class AboutController : Controller
{
public IActionResult Index()
Expand Down
118 changes: 68 additions & 50 deletions NeoWeb/Controllers/BlogController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using System.IO;
using System.Linq;
using System.Security.Claims;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml;

Expand All @@ -34,7 +33,6 @@ public BlogController(ApplicationDbContext context, IHttpContextAccessor httpCon
if (_userId != null)
{
_userRules = _context.UserRoles.Any(p => p.UserId == _userId);
var asfs = _context.UserRoles.Where(p => p.UserId == _userId).ToList();
}
}

Expand All @@ -57,10 +55,12 @@ public async Task<IActionResult> Details(int? id, string language = null)
language = !string.IsNullOrEmpty(language) ? language : _sharedLocalizer["en"];

#region Previous and Next

var idList = _context.Blogs.OrderByDescending(o => o.CreateTime).Select(p => p.Id).ToList();
ViewBag.NextBlogId = idList.Count == 0 ? id: idList[Math.Max(idList.IndexOf((int)id) - 1, 0)];
ViewBag.PrevBlogId = idList.Count == 0 ? id : idList[Math.Min(idList.IndexOf((int)id) + 1, idList.Count - 1)];
#endregion
ViewBag.NextBlogId = idList.Count == 0 ? id : idList[Math.Max(idList.IndexOf((int)id) - 1, 0)];
ViewBag.PrevBlogId = idList.Count == 0 ? id : idList[Math.Min(idList.IndexOf((int)id) + 1, idList.Count - 1)];

#endregion Previous and Next

ViewBag.UserRules = _userRules;

Expand Down Expand Up @@ -92,24 +92,38 @@ public async Task<IActionResult> Create(
{
if (chineseCover != null)
{
var fileName = Helper.UploadMedia(chineseCover, _env, 1000);
if (Helper.ValidateCover(_env, fileName))
blog.ChineseCover = fileName;
else
ModelState.AddModelError("ChineseCover", "Cover size must be 16:9.");
try
{
var fileName = Helper.UploadMedia(chineseCover, _env, 1000);
if (Helper.ValidateCover(_env, fileName))
blog.ChineseCover = fileName;
else
ModelState.AddModelError("ChineseCover", "Cover size must be 16:9.");
}
catch (ArgumentException)
{
ModelState.AddModelError("ChineseCover", "Image files exceeding 10MB or in an unsupported format.");
}
}
if (englishCover != null)
{
var fileName = Helper.UploadMedia(englishCover, _env, 1000);
if (Helper.ValidateCover(_env, fileName))
blog.EnglishCover = fileName;
else
ModelState.AddModelError("EnglishCover", "Cover size must be 16:9.");
try
{
var fileName = Helper.UploadMedia(englishCover, _env, 1000);
if (Helper.ValidateCover(_env, fileName))
blog.EnglishCover = fileName;
else
ModelState.AddModelError("EnglishCover", "Cover size must be 16:9.");
}
catch (ArgumentException)
{
ModelState.AddModelError("EnglishCover", "Image files exceeding 10MB or in an unsupported format.");
}
}
if(!ModelState.IsValid) return View(blog);
if (!ModelState.IsValid) return View(blog);

blog.ChineseContent = Convert(blog.ChineseContent);
blog.EnglishContent = Convert(blog.EnglishContent);
blog.ChineseContent = Helper.Sanitizer(blog.ChineseContent);
blog.EnglishContent = Helper.Sanitizer(blog.EnglishContent);
blog.ChineseSummary = blog.ChineseContent.ClearHtmlTag(150);
blog.EnglishSummary = blog.EnglishContent.ClearHtmlTag(150);
blog.ChineseTags = blog.ChineseTags?.Replace(", ", ",").Replace(",", ",").Replace(", ", ",");
Expand All @@ -130,7 +144,8 @@ public async Task<IActionResult> Create(
return RedirectToAction("index", "news", new { type = NewsViewModelType.Blog });
}
return View(blog);
}
}

// GET: blog/edit/5
public IActionResult Edit(int? id)
{
Expand Down Expand Up @@ -164,37 +179,51 @@ public async Task<IActionResult> Edit(
var item = _context.Blogs.FirstOrDefault(p => p.Id == blog.Id);
if (chineseCover != null)
{
var fileName = Helper.UploadMedia(chineseCover, _env, 1000);
if (Helper.ValidateCover(_env, fileName))
try
{
if (!string.IsNullOrEmpty(blog.ChineseCover))
System.IO.File.Delete(Path.Combine(_env.ContentRootPath, "wwwroot/upload", blog.ChineseCover));
item.ChineseCover = fileName;
var fileName = Helper.UploadMedia(chineseCover, _env, 1000);
if (Helper.ValidateCover(_env, fileName))
{
if (!string.IsNullOrEmpty(blog.ChineseCover))
System.IO.File.Delete(Path.Combine(_env.ContentRootPath, "wwwroot/upload", blog.ChineseCover));
item.ChineseCover = fileName;
}
else
{
ModelState.AddModelError("ChineseCover", "Cover size must be 16:9");
}
}
else
catch (ArgumentException)
{
ModelState.AddModelError("ChineseCover", "Cover size must be 16:9");
ModelState.AddModelError("ChineseCover", "Image files exceeding 10MB or in an unsupported format.");
}
}
if (englishCover != null)
{
var fileName = Helper.UploadMedia(englishCover, _env, 1000);
if (Helper.ValidateCover(_env, fileName))
try
{
if (!string.IsNullOrEmpty(blog.EnglishCover))
System.IO.File.Delete(Path.Combine(_env.ContentRootPath, "wwwroot/upload", blog.EnglishCover));
item.EnglishCover = fileName;
var fileName = Helper.UploadMedia(englishCover, _env, 1000);
if (Helper.ValidateCover(_env, fileName))
{
if (!string.IsNullOrEmpty(blog.EnglishCover))
System.IO.File.Delete(Path.Combine(_env.ContentRootPath, "wwwroot/upload", blog.EnglishCover));
item.EnglishCover = fileName;
}
else
{
ModelState.AddModelError("EnglishCover", "Cover size must be 16:9");
}
}
else
catch (ArgumentException)
{
ModelState.AddModelError("EnglishCover", "Cover size must be 16:9");
ModelState.AddModelError("EnglishCover", "Image files exceeding 10MB or in an unsupported format.");
}
}
if (!ModelState.IsValid) return View(blog);
try
{
item.ChineseContent = Convert(blog.ChineseContent);
item.EnglishContent = Convert(blog.EnglishContent);
item.ChineseContent = Helper.Sanitizer(blog.ChineseContent);
item.EnglishContent = Helper.Sanitizer(blog.EnglishContent);
item.ChineseSummary = blog.ChineseContent.ClearHtmlTag(150);
item.EnglishSummary = blog.EnglishContent.ClearHtmlTag(150);
item.ChineseTags = blog.ChineseTags?.Replace(", ", ",").Replace(",", ",").Replace(", ", ",");
Expand All @@ -204,7 +233,7 @@ public async Task<IActionResult> Edit(
item.Editor = blog.Editor;
item.EditTime = DateTime.Now;
item.IsShow = blog.IsShow;

_context.Update(item);
if (isTop != null)
{
Expand Down Expand Up @@ -256,7 +285,8 @@ public async Task<IActionResult> DeleteConfirmed(int id)
_context.Blogs.Remove(blog);
await _context.SaveChangesAsync();
return RedirectToAction("index", "news", new { type = NewsViewModelType.Blog });
}
}

private async Task UpdateRSSAsync()
{
await Task.Run(() =>
Expand Down Expand Up @@ -332,8 +362,7 @@ private void UpdateRssChinese()
}
rss.AppendChild(channel);
xml.AppendChild(rss);
RssModel.Chinese = xml.OuterXml;

RssModel.Chinese = xml.OuterXml;
}

private void UpdateRssEnglish()
Expand Down Expand Up @@ -441,17 +470,6 @@ private bool BlogExists(int id)
return _context.Blogs.Any(e => e.Id == id);
}

private static string Convert(string input)
{
input = Regex.Replace(input, @"<!\-\-\[if gte mso 9\]>[\s\S]*<!\[endif\]\-\->", ""); //删除 ms office 注解
input = Regex.Replace(input, "src=\".*/upload", "data-original=\"/upload"); //替换上传图片的链接
input = Regex.Replace(input, "<img src=", "<img data-original="); //替换外部图片的链接
input = Regex.Replace(input, @"<p>((&nbsp;\s)|(&nbsp;)|\s)+", "<p>"); //删除段首由空格造成的缩进
input = Regex.Replace(input, @"\sstyle="".*?""", ""); //删除 Style 样式
input = Regex.Replace(input, @"\sclass="".*?""", ""); //删除 Class 样式
return input;
}

private static string XmlEncode(string input)
{
return input?.Replace(">", "&gt;").Replace("<", "&lt;").Replace("&", "&amp;").Replace("'", "&apos;").Replace("\"", "&quot;");
Expand Down
Loading