Beispiel #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 static Blog ToShopifyModel(this StorefrontModel.Blog blog)
        {
            var retVal = new Blog();

            retVal.InjectFrom <NullableAndEnumValueInjecter>(blog);

            if (blog.Articles != null)
            {
                retVal.Articles = new StorefrontPagedList <Article>(blog.Articles.Select(x => x.ToShopifyModel()), blog.Articles, blog.Articles.GetPageUrl);
            }
            return(retVal);
        }
Beispiel #3
0
        public static Blog ToShopifyModel(this StorefrontModel.Blog blog, Storefront.Model.Language language)
        {
            var retVal = new Blog();

            retVal.InjectFrom <NullableAndEnumValueInjecter>(blog);
            retVal.Handle = blog.Name;
            if (blog.Articles != null)
            {
                retVal.Articles = new MutablePagedList <Article>((pageNumber, pageSize) =>
                {
                    var articlesForLanguage = blog.Articles.Where(x => x.Language == language || x.Language.IsInvariant).GroupBy(x => x.Name).Select(x => x.OrderByDescending(y => y.Language).FirstOrDefault());
                    return(new PagedList <Article>(articlesForLanguage.Select(x => x.ToShopifyModel()), pageNumber, pageSize));
                }, blog.Articles.PageNumber, blog.Articles.PageSize);
            }
            return(retVal);
        }
        private Blog LoadBlog(string blogName)
        {
            var context = base.WorkContext;
            var retVal = _contentService.LoadContentItemsByUrl("/blogs/" + blogName + "/default", context.CurrentStore, context.CurrentLanguage, () => new Blog())
                                           .OfType<Blog>().FirstOrDefault();
            if (retVal == null)
            {
                //If default file not found need create manually
                retVal = new Blog();
                retVal.Name = blogName;
                retVal.Title = blogName;
            }
            if(retVal.Title == "default")
            {
                retVal.Title = blogName;
            }
            retVal.Url = "blogs/" + blogName;
            return retVal;

        }
Beispiel #5
0
        public virtual Blog ToLiquidBlog(StorefrontModel.Blog blog, Storefront.Model.Language language)
        {
            var retVal = new Blog();

            retVal.Title = blog.Title;
            retVal.Url   = blog.Url;

            if (blog.Articles != null)
            {
                retVal.Articles = new MutablePagedList <Article>((pageNumber, pageSize, sortInfos) =>
                {
                    //var articlesForLanguage = blog.Articles.Where(x => x.Language == language || x.Language.IsInvariant).GroupBy(x => x.Name).Select(x => x.OrderByDescending(y => y.Language).FirstOrDefault());
                    // ordering generating exception
                    var articlesForLanguage = blog.Articles.GroupBy(x => x.Name).Select(x => x.FindWithLanguage(language)).Where(x => x != null && x.IsPublished);
                    return(new PagedList <Article>(articlesForLanguage.Select(x => x.ToShopifyModel()).OrderByDescending(x => x.CreatedAt).AsQueryable(), pageNumber, pageSize));
                }, blog.Articles.PageNumber, blog.Articles.PageSize);
            }

            retVal.Handle     = blog.Name.Replace(" ", "-").ToLower();
            retVal.Categories = blog.Categories;

            return(retVal);
        }
Beispiel #6
0
        public static Blog ToShopifyModel(this StorefrontModel.Blog blog, Storefront.Model.Language language)
        {
            var retVal = new Blog();

            retVal.InjectFrom <NullableAndEnumValueInjecter>(blog);
            retVal.Handle = blog.Name;

            if (blog.Articles != null)
            {
                retVal.Articles = new MutablePagedList <Article>((pageNumber, pageSize, sortInfos) =>
                {
                    //var articlesForLanguage = blog.Articles.Where(x => x.Language == language || x.Language.IsInvariant).GroupBy(x => x.Name).Select(x => x.OrderByDescending(y => y.Language).FirstOrDefault());
                    // ordering generating exception
                    var articlesForLanguage = blog.Articles.GroupBy(x => x.Name).Select(x => x.FindWithLanguage(language)).Where(x => x != null && x.PublicationStatus != Storefront.Model.StaticContent.ContentPublicationStatus.Private);
                    return(new PagedList <Article>(articlesForLanguage.Select(x => x.ToShopifyModel()).OrderByDescending(x => x.CreatedAt), pageNumber, pageSize));
                }, blog.Articles.PageNumber, blog.Articles.PageSize);
            }

            retVal.Handle     = blog.Name.Replace(" ", "-").ToLower();
            retVal.Categories = blog.Categories;

            return(retVal);
        }
        public virtual Blog ToLiquidBlog(StorefrontModel.Blog blog, Storefront.Model.Language language)
        {
            var factory = ServiceLocator.Current.GetInstance <ShopifyModelFactory>();
            var retVal  = factory.CreateBlog();

            retVal.InjectFrom <NullableAndEnumValueInjecter>(blog);
            retVal.Handle = blog.Name;

            if (blog.Articles != null)
            {
                retVal.Articles = new MutablePagedList <Article>((pageNumber, pageSize, sortInfos) =>
                {
                    //var articlesForLanguage = blog.Articles.Where(x => x.Language == language || x.Language.IsInvariant).GroupBy(x => x.Name).Select(x => x.OrderByDescending(y => y.Language).FirstOrDefault());
                    // ordering generating exception
                    var articlesForLanguage = blog.Articles.GroupBy(x => x.Name).Select(x => x.FindWithLanguage(language)).Where(x => x != null && x.IsPublished);
                    return(new PagedList <Article>(articlesForLanguage.Select(x => x.ToShopifyModel()).OrderByDescending(x => x.CreatedAt), pageNumber, pageSize));
                }, blog.Articles.PageNumber, blog.Articles.PageSize);
            }

            retVal.Handle     = blog.Name.Replace(" ", "-").ToLower();
            retVal.Categories = blog.Categories;

            return(retVal);
        }
        public static Blog ToShopifyModel(this StorefrontModel.Blog blog, Storefront.Model.Language language)
        {
            var converter = ServiceLocator.Current.GetInstance <ShopifyModelConverter>();

            return(converter.ToLiquidBlog(blog, language));
        }
Beispiel #9
0
        public static Blog ToShopifyModel(this StorefrontModel.Blog blog, Storefront.Model.Language language)
        {
            var converter = new ShopifyModelConverter();

            return(converter.ToLiquidBlog(blog, language));
        }