Esempio n. 1
0
        public void RawPostWordPressTest()
        {
            var rawPost = new Post()
            {
                Body         = "<b>Markdown Text</b>",
                DateCreated  = DateTime.UtcNow,
                mt_keywords  = "Test,NewPost",
                CustomFields = new CustomField[]
                {
                    new CustomField()
                    {
                        ID    = Guid.NewGuid().ToString(),
                        Key   = "mt_Markdown",
                        Value = "**Markdown Text**"
                    }
                },
                PostID = 0,
                Title  = "Testing a post"
            };

            WeblogInfo weblogInfo = WeblogAddinConfiguration.Current.Weblogs[ConstWordPressWeblogName];

            var wrapper = new WordPressWrapper(weblogInfo.ApiUrl,
                                               weblogInfo.Username,
                                               weblogInfo.Password);

            rawPost.PostID = wrapper.NewPost(rawPost, true);
        }
Esempio n. 2
0
 public LocalJekyllPublisher(WeblogPostMetadata postMetadata,
                             WeblogInfo weblogInfo,
                             string documentFilename)
 {
     PostMetadata     = postMetadata;
     WeblogInfo       = weblogInfo;
     DocumentFilename = documentFilename;
 }
Esempio n. 3
0
        public MediumApiClient(WeblogInfo weblogInfo)
        {
            WeblogInfo        = weblogInfo;
            WeblogInfo.ApiUrl = MediumApiUrl;

            MediumApiUserToken = mmApp.DecryptString(WeblogInfo.AccessToken);

            GetUser();
        }
Esempio n. 4
0
        public MediumTests()
        {
            // create a file with your test account api key
            MediumApiKey = File.ReadAllText(".\\ApiKey.txt");
            if (string.IsNullOrEmpty(MediumApiKey) || MediumApiKey.Contains(" "))
            {
                Assert.IsTrue(false, "Please add a valid Medium integration token into apikey.txt.");
            }

            WeblogInfo = new WeblogInfo
            {
                AccessToken = MediumApiKey,
                Name        = "Markdown Monster Test Blog",
            };
        }
Esempio n. 5
0
        public void GetPostConfigFromMarkdown()
        {
            WeblogInfo weblogInfo = WeblogAddinConfiguration.Current.Weblogs[ConstWeblogName];

            string markdown = MarkdownWithoutPostId;

            var addin = new WeblogAddin.WebLogAddin();
            var meta  = addin.GetPostConfigFromMarkdown(markdown, weblogInfo);

            Console.WriteLine(JsonConvert.SerializeObject(meta, Formatting.Indented));

            Assert.IsTrue(meta.Abstract == "Abstract");
            Assert.IsTrue(meta.Keywords == "Keywords");
            Assert.IsTrue(meta.WeblogName == "WebLogName");
        }
Esempio n. 6
0
        public void GetPostYaml()
        {
            var weblogInfo = new WeblogInfo()
            {
                Name   = "West Wind Web Log",
                ApiUrl = "https://weblog.west-wind.com/metaweblog.ashx",
                BlogId = "1",
            };
            var post = new Post();

            var meta = WeblogPostMetadata.GetPostYamlConfigFromMarkdown(STR_postWithMetaData, post);

            Console.WriteLine(meta.Title);
            Console.WriteLine(meta.Abstract);
            Console.WriteLine(meta.CustomFields.Count);
        }
        public void GetPostTest()
        {
            var weblogInfo = new WeblogInfo
            {
                ApiUrl = STR_JEKYLL_PROJECT_FOLDER,
                Name   = "Jekyll Test Blog"
            };


            var pub = new LocalJekyllPublisher(null, weblogInfo, null);

            var post = pub.GetPost(STR_JEKYLL_POST_ID);

            Assert.IsNotNull(post);
            Assert.IsNotNull(post.Body);
        }
Esempio n. 8
0
        public void GetRecentPosts()
        {
            WeblogInfo weblogInfo = WeblogAddinConfiguration.Current.Weblogs[ConstWeblogName];

            var wrapper = new MetaWeblogWrapper(weblogInfo.ApiUrl,
                                                weblogInfo.Username,
                                                weblogInfo.Password);

            var posts = wrapper.GetRecentPosts(2).ToList();

            Assert.IsTrue(posts.Count == 2);

            foreach (var post in posts)
            {
                Console.WriteLine(post.Title + "  " + post.DateCreated);
            }
        }
        public void PublishTest()
        {
            var webLogInfo = new WeblogInfo
            {
                ApiUrl = STR_JEKYLL_PROJECT_FOLDER,
                Name   = "Jekyll Test Blog"
            };

            var rawMd = System.IO.File.ReadAllText(STR_MM_POST_FILE_NAME);

            var post = new Post();  // filled from meta data but not used here
            var meta = WeblogPostMetadata.GetPostYamlConfigFromMarkdown(rawMd);


            var pub = new LocalJekyllPublisher(meta, webLogInfo, STR_MM_POST_FILE_NAME);

            pub.PublishPost(false);
        }
Esempio n. 10
0
        public void GetRecentPost()
        {
            WeblogInfo weblogInfo = WeblogAddinConfiguration.Current.Weblogs[ConstWeblogName];

            var wrapper = new MetaWeblogWrapper(weblogInfo.ApiUrl,
                                                weblogInfo.Username,
                                                weblogInfo.Password);

            var posts = wrapper.GetRecentPosts(2).ToList();

            Assert.IsTrue(posts.Count == 2);

            var postId = posts[0].PostID;

            var post = wrapper.GetPost(postId.ToString());

            Assert.IsNotNull(post);
            Console.WriteLine(post.Title);

            // markdown
            Console.WriteLine(post.CustomFields?[0].Value);
        }
Esempio n. 11
0
        public void GetCategories()
        {
            WeblogInfo weblogInfo = WeblogAddinConfiguration.Current.Weblogs[ConstWeblogName];

            var wrapper = new MetaWeblogWrapper(weblogInfo.ApiUrl,
                                                weblogInfo.Username,
                                                weblogInfo.Password);

            var categoryStrings = new List <string>();

            var categories = wrapper.GetCategories();

            foreach (var cat in categories)
            {
                categoryStrings.Add(cat.Description);
            }

            Assert.IsTrue(categoryStrings.Count > 0);

            foreach (string cat in categoryStrings)
            {
                Console.WriteLine(cat);
            }
        }
        public void GetPosts()
        {
            var webLogInfo = new WeblogInfo
            {
                ApiUrl = STR_JEKYLL_PROJECT_FOLDER,
                Name   = "Jekyll Test Blog"
            };

            var rawMd = System.IO.File.ReadAllText(STR_MM_POST_FILE_NAME);

            var post = new Post();  // filled from meta data but not used here
            var meta = WeblogPostMetadata.GetPostYamlConfigFromMarkdown(rawMd, post);


            var pub   = new LocalJekyllPublisher(meta, webLogInfo, null);
            var posts = pub.GetRecentPosts(20).ToList();

            Console.WriteLine(posts.Count);

            foreach (var pst in posts)
            {
                Console.WriteLine($"{pst.Title} -  {pst.mt_excerpt}");
            }
        }
 public MetaWebLogWordpressApiClient(WeblogInfo weblogInfo)
 {
     WeblogInfo = weblogInfo;
 }