BlogEngine.NET Web 1.5 Akismet
Produced: 5/26/2009 8:16:12 AM
   
Mode:  Differences, With Context, Ignoring Unimportant  
Left base folder: E:\CodeOptimism\BlogEngine.Web 1.5 original  
Right base folder: E:\CodeOptimism\BlogEngine.Web 1.5 Akismet  
   
File: blog.js  
112   = 112  
113         BlogEngine.comments.nameBox.focus();   113         BlogEngine.comments.nameBox.focus();
114     }   114     }
115         ,   115         ,
116     appendComment: function(args, context) {   116     appendComment: function(args, context) {
117         if (context == "comment") {   117         if (context == "comment") {
    -+ 118             var isModerated = false;
      119             if (BlogEngine.comments.moderation) {
      120                 var isModeratedLen = "isModerated".length;
      121                 if (args.substr(0, isModeratedLen) == "isModerated") {
      122                     isModerated = true;
      123                     args = args.substr(isModeratedLen);
      124                 }
      125             }
118             var commentList = BlogEngine.$("commentlist"); = 126             var commentList = BlogEngine.$("commentlist");
119             if (commentList.innerHTML.length < 10)   127             if (commentList.innerHTML.length < 10)
120                 commentList.innerHTML = "<h1 id='comment'>" + BlogEngine.i18n.comments + "</h1>"   128                 commentList.innerHTML = "<h1 id='comment'>" + BlogEngine.i18n.comments + "</h1>"
121     129  
122             // add comment html to the right place   130             // add comment html to the right place
123             var id = BlogEngine.comments.replyToId ? BlogEngine.comments.replyToId.value : '';   131             var id = BlogEngine.comments.replyToId ? BlogEngine.comments.replyToId.value : '';
 
133             // reset form values = 141             // reset form values
134             BlogEngine.comments.contentBox.value = "";   142             BlogEngine.comments.contentBox.value = "";
135             BlogEngine.comments.contentBox = BlogEngine.$(BlogEngine.comments.contentBox.id);   143             BlogEngine.comments.contentBox = BlogEngine.$(BlogEngine.comments.contentBox.id);
136             BlogEngine.$("ajaxLoader").style.display = "none";   144             BlogEngine.$("ajaxLoader").style.display = "none";
137             BlogEngine.$("status").className = "success";   145             BlogEngine.$("status").className = "success";
138     146  
139             if (!BlogEngine.comments.moderation) <> 147             if (isModerated)
140                 BlogEngine.$("status").innerHTML = BlogEngine.i18n.commentWasSaved;   148                 BlogEngine.$("status").innerHTML = BlogEngine.i18n.commentWaitingModeration;
141             else = 149             else
142                 BlogEngine.$("status").innerHTML = BlogEngine.i18n.commentWaitingModeration; <> 150                 BlogEngine.$("status").innerHTML = BlogEngine.i18n.commentWasSaved;
143   = 151  
144             BlogEngine.composeComment();   152             BlogEngine.composeComment();
145     153  
146             // move form back to bottom   154             // move form back to bottom
147             var commentForm = BlogEngine.$('comment-form');   155             var commentForm = BlogEngine.$('comment-form');
148             commentList.appendChild(commentForm);   156             commentList.appendChild(commentForm);
   
File: User controls\CommentView.ascx.cs  
13 using System.Web.Security; = 13 using System.Web.Security;
14 using System.Web.UI;   14 using System.Web.UI;
15 using System.Web.UI.WebControls;   15 using System.Web.UI.WebControls;
16 using System.Data;   16 using System.Data;
17 using BlogEngine.Core;   17 using BlogEngine.Core;
18 using BlogEngine.Core.Web.Controls;   18 using BlogEngine.Core.Web.Controls;
    -+ 19 using Joel.Net;
19   = 20  
20 #endregion   21 #endregion
21     22  
22 public partial class User_controls_CommentView : UserControl, ICallbackEventHandler   23 public partial class User_controls_CommentView : UserControl, ICallbackEventHandler
23 {   24 {
    -+ 25     static readonly Akismet akismet = new Akismet("your Akismet api key here", "http://yoursiteurl.com", "Joel.Net's Akismet API/1.0");
24   = 26  
25     #region ICallbackEventHandler Members   27     #region ICallbackEventHandler Members
26     28  
27     private string _Callback;   29     private string _Callback;
28     30  
29     /// <summary>   31     /// <summary>
 
68         comment.Email = email; = 70         comment.Email = email;
69         comment.Content = Server.HtmlEncode(content);   71         comment.Content = Server.HtmlEncode(content);
70         comment.IP = Request.UserHostAddress;   72         comment.IP = Request.UserHostAddress;
71         comment.Country = country;   73         comment.Country = country;
72         comment.DateCreated = DateTime.Now;   74         comment.DateCreated = DateTime.Now;
73         comment.Parent = Post;   75         comment.Parent = Post;
74         comment.IsApproved = !BlogSettings.Instance.EnableCommentsModeration; +-    
75   = 76  
76         if (Page.User.Identity.IsAuthenticated)   77         if (Page.User.Identity.IsAuthenticated)
77             comment.IsApproved = true;   78             comment.IsApproved = true;
78     79  
79         if (website.Trim().Length > 0)   80         if (website.Trim().Length > 0)
80         {   81         {
81             if (!website.ToLowerInvariant().Contains("://"))   82             if (!website.ToLowerInvariant().Contains("://"))
82                 website = "http://" + website;   83                 website = "http://" + website;
83     84  
84             Uri url;   85             Uri url;
85             if (Uri.TryCreate(website, UriKind.Absolute, out url))   86             if (Uri.TryCreate(website, UriKind.Absolute, out url))
86                 comment.Website = url;   87                 comment.Website = url;
    -+ 88         }
      89         if (BlogSettings.Instance.EnableCommentsModeration)
      90         {
      91             bool isSpam = akismet.CommentCheck(comment, Request, Post);
      92             comment.IsApproved = !isSpam;
      93             if (isSpam)
      94                 _Callback = "isModerated";
      95         }
      96         else
      97         {
      98             comment.IsApproved = true;
87         } = 99         }
88     100  
89         if (notify && !Post.NotificationEmails.Contains(email))   101         if (notify && !Post.NotificationEmails.Contains(email))
90             Post.NotificationEmails.Add(email);   102             Post.NotificationEmails.Add(email);
91         else if (!notify && Post.NotificationEmails.Contains(email))   103         else if (!notify && Post.NotificationEmails.Contains(email))
92             Post.NotificationEmails.Remove(email);   104             Post.NotificationEmails.Remove(email);
 
103         control.Comment = comment; = 115         control.Comment = comment;
104         control.Post = Post;   116         control.Post = Post;
105     117  
106         using (StringWriter sw = new StringWriter())   118         using (StringWriter sw = new StringWriter())
107         {   119         {
108             control.RenderControl(new HtmlTextWriter(sw));   120             control.RenderControl(new HtmlTextWriter(sw));
109             _Callback = sw.ToString(); <> 121             _Callback += sw.ToString();
110         } = 122         }
111     }   123     }
112     124  
113     #endregion   125     #endregion
114     126  
115     protected void Page_Load(object sender, EventArgs e)   127     protected void Page_Load(object sender, EventArgs e)
 
118             Response.Redirect(Utils.RelativeWebRoot); = 130             Response.Redirect(Utils.RelativeWebRoot);
119     131  
120         if (!Page.IsPostBack && !Page.IsCallback)   132         if (!Page.IsPostBack && !Page.IsCallback)
121         {   133         {
122             if (Page.User.Identity.IsAuthenticated)   134             if (Page.User.Identity.IsAuthenticated)
123             {   135             {
    -+ 136                 if (!string.IsNullOrEmpty(Request.QueryString["spamcomment"]))
      137                     DeleteComment(true);
      138                 if (!string.IsNullOrEmpty(Request.QueryString["hamcomment"]))
      139                     ApproveComment(true);
124                 if (Request.QueryString["deletecomment"] != null) = 140                 if (Request.QueryString["deletecomment"] != null)
125                     DeleteComment(); <> 141                     DeleteComment(false);
126   = 142  
127                 if (Request.QueryString["deletecommentandchildren"] != null)   143                 if (Request.QueryString["deletecommentandchildren"] != null)
128                     DeleteCommentAndChildren();   144                     DeleteCommentAndChildren();
129     145  
130                 if (!string.IsNullOrEmpty(Request.QueryString["approvecomment"]))   146                 if (!string.IsNullOrEmpty(Request.QueryString["approvecomment"]))
131                     ApproveComment(); <> 147                     ApproveComment(false);
132   = 148  
133                 if (!string.IsNullOrEmpty(Request.QueryString["approveallcomments"]))   149                 if (!string.IsNullOrEmpty(Request.QueryString["approveallcomments"]))
134                     ApproveAllComments();   150                     ApproveAllComments();
135             }   151             }
136     152  
137             string theme = BlogSettings.Instance.Theme;   153             string theme = BlogSettings.Instance.Theme;
 
224   = 240  
225                 phComments.Controls.Add(control);   241                 phComments.Controls.Add(control);
226             }   242             }
227         }   243         }
228     }   244     }
229     245  
230     private void ApproveComment() <> 246     private void ApproveComment(bool isHam)
231     { = 247     {
232         foreach (Comment comment in Post.NotApprovedComments)   248         foreach (Comment comment in Post.NotApprovedComments)
233         {   249         {
    <> 250             var queryString = isHam ? "hamcomment" : "approvecomment";
234             if (comment.Id == new Guid(Request.QueryString["approvecomment"]))   251             if (comment.Id == new Guid(Request.QueryString[queryString]))
235             { = 252             {
    -+ 253                 if (isHam)
      254                     akismet.SubmitHam(comment, Request, Post);
236                 Post.ApproveComment(comment); = 255                 Post.ApproveComment(comment);
237     256  
238                 int index = Request.RawUrl.IndexOf("?");   257                 int index = Request.RawUrl.IndexOf("?");
239                 string url = Request.RawUrl.Substring(0, index);   258                 string url = Request.RawUrl.Substring(0, index);
240                 Response.Redirect(url, true);   259                 Response.Redirect(url, true);
241             }   260             }
 
249   = 268  
250         int index = Request.RawUrl.IndexOf("?");   269         int index = Request.RawUrl.IndexOf("?");
251         string url = Request.RawUrl.Substring(0, index);   270         string url = Request.RawUrl.Substring(0, index);
252         Response.Redirect(url, true);   271         Response.Redirect(url, true);
253     }   272     }
254     273  
255     private void DeleteComment() <> 274     private void DeleteComment(bool isSpam)
256     { = 275     {
257         foreach (Comment comment in Post.Comments)   276         foreach (Comment comment in Post.Comments)
258         {   277         {
    <> 278             var queryString = isSpam ? "spamcomment" : "deletecomment";
259             if (comment.Id == new Guid(Request.QueryString["deletecomment"]))   279             if (comment.Id == new Guid(Request.QueryString[queryString]))
260             { = 280             {
    -+ 281                 if (isSpam)
      282                     akismet.SubmitSpam(comment, Request, Post);
261                 Post.RemoveComment(comment); = 283                 Post.RemoveComment(comment);
262     284  
263                 int index = Request.RawUrl.IndexOf("?");   285                 int index = Request.RawUrl.IndexOf("?");
264                 string url = Request.RawUrl.Substring(0, index) + "#comment";   286                 string url = Request.RawUrl.Substring(0, index) + "#comment";
265                 Response.Redirect(url, true);   287                 Response.Redirect(url, true);
266             }   288             }
   
File: App_GlobalResources\labels.resx  
148     <value>Approve all Post Comments</value> = 148     <value>Approve all Post Comments</value>
149   </data>   149   </data>
150   <data name="archive" xml:space="preserve">   150   <data name="archive" xml:space="preserve">
151     <value>Archive</value>   151     <value>Archive</value>
152   </data>   152   </data>
153   <data name="areYouSure" xml:space="preserve">   153   <data name="areYouSure" xml:space="preserve">
154     <value>Are you sure you want to {0} {1}?</value> <> 154     <value>Are you sure you want to {0} {1}</value>
155   </data> = 155   </data>
156   <data name="attachFile" xml:space="preserve">   156   <data name="attachFile" xml:space="preserve">
157     <value>Attach a file</value>   157     <value>Attach a file</value>
158   </data>   158   </data>
159   <data name="author" xml:space="preserve">   159   <data name="author" xml:space="preserve">
160     <value>Author</value>   160     <value>Author</value>
 
202     <value>Comments</value> = 202     <value>Comments</value>
203   </data>   203   </data>
204   <data name="commentsAreClosed" xml:space="preserve">   204   <data name="commentsAreClosed" xml:space="preserve">
205     <value>Comments are closed</value>   205     <value>Comments are closed</value>
206   </data>   206   </data>
207   <data name="commentWasSaved" xml:space="preserve">   207   <data name="commentWasSaved" xml:space="preserve">
208     <value>The comment was saved. Thank you for the feedback</value> <> 208     <value>The comment was saved. Thank you for the feedback.</value>
209   </data> = 209   </data>
210   <data name="contact" xml:space="preserve">   210   <data name="contact" xml:space="preserve">
211     <value>Contact</value>   211     <value>Contact</value>
212   </data>   212   </data>
213   <data name="contactForm" xml:space="preserve">   213   <data name="contactForm" xml:space="preserve">
214     <value>Contact form</value>   214     <value>Contact form</value>
 
689     <value>Profile</value> = 689     <value>Profile</value>
690   </data>   690   </data>
691   <data name="calendar" xml:space="preserve">   691   <data name="calendar" xml:space="preserve">
692     <value>Calendar</value>   692     <value>Calendar</value>
693   </data>   693   </data>
694   <data name="commentWaitingModeration" xml:space="preserve">   694   <data name="commentWaitingModeration" xml:space="preserve">
695     <value>Thank you for the feedback. The comment is now awaiting moderation</value> <> 695     <value>Thank you for the feedback. The comment is now awaiting moderation.</value>
696   </data> = 696   </data>
697   <data name="requireSslForMetaWeblogApi" xml:space="preserve">   697   <data name="requireSslForMetaWeblogApi" xml:space="preserve">
698     <value>Require SSL for MetaWeblog API</value>   698     <value>Require SSL for MetaWeblog API</value>
699   </data>   699   </data>
700   <data name="requireSslForMetaWeblogApiDescription" xml:space="preserve">   700   <data name="requireSslForMetaWeblogApiDescription" xml:space="preserve">
701     <value>Enforce the use of SSL when communicating with the MetaWeblog API</value>   701     <value>Enforce the use of SSL when communicating with the MetaWeblog API</value>
 
760   <data name="cancelReply" xml:space="preserve"> = 760   <data name="cancelReply" xml:space="preserve">
761     <value>Cancel reply to comment</value>   761     <value>Cancel reply to comment</value>
762   </data>   762   </data>
763   <data name="numberOfCharacters" xml:space="preserve">   763   <data name="numberOfCharacters" xml:space="preserve">
764     <value>Number of characters</value>   764     <value>Number of characters</value>
765   </data>   765   </data>
    -+ 766   <data name="areYouSureHam" xml:space="preserve">
      767     <value>Are you sure you want to submit this to Akismet as a false positive</value>
      768   </data>
      769   <data name="areYouSureSpam" xml:space="preserve">
      770     <value>Are you sure you want to submit this to Akismet as spam</value>
      771   </data>
      772   <data name="ham" xml:space="preserve">
      773     <value>Ham</value>
      774   </data>
      775   <data name="spam" xml:space="preserve">
      776     <value>Spam</value>
      777   </data>
766 </root> = 778 </root>
   
File: App_Code\Extensions\SendCommentMail.cs  
48             mail.To.Add(BlogSettings.Instance.Email); = 48             mail.To.Add(BlogSettings.Instance.Email);
49             mail.Subject = BlogSettings.Instance.EmailSubjectPrefix + subject + post.Title;   49             mail.Subject = BlogSettings.Instance.EmailSubjectPrefix + subject + post.Title;
50             mail.Body = "<div style=\"font: 11px verdana, arial\">";   50             mail.Body = "<div style=\"font: 11px verdana, arial\">";
51             mail.Body += body.Replace(Environment.NewLine, "<br />") + "<br /><br />";   51             mail.Body += body.Replace(Environment.NewLine, "<br />") + "<br /><br />";
52             mail.Body += string.Format("<strong>{0}</strong>: <a href=\"{1}\">{2}</a><br /><br />", Resources.labels.post, post.PermaLink + "#id_" + comment.Id, post.Title);   52             mail.Body += string.Format("<strong>{0}</strong>: <a href=\"{1}\">{2}</a><br /><br />", Resources.labels.post, post.PermaLink + "#id_" + comment.Id, post.Title);
53     53  
    -+ 54             if (BlogSettings.Instance.EnableCommentsModeration)
      55             {
      56                 if (comment.IsApproved)
      57                 {
      58                     string spamLink = post.AbsoluteLink + "?spamcomment=" + comment.Id;
      59                     mail.Body += string.Format(" | <a href=\"{0}\">{1}</a> | ", spamLink, Resources.labels.spam);
      60                 }
      61                 else
      62                 {
      63                     string hamLink = post.AbsoluteLink + "?hamcomment=" + comment.Id;
      64                     mail.Body += string.Format(" | <a href=\"{0}\">{1}</a> | ", hamLink, Resources.labels.ham);
      65                 }
      66             }
54             string deleteLink = post.AbsoluteLink + "?deletecomment=" + comment.Id; = 67             string deleteLink = post.AbsoluteLink + "?deletecomment=" + comment.Id;
55             mail.Body += string.Format("<a href=\"{0}\">{1}</a>", deleteLink, Resources.labels.delete);   68             mail.Body += string.Format("<a href=\"{0}\">{1}</a>", deleteLink, Resources.labels.delete);
56     69  
57             if (BlogSettings.Instance.EnableCommentsModeration) <> 70             if (BlogSettings.Instance.EnableCommentsModeration && !comment.IsApproved)
58             { = 71             {
59                 string approveLink = post.AbsoluteLink + "?approvecomment=" + comment.Id;   72                 string approveLink = post.AbsoluteLink + "?approvecomment=" + comment.Id;
60                 mail.Body += string.Format(" | <a href=\"{0}\">{1}</a>", approveLink, Resources.labels.approve);   73                 mail.Body += string.Format(" | <a href=\"{0}\">{1}</a>", approveLink, Resources.labels.approve);
61             }   74             }
62     75  
63             mail.Body += "<br />_______________________________________________________________________________<br />";   76             mail.Body += "<br />_______________________________________________________________________________<br />";
   
File: App_Data\settings.xml  
64   <language>en-US</language> = 64   <language>en-US</language>
65   <enablereferrertracking>False</enablereferrertracking>   65   <enablereferrertracking>False</enablereferrertracking>
66   <enablecontactattachments>True</enablecontactattachments>   66   <enablecontactattachments>True</enablecontactattachments>
67   <blogrollupdateminutes>60</blogrollupdateminutes>   67   <blogrollupdateminutes>60</blogrollupdateminutes>
68   <culture>Auto</culture>   68   <culture>Auto</culture>
69   <sendmailoncomment>True</sendmailoncomment>   69   <sendmailoncomment>True</sendmailoncomment>
70   <enablecommentsmoderation>False</enablecommentsmoderation> <> 70   <enablecommentsmoderation>True</enablecommentsmoderation>
71   <enablehttpcompression>True</enablehttpcompression> = 71   <enablehttpcompression>True</enablehttpcompression>
72 </settings>   72 </settings>