From 2406d2238fa2f3370b291d3b3ed01128752ab7a9 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Fri, 21 Feb 2014 11:47:35 -0800 Subject: [PATCH] Adding support for RSS feed proxies --- src/Orchard.Web/Core/Feeds/IFeedManager.cs | 2 ++ .../Core/Feeds/Services/FeedManager.cs | 10 +++++++--- .../Orchard.Blogs/Drivers/BlogPartDriver.cs | 6 ++++++ .../Extensions/FeedManagerExtensions.cs | 14 ++++++++++++-- .../Modules/Orchard.Blogs/Models/BlogPart.cs | 10 ++++++++++ .../Parts.Blogs.Blog.Fields.cshtml | 19 +++++++++++++++++-- 6 files changed, 54 insertions(+), 7 deletions(-) diff --git a/src/Orchard.Web/Core/Feeds/IFeedManager.cs b/src/Orchard.Web/Core/Feeds/IFeedManager.cs index 90d76bfe6..b22e96253 100644 --- a/src/Orchard.Web/Core/Feeds/IFeedManager.cs +++ b/src/Orchard.Web/Core/Feeds/IFeedManager.cs @@ -1,9 +1,11 @@ +using System; using System.Web.Mvc; using System.Web.Routing; namespace Orchard.Core.Feeds { public interface IFeedManager : IDependency { void Register(string title, string format, RouteValueDictionary values); + void Register(string title, string format, string url); MvcHtmlString GetRegisteredLinks(HtmlHelper html); // Currently implemented in FeedController action... tbd diff --git a/src/Orchard.Web/Core/Feeds/Services/FeedManager.cs b/src/Orchard.Web/Core/Feeds/Services/FeedManager.cs index f8cd2ff76..d975250ee 100644 --- a/src/Orchard.Web/Core/Feeds/Services/FeedManager.cs +++ b/src/Orchard.Web/Core/Feeds/Services/FeedManager.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Text; using System.Web.Mvc; @@ -12,6 +13,7 @@ namespace Orchard.Core.Feeds.Services { class Link { public string Title { get; set; } public RouteValueDictionary RouteValues { get; set; } + public string Url { get; set; } } public void Register(string title, string format, RouteValueDictionary values) { @@ -28,14 +30,16 @@ namespace Orchard.Core.Feeds.Services { _links.Add(new Link { Title = title, RouteValues = link }); } - - + public void Register(string title, string format, string url) { + _links.Add(new Link { Title = title, Url = url }); + } + public MvcHtmlString GetRegisteredLinks(HtmlHelper html) { var urlHelper = new UrlHelper(html.ViewContext.RequestContext, html.RouteCollection); var sb = new StringBuilder(); foreach (var link in _links) { - var linkUrl = urlHelper.RouteUrl(link.RouteValues); + var linkUrl = String.IsNullOrWhiteSpace(link.Url) ? urlHelper.RouteUrl(link.RouteValues) : link.Url; sb.Append("\r\n"); sb.Append(@" x.PostCount); } set { this.Store(x => x.PostCount, value); } } + + public string FeedProxyUrl { + get { return this.Retrieve(x => x.FeedProxyUrl); } + set { this.Store(x => x.FeedProxyUrl, value); } + } + + public bool EnableCommentsFeed { + get { return this.Retrieve(x => x.EnableCommentsFeed, false); } + set { this.Store(x => x.EnableCommentsFeed, value); } + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Views/EditorTemplates/Parts.Blogs.Blog.Fields.cshtml b/src/Orchard.Web/Modules/Orchard.Blogs/Views/EditorTemplates/Parts.Blogs.Blog.Fields.cshtml index a9bf742b0..9623f44db 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Views/EditorTemplates/Parts.Blogs.Blog.Fields.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Views/EditorTemplates/Parts.Blogs.Blog.Fields.cshtml @@ -1,5 +1,20 @@ -@model Orchard.Blogs.Models.BlogPart +@using Orchard.Mvc.Extensions +@model Orchard.Blogs.Models.BlogPart +
@Html.LabelFor(m => m.Description, T("Description")) @Html.TextAreaFor(m => m.Description, 5, 60, null) -
\ No newline at end of file + + +
+ @Html.LabelFor(m => m.FeedProxyUrl, T("Feed proxy Url")) + @Html.TextBoxFor(m => m.FeedProxyUrl, new { @class = "text medium" }) + @T("Provide a custom public url which will be used to proxy the local rss feed.") + @T("The current feed is available at {0}.", Url.AbsoluteAction("Index", "Feed", new { area = "Feeds", containerid = Model.Id })) +
+ +
+ @Html.CheckBoxFor(m => m.EnableCommentsFeed) + @Html.LabelFor(m => m.EnableCommentsFeed, T("Render a comments rss feed").Text, new { @class = "forcheckbox" }) + @T("Enable to render the comments rss feed.") +