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 Orchard.Events;
|
||||||
using System.Web.Routing;
|
using System.Web.Routing;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
|
using Orchard.Blogs.Models;
|
||||||
|
using Orchard.Core.Common.Models;
|
||||||
|
|
||||||
namespace Orchard.Blogs.Routing {
|
namespace Orchard.Blogs.Routing {
|
||||||
public interface IAutorouteEventHandler : IEventHandler {
|
public interface IAutorouteEventHandler : IEventHandler {
|
||||||
@@ -15,23 +17,17 @@ namespace Orchard.Blogs.Routing {
|
|||||||
public void Routed(IContent content, string path, ICollection<Tuple<string, RouteValueDictionary>> aliases) {
|
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?
|
// TODO: (PH:Autoroute) Cheap and it works. But could there be a better way?
|
||||||
|
if (content.Is<BlogPart>()) {
|
||||||
// Add RSD route
|
// Add RSD route
|
||||||
aliases.Add(Tuple.Create(
|
aliases.Add(Tuple.Create(
|
||||||
path+"/rsd",
|
path + "/rsd",
|
||||||
new RouteValueDictionary {{"area", "Orchard.Blogs"},
|
new RouteValueDictionary {{"area", "Orchard.Blogs"},
|
||||||
{"controller", "RemoteBlogPublishing"},
|
{"controller", "RemoteBlogPublishing"},
|
||||||
{"action", "Rsd"},
|
{"action", "Rsd"},
|
||||||
{"blogId", content.Id}
|
{"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(
|
aliases.Add(Tuple.Create(
|
||||||
path+"/Archive",
|
path + "/Archive",
|
||||||
new RouteValueDictionary {
|
new RouteValueDictionary {
|
||||||
{"area", "Orchard.Blogs"},
|
{"area", "Orchard.Blogs"},
|
||||||
{"controller", "BlogPost"},
|
{"controller", "BlogPost"},
|
||||||
@@ -39,33 +35,44 @@ namespace Orchard.Blogs.Routing {
|
|||||||
{"blogId", content.Id},
|
{"blogId", content.Id},
|
||||||
{"archiveData", ""}
|
{"archiveData", ""}
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
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(
|
aliases.Add(Tuple.Create(
|
||||||
path+String.Format("/Archive/{0}",year),
|
pathStart + String.Format("{0}", year),
|
||||||
new RouteValueDictionary {
|
new RouteValueDictionary {
|
||||||
{"area", "Orchard.Blogs"},
|
{"area", "Orchard.Blogs"},
|
||||||
{"controller", "BlogPost"},
|
{"controller", "BlogPost"},
|
||||||
{"action", "ListByArchive"},
|
{"action", "ListByArchive"},
|
||||||
{"blogId", content.Id},
|
{"blogId", content.As<CommonPart>().Container.Id},
|
||||||
{"archiveData", String.Format("{0}",year)}
|
{"archiveData", String.Format("{0}",year)}
|
||||||
}));
|
}));
|
||||||
aliases.Add(Tuple.Create(
|
aliases.Add(Tuple.Create(
|
||||||
path+String.Format("/Archive/{0}/{1}",year,month),
|
pathStart + String.Format("{0}/{1}", year, month),
|
||||||
new RouteValueDictionary {
|
new RouteValueDictionary {
|
||||||
{"area", "Orchard.Blogs"},
|
{"area", "Orchard.Blogs"},
|
||||||
{"controller", "BlogPost"},
|
{"controller", "BlogPost"},
|
||||||
{"action", "ListByArchive"},
|
{"action", "ListByArchive"},
|
||||||
{"blogId", content.Id},
|
{"blogId", content.As<CommonPart>().Container.Id},
|
||||||
{"archiveData", String.Format("{0}/{2}",year,month)}
|
{"archiveData", String.Format("{0}/{1}",year,month)}
|
||||||
}));
|
}));
|
||||||
aliases.Add(Tuple.Create(
|
aliases.Add(Tuple.Create(
|
||||||
path+String.Format("/Archive/{0}/{1}/{2}",year,month,day),
|
pathStart + String.Format("{0}/{1}/{2}", year, month, day),
|
||||||
new RouteValueDictionary {
|
new RouteValueDictionary {
|
||||||
{"area", "Orchard.Blogs"},
|
{"area", "Orchard.Blogs"},
|
||||||
{"controller", "BlogPost"},
|
{"controller", "BlogPost"},
|
||||||
{"action", "ListByArchive"},
|
{"action", "ListByArchive"},
|
||||||
{"blogId", content.Id},
|
{"blogId", content.As<CommonPart>().Container.Id},
|
||||||
{"archiveData", String.Format("{0}/{1}/{2}",year,month,day)}
|
{"archiveData", String.Format("{0}/{1}/{2}",year,month,day)}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user