Example #1
0
        public static ContentItem GetContentItemFromPath(string path)
        {
            ContentItem retVal = null;
            if (!string.IsNullOrEmpty(path))
            {
                //Blog
                var blogMatch = _blogMatchRegex.Match(path);
                if (blogMatch.Success)
                {
                    var blogName = blogMatch.Groups["blog"].Value;
                    var fileName = Path.GetFileNameWithoutExtension(path);
                    if (fileName.ToLower() == "default")
                    {
                        retVal = new Blog()
                        {
                            Name = blogName,
                        };
                    }
                    else
                    {
                        retVal = new BlogArticle()
                        {
                            BlogName = blogName
                        };
                    }
                }
                else
                {
                    retVal = new ContentPage();
                }
            }

            return retVal;
        }
 public void GetUrl_preserves_dash_separated_values_that_arent_timestamps()
 {
     var contentItem = new ContentPage
     {
         StoragePath = @"/temp/foo-bar-baz-qak-foobar_baz.md",
     };
     contentItem.Permalink = ":title";
     contentItem.LoadContent(string.Empty, null, null);
     Assert.Equal("foo-bar-baz-qak-foobar_baz", contentItem.Url);
 }
 public void GetUrl_returns_strips_timestamp()
 {
     var contentItem = new ContentPage
     {
         StoragePath = @"/temp/2012-01-03-foobar_baz.md",
     };
     contentItem.Permalink = ":title";
     contentItem.LoadContent(string.Empty, null, null);
     Assert.Equal("foobar_baz", contentItem.Url);
 }
 public void GetUrl_returns_file_name_when_no_folder()
 {
     var contentItem = new ContentPage
     {
         StoragePath = @"/foobar_baz.en-us.md",
     };
     contentItem.Permalink = ":title";
     contentItem.LoadContent(string.Empty, null, null);
     Assert.Equal("foobar_baz", contentItem.Url);
 }
 public void GetUrl_returns_folder_and_original_value_when_no_timestamp()
 {
     var contentItem = new ContentPage
     {
         StoragePath = @"/temp/foobar_baz.md",
     };
     contentItem.Permalink = ":folder/:title";
     contentItem.LoadContent(string.Empty, null, null);
     Assert.Equal("temp/foobar_baz", contentItem.Url);
 }
Example #6
0
 //Called from SEO route by page permalink
 public ActionResult GetContentPage(ContentPage page)
 {
     base.WorkContext.CurrentPage = page;
     return View("page", base.WorkContext);
 }
 public void EvaluatePermalink_url_is_well_formatted(string permalink, string expectedUrl, string categories)
 {
     var page = new ContentPage
     {
         Categories = categories == null ? new List<string>() : categories.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(),
         PublishedDate = new DateTime(2015, 03, 09),
         StoragePath = @"/temp/2015-03-09-foobar-baz.md",
         Permalink = permalink
     };
     page.LoadContent(string.Empty, null, null);
     Assert.Equal(expectedUrl, page.Url);
 }