mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Register blog feed in Drivers
This makes feed registration more resilient to routing overrides. --HG-- branch : dev
This commit is contained in:
@@ -17,14 +17,12 @@ namespace Orchard.Blogs.Controllers {
|
||||
private readonly IOrchardServices _services;
|
||||
private readonly IBlogService _blogService;
|
||||
private readonly IBlogSlugConstraint _blogSlugConstraint;
|
||||
private readonly IFeedManager _feedManager;
|
||||
private readonly RouteCollection _routeCollection;
|
||||
|
||||
public BlogController(IOrchardServices services, IBlogService blogService, IBlogSlugConstraint blogSlugConstraint, IFeedManager feedManager, RouteCollection routeCollection) {
|
||||
public BlogController(IOrchardServices services, IBlogService blogService, IBlogSlugConstraint blogSlugConstraint, RouteCollection routeCollection) {
|
||||
_services = services;
|
||||
_blogService = blogService;
|
||||
_blogSlugConstraint = blogSlugConstraint;
|
||||
_feedManager = feedManager;
|
||||
_routeCollection = routeCollection;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
@@ -53,7 +51,6 @@ namespace Orchard.Blogs.Controllers {
|
||||
Blog = _services.ContentManager.BuildDisplayModel(blog, "Detail")
|
||||
};
|
||||
|
||||
_feedManager.Register(blog);
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
@@ -54,8 +54,6 @@ namespace Orchard.Blogs.Controllers {
|
||||
BlogPost = _services.ContentManager.BuildDisplayModel(postPart, "Detail")
|
||||
};
|
||||
|
||||
_feedManager.Register(blogPart);
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
@@ -2,12 +2,14 @@
|
||||
using System.Linq;
|
||||
using System.Web.Routing;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Blogs.Extensions;
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.Blogs.Services;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.Contents.ViewModels;
|
||||
using Orchard.Core.ContentsLocation.Models;
|
||||
using Orchard.Core.Feeds;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
@@ -23,11 +25,13 @@ namespace Orchard.Blogs.Drivers {
|
||||
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IBlogPostService _blogPostService;
|
||||
private readonly IFeedManager _feedManager;
|
||||
|
||||
public BlogPartDriver(IOrchardServices services, IContentManager contentManager, IBlogPostService blogPostService) {
|
||||
public BlogPartDriver(IOrchardServices services, IContentManager contentManager, IBlogPostService blogPostService, IFeedManager feedManager) {
|
||||
Services = services;
|
||||
_contentManager = contentManager;
|
||||
_blogPostService = blogPostService;
|
||||
_feedManager = feedManager;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
@@ -71,6 +75,7 @@ namespace Orchard.Blogs.Drivers {
|
||||
else if (displayType.StartsWith("Detail")) {
|
||||
blogPosts = _blogPostService.Get(blogPart)
|
||||
.Select(bp => _contentManager.BuildDisplayModel(bp, "Summary"));
|
||||
_feedManager.Register(blogPart);
|
||||
}
|
||||
|
||||
return Combined(
|
||||
|
@@ -1,13 +1,16 @@
|
||||
using System.Web.Routing;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.Blogs.Extensions;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.Feeds;
|
||||
using Orchard.Localization;
|
||||
|
||||
namespace Orchard.Blogs.Drivers {
|
||||
[UsedImplicitly]
|
||||
public class BlogPostPartDriver : ContentItemDriver<BlogPostPart> {
|
||||
private readonly IFeedManager _feedManager;
|
||||
public IOrchardServices Services { get; set; }
|
||||
|
||||
public readonly static ContentType ContentType = new ContentType {
|
||||
@@ -15,7 +18,8 @@ namespace Orchard.Blogs.Drivers {
|
||||
DisplayName = "Blog Post"
|
||||
};
|
||||
|
||||
public BlogPostPartDriver(IOrchardServices services) {
|
||||
public BlogPostPartDriver(IOrchardServices services, IFeedManager feedManager) {
|
||||
_feedManager = feedManager;
|
||||
Services = services;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -70,6 +74,14 @@ namespace Orchard.Blogs.Drivers {
|
||||
};
|
||||
}
|
||||
|
||||
protected override DriverResult Display(BlogPostPart part, string displayType) {
|
||||
if (displayType.StartsWith("Detail")) {
|
||||
_feedManager.Register(part.BlogPart);
|
||||
}
|
||||
|
||||
return base.Display(part, displayType);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(BlogPostPart postPart) {
|
||||
return ContentItemTemplate("Items/Blogs.BlogPost");
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ description: The Orchard Blogs module is implementing basic blogging features.
|
||||
features:
|
||||
Orchard.Blogs:
|
||||
Description: A simple web log.
|
||||
Dependencies: Feeds
|
||||
Category: Content
|
||||
Remote Blog Publishing:
|
||||
Description: Blog easier using a dedicated MetaWeblogAPI-compatible publishing tool.
|
||||
|
Reference in New Issue
Block a user