예제 #1
0
        public void RunActions()
        {
            blogServer.Initialize(Server, Username, Password);

            var pipeline = pipelineFactory.Build();
            var files    = fileSystem.FindFiles("*.md");

            foreach (var file in files)
            {
                var post = new BlogPost(file, fileSystem);
                var html = Markdown.ToHtml(post.GetContent(), pipeline);

                var newName = fileSystem.ChangeExtension(file, ".html");
                fileSystem.WriteText(newName, html);

                var response = (BlogPostResponse)null;
                if (post.PostId < 1)
                {
                    response = blogServer.AddPost(post.PublishDate, html, post.Title, slug: null);
                }
                else
                {
                    response = blogServer.UpdatePost(post.PostId, html, post.Title);
                }

                post.PostId = response.Id;
                post.Link   = response.Permalink;
                post.SaveContent();
            }
        }
예제 #2
0
        public void CanGetContent()
        {
            var content = "are we in trouble now?";
            var fs      = new TestFileSystem(textContent: content);

            var post     = new BlogPost("blog.md", fs);
            var markdown = post.GetContent();

            Assert.Equal(content, markdown);
        }