mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Reinstating archives and RSD
--HG-- branch : autoroute
This commit is contained in:
@@ -61,6 +61,7 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Item(int blogId, PagerParameters pagerParameters) {
|
public ActionResult Item(int blogId, PagerParameters pagerParameters) {
|
||||||
|
// TODO: (PH:Autoroute) Should use Containers so we can lose this action and rely on ContainerPartDriver instead
|
||||||
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
|
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
|
||||||
|
|
||||||
var blogPart = _blogService.Get(blogId, VersionOptions.Published).As<BlogPart>();
|
var blogPart = _blogService.Get(blogId, VersionOptions.Published).As<BlogPart>();
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using Orchard.Mvc.Html;
|
|||||||
|
|
||||||
namespace Orchard.Blogs.Extensions {
|
namespace Orchard.Blogs.Extensions {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// TODO: (PH:Autoroute) Most of these
|
/// TODO: (PH:Autoroute) Many of these are or could be redundant (see controllers)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class UrlHelperExtensions {
|
public static class UrlHelperExtensions {
|
||||||
public static string Blogs(this UrlHelper urlHelper) {
|
public static string Blogs(this UrlHelper urlHelper) {
|
||||||
@@ -35,11 +35,11 @@ namespace Orchard.Blogs.Extensions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static string BlogArchiveMonth(this UrlHelper urlHelper, BlogPart blogPart, int year, int month) {
|
public static string BlogArchiveMonth(this UrlHelper urlHelper, BlogPart blogPart, int year, int month) {
|
||||||
return urlHelper.Action("ListByArchive", "BlogPost", new { blogId = blogPart.ContentItem.Id, archiveData = string.Format("{0}/{1}", year, month), area = "Orchard.Blogs" });
|
return urlHelper.Action("ListByArchive", "BlogPost", new { blogId = blogPart.ContentItem.Id, archiveData = string.Format("{0:0000}/{1:00}", year, month), area = "Orchard.Blogs" });
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BlogArchiveDay(this UrlHelper urlHelper, BlogPart blogPart, int year, int month, int day) {
|
public static string BlogArchiveDay(this UrlHelper urlHelper, BlogPart blogPart, int year, int month, int day) {
|
||||||
return urlHelper.Action("ListByArchive", "BlogPost", new { blogId = blogPart.ContentItem.Id, archiveData = string.Format("{0}/{1}/{2}", year, month, day), area = "Orchard.Blogs" });
|
return urlHelper.Action("ListByArchive", "BlogPost", new { blogId = blogPart.ContentItem.Id, archiveData = string.Format("{0:0000}/{1:00}/{2:00}", year, month, day), area = "Orchard.Blogs" });
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BlogForAdmin(this UrlHelper urlHelper, BlogPart blogPart) {
|
public static string BlogForAdmin(this UrlHelper urlHelper, BlogPart blogPart) {
|
||||||
|
|||||||
@@ -79,6 +79,7 @@
|
|||||||
<Compile Include="Handlers\BlogPartArchiveHandler.cs" />
|
<Compile Include="Handlers\BlogPartArchiveHandler.cs" />
|
||||||
<Compile Include="Models\BlogPartArchiveRecord.cs" />
|
<Compile Include="Models\BlogPartArchiveRecord.cs" />
|
||||||
<Compile Include="Permissions.cs" />
|
<Compile Include="Permissions.cs" />
|
||||||
|
<Compile Include="Routing\BlogAutoroutes.cs" />
|
||||||
<Compile Include="Routing\IsArchiveConstraint.cs" />
|
<Compile Include="Routing\IsArchiveConstraint.cs" />
|
||||||
<Compile Include="Security\BlogAuthorizationEventHandler.cs" />
|
<Compile Include="Security\BlogAuthorizationEventHandler.cs" />
|
||||||
<Compile Include="Services\BlogService.cs" />
|
<Compile Include="Services\BlogService.cs" />
|
||||||
|
|||||||
@@ -169,59 +169,7 @@ namespace Orchard.Blogs {
|
|||||||
{"area", "Orchard.Blogs"}
|
{"area", "Orchard.Blogs"}
|
||||||
},
|
},
|
||||||
new MvcRouteHandler())
|
new MvcRouteHandler())
|
||||||
},
|
}
|
||||||
new RouteDescriptor {
|
|
||||||
Route = new Route(
|
|
||||||
"Archive/{*archiveData}",
|
|
||||||
new RouteValueDictionary {
|
|
||||||
{"blogPath", ""},
|
|
||||||
{"area", "Orchard.Blogs"},
|
|
||||||
{"controller", "BlogPost"},
|
|
||||||
{"action", "ListByArchive"}
|
|
||||||
},
|
|
||||||
new RouteValueDictionary {
|
|
||||||
{"archiveData", new IsArchiveConstraint()}
|
|
||||||
},
|
|
||||||
new RouteValueDictionary {
|
|
||||||
{"area", "Orchard.Blogs"}
|
|
||||||
},
|
|
||||||
new MvcRouteHandler())
|
|
||||||
}/*,
|
|
||||||
TODO: (PH:Autoroute) Needs reimplementing
|
|
||||||
new RouteDescriptor {
|
|
||||||
Route = new Route(
|
|
||||||
"{blogPath}/Archive/{*archiveData}",
|
|
||||||
new RouteValueDictionary {
|
|
||||||
{"area", "Orchard.Blogs"},
|
|
||||||
{"controller", "BlogPost"},
|
|
||||||
{"action", "ListByArchive"}
|
|
||||||
},
|
|
||||||
new RouteValueDictionary {
|
|
||||||
{"blogPath", _blogPathConstraint},
|
|
||||||
{"archiveData", new IsArchiveConstraint()}
|
|
||||||
},
|
|
||||||
new RouteValueDictionary {
|
|
||||||
{"area", "Orchard.Blogs"}
|
|
||||||
},
|
|
||||||
new MvcRouteHandler())
|
|
||||||
},
|
|
||||||
new RouteDescriptor {
|
|
||||||
Priority = 11,
|
|
||||||
Route = new Route(
|
|
||||||
"{blogPath}/rsd",
|
|
||||||
new RouteValueDictionary {
|
|
||||||
{"area", "Orchard.Blogs"},
|
|
||||||
{"controller", "RemoteBlogPublishing"},
|
|
||||||
{"action", "Rsd"}
|
|
||||||
},
|
|
||||||
new RouteValueDictionary {
|
|
||||||
{"blogPath", _blogPathConstraint}
|
|
||||||
},
|
|
||||||
new RouteValueDictionary {
|
|
||||||
{"area", "Orchard.Blogs"}
|
|
||||||
},
|
|
||||||
new MvcRouteHandler())
|
|
||||||
}*/
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using Orchard.Events;
|
||||||
|
using System.Web.Routing;
|
||||||
|
using Orchard.ContentManagement;
|
||||||
|
|
||||||
|
namespace Orchard.Blogs.Routing {
|
||||||
|
public interface IAutorouteEventHandler : IEventHandler {
|
||||||
|
void Routed(IContent content, String path, ICollection<Tuple<string, RouteValueDictionary>> aliases);
|
||||||
|
}
|
||||||
|
public class BlogAutoroutes : IAutorouteEventHandler {
|
||||||
|
|
||||||
|
public void Routed(IContent content, string path, ICollection<Tuple<string, RouteValueDictionary>> aliases) {
|
||||||
|
|
||||||
|
// TODO: (PH:Autoroute) Cheap and it works. But could there be a better way?
|
||||||
|
|
||||||
|
// Add RSD route
|
||||||
|
aliases.Add(Tuple.Create(
|
||||||
|
path+"/rsd",
|
||||||
|
new RouteValueDictionary {{"area", "Orchard.Blogs"},
|
||||||
|
{"controller", "RemoteBlogPublishing"},
|
||||||
|
{"action", "Rsd"},
|
||||||
|
{"blogId", content.Id}
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Add Archives routes
|
||||||
|
var year = "{Content.Date.Format:yyyy}";
|
||||||
|
var month = "{Content.Date.Format:MM}";
|
||||||
|
var day = "{Content.Date.Format:dd}";
|
||||||
|
|
||||||
|
aliases.Add(Tuple.Create(
|
||||||
|
path+"/Archive",
|
||||||
|
new RouteValueDictionary {
|
||||||
|
{"area", "Orchard.Blogs"},
|
||||||
|
{"controller", "BlogPost"},
|
||||||
|
{"action", "ListByArchive"},
|
||||||
|
{"blogId", content.Id},
|
||||||
|
{"archiveData", ""}
|
||||||
|
}));
|
||||||
|
aliases.Add(Tuple.Create(
|
||||||
|
path+String.Format("/Archive/{0}",year),
|
||||||
|
new RouteValueDictionary {
|
||||||
|
{"area", "Orchard.Blogs"},
|
||||||
|
{"controller", "BlogPost"},
|
||||||
|
{"action", "ListByArchive"},
|
||||||
|
{"blogId", content.Id},
|
||||||
|
{"archiveData", String.Format("{0}",year)}
|
||||||
|
}));
|
||||||
|
aliases.Add(Tuple.Create(
|
||||||
|
path+String.Format("/Archive/{0}/{1}",year,month),
|
||||||
|
new RouteValueDictionary {
|
||||||
|
{"area", "Orchard.Blogs"},
|
||||||
|
{"controller", "BlogPost"},
|
||||||
|
{"action", "ListByArchive"},
|
||||||
|
{"blogId", content.Id},
|
||||||
|
{"archiveData", String.Format("{0}/{2}",year,month)}
|
||||||
|
}));
|
||||||
|
aliases.Add(Tuple.Create(
|
||||||
|
path+String.Format("/Archive/{0}/{1}/{2}",year,month,day),
|
||||||
|
new RouteValueDictionary {
|
||||||
|
{"area", "Orchard.Blogs"},
|
||||||
|
{"controller", "BlogPost"},
|
||||||
|
{"action", "ListByArchive"},
|
||||||
|
{"blogId", content.Id},
|
||||||
|
{"archiveData", String.Format("{0}/{1}/{2}",year,month,day)}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user