mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-03 03:58:13 +08:00
Finish blog implementation of all routes
--HG-- branch : autoroute rename : src/Orchard.Web/Modules/Orchard.Blogs/Routing/BlogAutoroutes.cs => src/Orchard.Web/Modules/Orchard.Blogs/Providers/BlogAutoroutes.cs
This commit is contained in:
@@ -3,7 +3,6 @@ using System.Reflection;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Blogs.Extensions;
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.Blogs.Routing;
|
||||
using Orchard.Blogs.Services;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
|
||||
@@ -2,7 +2,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Blogs.Extensions;
|
||||
using Orchard.Blogs.Routing;
|
||||
using Orchard.Blogs.Services;
|
||||
using Orchard.Core.Feeds;
|
||||
using Orchard.DisplayManagement;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.Blogs.Routing;
|
||||
using Orchard.Blogs.Services;
|
||||
using Orchard.Blogs.ViewModels;
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Linq;
|
||||
using System.Web.Routing;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.Blogs.Routing;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Data;
|
||||
|
||||
@@ -79,8 +79,7 @@
|
||||
<Compile Include="Handlers\BlogPartArchiveHandler.cs" />
|
||||
<Compile Include="Models\BlogPartArchiveRecord.cs" />
|
||||
<Compile Include="Permissions.cs" />
|
||||
<Compile Include="Routing\BlogAutoroutes.cs" />
|
||||
<Compile Include="Routing\IsArchiveConstraint.cs" />
|
||||
<Compile Include="Providers\BlogAutoroutes.cs" />
|
||||
<Compile Include="Security\BlogAuthorizationEventHandler.cs" />
|
||||
<Compile Include="Services\BlogService.cs" />
|
||||
<Compile Include="Controllers\BlogController.cs" />
|
||||
|
||||
@@ -10,7 +10,7 @@ using Orchard.Core.Common.Models;
|
||||
using Orchard.Autoroute.Services;
|
||||
using Orchard.Localization;
|
||||
|
||||
namespace Orchard.Blogs.Routing {
|
||||
namespace Orchard.Blogs.Providers {
|
||||
public class BlogAutoroutes : IRoutePatternProvider {
|
||||
|
||||
public BlogAutoroutes() {
|
||||
@@ -30,16 +30,16 @@ namespace Orchard.Blogs.Routing {
|
||||
public void Describe(DescribePatternContext 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: Must restrict these to appropriate parts/types...
|
||||
describe.For("Content")
|
||||
// .Where<IContent>(c => c.Is<BlogPart>())
|
||||
describe.For<IContent>("Content")
|
||||
.Match(c => c.Is<BlogPart>())
|
||||
.Pattern("Rsd", T("Remote Blog Publishing"), T("Remote Blog Publishing destination Url"),
|
||||
new RouteValueDictionary {
|
||||
c => new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"},
|
||||
{"controller", "RemoteBlogPublishing"},
|
||||
{"action", "Rsd"},
|
||||
{"blogId", idToken}})
|
||||
.Pattern("Archive", T("Blog Archives"), T("Displays a list of all blog archives"),
|
||||
new RouteValueDictionary {
|
||||
c => new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"},
|
||||
{"controller", "BlogPost"},
|
||||
{"action", "ListByArchive"},
|
||||
@@ -47,26 +47,26 @@ namespace Orchard.Blogs.Routing {
|
||||
{"archiveData", ""}
|
||||
})
|
||||
;
|
||||
describe.For("Content")
|
||||
// .Where<IContent>(c => c.Is<BlogPostPart>())
|
||||
.Pattern("ArchiveYear", T("Blog Archives by Year"), T("Displays a list of all blog archives for a particular year"),
|
||||
new RouteValueDictionary {
|
||||
describe.For<IContent>("Content")
|
||||
.Match(c => c.Is<BlogPostPart>())
|
||||
.Pattern("Archive.Year", T("Blog Archives by Year"), T("Displays a list of all blog archives for a particular year"),
|
||||
c=> new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"},
|
||||
{"controller", "BlogPost"},
|
||||
{"action", "ListByArchive"},
|
||||
{"blogId", idParentToken},
|
||||
{"archiveData", String.Format("{0}",yearToken)}
|
||||
})
|
||||
.Pattern("ArchiveMonth", T("Blog Archives by Month"), T("Displays a list of all blog archives for a particular year and month"),
|
||||
new RouteValueDictionary {
|
||||
.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 {
|
||||
{"area", "Orchard.Blogs"},
|
||||
{"controller", "BlogPost"},
|
||||
{"action", "ListByArchive"},
|
||||
{"blogId", idParentToken},
|
||||
{"archiveData", String.Format("{0}/{1}",yearToken,monthToken)}
|
||||
})
|
||||
.Pattern("ArchiveDay", T("Blog Archives by Day"), T("Displays a list of all blog archives for a particular date"),
|
||||
new RouteValueDictionary {
|
||||
.Pattern("Archive.Day", T("Blog Archives by Day"), T("Displays a list of all blog archives for a particular date"),
|
||||
c => new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"},
|
||||
{"controller", "BlogPost"},
|
||||
{"action", "ListByArchive"},
|
||||
@@ -81,10 +81,12 @@ namespace Orchard.Blogs.Routing {
|
||||
.Suggest("Archives", "blog-title/archives", blogToken + "/archives", T("Archives is a sub-path of the blog post"))
|
||||
.Suggest("View", "blog-title", blogToken, T("Blog title"))
|
||||
.Suggest("View", "blog-title/post-title", blogPostToken, T("Nested blog/post path"))
|
||||
.Suggest("ArchivesYear", "blog-title/post-title/archives/yy", String.Format("{0}/archives/{1}",blogPostToken,yearToken), T("Archives year"))
|
||||
.Suggest("ArchivesMonth", "blog-title/post-title/archives/yy/mm", String.Format("{0}/archives/{1}/{2}",blogPostToken,yearToken,monthToken), T("Archives year/month"))
|
||||
.Suggest("ArchivesDay", "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.Year", "blog-title/post-title/archives/yy", String.Format("{0}/archives/{1}",blogPostToken,yearToken), T("Archives year"))
|
||||
.Suggest("Archive.Month", "blog-title/post-title/archives/yy/mm", String.Format("{0}/archives/{1}/{2}",blogPostToken,yearToken,monthToken), T("Archives year/month"))
|
||||
.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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Blogs.Routing;
|
||||
using Orchard.Mvc.Routes;
|
||||
|
||||
namespace Orchard.Blogs {
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
using System.Web;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Blogs.Models;
|
||||
|
||||
namespace Orchard.Blogs.Routing {
|
||||
public class IsArchiveConstraint : IRouteConstraint {
|
||||
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values,
|
||||
RouteDirection routeDirection) {
|
||||
if(values[parameterName] == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
var archiveData = new ArchiveData(values[parameterName].ToString());
|
||||
archiveData.ToDateTime();
|
||||
return true;
|
||||
}
|
||||
catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.Blogs.Routing;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Core.Title.Models;
|
||||
|
||||
Reference in New Issue
Block a user