This commit is contained in:
Hamid Reza Mohammadi 2025-03-24 13:17:57 +03:30
parent 8ba2b15668
commit 5feaf8cea4
5 changed files with 61 additions and 52 deletions

View File

@ -9,11 +9,11 @@ using System.Net.Http;
using System.Threading.Tasks;
using System.Linq;
using RMuseum.Models.Ganjoor;
using static GanjooRazor.Areas.Admin.Pages.ReviewEditsModel;
using System.Text;
using System;
using RMuseum.Utils;
using System.Collections.Generic;
using GanjooRazor.Models;
namespace GanjooRazor.Areas.Admin.Pages
{

View File

@ -3,6 +3,7 @@ using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using GanjooRazor.Models;
using GanjooRazor.Utils;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
@ -223,24 +224,6 @@ namespace GanjooRazor.Areas.Admin.Pages
return Page();
}
public class PoemMoerationStructure
{
public int correctionId{ get; set; }
public string titleReviewResult { get; set; }
public string summaryReviewResult { get; set; }
public string rhythmReviewResult { get; set; }
public string rhythm2ReviewResult { get; set; }
public string rhymeReviewResult { get; set; }
public string titleReviewNote { get; set; }
public string[] verseReviewResult { get; set; }
public string[] versePosReviewResult { get; set; }
public string[] verseSummaryResults { get; set; }
public string[] verseLanguageReviewResult { get; set; }
public string[] verseReviewNotes { get; set; }
public string poemformatReviewResult { get; set; }
public string poemformatReviewNote { get; set; }
}
public async Task<IActionResult> OnPostSendCorrectionsModerationAsync([FromBody] PoemMoerationStructure pms)

View File

@ -0,0 +1,20 @@
namespace GanjooRazor.Models
{
public class PoemMoerationStructure
{
public int correctionId { get; set; }
public string titleReviewResult { get; set; }
public string summaryReviewResult { get; set; }
public string rhythmReviewResult { get; set; }
public string rhythm2ReviewResult { get; set; }
public string rhymeReviewResult { get; set; }
public string titleReviewNote { get; set; }
public string[] verseReviewResult { get; set; }
public string[] versePosReviewResult { get; set; }
public string[] verseSummaryResults { get; set; }
public string[] verseLanguageReviewResult { get; set; }
public string[] verseReviewNotes { get; set; }
public string poemformatReviewResult { get; set; }
public string poemformatReviewNote { get; set; }
}
}

View File

@ -0,0 +1,38 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
namespace RMuseum.Utils
{
public class GanjoorHtmlTools
{
public static string StripHtmlTags(string input)
{
// Remove HTML tags using Regex
string textWithoutTags = Regex.Replace(input, "<.*?>", string.Empty);
// Decode HTML entities (e.g., &amp; → &)
return HttpUtility.HtmlDecode(textWithoutTags);
}
public static List<string> ExtractLinksWithRegex(string html)
{
List<string> links = new List<string>();
string pattern = @"<(a|img)\b[^>]*?\b(href|src)\s*=\s*[""']?([^""' >]+)[""']?";
MatchCollection matches = Regex.Matches(html, pattern, RegexOptions.IgnoreCase);
foreach (Match match in matches)
{
if (match.Groups.Count >= 4)
{
string url = match.Groups[3].Value;
if (!string.IsNullOrEmpty(url))
links.Add(url);
}
}
return links.Distinct().ToList(); // Remove duplicates
}
}
}

View File

@ -1,9 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
namespace RMuseum.Utils
namespace RMuseum.Utils
{
/// <summary>
/// ganjoor poem tools
@ -43,32 +38,5 @@ namespace RMuseum.Utils
return poemHtml;
}
public static string StripHtmlTags(string input)
{
// Remove HTML tags using Regex
string textWithoutTags = Regex.Replace(input, "<.*?>", string.Empty);
// Decode HTML entities (e.g., &amp; → &)
return HttpUtility.HtmlDecode(textWithoutTags);
}
public static List<string> ExtractLinksWithRegex(string html)
{
List<string> links = new List<string>();
string pattern = @"<(a|img)\b[^>]*?\b(href|src)\s*=\s*[""']?([^""' >]+)[""']?";
MatchCollection matches = Regex.Matches(html, pattern, RegexOptions.IgnoreCase);
foreach (Match match in matches)
{
if (match.Groups.Count >= 4)
{
string url = match.Groups[3].Value;
if (!string.IsNullOrEmpty(url))
links.Add(url);
}
}
return links.Distinct().ToList(); // Remove duplicates
}
}
}