mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +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.Core.Routable.Models;
|
||||||
using Orchard.Tests.Modules;
|
using Orchard.Tests.Modules;
|
||||||
using Orchard.Tests.Stubs;
|
using Orchard.Tests.Stubs;
|
||||||
|
using Orchard.Core.Title.Models;
|
||||||
|
|
||||||
namespace Orchard.Core.Tests.Feeds.Controllers {
|
namespace Orchard.Core.Tests.Feeds.Controllers {
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
@@ -148,16 +149,16 @@ namespace Orchard.Core.Tests.Feeds.Controllers {
|
|||||||
var clock = new StubClock();
|
var clock = new StubClock();
|
||||||
var hello = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("hello").Build())
|
var hello = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("hello").Build())
|
||||||
.Weld<CommonPart>()
|
.Weld<CommonPart>()
|
||||||
.Weld<RoutePart>()
|
.Weld<TitlePart>()
|
||||||
.Weld<BodyPart>()
|
.Weld<BodyPart>()
|
||||||
.Build();
|
.Build();
|
||||||
hello.As<CommonPart>().Record = new CommonPartRecord();
|
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<BodyPart>().Record = new BodyPartRecord();
|
||||||
|
|
||||||
hello.As<CommonPart>().PublishedUtc = clock.UtcNow;
|
hello.As<CommonPart>().PublishedUtc = clock.UtcNow;
|
||||||
hello.As<RoutePart>().Title = "alpha";
|
hello.As<TitlePart>().Title = "alpha";
|
||||||
hello.As<RoutePart>().Slug = "beta";
|
// hello.As<RoutePart>().Slug = "beta";
|
||||||
hello.As<BodyPart>().Text = "gamma";
|
hello.As<BodyPart>().Text = "gamma";
|
||||||
|
|
||||||
var query = new StubQuery(new[] {
|
var query = new StubQuery(new[] {
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ using Orchard.Tests.Stubs;
|
|||||||
using Orchard.UI.Notify;
|
using Orchard.UI.Notify;
|
||||||
|
|
||||||
namespace Orchard.Core.Tests.Routable.Services {
|
namespace Orchard.Core.Tests.Routable.Services {
|
||||||
|
|
||||||
|
// TODO: (PH)
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class RoutableServiceTests : DatabaseEnabledTestsBase {
|
public class RoutableServiceTests : DatabaseEnabledTestsBase {
|
||||||
[SetUp]
|
[SetUp]
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using Orchard.ContentManagement;
|
|||||||
using Orchard.ContentManagement.Aspects;
|
using Orchard.ContentManagement.Aspects;
|
||||||
using Orchard.Core.Routable.Services;
|
using Orchard.Core.Routable.Services;
|
||||||
using Orchard.Mvc.Extensions;
|
using Orchard.Mvc.Extensions;
|
||||||
|
using Orchard.Mvc.Html;
|
||||||
|
|
||||||
namespace Orchard.Blogs.Extensions {
|
namespace Orchard.Blogs.Extensions {
|
||||||
public static class UrlHelperExtensions {
|
public static class UrlHelperExtensions {
|
||||||
@@ -16,7 +17,7 @@ namespace Orchard.Blogs.Extensions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static string Blog(this UrlHelper urlHelper, BlogPart blogPart) {
|
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) {
|
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) {
|
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) {
|
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) {
|
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) {
|
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) {
|
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) {
|
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) {
|
public static string BlogPostEdit(this UrlHelper urlHelper, BlogPostPart blogPostPart) {
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ namespace Orchard.Blogs.Handlers {
|
|||||||
if (blogPost == null)
|
if (blogPost == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Note: DisplayRouteValues are simply inherited from CommonPart
|
||||||
|
|
||||||
context.Metadata.CreateRouteValues = new RouteValueDictionary {
|
context.Metadata.CreateRouteValues = new RouteValueDictionary {
|
||||||
{"Area", "Orchard.Blogs"},
|
{"Area", "Orchard.Blogs"},
|
||||||
{"Controller", "BlogPostAdmin"},
|
{"Controller", "BlogPostAdmin"},
|
||||||
@@ -76,7 +78,7 @@ namespace Orchard.Blogs.Handlers {
|
|||||||
{"Controller", "BlogPostAdmin"},
|
{"Controller", "BlogPostAdmin"},
|
||||||
{"Action", "Delete"},
|
{"Action", "Delete"},
|
||||||
{"postId", context.ContentItem.Id},
|
{"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) {
|
public void Delete(ContentItem blog) {
|
||||||
_contentManager.Remove(blog);
|
_contentManager.Remove(blog);
|
||||||
_blogPathConstraint.RemovePath(blog.As<IRoutableAspect>().Path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,8 +63,8 @@ namespace Orchard.Indexing.Commands {
|
|||||||
Context.Output.WriteLine("├──────────────────────────────────────────────────────────────┼────────┤");
|
Context.Output.WriteLine("├──────────────────────────────────────────────────────────────┼────────┤");
|
||||||
foreach ( var searchHit in results ) {
|
foreach ( var searchHit in results ) {
|
||||||
var contentItem = _contentManager.Get(searchHit.ContentItemId);
|
var contentItem = _contentManager.Get(searchHit.ContentItemId);
|
||||||
var routable = contentItem.As<IRoutableAspect>();
|
var metadata = _contentManager.GetItemMetadata(contentItem);
|
||||||
var title = routable == null ? "- no title -" : routable.Title;
|
var title = String.IsNullOrWhiteSpace(metadata.DisplayText) ? "- no title -" : metadata.DisplayText;
|
||||||
title = title.Substring(0, Math.Min(60, title.Length));
|
title = title.Substring(0, Math.Min(60, title.Length));
|
||||||
var score = Math.Round(searchHit.Score, 2).ToString();
|
var score = Math.Round(searchHit.Score, 2).ToString();
|
||||||
Context.Output.WriteLine("│ {0} │ {1,6} │", title + new string(' ', 60 - title.Length), score);
|
Context.Output.WriteLine("│ {0} │ {1,6} │", title + new string(' ', 60 - title.Length), score);
|
||||||
|
|||||||
Reference in New Issue
Block a user