mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-08 00:14:31 +08:00
Removing further RoutePart references and fixing some tests
--HG-- branch : autoroute
This commit is contained in:
@@ -19,6 +19,7 @@ using Orchard.Core.Feeds.StandardBuilders;
|
||||
using Orchard.Core.Routable.Models;
|
||||
using Orchard.Tests.Modules;
|
||||
using Orchard.Tests.Stubs;
|
||||
using Orchard.Core.Title.Models;
|
||||
|
||||
namespace Orchard.Core.Tests.Feeds.Controllers {
|
||||
[TestFixture]
|
||||
@@ -148,16 +149,16 @@ namespace Orchard.Core.Tests.Feeds.Controllers {
|
||||
var clock = new StubClock();
|
||||
var hello = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("hello").Build())
|
||||
.Weld<CommonPart>()
|
||||
.Weld<RoutePart>()
|
||||
.Weld<TitlePart>()
|
||||
.Weld<BodyPart>()
|
||||
.Build();
|
||||
hello.As<CommonPart>().Record = new CommonPartRecord();
|
||||
hello.As<RoutePart>().Record = new RoutePartRecord();
|
||||
hello.As<TitlePart>().Record = new TitlePartRecord();
|
||||
hello.As<BodyPart>().Record = new BodyPartRecord();
|
||||
|
||||
hello.As<CommonPart>().PublishedUtc = clock.UtcNow;
|
||||
hello.As<RoutePart>().Title = "alpha";
|
||||
hello.As<RoutePart>().Slug = "beta";
|
||||
hello.As<TitlePart>().Title = "alpha";
|
||||
// hello.As<RoutePart>().Slug = "beta";
|
||||
hello.As<BodyPart>().Text = "gamma";
|
||||
|
||||
var query = new StubQuery(new[] {
|
||||
|
@@ -29,6 +29,8 @@ using Orchard.Tests.Stubs;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Core.Tests.Routable.Services {
|
||||
|
||||
// TODO: (PH)
|
||||
[TestFixture]
|
||||
public class RoutableServiceTests : DatabaseEnabledTestsBase {
|
||||
[SetUp]
|
||||
|
@@ -4,6 +4,7 @@ using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Core.Routable.Services;
|
||||
using Orchard.Mvc.Extensions;
|
||||
using Orchard.Mvc.Html;
|
||||
|
||||
namespace Orchard.Blogs.Extensions {
|
||||
public static class UrlHelperExtensions {
|
||||
@@ -16,7 +17,7 @@ namespace Orchard.Blogs.Extensions {
|
||||
}
|
||||
|
||||
public static string Blog(this UrlHelper urlHelper, BlogPart blogPart) {
|
||||
return urlHelper.Action("Item", "Blog", new { blogPath = blogPart.As<IRoutableAspect>().Path, area = "Orchard.Blogs" });
|
||||
return urlHelper.Action("Item", "Blog", new { blogId = blogPart.Id, area = "Orchard.Blogs" });
|
||||
}
|
||||
|
||||
public static string BlogLiveWriterManifest(this UrlHelper urlHelper, BlogPart blogPart) {
|
||||
@@ -24,19 +25,19 @@ namespace Orchard.Blogs.Extensions {
|
||||
}
|
||||
|
||||
public static string BlogRsd(this UrlHelper urlHelper, BlogPart blogPart) {
|
||||
return urlHelper.AbsoluteAction(() => urlHelper.Action("Rsd", "RemoteBlogPublishing", new { blogPath = blogPart.As<IRoutableAspect>().Path, area = "Orchard.Blogs" }));
|
||||
return urlHelper.AbsoluteAction(() => urlHelper.Action("Rsd", "RemoteBlogPublishing", new { blogPath = urlHelper.ItemDisplayUrl(blogPart), area = "Orchard.Blogs" }));
|
||||
}
|
||||
|
||||
public static string BlogArchiveYear(this UrlHelper urlHelper, BlogPart blogPart, int year) {
|
||||
return urlHelper.Action("ListByArchive", "BlogPost", new { blogPath = blogPart.As<IRoutableAspect>().Path, archiveData = year.ToString(), area = "Orchard.Blogs" });
|
||||
return urlHelper.Action("ListByArchive", "BlogPost", new { blogPath = urlHelper.ItemDisplayUrl(blogPart), archiveData = year.ToString(), area = "Orchard.Blogs" });
|
||||
}
|
||||
|
||||
public static string BlogArchiveMonth(this UrlHelper urlHelper, BlogPart blogPart, int year, int month) {
|
||||
return urlHelper.Action("ListByArchive", "BlogPost", new { blogPath = blogPart.As<IRoutableAspect>().Path, archiveData = string.Format("{0}/{1}", year, month), area = "Orchard.Blogs" });
|
||||
return urlHelper.Action("ListByArchive", "BlogPost", new { blogPath = urlHelper.ItemDisplayUrl(blogPart), archiveData = string.Format("{0}/{1}", year, month), area = "Orchard.Blogs" });
|
||||
}
|
||||
|
||||
public static string BlogArchiveDay(this UrlHelper urlHelper, BlogPart blogPart, int year, int month, int day) {
|
||||
return urlHelper.Action("ListByArchive", "BlogPost", new { blogPath = blogPart.As<IRoutableAspect>().Path, archiveData = string.Format("{0}/{1}/{2}", year, month, day), area = "Orchard.Blogs" });
|
||||
return urlHelper.Action("ListByArchive", "BlogPost", new { blogPath = urlHelper.ItemDisplayUrl(blogPart), archiveData = string.Format("{0}/{1}/{2}", year, month, day), area = "Orchard.Blogs" });
|
||||
}
|
||||
|
||||
public static string BlogForAdmin(this UrlHelper urlHelper, BlogPart blogPart) {
|
||||
@@ -60,7 +61,7 @@ namespace Orchard.Blogs.Extensions {
|
||||
}
|
||||
|
||||
public static string BlogPost(this UrlHelper urlHelper, BlogPostPart blogPostPart) {
|
||||
return urlHelper.Action("Item", "BlogPost", new { blogPath = blogPostPart.BlogPart.As<IRoutableAspect>().Path, postSlug = blogPostPart.As<IRoutableAspect>().GetEffectiveSlug(), area = "Orchard.Blogs" });
|
||||
return urlHelper.Action("Item", "BlogPost", new { blogPath = urlHelper.ItemDisplayUrl(blogPostPart.As<ICommonPart>().Container), postSlug = blogPostPart.As<IRoutableAspect>(), area = "Orchard.Blogs" });
|
||||
}
|
||||
|
||||
public static string BlogPostEdit(this UrlHelper urlHelper, BlogPostPart blogPostPart) {
|
||||
|
@@ -58,6 +58,8 @@ namespace Orchard.Blogs.Handlers {
|
||||
if (blogPost == null)
|
||||
return;
|
||||
|
||||
// Note: DisplayRouteValues are simply inherited from CommonPart
|
||||
|
||||
context.Metadata.CreateRouteValues = new RouteValueDictionary {
|
||||
{"Area", "Orchard.Blogs"},
|
||||
{"Controller", "BlogPostAdmin"},
|
||||
@@ -76,7 +78,7 @@ namespace Orchard.Blogs.Handlers {
|
||||
{"Controller", "BlogPostAdmin"},
|
||||
{"Action", "Delete"},
|
||||
{"postId", context.ContentItem.Id},
|
||||
{"blogPath", blogPost.BlogPart.As<RoutePart>().Path}
|
||||
{"blogId", blogPost.BlogPart.Id}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -47,7 +47,6 @@ namespace Orchard.Blogs.Services {
|
||||
|
||||
public void Delete(ContentItem blog) {
|
||||
_contentManager.Remove(blog);
|
||||
_blogPathConstraint.RemovePath(blog.As<IRoutableAspect>().Path);
|
||||
}
|
||||
}
|
||||
}
|
@@ -63,8 +63,8 @@ namespace Orchard.Indexing.Commands {
|
||||
Context.Output.WriteLine("├──────────────────────────────────────────────────────────────┼────────┤");
|
||||
foreach ( var searchHit in results ) {
|
||||
var contentItem = _contentManager.Get(searchHit.ContentItemId);
|
||||
var routable = contentItem.As<IRoutableAspect>();
|
||||
var title = routable == null ? "- no title -" : routable.Title;
|
||||
var metadata = _contentManager.GetItemMetadata(contentItem);
|
||||
var title = String.IsNullOrWhiteSpace(metadata.DisplayText) ? "- no title -" : metadata.DisplayText;
|
||||
title = title.Substring(0, Math.Min(60, title.Length));
|
||||
var score = Math.Round(searchHit.Score, 2).ToString();
|
||||
Context.Output.WriteLine("│ {0} │ {1,6} │", title + new string(' ', 60 - title.Length), score);
|
||||
|
Reference in New Issue
Block a user