@if (Page.ShowPaging == true) {

@Model.Title

@MarkupHelper.GetDescription(Model.Content, 235, "...")

بیشتر بخوانید »

} else {

@Model.CountApprovedComments(Context) Comments @Categories()
@Html.Raw(Model.Content)
@if (Blog.CurrentPost != null) {
@if (Model.CountApprovedComments(Context) > 0) {

Comments

} @foreach (Comment comment in Model.Comments) { if (comment.IsApproved || !Blog.ModerateComments || Context.User.Identity.IsAuthenticated) { @RenderPage("Comment.cshtml", comment) } }
if (Model.AreCommentsOpen(Context)) { @RenderPage("~/views/CommentForm.cshtml") } }
@helper Categories() { if (Model.Categories.Length > 0) { } } } @functions{ public class MarkupHelper { #region excerpt generation public static string GetDescription(string content, int length = 300, string ommission = "...") { return TruncateHtml(StripTags(content), 235, ommission); } public static string TruncateHtml(string input, int length = 300, string ommission = "...") { if (input == null || input.Length < length) return input; int nextSpace = input.LastIndexOf(" ", length); return string.Format("{0}" + ommission, input.Substring(0, (nextSpace > 0) ? nextSpace : length).Trim()); } public static string StripTags(string markup) { try { StringReader stringReader = new StringReader(markup); System.Xml.XPath.XPathDocument xPathdocument; using (System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(stringReader, new System.Xml.XmlReaderSettings() { ConformanceLevel = System.Xml.ConformanceLevel.Fragment })) { xPathdocument = new System.Xml.XPath.XPathDocument(xmlReader); } return xPathdocument.CreateNavigator().Value; } catch { return string.Empty; } } #endregion } }