public PopulatedTemplate(IBlogPost blogPost, HtmlDocument populatedDocument, NavigationButtons buttonsNeeded, string outputDirectory) { BlogPost = blogPost; PopulatedDocument = populatedDocument; ButtonsNeeded = buttonsNeeded; _outputDirectory = outputDirectory; }
public IActionResult BlogPost(string slug) { IBlogPost blogPost = _blogPostService.GetBlogPostForSlug(slug); if (blogPost == null) { return(NotFound()); } string currentUri = Request.GetDisplayUrl(); if (currentUri.StartsWith(Uri.UriSchemeHttp)) { currentUri = Uri.UriSchemeHttps + currentUri.Substring(Uri.UriSchemeHttp.Length); } return(View(new BlogPostViewModel { Title = blogPost.Title, Slug = blogPost.Slug, Description = blogPost.Description, ImageUrl = _blogPostService.ToAbsoluteUrl(blogPost.ImageUrl), ImageDescriptionAlt = blogPost.ImageDescriptionAlt, Url = _blogPostService.ToAbsoluteUrl(blogPost.RelativeUrl), Author = blogPost.Author, CurrentUrl = currentUri, })); }
private static void replaceAllTitles(HtmlDocument template, IBlogPost blogPost) { HtmlNodeCollection titles = template.DocumentNode.SelectNodes(TitleXPath); foreach (HtmlNode title in titles) { title.InnerHtml = blogPost.Metadata.Title; } }
public void Setup() { mockery = new MockRepository(); blogPostMapper = mockery.DynamicMock<IBlogPostMapper>(); post = mockery.DynamicMock<IBlogPost>(); blogPostRepository = mockery.DynamicMock<IBlogPostRepository>(); service = new BlogPostService(blogPostMapper, blogPostRepository); }
public void ApplyChanges(IBlogPost obj) { obj.Content = Content; obj.IsDeleted = false; obj.Summary = Summary; obj.Tags = Tags; obj.Title = Title; obj.IsDeleted = IsDeleted; }
private static void replaceAllDates(HtmlDocument template, IBlogPost blogPost) { HtmlNodeCollection dates = template.DocumentNode.SelectNodes(DateXPath); string dateString = blogPost.Metadata.Date.ToString(); foreach (HtmlNode date in dates) { date.InnerHtml = dateString; } }
/// <summary> /// Gets the posts matching the passed criteria. /// </summary> /// <param name="post">The post containing search criteria.</param> /// <returns> /// IEnumerable of IBlogPost containing results. /// </returns> /// <exception cref="NotImplementedException"></exception> public IEnumerable <IBlogPost> GetPosts(IBlogPost post) { if (post == null) { return(mockPosts); } else { return(mockPosts.Where(x => x.ID == post.ID)); } }
public BlogPostDrop(IPortalLiquidContext portalLiquidContext, IBlogPost post) : base(portalLiquidContext, post.Entity) { if (post == null) { throw new ArgumentNullException("post"); } Post = post; Author = Post.Author != null ? new AuthorDrop(portalLiquidContext, Post.Author) : null; }
public BlogPostViewModel(IBlogPost mdl) { ID = mdl.ID; Content = mdl.Content; CreatedBy = new UserViewModel(mdl.CreatedBy); CreatedOn = mdl.CreatedOn; Summary = mdl.Summary; Tags = mdl.Tags; Title = mdl.Title; IsDeleted = mdl.IsDeleted; }
public MSE.SWE.Interfaces.IBlogPost GetPost(int id) { IBlogPost post = _dal.GetPostList().SingleOrDefault(i => i.ID == id); if (post.IsDeleted == false || IsAdminUser() == true) { return(post); } else { throw new SecurityException(); } }
private void addBlogCSS(HtmlDocument template, IBlogPost blogPost, LayoutType layoutType = LayoutType.Post) { string cssLink = "../../css".AppendPath(OptionsContext.Current.Options.BlogCSSFile); // If we're doing the main page, we don't need to go up any directories if (layoutType == LayoutType.MainPage) { cssLink = "css".AppendPath(OptionsContext.Current.Options.BlogCSSFile); } string linkNodeString = Invariant($"<link rel=\"stylesheet\" type=\"text/css\" href=\"{cssLink}\" />"); HtmlNode headNode = template.DocumentNode.SelectSingleNode(HeadXPath); headNode.InnerHtml = (headNode.InnerHtml + linkNodeString); }
public static TType CopyTo <TType>(this IBlogPost source, TType destination) where TType : IBlogPost { if (destination == null) { throw new ArgumentNullException(nameof(destination)); } destination.BlogPostId = source.BlogPostId; destination.Title = source.Title; destination.Content = source.Content; destination.Created = source.Created; destination.LastUpdated = source.LastUpdated; destination.AuthorId = source.AuthorId; return(destination); }
private PopulatedTemplate createRootIndexPopulatedTemplate(IBlogPost blogPost, int posts) { try { HtmlDocument template = CopyOfTemplate; addBlogCSS(template, blogPost, LayoutType.MainPage); replaceBlogDiv(template, blogPost); replaceAllTitles(template, blogPost); replaceAllDates(template, blogPost); replaceAllFragments(template, LayoutType.MainPage); NavigationButtons buttonsNeeded; // Only two possible cases: // 1. There is only one blog post // 2. This is the first blog post of many // The first blog post should not need next or both navigation buttons. if (posts == 1) { buttonsNeeded = NavigationButtons.None; } else { buttonsNeeded = NavigationButtons.PreviousOnly; } return new PopulatedTemplate(blogPost, template, buttonsNeeded, OptionsContext.Current.Options.OutputDirectory); } catch (Exception e) { ErrorWriterContext.Current.WriteLine(Invariant($"Error creating blog post with title {blogPost.Metadata.Title}.")); ErrorWriterContext.Current.WriteLine(e.ToString()); throw e; } }
public void Save(IBlogPost post) { }
/// <summary> /// Gets one or more Blog Posts from the mock layer. /// </summary> /// <param name="post">Optional Param to specify a single blog post or null for many</param> /// <returns> /// Collection of blog posts matching criteria /// </returns> public IEnumerable <IBlogPost> GetPosts(IBlogPost post = null) => svc.GetPosts(post);
public BlogPostController(IBlogPost repository) { _repository = repository; }
public BlogCommentPolicyReader(IBlogPost blogPost) { _blogPost = blogPost; }
public void AddPost(IBlogPost blogPost) { _dal.AddPost(blogPost); }
public void DeletePost(IBlogPost blogPost) { blogPost.IsDeleted = true; SaveChanges(); //_dal.DeletePost(blogPost); }
private static void replaceBlogDiv(HtmlDocument template, IBlogPost blogPost) { HtmlNode blogDiv = template.DocumentNode.SelectSingleNode(BlogXPath); blogDiv.InnerHtml = blogPost.HTML; }