IsRoutable -> RoutePart

- updating part names to conform to a <name>Part convention

--HG--
branch : dev
rename : src/Orchard.Web/Core/Routable/Drivers/RoutableDriver.cs => src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs
rename : src/Orchard.Web/Core/Routable/Handlers/RoutableHandler.cs => src/Orchard.Web/Core/Routable/Handlers/RoutePartHandler.cs
rename : src/Orchard.Web/Core/Routable/Models/IsRoutable.cs => src/Orchard.Web/Core/Routable/Models/RoutePart.cs
rename : src/Orchard.Web/Core/Routable/Models/RoutableRecord.cs => src/Orchard.Web/Core/Routable/Models/RoutePartRecord.cs
rename : src/Orchard.Web/Core/Routable/Views/EditorTemplates/Parts/Routable.IsRoutable.ascx => src/Orchard.Web/Core/Routable/Views/EditorTemplates/Parts/Routable.RoutePart.ascx
This commit is contained in:
Nathan Heskew
2010-07-23 01:01:49 -07:00
parent 2e9eff17e0
commit f482c738ec
28 changed files with 101 additions and 101 deletions

View File

@@ -40,7 +40,7 @@ namespace Orchard.Core.Tests.Common.Services {
builder.RegisterType<DefaultContentQuery>().As<IContentQuery>(); builder.RegisterType<DefaultContentQuery>().As<IContentQuery>();
builder.RegisterInstance(new UrlHelper(new RequestContext(new StubHttpContext("~/"), new RouteData()))).As<UrlHelper>(); builder.RegisterInstance(new UrlHelper(new RequestContext(new StubHttpContext("~/"), new RouteData()))).As<UrlHelper>();
builder.RegisterType<RoutableHandler>().As<IContentHandler>(); builder.RegisterType<RoutePartHandler>().As<IContentHandler>();
} }
@@ -51,11 +51,11 @@ namespace Orchard.Core.Tests.Common.Services {
var contentManager = _container.Resolve<IContentManager>(); var contentManager = _container.Resolve<IContentManager>();
var thing = contentManager.Create<Thing>(ThingDriver.ContentType.Name, t => { var thing = contentManager.Create<Thing>(ThingDriver.ContentType.Name, t => {
t.As<IsRoutable>().Record = new RoutableRecord(); t.As<RoutePart>().Record = new RoutePartRecord();
t.Title = "Please do not use any of the following characters in your slugs: \":\", \"/\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\""; t.Title = "Please do not use any of the following characters in your slugs: \":\", \"/\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\"";
}); });
_routableService.FillSlug(thing.As<IsRoutable>()); _routableService.FillSlug(thing.As<RoutePart>());
Assert.That(thing.Slug, Is.EqualTo("please-do-not-use-any-of-the-following-characters-in-your-slugs-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"")); Assert.That(thing.Slug, Is.EqualTo("please-do-not-use-any-of-the-following-characters-in-your-slugs-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\"-\""));
} }
@@ -87,11 +87,11 @@ namespace Orchard.Core.Tests.Common.Services {
veryVeryLongTitle += "aaaaaaaaaa"; veryVeryLongTitle += "aaaaaaaaaa";
var thing = contentManager.Create<Thing>(ThingDriver.ContentType.Name, t => { var thing = contentManager.Create<Thing>(ThingDriver.ContentType.Name, t => {
t.As<IsRoutable>().Record = new RoutableRecord(); t.As<RoutePart>().Record = new RoutePartRecord();
t.Title = veryVeryLongTitle; t.Title = veryVeryLongTitle;
}); });
_routableService.FillSlug(thing.As<IsRoutable>()); _routableService.FillSlug(thing.As<RoutePart>());
Assert.That(veryVeryLongTitle.Length, Is.AtLeast(1001)); Assert.That(veryVeryLongTitle.Length, Is.AtLeast(1001));
Assert.That(thing.Slug.Length, Is.EqualTo(1000)); Assert.That(thing.Slug.Length, Is.EqualTo(1000));
@@ -138,11 +138,11 @@ namespace Orchard.Core.Tests.Common.Services {
var contentManager = _container.Resolve<IContentManager>(); var contentManager = _container.Resolve<IContentManager>();
var thing = contentManager.Create<Thing>(ThingDriver.ContentType.Name, t => { var thing = contentManager.Create<Thing>(ThingDriver.ContentType.Name, t => {
t.As<IsRoutable>().Record = new RoutableRecord(); t.As<RoutePart>().Record = new RoutePartRecord();
t.Title = "This Is Some Interesting Title"; t.Title = "This Is Some Interesting Title";
}); });
_routableService.FillSlug(thing.As<IsRoutable>()); _routableService.FillSlug(thing.As<RoutePart>());
Assert.That(thing.Slug, Is.EqualTo("this-is-some-interesting-title")); Assert.That(thing.Slug, Is.EqualTo("this-is-some-interesting-title"));
} }
@@ -152,12 +152,12 @@ namespace Orchard.Core.Tests.Common.Services {
var contentManager = _container.Resolve<IContentManager>(); var contentManager = _container.Resolve<IContentManager>();
var thing1 = contentManager.Create<Thing>(ThingDriver.ContentType.Name, t => { var thing1 = contentManager.Create<Thing>(ThingDriver.ContentType.Name, t => {
t.As<IsRoutable>().Record = new RoutableRecord(); t.As<RoutePart>().Record = new RoutePartRecord();
t.Title = "This Is Some Interesting Title"; t.Title = "This Is Some Interesting Title";
}); });
var thing2 = contentManager.Create<Thing>(ThingDriver.ContentType.Name, t => { var thing2 = contentManager.Create<Thing>(ThingDriver.ContentType.Name, t => {
t.As<IsRoutable>().Record = new RoutableRecord(); t.As<RoutePart>().Record = new RoutePartRecord();
t.Title = "This Is Some Interesting Title"; t.Title = "This Is Some Interesting Title";
}); });
@@ -169,12 +169,12 @@ namespace Orchard.Core.Tests.Common.Services {
var contentManager = _container.Resolve<IContentManager>(); var contentManager = _container.Resolve<IContentManager>();
var thing = contentManager.Create<Thing>(ThingDriver.ContentType.Name, t => { var thing = contentManager.Create<Thing>(ThingDriver.ContentType.Name, t => {
t.As<IsRoutable>().Record = new RoutableRecord(); t.As<RoutePart>().Record = new RoutePartRecord();
t.Title = "This Is Some Interesting Title"; t.Title = "This Is Some Interesting Title";
}); });
var stuff = contentManager.Create<Stuff>(StuffDriver.ContentType.Name, s => { var stuff = contentManager.Create<Stuff>(StuffDriver.ContentType.Name, s => {
s.As<IsRoutable>().Record = new RoutableRecord(); s.As<RoutePart>().Record = new RoutePartRecord();
s.Title = "This Is Some Interesting Title"; s.Title = "This Is Some Interesting Title";
}); });
@@ -185,7 +185,7 @@ namespace Orchard.Core.Tests.Common.Services {
protected override IEnumerable<Type> DatabaseTypes { protected override IEnumerable<Type> DatabaseTypes {
get { get {
return new[] { return new[] {
typeof(RoutableRecord), typeof(RoutePartRecord),
typeof(ContentTypeRecord), typeof(ContentTypeRecord),
typeof(ContentItemRecord), typeof(ContentItemRecord),
typeof(ContentItemVersionRecord), typeof(ContentItemVersionRecord),
@@ -201,7 +201,7 @@ namespace Orchard.Core.Tests.Common.Services {
Filters.Add(new ActivatingFilter<Thing>(ThingDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<Thing>(ThingDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<ContentPart<CommonPartVersionRecord>>(ThingDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<ContentPart<CommonPartVersionRecord>>(ThingDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<CommonPart>(ThingDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<CommonPart>(ThingDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<IsRoutable>(ThingDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<RoutePart>(ThingDriver.ContentType.Name));
} }
} }
@@ -209,13 +209,13 @@ namespace Orchard.Core.Tests.Common.Services {
public int Id { get { return ContentItem.Id; } } public int Id { get { return ContentItem.Id; } }
public string Title { public string Title {
get { return this.As<IsRoutable>().Title; } get { return this.As<RoutePart>().Title; }
set { this.As<IsRoutable>().Title = value; } set { this.As<RoutePart>().Title = value; }
} }
public string Slug { public string Slug {
get { return this.As<IsRoutable>().Slug; } get { return this.As<RoutePart>().Slug; }
set { this.As<IsRoutable>().Slug = value; } set { this.As<RoutePart>().Slug = value; }
} }
} }
@@ -232,7 +232,7 @@ namespace Orchard.Core.Tests.Common.Services {
Filters.Add(new ActivatingFilter<Stuff>(StuffDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<Stuff>(StuffDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<ContentPart<CommonPartVersionRecord>>(StuffDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<ContentPart<CommonPartVersionRecord>>(StuffDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<CommonPart>(StuffDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<CommonPart>(StuffDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<IsRoutable>(StuffDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<RoutePart>(StuffDriver.ContentType.Name));
} }
} }
@@ -240,13 +240,13 @@ namespace Orchard.Core.Tests.Common.Services {
public int Id { get { return ContentItem.Id; } } public int Id { get { return ContentItem.Id; } }
public string Title { public string Title {
get { return this.As<IsRoutable>().Title; } get { return this.As<RoutePart>().Title; }
set { this.As<IsRoutable>().Title = value; } set { this.As<RoutePart>().Title = value; }
} }
public string Slug { public string Slug {
get { return this.As<IsRoutable>().Slug; } get { return this.As<RoutePart>().Slug; }
set { this.As<IsRoutable>().Slug = value; } set { this.As<RoutePart>().Slug = value; }
} }
} }

View File

@@ -149,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<IsRoutable>() .Weld<RoutePart>()
.Weld<BodyPart>() .Weld<BodyPart>()
.Build(); .Build();
hello.As<CommonPart>().Record = new CommonPartRecord(); hello.As<CommonPart>().Record = new CommonPartRecord();
hello.As<IsRoutable>().Record = new RoutableRecord(); hello.As<RoutePart>().Record = new RoutePartRecord();
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<IsRoutable>().Title = "alpha"; hello.As<RoutePart>().Title = "alpha";
hello.As<IsRoutable>().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[] {

View File

@@ -93,7 +93,7 @@ namespace Orchard.Core.Common.Drivers {
if (common == null) if (common == null)
return this; return this;
var routable = common.Container.As<IsRoutable>(); var routable = common.Container.As<RoutePart>();
if (routable == null) if (routable == null)
return this; return this;
@@ -102,7 +102,7 @@ namespace Orchard.Core.Common.Drivers {
} }
public PathBuilder AddSlug() { public PathBuilder AddSlug() {
var routable = _content.As<IsRoutable>(); var routable = _content.As<RoutePart>();
if (routable == null) if (routable == null)
return this; return this;

View File

@@ -10,14 +10,14 @@ namespace Orchard.Core.Feeds.StandardBuilders {
private readonly IContent _item; private readonly IContent _item;
private readonly ContentItemMetadata _metadata; private readonly ContentItemMetadata _metadata;
private readonly ICommonPart _common; private readonly ICommonPart _common;
private readonly IsRoutable _routable; private readonly RoutePart _routable;
private readonly BodyPart _body; private readonly BodyPart _body;
public ItemInspector(IContent item, ContentItemMetadata metadata) { public ItemInspector(IContent item, ContentItemMetadata metadata) {
_item = item; _item = item;
_metadata = metadata; _metadata = metadata;
_common = item.Get<ICommonPart>(); _common = item.Get<ICommonPart>();
_routable = item.Get<IsRoutable>(); _routable = item.Get<RoutePart>();
_body = item.Get<BodyPart>(); _body = item.Get<BodyPart>();
} }

View File

@@ -114,10 +114,10 @@
<Compile Include="Reports\ViewModels\ReportsAdminIndexViewModel.cs" /> <Compile Include="Reports\ViewModels\ReportsAdminIndexViewModel.cs" />
<Compile Include="Routable\Controllers\ItemController.cs" /> <Compile Include="Routable\Controllers\ItemController.cs" />
<Compile Include="Routable\DataMigrations\RoutableDataMigration.cs" /> <Compile Include="Routable\DataMigrations\RoutableDataMigration.cs" />
<Compile Include="Routable\Drivers\RoutableDriver.cs" /> <Compile Include="Routable\Drivers\RoutePartDriver.cs" />
<Compile Include="Routable\Handlers\RoutableHandler.cs" /> <Compile Include="Routable\Handlers\RoutePartHandler.cs" />
<Compile Include="Routable\IRoutablePathConstraint.cs" /> <Compile Include="Routable\IRoutablePathConstraint.cs" />
<Compile Include="Routable\Models\IsRoutable.cs" /> <Compile Include="Routable\Models\RoutePart.cs" />
<Compile Include="Common\Permissions.cs" /> <Compile Include="Common\Permissions.cs" />
<Compile Include="Common\Models\CommonPartVersionRecord.cs" /> <Compile Include="Common\Models\CommonPartVersionRecord.cs" />
<Compile Include="Common\Utilities\LazyField.cs" /> <Compile Include="Common\Utilities\LazyField.cs" />
@@ -176,7 +176,7 @@
<Compile Include="Navigation\ViewModels\MenuItemEntry.cs" /> <Compile Include="Navigation\ViewModels\MenuItemEntry.cs" />
<Compile Include="Navigation\ViewModels\NavigationManagementViewModel.cs" /> <Compile Include="Navigation\ViewModels\NavigationManagementViewModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Routable\Models\RoutableRecord.cs" /> <Compile Include="Routable\Models\RoutePartRecord.cs" />
<Compile Include="Routable\Routes.cs" /> <Compile Include="Routable\Routes.cs" />
<Compile Include="Routable\Services\IRoutableService.cs" /> <Compile Include="Routable\Services\IRoutableService.cs" />
<Compile Include="Routable\Services\RoutablePathConstraint.cs" /> <Compile Include="Routable\Services\RoutablePathConstraint.cs" />
@@ -297,7 +297,7 @@
<Content Include="Localization\Views\CultureSelection.ascx" /> <Content Include="Localization\Views\CultureSelection.ascx" />
<Content Include="Routable\Module.txt" /> <Content Include="Routable\Module.txt" />
<Content Include="Routable\Scripts\jquery.slugify.js" /> <Content Include="Routable\Scripts\jquery.slugify.js" />
<Content Include="Routable\Views\EditorTemplates\Parts\Routable.IsRoutable.ascx" /> <Content Include="Routable\Views\EditorTemplates\Parts\Routable.RoutePart.ascx" />
<Content Include="Routable\Views\Item\Display.ascx" /> <Content Include="Routable\Views\Item\Display.ascx" />
<Content Include="Settings\Module.txt" /> <Content Include="Settings\Module.txt" />
<Content Include="Settings\Styles\admin.css" /> <Content Include="Settings\Styles\admin.css" />

View File

@@ -30,7 +30,7 @@ namespace Orchard.Core.Routable.Controllers {
} }
var hits = _contentManager var hits = _contentManager
.Query<IsRoutable, RoutableRecord>(VersionOptions.Published) .Query<RoutePart, RoutePartRecord>(VersionOptions.Published)
.Where(r => r.Path == matchedPath) .Where(r => r.Path == matchedPath)
.Slice(0, 2); .Slice(0, 2);
if (hits.Count() == 0) { if (hits.Count() == 0) {

View File

@@ -10,7 +10,7 @@ namespace Orchard.Core.Routable.DataMigrations {
public int Create() { public int Create() {
//CREATE TABLE Routable_RoutableRecord (Id INTEGER not null, Title TEXT, Slug TEXT, Path TEXT, ContentItemRecord_id INTEGER, primary key (Id)); //CREATE TABLE Routable_RoutableRecord (Id INTEGER not null, Title TEXT, Slug TEXT, Path TEXT, ContentItemRecord_id INTEGER, primary key (Id));
SchemaBuilder.CreateTable("RoutableRecord", table => table SchemaBuilder.CreateTable("RoutePartRecord", table => table
.ContentPartVersionRecord() .ContentPartVersionRecord()
.Column<string>("Title", column => column.WithLength(1024)) .Column<string>("Title", column => column.WithLength(1024))
.Column<string>("Slug") .Column<string>("Slug")
@@ -21,7 +21,7 @@ namespace Orchard.Core.Routable.DataMigrations {
} }
public int UpdateFrom1() { public int UpdateFrom1() {
ContentDefinitionManager.AlterPartDefinition(typeof(IsRoutable).Name, cfg => cfg ContentDefinitionManager.AlterPartDefinition(typeof(RoutePart).Name, cfg => cfg
.WithLocation(new Dictionary<string, ContentLocation> { .WithLocation(new Dictionary<string, ContentLocation> {
{"Editor", new ContentLocation { Zone = "primary", Position = "before.5" }} {"Editor", new ContentLocation { Zone = "primary", Position = "before.5" }}
} )); } ));

View File

@@ -9,17 +9,17 @@ using Orchard.Localization;
using Orchard.UI.Notify; using Orchard.UI.Notify;
namespace Orchard.Core.Routable.Drivers { namespace Orchard.Core.Routable.Drivers {
public class RoutableDriver : ContentPartDriver<IsRoutable> { public class RoutePartDriver : ContentPartDriver<RoutePart> {
private readonly IOrchardServices _services; private readonly IOrchardServices _services;
private readonly IRoutableService _routableService; private readonly IRoutableService _routableService;
public RoutableDriver(IOrchardServices services, IRoutableService routableService) { public RoutePartDriver(IOrchardServices services, IRoutableService routableService) {
_services = services; _services = services;
_routableService = routableService; _routableService = routableService;
T = NullLocalizer.Instance; T = NullLocalizer.Instance;
} }
private const string TemplateName = "Parts/Routable.IsRoutable"; private const string TemplateName = "Parts/Routable.RoutePart";
public Localizer T { get; set; } public Localizer T { get; set; }
@@ -46,7 +46,7 @@ namespace Orchard.Core.Routable.Drivers {
return null; return null;
} }
protected override DriverResult Editor(IsRoutable part) { protected override DriverResult Editor(RoutePart part) {
var model = new RoutableEditorViewModel { var model = new RoutableEditorViewModel {
ContentType = part.ContentItem.ContentType, ContentType = part.ContentItem.ContentType,
Id = part.ContentItem.Id, Id = part.ContentItem.Id,
@@ -71,7 +71,7 @@ namespace Orchard.Core.Routable.Drivers {
return ContentPartTemplate(model, TemplateName, Prefix).Location(location); return ContentPartTemplate(model, TemplateName, Prefix).Location(location);
} }
protected override DriverResult Editor(IsRoutable part, IUpdateModel updater) { protected override DriverResult Editor(RoutePart part, IUpdateModel updater) {
var model = new RoutableEditorViewModel(); var model = new RoutableEditorViewModel();
updater.TryUpdateModel(model, Prefix, null, null); updater.TryUpdateModel(model, Prefix, null, null);

View File

@@ -5,22 +5,22 @@ using Orchard.Core.Routable.Models;
using Orchard.Data; using Orchard.Data;
namespace Orchard.Core.Routable.Handlers { namespace Orchard.Core.Routable.Handlers {
public class RoutableHandler : ContentHandler { public class RoutePartHandler : ContentHandler {
private readonly IRoutablePathConstraint _routablePathConstraint; private readonly IRoutablePathConstraint _routablePathConstraint;
public RoutableHandler(IRepository<RoutableRecord> repository, IRoutablePathConstraint routablePathConstraint) { public RoutePartHandler(IRepository<RoutePartRecord> repository, IRoutablePathConstraint routablePathConstraint) {
_routablePathConstraint = routablePathConstraint; _routablePathConstraint = routablePathConstraint;
Filters.Add(StorageFilter.For(repository)); Filters.Add(StorageFilter.For(repository));
OnPublished<IsRoutable>((context, routable) => { OnPublished<RoutePart>((context, routable) => {
if (!string.IsNullOrEmpty(routable.Path)) if (!string.IsNullOrEmpty(routable.Path))
_routablePathConstraint.AddPath(routable.Path); _routablePathConstraint.AddPath(routable.Path);
}); });
} }
} }
public class IsRoutableHandler : ContentHandlerBase { public class RoutePartHandlerBase : ContentHandlerBase {
public override void GetContentItemMetadata(GetContentItemMetadataContext context) { public override void GetContentItemMetadata(GetContentItemMetadataContext context) {
var routable = context.ContentItem.As<IsRoutable>(); var routable = context.ContentItem.As<RoutePart>();
if (routable != null) { if (routable != null) {
context.Metadata.DisplayRouteValues = new RouteValueDictionary { context.Metadata.DisplayRouteValues = new RouteValueDictionary {
{"Area", "Routable"}, {"Area", "Routable"},

View File

@@ -2,7 +2,7 @@
using Orchard.ContentManagement.Aspects; using Orchard.ContentManagement.Aspects;
namespace Orchard.Core.Routable.Models { namespace Orchard.Core.Routable.Models {
public class IsRoutable : ContentPart<RoutableRecord>, IRoutableAspect { public class RoutePart : ContentPart<RoutePartRecord>, IRoutableAspect {
public string Title { public string Title {
get { return Record.Title; } get { return Record.Title; }
set { Record.Title = value; } set { Record.Title = value; }

View File

@@ -2,7 +2,7 @@
using Orchard.ContentManagement.Records; using Orchard.ContentManagement.Records;
namespace Orchard.Core.Routable.Models { namespace Orchard.Core.Routable.Models {
public class RoutableRecord : ContentPartVersionRecord { public class RoutePartRecord : ContentPartVersionRecord {
[StringLength(1024)] [StringLength(1024)]
public virtual string Title { get; set; } public virtual string Title { get; set; }

View File

@@ -4,14 +4,14 @@ using Orchard.Core.Routable.Models;
namespace Orchard.Core.Routable.Services { namespace Orchard.Core.Routable.Services {
public interface IRoutableService : IDependency { public interface IRoutableService : IDependency {
void FillSlug<TModel>(TModel model) where TModel : IsRoutable; void FillSlug<TModel>(TModel model) where TModel : RoutePart;
void FillSlug<TModel>(TModel model, Func<string, string> generateSlug) where TModel : IsRoutable; void FillSlug<TModel>(TModel model, Func<string, string> generateSlug) where TModel : RoutePart;
string GenerateUniqueSlug(string slugCandidate, IEnumerable<string> existingSlugs); string GenerateUniqueSlug(string slugCandidate, IEnumerable<string> existingSlugs);
/// <summary> /// <summary>
/// Returns any content item of the specified content type with similar slugs /// Returns any content item of the specified content type with similar slugs
/// </summary> /// </summary>
IEnumerable<IsRoutable> GetSimilarSlugs(string contentType, string slug); IEnumerable<RoutePart> GetSimilarSlugs(string contentType, string slug);
/// <summary> /// <summary>
/// Validates the given slug /// Validates the given slug
@@ -22,7 +22,7 @@ namespace Orchard.Core.Routable.Services {
/// Defines the slug of a RoutableAspect and validate its unicity /// Defines the slug of a RoutableAspect and validate its unicity
/// </summary> /// </summary>
/// <returns>True if the slug has been created, False if a conflict occured</returns> /// <returns>True if the slug has been created, False if a conflict occured</returns>
bool ProcessSlug(IsRoutable part); bool ProcessSlug(RoutePart part);
} }
} }

View File

@@ -28,11 +28,11 @@ namespace Orchard.Core.Routable.Services {
public ActionResult GetHomePage(int itemId) { public ActionResult GetHomePage(int itemId) {
var contentItem = _contentManager.Get(itemId, VersionOptions.Published); var contentItem = _contentManager.Get(itemId, VersionOptions.Published);
if (contentItem == null || !contentItem.Is<IsRoutable>()) if (contentItem == null || !contentItem.Is<RoutePart>())
return new NotFoundResult(); return new NotFoundResult();
var model = new RoutableDisplayViewModel { var model = new RoutableDisplayViewModel {
Routable = _contentManager.BuildDisplayModel<IRoutableAspect>(contentItem.As<IsRoutable>(), "Detail") Routable = _contentManager.BuildDisplayModel<IRoutableAspect>(contentItem.As<RoutePart>(), "Detail")
}; };
return new ViewResult { return new ViewResult {

View File

@@ -9,9 +9,9 @@ namespace Orchard.Core.Routable.Services {
[UsedImplicitly] [UsedImplicitly]
public class RoutablePathConstraintUpdator : IOrchardShellEvents, IBackgroundTask { public class RoutablePathConstraintUpdator : IOrchardShellEvents, IBackgroundTask {
private readonly IRoutablePathConstraint _pageSlugConstraint; private readonly IRoutablePathConstraint _pageSlugConstraint;
private readonly IRepository<RoutableRecord> _repository; private readonly IRepository<RoutePartRecord> _repository;
public RoutablePathConstraintUpdator(IRoutablePathConstraint pageSlugConstraint, IRepository<RoutableRecord> repository) { public RoutablePathConstraintUpdator(IRoutablePathConstraint pageSlugConstraint, IRepository<RoutePartRecord> repository) {
_pageSlugConstraint = pageSlugConstraint; _pageSlugConstraint = pageSlugConstraint;
_repository = repository; _repository = repository;
} }

View File

@@ -14,7 +14,7 @@ namespace Orchard.Core.Routable.Services {
_contentManager = contentManager; _contentManager = contentManager;
} }
public void FillSlug<TModel>(TModel model) where TModel : IsRoutable { public void FillSlug<TModel>(TModel model) where TModel : RoutePart {
if (!string.IsNullOrEmpty(model.Slug) || string.IsNullOrEmpty(model.Title)) if (!string.IsNullOrEmpty(model.Slug) || string.IsNullOrEmpty(model.Title))
return; return;
@@ -30,7 +30,7 @@ namespace Orchard.Core.Routable.Services {
model.Slug = slug.ToLowerInvariant(); model.Slug = slug.ToLowerInvariant();
} }
public void FillSlug<TModel>(TModel model, Func<string, string> generateSlug) where TModel : IsRoutable { public void FillSlug<TModel>(TModel model, Func<string, string> generateSlug) where TModel : RoutePart {
if (!string.IsNullOrEmpty(model.Slug) || string.IsNullOrEmpty(model.Title)) if (!string.IsNullOrEmpty(model.Slug) || string.IsNullOrEmpty(model.Title))
return; return;
@@ -60,12 +60,12 @@ namespace Orchard.Core.Routable.Services {
: null; : null;
} }
public IEnumerable<IsRoutable> GetSimilarSlugs(string contentType, string slug) public IEnumerable<RoutePart> GetSimilarSlugs(string contentType, string slug)
{ {
return return
_contentManager.Query().Join<RoutableRecord>() _contentManager.Query().Join<RoutePartRecord>()
.List() .List()
.Select(i => i.As<IsRoutable>()) .Select(i => i.As<RoutePart>())
.Where(routable => routable.Path != null && routable.Path.Equals(slug, StringComparison.OrdinalIgnoreCase)) // todo: for some reason the filter doesn't work within the query, even without StringComparison or StartsWith .Where(routable => routable.Path != null && routable.Path.Equals(slug, StringComparison.OrdinalIgnoreCase)) // todo: for some reason the filter doesn't work within the query, even without StringComparison or StartsWith
.ToArray(); .ToArray();
} }
@@ -75,7 +75,7 @@ namespace Orchard.Core.Routable.Services {
return slug == null || String.IsNullOrEmpty(slug.Trim()) || Regex.IsMatch(slug, @"^[^/:?#\[\]@!$&'()*+,;=\s]+$"); return slug == null || String.IsNullOrEmpty(slug.Trim()) || Regex.IsMatch(slug, @"^[^/:?#\[\]@!$&'()*+,;=\s]+$");
} }
public bool ProcessSlug(IsRoutable part) public bool ProcessSlug(RoutePart part)
{ {
FillSlug(part); FillSlug(part);

View File

@@ -54,8 +54,8 @@ namespace Orchard.Blogs.Commands {
var blog = _contentManager.New("Blog"); var blog = _contentManager.New("Blog");
blog.As<ICommonPart>().Owner = admin; blog.As<ICommonPart>().Owner = admin;
blog.As<IsRoutable>().Slug = Slug; blog.As<RoutePart>().Slug = Slug;
blog.As<IsRoutable>().Title = Title; blog.As<RoutePart>().Title = Title;
if ( !String.IsNullOrWhiteSpace(MenuText) ) { if ( !String.IsNullOrWhiteSpace(MenuText) ) {
blog.As<MenuPart>().OnMainMenu = true; blog.As<MenuPart>().OnMainMenu = true;
blog.As<MenuPart>().MenuPosition = _menuService.Get().Select(menuPart => menuPart.MenuPosition).Max() + 1 + ".0"; blog.As<MenuPart>().MenuPosition = _menuService.Get().Select(menuPart => menuPart.MenuPosition).Max() + 1 + ".0";
@@ -97,8 +97,8 @@ namespace Orchard.Blogs.Commands {
var post = _contentManager.New("BlogPost"); var post = _contentManager.New("BlogPost");
post.As<ICommonPart>().Owner = admin; post.As<ICommonPart>().Owner = admin;
post.As<ICommonPart>().Container = blog; post.As<ICommonPart>().Container = blog;
post.As<IsRoutable>().Slug = Slugify(postName); post.As<RoutePart>().Slug = Slugify(postName);
post.As<IsRoutable>().Title = postName; post.As<RoutePart>().Title = postName;
post.As<BodyPart>().Text = item.Element("description").Value; post.As<BodyPart>().Text = item.Element("description").Value;
_contentManager.Create(post); _contentManager.Create(post);
} }

View File

@@ -33,7 +33,7 @@ namespace Orchard.Blogs.DataMigrations {
cfg => cfg cfg => cfg
.WithPart("BlogPart") .WithPart("BlogPart")
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("IsRoutable") .WithPart("RoutePart")
); );
ContentDefinitionManager.AlterTypeDefinition("BlogPost", ContentDefinitionManager.AlterTypeDefinition("BlogPost",
@@ -41,7 +41,7 @@ namespace Orchard.Blogs.DataMigrations {
.WithPart("BlogPostPart") .WithPart("BlogPostPart")
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("PublishLaterPart") .WithPart("PublishLaterPart")
.WithPart("IsRoutable") .WithPart("RoutePart")
.WithPart("BodyPart") .WithPart("BodyPart")
); );

View File

@@ -8,14 +8,14 @@ namespace Orchard.Blogs.Models {
public int Id { get { return ContentItem.Id; } } public int Id { get { return ContentItem.Id; } }
public string Name { public string Name {
get { return this.As<IsRoutable>().Title; } get { return this.As<RoutePart>().Title; }
set { this.As<IsRoutable>().Title = value; } set { this.As<RoutePart>().Title = value; }
} }
//TODO: (erikpo) Need a data type for slug //TODO: (erikpo) Need a data type for slug
public string Slug { public string Slug {
get { return this.As<IsRoutable>().Slug; } get { return this.As<RoutePart>().Slug; }
set { this.As<IsRoutable>().Slug = value; } set { this.As<RoutePart>().Slug = value; }
} }
public string Description { public string Description {

View File

@@ -14,13 +14,13 @@ namespace Orchard.Blogs.Models {
} }
public string Title { public string Title {
get { return this.As<IsRoutable>().Title; } get { return this.As<RoutePart>().Title; }
set { this.As<IsRoutable>().Title = value; } set { this.As<RoutePart>().Title = value; }
} }
public string Slug { public string Slug {
get { return this.As<IsRoutable>().Slug; } get { return this.As<RoutePart>().Slug; }
set { this.As<IsRoutable>().Slug = value; } set { this.As<RoutePart>().Slug = value; }
} }
public string Text { public string Text {

View File

@@ -29,7 +29,7 @@ namespace Orchard.Blogs.Services {
public BlogPostPart Get(BlogPart blogPart, string slug, VersionOptions versionOptions) { public BlogPostPart Get(BlogPart blogPart, string slug, VersionOptions versionOptions) {
return return
_contentManager.Query(versionOptions, BlogPostPartDriver.ContentType.Name).Join<RoutableRecord>().Where(rr => rr.Slug == slug). _contentManager.Query(versionOptions, BlogPostPartDriver.ContentType.Name).Join<RoutePartRecord>().Where(rr => rr.Slug == slug).
Join<CommonPartRecord>().Where(cr => cr.Container == blogPart.Record.ContentItemRecord).List(). Join<CommonPartRecord>().Where(cr => cr.Container == blogPart.Record.ContentItemRecord).List().
SingleOrDefault().As<BlogPostPart>(); SingleOrDefault().As<BlogPostPart>();
} }

View File

@@ -20,13 +20,13 @@ namespace Orchard.Blogs.Services {
public BlogPart Get(string slug) { public BlogPart Get(string slug) {
return _contentManager.Query<BlogPart, BlogPartRecord>() return _contentManager.Query<BlogPart, BlogPartRecord>()
.Join<RoutableRecord>().Where(rr => rr.Slug == slug) .Join<RoutePartRecord>().Where(rr => rr.Slug == slug)
.List().FirstOrDefault(); .List().FirstOrDefault();
} }
public IEnumerable<BlogPart> Get() { public IEnumerable<BlogPart> Get() {
return _contentManager.Query<BlogPart, BlogPartRecord>() return _contentManager.Query<BlogPart, BlogPartRecord>()
.Join<RoutableRecord>() .Join<RoutePartRecord>()
.OrderBy(br => br.Title) .OrderBy(br => br.Title)
.List(); .List();
} }

View File

@@ -27,9 +27,9 @@ namespace Orchard.DevTools.Commands {
var pageName = "page" + index; var pageName = "page" + index;
var page = _contentManager.Create("Page", VersionOptions.Draft); var page = _contentManager.Create("Page", VersionOptions.Draft);
page.As<ICommonPart>().Owner = admin; page.As<ICommonPart>().Owner = admin;
page.As<IsRoutable>().Slug = pageName; page.As<RoutePart>().Slug = pageName;
page.As<IsRoutable>().Path = pageName; page.As<RoutePart>().Path = pageName;
page.As<IsRoutable>().Title = pageName; page.As<RoutePart>().Title = pageName;
page.As<BodyPart>().Text = pageName; page.As<BodyPart>().Text = pageName;
page.As<MenuPart>().OnMainMenu = true; page.As<MenuPart>().OnMainMenu = true;
page.As<MenuPart>().MenuPosition = "5." + index; page.As<MenuPart>().MenuPosition = "5." + index;
@@ -39,9 +39,9 @@ namespace Orchard.DevTools.Commands {
var blogName = "blog" + index; var blogName = "blog" + index;
var blog = _contentManager.New("Blog"); var blog = _contentManager.New("Blog");
blog.As<ICommonPart>().Owner = admin; blog.As<ICommonPart>().Owner = admin;
blog.As<IsRoutable>().Slug = blogName; blog.As<RoutePart>().Slug = blogName;
blog.As<IsRoutable>().Path = blogName; blog.As<RoutePart>().Path = blogName;
blog.As<IsRoutable>().Title = blogName; blog.As<RoutePart>().Title = blogName;
blog.As<MenuPart>().OnMainMenu = true; blog.As<MenuPart>().OnMainMenu = true;
blog.As<MenuPart>().MenuPosition = "6." + index; blog.As<MenuPart>().MenuPosition = "6." + index;
blog.As<MenuPart>().MenuText = blogName; blog.As<MenuPart>().MenuText = blogName;

View File

@@ -10,7 +10,7 @@ namespace Orchard.Pages.DataMigrations {
cfg => cfg cfg => cfg
.WithPart("Page") .WithPart("Page")
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("IsRoutable") .WithPart("RoutePart")
.WithPart("BodyPart") .WithPart("BodyPart")
); );

View File

@@ -12,12 +12,12 @@ namespace Orchard.Pages.Models {
public int Id { get { return ContentItem.Id; } } public int Id { get { return ContentItem.Id; } }
public string Title { public string Title {
get { return this.As<IsRoutable>().Title; } get { return this.As<RoutePart>().Title; }
} }
public string Slug { public string Slug {
get { return this.As<IsRoutable>().Slug; } get { return this.As<RoutePart>().Slug; }
set { this.As<IsRoutable>().Slug = value; } set { this.As<RoutePart>().Slug = value; }
} }
public IUser Creator { public IUser Creator {

View File

@@ -35,11 +35,11 @@ namespace Orchard.Pages.Services {
public IEnumerable<Page> Get(PageStatus status) { public IEnumerable<Page> Get(PageStatus status) {
switch (status) { switch (status) {
case PageStatus.All: case PageStatus.All:
return _contentManager.Query(PageDriver.ContentType.Name).Join<RoutableRecord>().ForVersion(VersionOptions.Latest).List().AsPart<Page>(); return _contentManager.Query(PageDriver.ContentType.Name).Join<RoutePartRecord>().ForVersion(VersionOptions.Latest).List().AsPart<Page>();
case PageStatus.Published: case PageStatus.Published:
return _contentManager.Query(PageDriver.ContentType.Name).Join<RoutableRecord>().ForVersion(VersionOptions.Published).List().AsPart<Page>(); return _contentManager.Query(PageDriver.ContentType.Name).Join<RoutePartRecord>().ForVersion(VersionOptions.Published).List().AsPart<Page>();
case PageStatus.Offline: case PageStatus.Offline:
return _contentManager.Query(PageDriver.ContentType.Name).Join<RoutableRecord>().ForVersion(VersionOptions.Latest).Where<ContentPartVersionRecord>(ci => !ci.ContentItemVersionRecord.Published).List().AsPart<Page>(); return _contentManager.Query(PageDriver.ContentType.Name).Join<RoutePartRecord>().ForVersion(VersionOptions.Latest).Where<ContentPartVersionRecord>(ci => !ci.ContentItemVersionRecord.Published).List().AsPart<Page>();
default: default:
return Enumerable.Empty<Page>(); return Enumerable.Empty<Page>();
} }
@@ -51,7 +51,7 @@ namespace Orchard.Pages.Services {
public Page Get(string slug) { public Page Get(string slug) {
return return
_contentManager.Query(PageDriver.ContentType.Name).Join<RoutableRecord>().Where(rr => rr.Slug == slug).List().FirstOrDefault _contentManager.Query(PageDriver.ContentType.Name).Join<RoutePartRecord>().Where(rr => rr.Slug == slug).List().FirstOrDefault
().As<Page>(); ().As<Page>();
} }
@@ -61,7 +61,7 @@ namespace Orchard.Pages.Services {
public Page GetLatest(string slug) { public Page GetLatest(string slug) {
return return
_contentManager.Query(VersionOptions.Latest, PageDriver.ContentType.Name).Join<RoutableRecord>().Where(rr => rr.Slug == slug) _contentManager.Query(VersionOptions.Latest, PageDriver.ContentType.Name).Join<RoutePartRecord>().Where(rr => rr.Slug == slug)
.Slice(0, 1).FirstOrDefault().As<Page>(); .Slice(0, 1).FirstOrDefault().As<Page>();
} }

View File

@@ -24,7 +24,7 @@ namespace Orchard.Sandbox.DataMigrations {
cfg => cfg cfg => cfg
.WithPart("SandboxPagePart") .WithPart("SandboxPagePart")
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("IsRoutable") .WithPart("RoutePart")
.WithPart("BodyPart") .WithPart("BodyPart")
); );

View File

@@ -202,7 +202,7 @@ namespace Orchard.Setup.Services {
.DisplayedAs("Page") .DisplayedAs("Page")
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("PublishLaterPart") .WithPart("PublishLaterPart")
.WithPart("IsRoutable") .WithPart("RoutePart")
.WithPart("BodyPart") .WithPart("BodyPart")
.WithPart("CommentsPart") .WithPart("CommentsPart")
.WithPart("TagsPart") .WithPart("TagsPart")
@@ -215,9 +215,9 @@ namespace Orchard.Setup.Services {
// create home page as a CMS page // create home page as a CMS page
var page = contentManager.Create("Page", VersionOptions.Draft); var page = contentManager.Create("Page", VersionOptions.Draft);
page.As<BodyPart>().Text = "<p>Welcome to Orchard!</p><p>Congratulations, you've successfully set-up your Orchard site.</p><p>This is the home page of your new site. We've taken the liberty to write here about a few things you could look at next in order to get familiar with the application. Once you feel confident you don't need this anymore, just click <a href=\"Admin/Pages/Edit/3\">Edit</a> to go into edit mode and replace this with whatever you want on your home page to make it your own.</p><p>One thing you could do (but you don't have to) is go into <a href=\"Admin/Settings\">Manage Settings</a> (follow the <a href=\"Admin\">Admin</a> link and then look for it under \"Settings\" in the menu on the left) and check that everything is configured the way you want.</p><p>You probably want to make the site your own. One of the ways you can do that is by clicking <a href=\"Admin/Themes\">Manage Themes</a> in the admin menu. A theme is a packaged look and feel that affects the whole site.</p><p>Next, you can start playing with the content types that we installed. For example, go ahead and click <a href=\"Admin/Pages/Create\">Add New Page</a> in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to <a href=\"Admin/Navigation\">Manage Menu</a>. You can also click <a href=\"Admin/Blogs/Create\">Add New Blog</a> and start posting by clicking \"Add New Post\".</p><p>Finally, Orchard has been designed to be extended. It comes with a few built-in modules such as pages and blogs or themes. You can install new themes by going to <a href=\"Admin/Themes\">Manage Themes</a> and clicking <a href=\"Admin/Themes/Install\">Install a new Theme</a>. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please <a href=\"http://www.orchardproject.net/\">consider participating</a>.</p><p>--The Orchard Crew</p>"; page.As<BodyPart>().Text = "<p>Welcome to Orchard!</p><p>Congratulations, you've successfully set-up your Orchard site.</p><p>This is the home page of your new site. We've taken the liberty to write here about a few things you could look at next in order to get familiar with the application. Once you feel confident you don't need this anymore, just click <a href=\"Admin/Pages/Edit/3\">Edit</a> to go into edit mode and replace this with whatever you want on your home page to make it your own.</p><p>One thing you could do (but you don't have to) is go into <a href=\"Admin/Settings\">Manage Settings</a> (follow the <a href=\"Admin\">Admin</a> link and then look for it under \"Settings\" in the menu on the left) and check that everything is configured the way you want.</p><p>You probably want to make the site your own. One of the ways you can do that is by clicking <a href=\"Admin/Themes\">Manage Themes</a> in the admin menu. A theme is a packaged look and feel that affects the whole site.</p><p>Next, you can start playing with the content types that we installed. For example, go ahead and click <a href=\"Admin/Pages/Create\">Add New Page</a> in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to <a href=\"Admin/Navigation\">Manage Menu</a>. You can also click <a href=\"Admin/Blogs/Create\">Add New Blog</a> and start posting by clicking \"Add New Post\".</p><p>Finally, Orchard has been designed to be extended. It comes with a few built-in modules such as pages and blogs or themes. You can install new themes by going to <a href=\"Admin/Themes\">Manage Themes</a> and clicking <a href=\"Admin/Themes/Install\">Install a new Theme</a>. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please <a href=\"http://www.orchardproject.net/\">consider participating</a>.</p><p>--The Orchard Crew</p>";
page.As<IsRoutable>().Slug = "home"; page.As<RoutePart>().Slug = "home";
page.As<IsRoutable>().Path = "home"; page.As<RoutePart>().Path = "home";
page.As<IsRoutable>().Title = T("Home").ToString(); page.As<RoutePart>().Title = T("Home").ToString();
page.As<CommonPart>().Owner = user; page.As<CommonPart>().Owner = user;
if (page.Has<CommentsPart>()) { if (page.Has<CommentsPart>()) {
page.As<CommentsPart>().CommentsShown = false; page.As<CommentsPart>().CommentsShown = false;