Skip to content

Commit 7d1797a

Browse files
committed
Refactoring comments moderation and providers
1 parent ccd13e6 commit 7d1797a

16 files changed

Lines changed: 149 additions & 211 deletions

File tree

BlogEngine/BlogEngine.Core/BlogSettings.cs

Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -734,16 +734,6 @@ public bool EnablePasswordReset
734734

735735
#endregion
736736

737-
#region EnableCommentsModeration
738-
739-
/// <summary>
740-
/// Gets or sets a value indicating if comments moderation is used for posts.
741-
/// </summary>
742-
/// <value><b>true</b> if comments are moderated for posts, otherwise returns <b>false</b>.</value>
743-
public bool EnableCommentsModeration { get; set; }
744-
745-
#endregion
746-
747737
#region Avatar
748738

749739
/// <summary>
@@ -773,25 +763,6 @@ public bool EnablePasswordReset
773763

774764
#endregion
775765

776-
#region DISQUS
777-
778-
/// <summary>
779-
/// Short website name that used to identify Disqus account
780-
/// </summary>
781-
public string DisqusWebsiteName { get; set; }
782-
783-
/// <summary>
784-
/// Development mode to test disqus on local host
785-
/// </summary>
786-
public bool DisqusDevMode { get; set; }
787-
788-
/// <summary>
789-
/// Allow also to add comments to the pages
790-
/// </summary>
791-
public bool DisqusAddCommentsToPages { get; set; }
792-
793-
#endregion
794-
795766
#region White list count
796767

797768
///<summary>
@@ -860,41 +831,58 @@ public int CommentsPerPage
860831

861832
#endregion
862833

834+
#region Comment providers and moderation
835+
863836
/// <summary>
864-
/// Type of comment moderation
837+
/// Comments provider
865838
/// </summary>
866-
public enum Moderation
839+
public enum CommentsBy
867840
{
868841
/// <summary>
869-
/// Comments moderated manually
842+
/// Internal BlogEngine comments
870843
/// </summary>
871-
Manual = 0,
844+
BlogEngine = 0,
872845
/// <summary>
873-
/// Comments moderated by filters
846+
/// Comments by Disqus
874847
/// </summary>
875-
Auto = 1,
848+
Disqus = 1,
876849
/// <summary>
877-
/// Moderated by Disqus
850+
/// Comments by Facebook
878851
/// </summary>
879-
Disqus = 2,
880-
/// <summary>
881-
/// Moderated by Facebook
882-
/// </summary>
883-
Facebook = 3
852+
Facebook = 2
884853
}
885854

886-
#region Moderation type
855+
/// <summary>
856+
/// Gets or sets a value indicating comment provider
857+
/// </summary>
858+
public CommentsBy CommentProvider { get; set; }
887859

888860
/// <summary>
889-
/// Gets or sets a value indicating type of moderation
861+
/// Gets or sets a value indicating if comments moderation is used for posts.
890862
/// </summary>
891-
public Moderation ModerationType { get; set; }
863+
/// <value><b>true</b> if comments are moderated for posts, otherwise returns <b>false</b>.</value>
864+
public bool EnableCommentsModeration { get; set; }
892865

893866
/// <summary>
894867
/// Enables to report mistakes back to service
895868
/// </summary>
896869
public bool CommentReportMistakes { get; set; }
897870

871+
/// <summary>
872+
/// Short website name that used to identify Disqus account
873+
/// </summary>
874+
public string DisqusWebsiteName { get; set; }
875+
876+
/// <summary>
877+
/// Development mode to test disqus on local host
878+
/// </summary>
879+
public bool DisqusDevMode { get; set; }
880+
881+
/// <summary>
882+
/// Allow also to add comments to the pages
883+
/// </summary>
884+
public bool DisqusAddCommentsToPages { get; set; }
885+
898886
#endregion
899887

900888
#region BlogrollMaxLength

BlogEngine/BlogEngine.Core/Data/Models/Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public Settings() { }
167167
public bool EnableWebsiteInComments { get; set; }
168168
public bool ShowLivePreview { get; set; }
169169

170-
public BlogSettings.Moderation ModerationType { get; set; }
170+
public BlogSettings.CommentsBy CommentProvider { get; set; }
171171
public bool UseDisqus { get; set; }
172172
public bool DisqusDevMode { get; set; }
173173
public bool DisqusAddCommentsToPages { get; set; }

BlogEngine/BlogEngine.Core/Data/SettingsRepository.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ public Settings Get()
114114
ns.EnableWebsiteInComments = bs.EnableWebsiteInComments;
115115
ns.ShowLivePreview = bs.ShowLivePreview;
116116

117-
ns.ModerationType = bs.ModerationType;
118-
ns.UseDisqus = bs.ModerationType == BlogSettings.Moderation.Disqus;
117+
ns.CommentProvider = bs.CommentProvider;
118+
ns.UseDisqus = bs.CommentProvider == BlogSettings.CommentsBy.Disqus;
119119
ns.DisqusDevMode = bs.DisqusDevMode;
120120
ns.DisqusAddCommentsToPages = bs.DisqusAddCommentsToPages;
121121
ns.DisqusWebsiteName = bs.DisqusWebsiteName;
@@ -231,8 +231,7 @@ public bool Update(Settings ns)
231231
bs.EnableWebsiteInComments = ns.EnableWebsiteInComments;
232232
bs.ShowLivePreview = ns.ShowLivePreview;
233233

234-
bs.ModerationType = ns.ModerationType;
235-
//bs.ModerationType = ns.UseDisqus ? BlogSettings.Moderation.Disqus : BlogSettings.Moderation.Auto;
234+
bs.CommentProvider = ns.CommentProvider;
236235
bs.DisqusDevMode = ns.DisqusDevMode;
237236
bs.DisqusAddCommentsToPages = ns.DisqusAddCommentsToPages;
238237
bs.DisqusWebsiteName = ns.DisqusWebsiteName;

BlogEngine/BlogEngine.Core/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
[assembly: CLSCompliant(false)]
2020
[assembly: ComVisible(false)]
2121
[assembly: AllowPartiallyTrustedCallers]
22-
[assembly: AssemblyVersion("3.1.2.5")]
22+
[assembly: AssemblyVersion("3.1.2.6")]
2323
[assembly: SecurityRules(SecurityRuleSet.Level1)]

BlogEngine/BlogEngine.Core/Services/Syndication/SyndicationGenerator.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -195,18 +195,6 @@ private static Dictionary<string, string> SupportedMedia
195195
}
196196
}
197197

198-
private static string CommentHash
199-
{
200-
get
201-
{
202-
if (BlogSettings.Instance.ModerationType == BlogSettings.Moderation.Disqus)
203-
return "#disqus_thread";
204-
if (BlogSettings.Instance.ModerationType == BlogSettings.Moderation.Facebook)
205-
return "#facebook_thread";
206-
return "#comment";
207-
}
208-
}
209-
210198
#endregion
211199

212200
#region Public Methods
@@ -524,7 +512,7 @@ private static void WriteAtomEntry(XmlWriter writer, IPublishable publishable)
524512

525513
writer.WriteStartElement("link");
526514
writer.WriteAttributeString("rel", "related");
527-
writer.WriteAttributeString("href", String.Concat(publishable.AbsoluteLink.ToString(), CommentHash));
515+
writer.WriteAttributeString("href", String.Concat(publishable.AbsoluteLink.ToString(), "#comment"));
528516
writer.WriteEndElement();
529517

530518
// ------------------------------------------------------------
@@ -631,7 +619,7 @@ private static void WriteAtomEntry(XmlWriter writer, IPublishable publishable)
631619
"comment",
632620
"http://wellformedweb.org/CommentAPI/",
633621
String.Concat(publishable.AbsoluteLink.ToString(),
634-
CommentHash));
622+
"#comment"));
635623
writer.WriteElementString(
636624
"wfw",
637625
"commentRss",
@@ -724,7 +712,7 @@ private static void WriteRssItem(XmlWriter writer, IPublishable publishable)
724712
{
725713
writer.WriteElementString(
726714
"comments", String.Concat(publishable.AbsoluteLink.ToString(),
727-
CommentHash));
715+
"#comment"));
728716
}
729717

730718
writer.WriteElementString("guid", GetPermaLink(publishable).ToString());
@@ -818,7 +806,7 @@ private static void WriteRssItem(XmlWriter writer, IPublishable publishable)
818806
"comment",
819807
"http://wellformedweb.org/CommentAPI/",
820808
String.Concat(publishable.AbsoluteLink.ToString(),
821-
CommentHash));
809+
"#comment"));
822810
writer.WriteElementString(
823811
"wfw",
824812
"commentRss",

0 commit comments

Comments
 (0)