Implementing IAliasAspect

--HG--
branch : autoroute
This commit is contained in:
Sebastien Ros 2012-01-31 18:13:54 -08:00
parent 367066e741
commit b5e69f827d
11 changed files with 21 additions and 28 deletions

View File

@ -1,5 +1,5 @@
81cb672c85fd980dd3db0515544b79a918e5eb69 src/Orchard.Web/Modules/Orchard.Alias 81cb672c85fd980dd3db0515544b79a918e5eb69 src/Orchard.Web/Modules/Orchard.Alias
f142e9e8cebf92caf3ca091d6e54849e02a27a4c src/Orchard.Web/Modules/Orchard.Autoroute 38ee40302540edd0f4671b8110788b295573c345 src/Orchard.Web/Modules/Orchard.Autoroute
c54cb640d6bc14c51b9fb9bd78231bb0facec067 src/Orchard.Web/Modules/Orchard.Forms c54cb640d6bc14c51b9fb9bd78231bb0facec067 src/Orchard.Web/Modules/Orchard.Forms
c27801666ed3e8f9b9c7979a837e7d770763352a src/Orchard.Web/Modules/Orchard.Projections c27801666ed3e8f9b9c7979a837e7d770763352a src/Orchard.Web/Modules/Orchard.Projections
a1ef39ba4e2d0cd78b3c91d6150e841793acb34b src/Orchard.Web/Modules/Orchard.Routable a1ef39ba4e2d0cd78b3c91d6150e841793acb34b src/Orchard.Web/Modules/Orchard.Routable

View File

@ -1,5 +1,4 @@
using System.Web.Mvc; using System.Web.Mvc;
using Orchard.Autoroute.Models;
using Orchard.Blogs.Models; using Orchard.Blogs.Models;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects; using Orchard.ContentManagement.Aspects;
@ -27,19 +26,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 { path = blogPart.As<IAliasAspect>().Path + "/rsd", 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<AutoroutePart>().DisplayAlias, archiveData = year.ToString(), area = "Orchard.Blogs" }); return urlHelper.Action("ListByArchive", "BlogPost", new { path = blogPart.As<IAliasAspect>().Path + "/archive/" + 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<AutoroutePart>().DisplayAlias, archiveData = string.Format("{0}/{1}", year, month), area = "Orchard.Blogs" }); return urlHelper.Action("ListByArchive", "BlogPost", new { path = blogPart.As<IAliasAspect>().Path + "/archive/" + 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<AutoroutePart>().DisplayAlias, archiveData = string.Format("{0}/{1}/{2}", year, month, day), area = "Orchard.Blogs" }); return urlHelper.Action("ListByArchive", "BlogPost", new { path = blogPart.As<IAliasAspect>().Path + "/archive/" + 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) {

View File

@ -1,9 +1,9 @@
using System.Web.Routing; using System.Web.Routing;
using JetBrains.Annotations; using JetBrains.Annotations;
using Orchard.Autoroute.Models;
using Orchard.Blogs.Models; using Orchard.Blogs.Models;
using Orchard.Blogs.Routing; using Orchard.Blogs.Routing;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;
using Orchard.Data; using Orchard.Data;
@ -21,8 +21,8 @@ namespace Orchard.Blogs.Handlers {
context.Shape.PostCount = blog.PostCount; context.Shape.PostCount = blog.PostCount;
}); });
OnPublished<BlogPart>((context, blog) => _blogPathConstraint.AddPath(blog.As<AutoroutePart>().DisplayAlias)); OnPublished<BlogPart>((context, blog) => _blogPathConstraint.AddPath(blog.As<IAliasAspect>().Path));
OnUnpublished<BlogPart>((context, blog) => _blogPathConstraint.RemovePath(blog.As<AutoroutePart>().DisplayAlias)); OnUnpublished<BlogPart>((context, blog) => _blogPathConstraint.RemovePath(blog.As<IAliasAspect>().Path));
} }
protected override void GetItemMetadata(GetContentItemMetadataContext context) { protected override void GetItemMetadata(GetContentItemMetadataContext context) {

View File

@ -12,5 +12,5 @@ Features:
Orchard.Blogs.RemotePublishing: Orchard.Blogs.RemotePublishing:
Name: Remote Blog Publishing Name: Remote Blog Publishing
Description: Blog easier using a dedicated MetaWeblogAPI-compatible publishing tool. Description: Blog easier using a dedicated MetaWeblogAPI-compatible publishing tool.
Dependencies: XmlRpc, Orchard.Blogs Dependencies: XmlRpc, Orchard.Blogs, Orchard.Autoroute
Category: Content Publishing Category: Content Publishing

View File

@ -140,14 +140,6 @@
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project> <Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name> <Name>Orchard.Core</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\Orchard.Alias\Orchard.Alias.csproj">
<Project>{475B6C45-B27C-438B-8966-908B9D6D1077}</Project>
<Name>Orchard.Alias</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.Autoroute\Orchard.Autoroute.csproj">
<Project>{66FCCD76-2761-47E3-8D11-B45D0001DDAA}</Project>
<Name>Orchard.Autoroute</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Placement.info"> <Content Include="Placement.info">

View File

@ -10,7 +10,7 @@ using Orchard.Logging;
namespace Orchard.Blogs.Routing { namespace Orchard.Blogs.Routing {
[UsedImplicitly] [UsedImplicitly]
public class BlogPathConstraint : IBlogPathConstraint { public class BlogPathConstraint : IBlogPathConstraint {
private ConcurrentDictionary<string, string> _paths = new ConcurrentDictionary<string, string>(StringComparer.OrdinalIgnoreCase); private readonly ConcurrentDictionary<string, string> _paths = new ConcurrentDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
public BlogPathConstraint() { public BlogPathConstraint() {
Logger = NullLogger.Instance; Logger = NullLogger.Instance;

View File

@ -1,8 +1,8 @@
using System.Linq; using System.Linq;
using JetBrains.Annotations; using JetBrains.Annotations;
using Orchard.Autoroute.Models;
using Orchard.Blogs.Services; using Orchard.Blogs.Services;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.Environment; using Orchard.Environment;
using Orchard.Tasks; using Orchard.Tasks;
@ -29,7 +29,7 @@ namespace Orchard.Blogs.Routing {
} }
private void Refresh() { private void Refresh() {
_blogPathConstraint.SetPaths(_blogService.Get().Select(b => b.As<AutoroutePart>().DisplayAlias).ToList()); _blogPathConstraint.SetPaths(_blogService.Get().Select(b => b.As<IAliasAspect>().Path).ToList());
} }
} }
} }

View File

@ -1,7 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using JetBrains.Annotations; using JetBrains.Annotations;
using Orchard.Autoroute.Models;
using Orchard.Blogs.Models; using Orchard.Blogs.Models;
using Orchard.Blogs.Routing; using Orchard.Blogs.Routing;
using Orchard.ContentManagement; using Orchard.ContentManagement;
@ -20,9 +19,7 @@ namespace Orchard.Blogs.Services {
} }
public BlogPart Get(string path) { public BlogPart Get(string path) {
return _contentManager.Query<BlogPart, BlogPartRecord>() return _contentManager.Query<BlogPart>().List().FirstOrDefault(rr => rr.As<IAliasAspect>().Path == path);
.Join<AutoroutePartRecord>().Where(rr => rr.DisplayAlias == path)
.Slice(0, 1).FirstOrDefault();
} }
public ContentItem Get(int id, VersionOptions versionOptions) { public ContentItem Get(int id, VersionOptions versionOptions) {
@ -42,7 +39,7 @@ namespace Orchard.Blogs.Services {
public void Delete(ContentItem blog) { public void Delete(ContentItem blog) {
_contentManager.Remove(blog); _contentManager.Remove(blog);
_blogPathConstraint.RemovePath(blog.As<AutoroutePart>().DisplayAlias); _blogPathConstraint.RemovePath(blog.As<IAliasAspect>().Path);
} }
} }
} }

View File

@ -0,0 +1,5 @@
namespace Orchard.ContentManagement.Aspects {
public interface IAliasAspect : IContent {
string Path { get; }
}
}

View File

@ -1,6 +1,5 @@
namespace Orchard.ContentManagement.Aspects { namespace Orchard.ContentManagement.Aspects {
public interface IRoutableAspect : ITitleAspect { public interface IRoutableAspect : ITitleAspect, IAliasAspect {
string Slug { get; set; } string Slug { get; set; }
string Path { get; set; }
} }
} }

View File

@ -159,6 +159,7 @@
<Compile Include="Caching\DefaultParallelCacheContext.cs" /> <Compile Include="Caching\DefaultParallelCacheContext.cs" />
<Compile Include="Caching\ICacheContextAccessor.cs" /> <Compile Include="Caching\ICacheContextAccessor.cs" />
<Compile Include="Caching\IParallelCacheContext.cs" /> <Compile Include="Caching\IParallelCacheContext.cs" />
<Compile Include="ContentManagement\Aspects\IAliasAspect.cs" />
<Compile Include="ContentManagement\Aspects\ITitleAspect.cs" /> <Compile Include="ContentManagement\Aspects\ITitleAspect.cs" />
<Compile Include="ContentManagement\Aspects\ILocalizableAspect.cs" /> <Compile Include="ContentManagement\Aspects\ILocalizableAspect.cs" />
<Compile Include="ContentManagement\ContentIdentity.cs" /> <Compile Include="ContentManagement\ContentIdentity.cs" />