public BlogPostPart Get(BlogPart blogPart, string slug, VersionOptions versionOptions) { var postPath = blogPart.As<IRoutableAspect>().GetChildPath(slug); return _contentManager.Query(versionOptions, "BlogPost").Join<RoutePartRecord>().Where(rr => rr.Path == postPath). Join<CommonPartRecord>().Where(cr => cr.Container == blogPart.Record.ContentItemRecord).List(). SingleOrDefault().As<BlogPostPart>(); }
public IEnumerable<BlogPostPart> Get(BlogPart blogPart, int skip, int count, VersionOptions versionOptions) { return GetBlogQuery(blogPart, versionOptions) .Slice(skip, count) .ToList() .Select(ci => ci.As<BlogPostPart>()); }
public IEnumerable<KeyValuePair<ArchiveData, int>> GetArchives(BlogPart blogPart) { var query = from bar in _blogArchiveRepository.Table where bar.BlogPart.Id == blogPart.Id orderby bar.Year descending, bar.Month descending select bar; return query.ToList().Select( bar => new KeyValuePair<ArchiveData, int>(new ArchiveData(string.Format("{0}/{1}", bar.Year, bar.Month)), bar.PostCount)); }
public static void Register(this IFeedManager feedManager, BlogPart blogPart, string blogTitle) { if (String.IsNullOrWhiteSpace(blogPart.FeedProxyUrl)) { feedManager.Register(blogTitle, "rss", new RouteValueDictionary {{"containerid", blogPart.Id}}); } else { feedManager.Register(blogTitle, "rss", blogPart.FeedProxyUrl); } if (blogPart.EnableCommentsFeed) { feedManager.Register(blogTitle + " - Comments", "rss", new RouteValueDictionary {{"commentedoncontainer", blogPart.Id}}); } }
public IEnumerable<BlogPostPart> Get(BlogPart blogPart, ArchiveData archiveData) { var query = GetBlogQuery(blogPart, VersionOptions.Published); if (archiveData.Day > 0) { var dayDate = new DateTime(archiveData.Year, archiveData.Month, archiveData.Day); query = query.Where(cr => cr.CreatedUtc >= dayDate && cr.CreatedUtc < dayDate.AddDays(1)); } else if (archiveData.Month > 0) { var monthDate = new DateTime(archiveData.Year, archiveData.Month, 1); query = query.Where(cr => cr.CreatedUtc >= monthDate && cr.CreatedUtc < monthDate.AddMonths(1)); } else { var yearDate = new DateTime(archiveData.Year, 1, 1); query = query.Where(cr => cr.CreatedUtc >= yearDate && cr.CreatedUtc < yearDate.AddYears(1)); } return query.List().Select(ci => ci.As<BlogPostPart>()); }
public int PostCount(BlogPart blogPart, VersionOptions versionOptions) { return GetBlogQuery(blogPart, versionOptions).Count(); }
public int PostCount(BlogPart blogPart) { return PostCount(blogPart, VersionOptions.Published); }
public static string BlogPostCreate(this UrlHelper urlHelper, BlogPart blogPart) { return urlHelper.Action("Create", "BlogPostAdmin", new { blogId = blogPart.Id, area = "Orchard.Blogs" }); }
public static string BlogArchiveDay(this UrlHelper urlHelper, BlogPart blogPart, int year, int month, int day) { return urlHelper.Action("ListByArchive", "BlogPost", new { blogPath = blogPart.As<IRoutableAspect>().Path, archiveData = string.Format("{0}/{1}/{2}", year, month, day), area = "Orchard.Blogs" }); }
public static string BlogRsd(this UrlHelper urlHelper, BlogPart blogPart) { return urlHelper.AbsoluteAction(() => urlHelper.Action("Rsd", "RemoteBlogPublishing", new { blogPath = blogPart.As<IRoutableAspect>().Path, area = "Orchard.Blogs" })); }
public static string Blog(this UrlHelper urlHelper, BlogPart blogPart) { return urlHelper.Action("Item", "Blog", new { blogPath = blogPart.As<IRoutableAspect>().Path, area = "Orchard.Blogs" }); }
public static string Blog(this UrlHelper urlHelper, BlogPart blogPart) { return urlHelper.Action("Item", "Blog", new { blogId = blogPart.Id, area = "Orchard.Blogs" }); }
public BlogPostPart Get(BlogPart blogPart, string slug) { return Get(blogPart, slug, VersionOptions.Published); }
public int PostCount(BlogPart blogPart, VersionOptions versionOptions) { return _contentManager.Query(versionOptions, "BlogPost") .Join<CommonPartRecord>().Where( cr => cr.Container.Id == blogPart.Id) .Count(); }
private IContentQuery<ContentItem, CommonPartRecord> GetBlogQuery(BlogPart blog, VersionOptions versionOptions) { return _contentManager.Query(versionOptions, "BlogPost") .Join<CommonPartRecord>().Where( cr => cr.Container.Id == blog.Id).OrderByDescending(cr => cr.CreatedUtc) ; }
public void RebuildArchive(BlogPart blogPart) { var first = _contentManager.Query<BlogPostPart>().Where<CommonPartRecord>(bp => bp.Container.Id == blogPart.Record.Id).OrderBy<CommonPartRecord>(x => x.CreatedUtc).Slice(0, 1).FirstOrDefault(); if (first == null) { return; } var last = _contentManager.Query<BlogPostPart>().Where<CommonPartRecord>(bp => bp.Container.Id == blogPart.Record.Id).OrderByDescending<CommonPartRecord>(x => x.CreatedUtc).Slice(0, 1).FirstOrDefault(); DateTime? start = DateTime.MaxValue; if (first.As<CommonPart>() != null) { start = first.As<CommonPart>().CreatedUtc; } DateTime? end = DateTime.MinValue; if (last.As<CommonPart>() != null) { end = last.As<CommonPart>().CreatedUtc; } // delete previous archive records foreach (var record in _blogArchiveRepository.Table.Where(x => x.BlogPart == blogPart.Record)) { _blogArchiveRepository.Delete(record); } if (!start.HasValue || !end.HasValue) { return; } // get the time zone for the current request var timeZone = _workContextAccessor.GetContext().CurrentTimeZone; // build a collection of all the post dates var blogPostDates = new List<DateTime>(); var blogPosts = _contentManager.Query<BlogPostPart>().Where<CommonPartRecord>(bp => bp.Container.Id == blogPart.Record.Id); foreach (var blogPost in blogPosts.List()) { if (blogPost.As<CommonPart>() != null) if (blogPost.As<CommonPart>().CreatedUtc.HasValue) { DateTime timeZoneAdjustedCreatedDate = TimeZoneInfo.ConvertTimeFromUtc(blogPost.As<CommonPart>().CreatedUtc.Value, timeZone); blogPostDates.Add(timeZoneAdjustedCreatedDate); } } for (int year = start.Value.Year; year <= end.Value.Year; year++) { for (int month = 1; month <= 12; month++) { var fromDateUtc = new DateTime(year, month, 1); var from = TimeZoneInfo.ConvertTimeFromUtc(fromDateUtc, timeZone); var to = TimeZoneInfo.ConvertTimeFromUtc(fromDateUtc.AddMonths(1), timeZone); // skip the first months of the first year until a month has posts // for instance, if started posting in May 2000, don't write counts for Jan 200 > April 2000... start May 2000 if (from < TimeZoneInfo.ConvertTimeFromUtc(new DateTime(start.Value.Year, start.Value.Month, 1), timeZone)) continue; // skip the last months of the last year if no posts // for instance, no need to have archives for months in the future if (to > end.Value.AddMonths(1)) continue; //var count = _contentManager.Query<BlogPostPart>().Where<CommonPartRecord>(x => x.CreatedUtc.Value >= from && x.CreatedUtc.Value < to).Count(); var count = blogPostDates.Count(bp => bp >= @from && bp < to); var newArchiveRecord = new BlogPartArchiveRecord { BlogPart = blogPart.Record, Year = year, Month = month, PostCount = count }; _blogArchiveRepository.Create(newArchiveRecord); } } }
public static string BlogArchiveYear(this UrlHelper urlHelper, BlogPart blogPart, int year) { var blogPath = blogPart.As<IAliasAspect>().Path; return urlHelper.Action("ListByArchive", "BlogPost", new { path = (string.IsNullOrWhiteSpace(blogPath) ? "archive/" : blogPath + "/archive/") + year.ToString(), area = "Orchard.Blogs" }); }
public static string BlogLiveWriterManifest(this UrlHelper urlHelper, BlogPart blogPart) { return urlHelper.AbsoluteAction(() => urlHelper.Action("Manifest", "LiveWriter", new { area = "XmlRpc" })); }
public static string BlogArchiveDay(this UrlHelper urlHelper, BlogPart blogPart, int year, int month, int day) { var blogPath = blogPart.As<IAliasAspect>().Path; return urlHelper.Action("ListByArchive", "BlogPost", new { path = (string.IsNullOrWhiteSpace(blogPath) ? "archive/" : blogPath + "/archive/") + string.Format("{0}/{1}/{2}", year, month, day), area = "Orchard.Blogs" }); }
public static string BlogArchiveYear(this UrlHelper urlHelper, BlogPart blogPart, int year) { return urlHelper.Action("ListByArchive", "BlogPost", new { blogPath = blogPart.As<IRoutableAspect>().Path, archiveData = year.ToString(), area = "Orchard.Blogs" }); }
public IEnumerable<BlogPostPart> Get(BlogPart blogPart) { return Get(blogPart, VersionOptions.Published); }
public static string BlogEdit(this UrlHelper urlHelper, BlogPart blogPart) { return urlHelper.Action("Edit", "BlogAdmin", new { blogId = blogPart.Id, area = "Orchard.Blogs" }); }
public IEnumerable<BlogPostPart> Get(BlogPart blogPart, VersionOptions versionOptions) { return GetBlogQuery(blogPart, versionOptions).List().Select(ci => ci.As<BlogPostPart>()); }
public IEnumerable<BlogPostPart> Get(BlogPart blogPart, int skip, int count) { return Get(blogPart, skip, count, VersionOptions.Published); }
public static void Register(this IFeedManager feedManager, BlogPart blogPart) { feedManager.Register(blogPart.Name, "rss", new RouteValueDictionary { { "containerid", blogPart.Id } }); feedManager.Register(blogPart.Name + " - Comments", "rss", new RouteValueDictionary { { "commentedoncontainer", blogPart.Id } }); }