mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Fix archive/rsd routes for BlogPart and BlogPostPart
--HG-- branch : autoroute
This commit is contained in:
@@ -5,6 +5,8 @@ using System.Web;
|
||||
using Orchard.Events;
|
||||
using System.Web.Routing;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.Core.Common.Models;
|
||||
|
||||
namespace Orchard.Blogs.Routing {
|
||||
public interface IAutorouteEventHandler : IEventHandler {
|
||||
@@ -15,57 +17,62 @@ namespace Orchard.Blogs.Routing {
|
||||
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"},
|
||||
if (content.Is<BlogPart>()) {
|
||||
// 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 {
|
||||
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 {
|
||||
}
|
||||
|
||||
if (content.Is<BlogPostPart>()) {
|
||||
var pathStart = "{Content.Container.Slug}/Archive/";
|
||||
|
||||
// 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(
|
||||
pathStart + String.Format("{0}", year),
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"},
|
||||
{"controller", "BlogPost"},
|
||||
{"action", "ListByArchive"},
|
||||
{"blogId", content.Id},
|
||||
{"blogId", content.As<CommonPart>().Container.Id},
|
||||
{"archiveData", String.Format("{0}",year)}
|
||||
}));
|
||||
aliases.Add(Tuple.Create(
|
||||
path+String.Format("/Archive/{0}/{1}",year,month),
|
||||
new RouteValueDictionary {
|
||||
aliases.Add(Tuple.Create(
|
||||
pathStart + String.Format("{0}/{1}", year, month),
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"},
|
||||
{"controller", "BlogPost"},
|
||||
{"action", "ListByArchive"},
|
||||
{"blogId", content.Id},
|
||||
{"archiveData", String.Format("{0}/{2}",year,month)}
|
||||
{"blogId", content.As<CommonPart>().Container.Id},
|
||||
{"archiveData", String.Format("{0}/{1}",year,month)}
|
||||
}));
|
||||
aliases.Add(Tuple.Create(
|
||||
path+String.Format("/Archive/{0}/{1}/{2}",year,month,day),
|
||||
new RouteValueDictionary {
|
||||
aliases.Add(Tuple.Create(
|
||||
pathStart + String.Format("{0}/{1}/{2}", year, month, day),
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"},
|
||||
{"controller", "BlogPost"},
|
||||
{"action", "ListByArchive"},
|
||||
{"blogId", content.Id},
|
||||
{"blogId", content.As<CommonPart>().Container.Id},
|
||||
{"archiveData", String.Format("{0}/{1}/{2}",year,month,day)}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user