mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Using the blog's description in RSS feeds
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using System.Xml.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Feeds;
|
||||
using Orchard.Core.Feeds.Models;
|
||||
using Orchard.Mvc.Extensions;
|
||||
using Orchard.Services;
|
||||
|
||||
namespace Orchard.Blogs.Feeds {
|
||||
public class BlogPartFeedItemBuilder : IFeedItemBuilder {
|
||||
private IContentManager _contentManager;
|
||||
public BlogPartFeedItemBuilder(IContentManager contentManager) {
|
||||
_contentManager = contentManager;
|
||||
}
|
||||
|
||||
public void Populate(FeedContext context) {
|
||||
var containerIdValue = context.ValueProvider.GetValue("containerid");
|
||||
if (containerIdValue == null)
|
||||
return;
|
||||
|
||||
var containerId = (int)containerIdValue.ConvertTo(typeof(int));
|
||||
var container = _contentManager.Get(containerId);
|
||||
|
||||
if (container == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (container.ContentType != "Blog") {
|
||||
return;
|
||||
}
|
||||
|
||||
var blog = container.As<BlogPart>();
|
||||
|
||||
if (context.Format == "rss") {
|
||||
context.Response.Element.SetElementValue("description", blog.Description);
|
||||
}
|
||||
else {
|
||||
context.Builder.AddProperty(context, null, "description", blog.Description);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -72,6 +72,7 @@
|
||||
<Compile Include="Drivers\BlogArchivesPartDriver.cs" />
|
||||
<Compile Include="Drivers\RemoteBlogPublishingDriver.cs" />
|
||||
<Compile Include="Drivers\RecentBlogPostsPartDriver.cs" />
|
||||
<Compile Include="Feeds\BlogPartFeedItemBuilder.cs" />
|
||||
<Compile Include="Handlers\BlogArchivesPartHandler.cs" />
|
||||
<Compile Include="Handlers\RecentBlogPostsPartHandler.cs" />
|
||||
<Compile Include="Models\BlogArchivesPart.cs" />
|
||||
|
Reference in New Issue
Block a user