Remove Blogs dependency on Autoroute

--HG--
branch : autoroute
This commit is contained in:
randompete
2012-01-20 21:19:52 +00:00
parent fa0f87d4c4
commit 994135917b
2 changed files with 21 additions and 21 deletions
@@ -134,10 +134,6 @@
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project> <Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name> <Name>Orchard.Core</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\Orchard.Autoroute\Orchard.Autoroute.csproj">
<Project>{66FCCD76-2761-47E3-8D11-B45D0001DDAA}</Project>
<Name>Orchard.Autoroute</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Placement.info"> <Content Include="Placement.info">
@@ -7,10 +7,16 @@ using System.Web.Routing;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.Blogs.Models; using Orchard.Blogs.Models;
using Orchard.Core.Common.Models; using Orchard.Core.Common.Models;
using Orchard.Autoroute.Services;
using Orchard.Localization; using Orchard.Localization;
namespace Orchard.Blogs.Providers { namespace Orchard.Blogs.Providers {
public interface IRoutePatternProvider : IEventHandler {
void Describe(dynamic describe);
void Suggest(dynamic suggest);
}
public class BlogAutoroutes : IRoutePatternProvider { public class BlogAutoroutes : IRoutePatternProvider {
public BlogAutoroutes() { public BlogAutoroutes() {
@@ -27,55 +33,55 @@ namespace Orchard.Blogs.Providers {
const string blogToken = "{Content.Slug}"; const string blogToken = "{Content.Slug}";
const string blogPostToken = "{Content.Container.Path}/{Content.Slug}"; const string blogPostToken = "{Content.Container.Path}/{Content.Slug}";
public void Describe(DescribePatternContext describe) { public void Describe(dynamic describe) {
// TODO: (PH) Could implement RSD for non-blog content much more easily now the routing can be applied to any content item... (maybe need a RemotePublishingPart?) // TODO: (PH) Could implement RSD for non-blog content much more easily now the routing can be applied to any content item... (maybe need a RemotePublishingPart?)
// TODO: Must restrict these to appropriate parts/types... // TODO: Must restrict these to appropriate parts/types...
describe.For<IContent>("Content") describe.For<IContent>("Content")
.Match(c => c.Is<BlogPart>()) .Match((Func<IContent,bool>)(c => c.Is<BlogPart>()))
.Pattern("Rsd", T("Remote Blog Publishing"), T("Remote Blog Publishing destination Url"), .Pattern("Rsd", T("Remote Blog Publishing"), T("Remote Blog Publishing destination Url"),
c => new RouteValueDictionary { (Func<IContent,RouteValueDictionary>)(c => new RouteValueDictionary {
{"area", "Orchard.Blogs"}, {"area", "Orchard.Blogs"},
{"controller", "RemoteBlogPublishing"}, {"controller", "RemoteBlogPublishing"},
{"action", "Rsd"}, {"action", "Rsd"},
{"blogId", idToken}}) {"blogId", idToken}}))
.Pattern("Archive", T("Blog Archives"), T("Displays a list of all blog archives"), .Pattern("Archive", T("Blog Archives"), T("Displays a list of all blog archives"),
c => new RouteValueDictionary { (Func<IContent,RouteValueDictionary>)(c => new RouteValueDictionary {
{"area", "Orchard.Blogs"}, {"area", "Orchard.Blogs"},
{"controller", "BlogPost"}, {"controller", "BlogPost"},
{"action", "ListByArchive"}, {"action", "ListByArchive"},
{"blogId", idToken}, {"blogId", idToken},
{"archiveData", ""} {"archiveData", ""}
}) }))
; ;
describe.For<IContent>("Content") describe.For<IContent>("Content")
.Match(c => c.Is<BlogPostPart>()) .Match((Func<IContent,bool>)(c => c.Is<BlogPostPart>()))
.Pattern("Archive.Year", T("Blog Archives by Year"), T("Displays a list of all blog archives for a particular year"), .Pattern("Archive.Year", T("Blog Archives by Year"), T("Displays a list of all blog archives for a particular year"),
c=> new RouteValueDictionary { (Func<IContent,RouteValueDictionary>)(c=> new RouteValueDictionary {
{"area", "Orchard.Blogs"}, {"area", "Orchard.Blogs"},
{"controller", "BlogPost"}, {"controller", "BlogPost"},
{"action", "ListByArchive"}, {"action", "ListByArchive"},
{"blogId", idParentToken}, {"blogId", idParentToken},
{"archiveData", String.Format("{0}",yearToken)} {"archiveData", String.Format("{0}",yearToken)}
}) }))
.Pattern("Archive.Month", T("Blog Archives by Month"), T("Displays a list of all blog archives for a particular year and month"), .Pattern("Archive.Month", T("Blog Archives by Month"), T("Displays a list of all blog archives for a particular year and month"),
c => new RouteValueDictionary { (Func<IContent,RouteValueDictionary>)(c => new RouteValueDictionary {
{"area", "Orchard.Blogs"}, {"area", "Orchard.Blogs"},
{"controller", "BlogPost"}, {"controller", "BlogPost"},
{"action", "ListByArchive"}, {"action", "ListByArchive"},
{"blogId", idParentToken}, {"blogId", idParentToken},
{"archiveData", String.Format("{0}/{1}",yearToken,monthToken)} {"archiveData", String.Format("{0}/{1}",yearToken,monthToken)}
}) }))
.Pattern("Archive.Day", T("Blog Archives by Day"), T("Displays a list of all blog archives for a particular date"), .Pattern("Archive.Day", T("Blog Archives by Day"), T("Displays a list of all blog archives for a particular date"),
c => new RouteValueDictionary { (Func<IContent,RouteValueDictionary>)(c => new RouteValueDictionary {
{"area", "Orchard.Blogs"}, {"area", "Orchard.Blogs"},
{"controller", "BlogPost"}, {"controller", "BlogPost"},
{"action", "ListByArchive"}, {"action", "ListByArchive"},
{"blogId", idParentToken}, {"blogId", idParentToken},
{"archiveData", String.Format("{0}/{1}/{2}",yearToken,monthToken,dayToken)} {"archiveData", String.Format("{0}/{1}/{2}",yearToken,monthToken,dayToken)}
}); }));
} }
public void Suggest(SuggestPatternContext suggest) { public void Suggest(dynamic suggest) {
suggest.For("Content") suggest.For("Content")
.Suggest("Rsd", "blog-title/rsd", blogToken + "/rsd", T("Rsd is a sub-path of the blog post")) .Suggest("Rsd", "blog-title/rsd", blogToken + "/rsd", T("Rsd is a sub-path of the blog post"))
.Suggest("Archives", "blog-title/archives", blogToken + "/archives", T("Archives is a sub-path of the blog post")) .Suggest("Archives", "blog-title/archives", blogToken + "/archives", T("Archives is a sub-path of the blog post"))
@@ -86,7 +92,5 @@ namespace Orchard.Blogs.Providers {
.Suggest("Archive.Day", "blog-title/post-title/archives/yy/mm/dd", String.Format("{0}/archives/{1}/{2}/{3}", blogPostToken, yearToken,monthToken,dayToken), T("Archives year/month/day")); .Suggest("Archive.Day", "blog-title/post-title/archives/yy/mm/dd", String.Format("{0}/archives/{1}/{2}/{3}", blogPostToken, yearToken,monthToken,dayToken), T("Archives year/month/day"));
} }
public void Match(MatchPatternContext context) {
}
} }
} }