diff --git a/RMuseum/Services/Implementation/GanjoorService-Imports/GanjoorService-MySqlImports.cs b/RMuseum/Services/Implementation/GanjoorService-Imports/GanjoorService-MySqlImports.cs
index 747b4d4e..0fc03710 100644
--- a/RMuseum/Services/Implementation/GanjoorService-Imports/GanjoorService-MySqlImports.cs
+++ b/RMuseum/Services/Implementation/GanjoorService-Imports/GanjoorService-MySqlImports.cs
@@ -1,4 +1,5 @@
-using Microsoft.EntityFrameworkCore;
+using DNTPersianUtils.Core;
+using Microsoft.EntityFrameworkCore;
using MySql.Data.MySqlClient;
using RMuseum.DbContext;
using RMuseum.Models.Artifact;
@@ -11,6 +12,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
+using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace RMuseum.Services.Implementation
@@ -518,7 +520,7 @@ namespace RMuseum.Services.Implementation
AuthorUrl = row["comment_author_url"].ToString(),
AuthorIpAddress = row["comment_author_IP"].ToString(),
CommentDate = (DateTime)row["comment_date"],
- HtmlComment = row["comment_content"].ToString(),
+ HtmlComment = _PrepareCommentHtml(row["comment_content"].ToString()),
Status = row["comment_approved"].ToString() == "1" ? PublishStatus.Published : PublishStatus.Awaiting
};
@@ -696,5 +698,36 @@ namespace RMuseum.Services.Implementation
return verses;
}
+
+ private string _Linkify(string SearchText)
+ {
+ // this will find links like:
+ // http://www.mysite.com
+ // as well as any links with other characters directly in front of it like:
+ // href="http://www.mysite.com"
+ // you can then use your own logic to determine which links to linkify
+ Regex regx = new Regex(@"\b(((\S+)?)(@|mailto\:|(news|(ht|f)tp(s?))\://)\S+)\b", RegexOptions.IgnoreCase);
+ SearchText = SearchText.Replace(" ", " ");
+ MatchCollection matches = regx.Matches(SearchText);
+
+ foreach (Match match in matches)
+ {
+ if (match.Value.StartsWith("http"))
+ { // if it starts with anything else then dont linkify -- may already be linked!
+ SearchText = SearchText.Replace(match.Value, "" + match.Value + "");
+ }
+ }
+
+ return SearchText;
+ }
+
+ private string _PrepareCommentHtml(string comment)
+ {
+ comment = comment.ToPersianNumbers().ApplyCorrectYeKe();
+ comment = _Linkify(comment);
+ comment = $"
{comment.Replace("\r\n", "\n").Replace("\n\n", "\n").Replace("\n", "
")}
";
+
+ return comment;
+ }
}
}
diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs
index 2d47b176..a2ff0a86 100644
--- a/RMuseum/Services/Implementation/GanjoorService.cs
+++ b/RMuseum/Services/Implementation/GanjoorService.cs
@@ -15,7 +15,6 @@ using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using RMuseum.Models.Artifact;
-using System.Text.RegularExpressions;
using RSecurityBackend.Services.Implementation;
using DNTPersianUtils.Core;
@@ -439,27 +438,7 @@ namespace RMuseum.Services.Implementation
}
}
- private string _Linkify(string SearchText)
- {
- // this will find links like:
- // http://www.mysite.com
- // as well as any links with other characters directly in front of it like:
- // href="http://www.mysite.com"
- // you can then use your own logic to determine which links to linkify
- Regex regx = new Regex(@"\b(((\S+)?)(@|mailto\:|(news|(ht|f)tp(s?))\://)\S+)\b", RegexOptions.IgnoreCase);
- SearchText = SearchText.Replace(" ", " ");
- MatchCollection matches = regx.Matches(SearchText);
-
- foreach (Match match in matches)
- {
- if (match.Value.StartsWith("http"))
- { // if it starts with anything else then dont linkify -- may already be linked!
- SearchText = SearchText.Replace(match.Value, "" + match.Value + "");
- }
- }
-
- return SearchText;
- }
+
///
/// get poem comments
@@ -495,7 +474,6 @@ namespace RMuseum.Services.Implementation
foreach(GanjoorCommentSummaryViewModel comment in allComments)
{
comment.AuthorName = comment.AuthorName.ToPersianNumbers().ApplyCorrectYeKe();
- comment.HtmlComment = _PrepareCommentHtml(comment.HtmlComment);
}
GanjoorCommentSummaryViewModel[] rootComments = allComments.Where(c => c.InReplyToId == null).ToArray();
@@ -556,9 +534,8 @@ namespace RMuseum.Services.Implementation
var userRes = await _appUserService.GetUserInformation(userId);
comment.HtmlComment = comment.HtmlComment.ToPersianNumbers().ApplyCorrectYeKe();
- comment.HtmlComment = _Linkify(comment.HtmlComment);
- comment.HtmlComment = $"{comment.HtmlComment.Replace("\r\n", "\n").Replace("\n\n", "\n").Replace("\n", "
")}
";
+
return new RServiceResult
(
@@ -637,7 +614,7 @@ namespace RMuseum.Services.Implementation
"حذف پاسخ شما به حاشیه",
$"پاسخ شما به یکی از حاشیههای گنجور به دلیل حذف زنجیرهٔ حاشیه توسط یکی از حاشیهگذاران حذف شده است.{Environment.NewLine}" +
$"این متن حاشیهٔ حذف شدهٔ شماست: {Environment.NewLine}" +
- $"{_PrepareCommentHtml(replies[i].HtmlComment)}"
+ $"{replies[i].HtmlComment}"
);
}
_context.GanjoorComments.Remove(replies[i]);
@@ -712,7 +689,6 @@ namespace RMuseum.Services.Implementation
foreach (GanjoorCommentFullViewModel comment in paginatedResult.Items)
{
comment.AuthorName = comment.AuthorName.ToPersianNumbers().ApplyCorrectYeKe();
- comment.HtmlComment = _PrepareCommentHtml(comment.HtmlComment);
}
return new RServiceResult<(PaginationMetadata PagingMeta, GanjoorCommentFullViewModel[] Items)>(paginatedResult);
@@ -723,14 +699,7 @@ namespace RMuseum.Services.Implementation
}
}
- private string _PrepareCommentHtml(string comment)
- {
- comment = comment.ToPersianNumbers().ApplyCorrectYeKe();
- comment = _Linkify(comment);
- comment = $"{comment.Replace("\r\n", "\n").Replace("\n\n", "\n").Replace("\n", "
")}
";
-
- return comment;
- }
+
///