/// <summary> /// The Syntax Highlighter js plugin requires code in a 'pre' block with a brush assigned. /// If this is contained in the blog content, then the page should load the plugin. /// </summary> private bool PostContainsSyntaxHighlight(BlogPost blogPost) { if (string.IsNullOrWhiteSpace(blogPost.Content)) { return false; } return blogPost.Content.Contains("<pre class=\"brush:"); }
private void SyncPostTags(BlogPost post, string tagsString) { var tagStrings = ParseTags(tagsString); if (post.Tags == null) { post.Tags = new List<Tag>(); } var newPostTags = new List<Tag>(); foreach (var tagString in tagStrings) { var tag = _db.Tags.FirstOrDefault(t => t.Title.Equals(tagString, StringComparison.CurrentCultureIgnoreCase)); if (tag == null) { tag = new Tag { Title = tagString }; _db.Tags.Add(tag); } newPostTags.Add(tag); if (!post.Tags.Any(t => t.Title == tag.Title)) { post.Tags.Add(tag); } } foreach (var tag in post.Tags.ToArray()) { if (!newPostTags.Any(t => t.Title == tag.Title)) { post.Tags.Remove(tag); } } }