--HG--
branch : dev
This commit is contained in:
Renaud Paquay
2010-11-26 00:09:49 -08:00
9 changed files with 74 additions and 23 deletions
@@ -21,6 +21,10 @@ namespace Orchard.Core.Feeds.Services {
dynamic Shape { get; set; }
public void OnResultExecuting(ResultExecutingContext filterContext) {
// should only run on a full view rendering result
if (!(filterContext.Result is ViewResult))
return;
var layout = _workContextAccessor.GetContext(filterContext).Layout;
var feed = Shape.Feed()
.FeedManager(_feedManager);
@@ -72,8 +72,15 @@ namespace Orchard.Core.Routable.Handlers {
public class RoutePartHandlerBase : ContentHandlerBase {
public override void GetContentItemMetadata(GetContentItemMetadataContext context) {
var routable = context.ContentItem.As<RoutePart>();
if (routable != null) {
context.Metadata.DisplayText = routable.Title;
if (routable == null)
return;
context.Metadata.DisplayText = routable.Title;
// set the display route values if it hasn't been set or only has been set by the Contents module.
// allows other modules to set their own display. probably not common enough to warrant some priority implemntation
if (context.Metadata.DisplayRouteValues == null || context.Metadata.DisplayRouteValues["Area"] as string == "Contents") {
context.Metadata.DisplayRouteValues = new RouteValueDictionary {
{"Area", "Routable"},
{"Controller", "Item"},
@@ -10,13 +10,16 @@ namespace Orchard.Core.Routable.Services {
[UsedImplicitly]
public class RoutableHomePageProvider : IHomePageProvider {
private readonly IContentManager _contentManager;
private readonly IWorkContextAccessor _workContextAccessor;
public const string Name = "RoutableHomePageProvider";
public RoutableHomePageProvider(
IOrchardServices services,
IContentManager contentManager,
IShapeFactory shapeFactory) {
IShapeFactory shapeFactory,
IWorkContextAccessor workContextAccessor) {
_contentManager = contentManager;
_workContextAccessor = workContextAccessor;
Services = services;
T = NullLocalizer.Instance;
Shape = shapeFactory;
@@ -39,11 +42,13 @@ namespace Orchard.Core.Routable.Services {
if (contentItem == null || !contentItem.Is<RoutePart>())
return new HttpNotFoundResult();
var model = _contentManager.BuildDisplay(contentItem);
// get the display metadata for the home page item
var displayRouteValues = _contentManager.GetItemMetadata(contentItem).DisplayRouteValues;
return new ViewResult {
var model = Shape.ViewModel(RouteValues: displayRouteValues);
return new PartialViewResult {
ViewName = "Routable.HomePage",
ViewData = new ViewDataDictionary<dynamic>(model)
ViewData = new ViewDataDictionary<object>(model)
};
}
}
@@ -1 +1,4 @@
@Display(Model)
@{
RouteValueDictionary routeValues = Model.RouteValues;
Html.RenderAction(routeValues["action"] as string, routeValues["controller"] as string, routeValues);
}
@@ -3,6 +3,7 @@ using JetBrains.Annotations;
using Orchard.Blogs.Models;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Routable.Models;
using Orchard.Data;
namespace Orchard.Blogs.Handlers {
@@ -23,6 +24,12 @@ namespace Orchard.Blogs.Handlers {
if (blog == null)
return;
context.Metadata.DisplayRouteValues = new RouteValueDictionary {
{"Area", "Orchard.Blogs"},
{"Controller", "Blog"},
{"Action", "Item"},
{"blogSlug", blog.As<RoutePart>().Slug}
};
context.Metadata.CreateRouteValues = new RouteValueDictionary {
{"Area", "Orchard.Blogs"},
{"Controller", "BlogAdmin"},