本文整理汇总了C#中BlogEngine.Core.ServingEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# ServingEventArgs类的具体用法?C# ServingEventArgs怎么用?C# ServingEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServingEventArgs类属于BlogEngine.Core命名空间,在下文中一共展示了ServingEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddMoreLink
/// <summary>
/// Replaces the [more] string with a hyperlink to the full post.
/// </summary>
private static void AddMoreLink(object sender, ServingEventArgs e)
{
Post post = (Post)sender;
int index = e.Body.IndexOf("[more]");
string link = "<a class=\"more\" href=\"" + post.RelativeLink + "#continue\">" + Resources.labels.more + "...</a>";
e.Body = e.Body.Substring(0, index) + link;
}
示例2: PostCommentServing
/// <summary>
/// Handles the CommentServing event of the Post control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="BlogEngine.Core.ServingEventArgs"/> instance containing the event data.</param>
private static void PostCommentServing(object sender, ServingEventArgs e)
{
if (!ExtensionManager.ExtensionEnabled("Smilies"))
return;
if (string.IsNullOrEmpty(e.Body))
return;
e.Body = e.Body.Replace("(H)", Convert("cool", "Cool"));
e.Body = e.Body.Replace(":'(", Convert("cry", "Cry"));
e.Body = e.Body.Replace(":$", Convert("embarassed", "Embarassed"));
e.Body = e.Body.Replace(":|", Convert("foot-in-mouth", "Foot"));
e.Body = e.Body.Replace(":(", Convert("frown", "Frown"));
e.Body = e.Body.Replace("(A)", Convert("innocent", "Innocent"));
e.Body = e.Body.Replace("(K)", Convert("kiss", "Kiss"));
e.Body = e.Body.Replace(":D", Convert("laughing", "Laughing"));
e.Body = e.Body.Replace("($)", Convert("money-mouth", "Money"));
e.Body = e.Body.Replace(":-#", Convert("sealed", "Sealed"));
e.Body = e.Body.Replace(":)", Convert("smile", "Smile"));
e.Body = e.Body.Replace(":-)", Convert("smile", "Smile"));
e.Body = e.Body.Replace(":-O", Convert("surprised", "Surprised"));
e.Body = e.Body.Replace(":P", Convert("tongue-out", "Tong"));
e.Body = e.Body.Replace("*-)", Convert("undecided", "Undecided"));
e.Body = e.Body.Replace(";-)", Convert("wink", "Wink"));
e.Body = e.Body.Replace("8o|", Convert("yell", "Yell"));
}
示例3: Post_Serving
private void Post_Serving(object sender, ServingEventArgs e)
{
if (e.Location != ServingLocation.PostList && e.Location != ServingLocation.SinglePost)
{
body.Attributes.Add("class", "altbg");
}
}
示例4: Post_CommentServing
/// <summary>
/// The event handler that is triggered every time a comment is served to a client.
/// </summary>
private static void Post_CommentServing(object sender, ServingEventArgs e)
{
if (string.IsNullOrEmpty(e.Body))
return;
e.Body = regex.Replace(e.Body, new MatchEvaluator(ResolveLinks.Evaluator));
}
示例5: ServePage
/// <summary>
/// Serves the page to the containing DIV tag on the page.
/// </summary>
/// <param name="id">
/// The id of the page to serve.
/// </param>
private void ServePage(Guid id)
{
var pg = this.Page;
if (pg == null || (!pg.IsVisible))
{
this.Response.Redirect(string.Format("{0}error404.aspx", Utils.RelativeWebRoot), true);
return; // WLF: ReSharper is stupid and doesn't know that redirect returns this method.... or does it not...?
}
this.h1Title.InnerHtml = System.Web.HttpContext.Current.Server.HtmlEncode(pg.Title);
var arg = new ServingEventArgs(pg.Content, ServingLocation.SinglePage);
BlogEngine.Core.Page.OnServing(pg, arg);
if (arg.Cancel)
{
this.Response.Redirect("error404.aspx", true);
}
if (arg.Body.Contains("[usercontrol", StringComparison.OrdinalIgnoreCase))
{
Utils.InjectUserControls(this.divText, arg.Body);
// this.InjectUserControls(arg.Body);
}
else
{
this.divText.InnerHtml = arg.Body;
}
}
示例6: Post_Serving
void Post_Serving(object sender, ServingEventArgs e)
{
// [gist id=1234]
e.Body = Regex.Replace(e.Body, "\\[gist\\s[^\\]]*id=([\\da-fA-F]+)[^\\]]*\\]", "<script src=\"https://gist.github.com/$1.js\"></script>");
// [gist]1234[/gist]
e.Body = Regex.Replace(e.Body, "\\[gist\\]([\\da-fA-F]+)\\[\\/gist\\]", "<script src=\"https://gist.github.com/$1.js\"></script>");
e.Body = Regex.Replace(e.Body, "(\\n|<(br|p)\\s*/?>)\\s*https://gist\\.github\\.com/(\\w+/)?(\\d+)/?\\s*(\\n|<(br|p)\\s*/?>|</p>|</li>)", "<script src=\"https://gist.github.com/$4.js\"></script>");
e.Body = Regex.Replace(e.Body, "\\[gist\\s+https://gist\\.github\\.com/(\\w+/)?(\\d+)/?\\s*\\]", "<script src=\"https://gist.github.com/$2.js\"></script>");
}
示例7: PostCommentServing
/// <summary>
/// Handles the CommentServing event of the Post control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="BlogEngine.Core.ServingEventArgs"/> instance containing the event data.</param>
private static void PostCommentServing(object sender, ServingEventArgs e)
{
if (string.IsNullOrEmpty(e.Body))
{
return;
}
e.Body = LinkRegex.Replace(e.Body, new MatchEvaluator(Evaluator));
}
示例8: GetPostExcerpt
static string GetPostExcerpt(ServingEventArgs e, string moreLink)
{
e.Body = Utils.StripHtml(e.Body);
if (e.Body.Length > postLength)
return e.Body.Substring(0, postLength) + "... " + moreLink;
return e.Body;
}
示例9: PostCommentServing
/// <summary>
/// Handles the CommentServing event of the Post control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="BlogEngine.Core.ServingEventArgs"/> instance containing the event data.</param>
private static void PostCommentServing(object sender, ServingEventArgs e)
{
if (!ExtensionManager.ExtensionEnabled("ResolveLinks"))
return;
if (string.IsNullOrEmpty(e.Body))
return;
e.Body = LinkRegex.Replace(e.Body, new MatchEvaluator(Evaluator));
}
示例10: InsertCopyCodeLink
private void InsertCopyCodeLink( ServingEventArgs e)
{
if( !string.IsNullOrEmpty(e.Body) )
{
//### find code-div
string postID = Guid.NewGuid().ToString().Replace( "{", "" ).Replace( "}", "" ).Replace( "-", "" );
string toFind = "<div class=\"csharpcode-wrapper\">";
int index = e.Body.IndexOf(toFind);
while( index != -1 )
{
//### grab code out of code-div
int end = e.Body.IndexOf( "</div>", index ); //### the first </div> should be the end of "csharpcode"
end = e.Body.IndexOf( "</div>", end ); //### the next </div> should be the end of "csharpcode-wrapper"
string code = e.Body.Substring(index, end - index);
//### parse code out of code-div
int codeStart = code.IndexOf("<pre ");
int codeEnd = code.LastIndexOf("</pre>") + 6;
code = code.Substring(codeStart, codeEnd - codeStart);
code = Regex.Replace( code, @"<(.|\n)*?>", string.Empty ); //### strip html
code = code.Replace( " ", "" ); //### remove unnecessary  s from the blank lines
code = code.Replace( " ", " " ); //### convert s to spaces
code = Regex.Replace( code, @"^(\s*)(\d+): ", "" ); //### remove line numbers on first line
code = Regex.Replace( code, @"(\n)(\s*)(\d+): ", "\n" ); //### remove line numbers on subsequent lines
//### create copy link
string insertScript = @"
<script type=""text/javascript"">
var [email protected] = CopyToClipboard_Strip('@CODE');
</script>";
string insertDiv = @"<div class=""CopyToClipboard"" style=""@STYLE""><div><a href=""javascript:void(0);"" onclick=""CopyToClipboard_ViewPlain([email protected]);"">@POPUPTEXT</a> | <a href=""javascript:void(0);"" onclick=""CopyToClipboard_Copy([email protected]);"">@COPYTEXT</a></div></div>";
//### set values for copy link and insert above/below code
string insert = insertDiv + OutputCommonMethods() + insertScript;
insert = insert.Replace( "@STYLE", settings.GetSingleValue("style") );
insert = insert.Replace( "@POPUPTEXT", settings.GetSingleValue("popupText") );
insert = insert.Replace( "@COPYTEXT", settings.GetSingleValue("copyText") );
insert = insert.Replace( "@INDEX", postID + "_" + index.ToString() ); //### use index of code-div as a unique ID to allow multiple code-divs on this post
insert = insert.Replace( "@CODE", code.Replace( "\\", "\\\\" ).Replace( "'", "\\'" ).Replace( "\r\n", "\\r\\n" ).Replace( "\\r\\n\\r\\n\\r\\n", "\\r\\n" ) );
if( settings.GetSingleValue("aboveBelow").ToLower() == "above" )
e.Body = e.Body.Insert( index, insert );
else
e.Body = e.Body.Insert( e.Body.IndexOf( "</div>", end + 1 ) + 6, insert );
//### prep index to find next code-div
index = index + insert.Length + 1; //### ensure we don't find this same code-div again
if( index > e.Body.Length ) break;
index = e.Body.IndexOf( toFind, index ); //### find any other code divs
}
}
}
示例11: PrepareFullPost
/// <summary>
/// Replaces the [more] string on the full post page.
/// </summary>
private static void PrepareFullPost(ServingEventArgs e)
{
HttpRequest request = HttpContext.Current.Request;
if (request.UrlReferrer == null || request.UrlReferrer.Host != request.Url.Host)
{
e.Body = e.Body.Replace("[more]", string.Empty);
}
else
{
e.Body = e.Body.Replace("[more]", "<span id=\"continue\"></span>");
}
}
示例12: PostServing
private static void PostServing(object sender, ServingEventArgs e)
{
if (e.Body.Contains("[more]"))
return;
if (e.Location == ServingLocation.PostList)
{
var post = (Post)sender;
string moreLink = string.Format("<a class=\"more\" href=\"{0}#continue\">{1}</a>", post.RelativeLink, labels.more);
//e.Body = GetPostPicture(e) + GetPostExcerpt(e, moreLink);
}
}
示例13: Post_CommentAdded
private static void Post_CommentAdded(object sender, EventArgs e)
{
Post post = (Post)((Comment)sender).Parent;
if (post != null && BlogSettings.Instance.SendMailOnComment && !Thread.CurrentPrincipal.Identity.IsAuthenticated)
{
Comment comment = post.Comments[post.Comments.Count - 1];
// Trackback and pingback comments don't have a '@' symbol in the e-mail field.
string from = comment.Email.Contains("@") ? comment.Email : BlogSettings.Instance.Email;
string subject = " comment on ";
if (comment.Email == "trackback")
subject = " trackback on ";
else if (comment.Email == "pingback")
subject = " pingback on ";
ServingEventArgs args = new ServingEventArgs(comment.Content, ServingLocation.Email);
Comment.OnServing(comment, args);
string body = args.Body;
MailMessage mail = new MailMessage();
mail.From = new MailAddress(from, HttpUtility.HtmlDecode(comment.Author));
mail.To.Add(BlogSettings.Instance.Email);
mail.Subject = BlogSettings.Instance.EmailSubjectPrefix + subject + post.Title;
mail.Body = "<div style=\"font: 11px verdana, arial\">";
mail.Body += body.Replace(Environment.NewLine, "<br />") + "<br /><br />";
mail.Body += string.Format("<strong>{0}</strong>: <a href=\"{1}\">{2}</a><br /><br />", Resources.labels.post, post.PermaLink + "#id_" + comment.Id, post.Title);
mail.Body += "_______________________________________________________________________________<br />";
mail.Body += "<h3>Author information</h3>";
mail.Body += "<div style=\"font-size:10px;line-height:16px\">";
mail.Body += "<strong>Name:</strong> " + comment.Author + "<br />";
mail.Body += "<strong>E-mail:</strong> " + comment.Email + "<br />";
mail.Body += string.Format("<strong>Website:</strong> <a href=\"{0}\">{0}</a><br />", comment.Website);
if (comment.Country != null)
mail.Body += "<strong>Country code:</strong> " + comment.Country.ToUpperInvariant() + "<br />";
if (HttpContext.Current != null)
{
mail.Body += "<strong>IP address:</strong> " + HttpContext.Current.Request.UserHostAddress + "<br />";
mail.Body += string.Format("<strong>Referrer:</strong> <a href=\"{0}\">{0}</a><br />", HttpContext.Current.Request.UrlReferrer);
mail.Body += "<strong>User-agent:</strong> " + HttpContext.Current.Request.UserAgent;
}
mail.Body += "</div>";
mail.Body += "</div>";
Utils.SendMailMessageAsync(mail);
}
}
示例14: Post_Serving
void Post_Serving(object sender, ServingEventArgs e)
{
if (e.Location == ServingLocation.Feed) return;
bool ShowPostList = Convert.ToBoolean(_extensionSettings.GetSingleValue("ShowPostList"));
if (e.Location == ServingLocation.PostList && !ShowPostList) return;
Post post = sender as Post;
ButtonSettings bSettings = new ButtonSettings();
StringBuilder sBuild = new StringBuilder();
sBuild.AppendLine("<div class=\"FacebookLike\">");
string likeScript = string.Format("<iframe src=\"http://www.facebook.com/plugins/like.php?href={0}&layout={1}&show_faces={2}&width={3}&action={4}&font&colorscheme={5}&height=80\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:450px; height:80px;\" allowTransparency=\"true\"></iframe>",
post.AbsoluteLink.AbsoluteUri, bSettings.Layout, bSettings.ShowFaces, bSettings.Width, bSettings.Action, bSettings.ColorScheme);
sBuild.AppendLine(likeScript);
sBuild.AppendLine("</div>");
e.Body += sBuild.ToString();
}
示例15: Post_Serving
/// <summary>
/// Handles the Post.Serving event to take care of the [more] keyword.
/// </summary>
private static void Post_Serving(object sender, ServingEventArgs e)
{
if (!e.Body.Contains("[more]"))
return;
if (e.Location == ServingLocation.PostList)
{
AddMoreLink(sender, e);
}
else if (e.Location == ServingLocation.SinglePost)
{
PrepareFullPost(e);
}
else if (e.Location == ServingLocation.Feed)
{
e.Body = e.Body.Replace("[more]", string.Empty);
}
}