Working prototype

--HG--
branch : autoroute
This commit is contained in:
randompete
2011-12-07 21:28:15 +00:00
parent b84e1545e5
commit 4b4571bc9d
8 changed files with 54 additions and 33 deletions

View File

@@ -1,8 +1,8 @@
ab240cad310cbfd08b91690d92225a2cdde3cb42 src/Orchard.Web/Modules/Orchard.Alias 257e7ead526630d8f4b95c9b86b1be748b101e5a src/Orchard.Web/Modules/Orchard.Alias
5fcf67b97db29312c56443875e69ccdae7fdd4fc src/Orchard.Web/Modules/Orchard.Autoroute 2d63c401025c60b636058e76803cd5db329d5584 src/Orchard.Web/Modules/Orchard.Autoroute
ec573e5476f7e8a5a61593d6393e9985e9484fcc src/Orchard.Web/Modules/Orchard.Forms ec573e5476f7e8a5a61593d6393e9985e9484fcc src/Orchard.Web/Modules/Orchard.Forms
0d1100754d594a2977eaab40630f1c46a9e8cf2c src/Orchard.Web/Modules/Orchard.Projections 0d1100754d594a2977eaab40630f1c46a9e8cf2c src/Orchard.Web/Modules/Orchard.Projections
bf1f2857f36786c66013e0dee3c37e94cd26465e src/Orchard.Web/Modules/Orchard.Routable bf1f2857f36786c66013e0dee3c37e94cd26465e src/Orchard.Web/Modules/Orchard.Routable
01b83c05050bb731d9f69256bbe8884d458ea1c9 src/Orchard.Web/Modules/Orchard.Rules 01b83c05050bb731d9f69256bbe8884d458ea1c9 src/Orchard.Web/Modules/Orchard.Rules
65057c6a5cd71f7994ba9bcbeece50dbb737620e src/Orchard.Web/Modules/Orchard.TaskLease 65057c6a5cd71f7994ba9bcbeece50dbb737620e src/Orchard.Web/Modules/Orchard.TaskLease
460f08a0d0befd36a3f7e974d8b782ae3df747e7 src/Orchard.Web/Modules/Orchard.Tokens b90a3f965f76bacd96bbded5670c7aa334a74f23 src/Orchard.Web/Modules/Orchard.Tokens

View File

@@ -14,6 +14,7 @@ using Orchard.Security;
using Orchard.Blogs.Services; using Orchard.Blogs.Services;
using Orchard.Core.Navigation.Services; using Orchard.Core.Navigation.Services;
using Orchard.Settings; using Orchard.Settings;
using Orchard.Core.Title.Models;
namespace Orchard.Blogs.Commands { namespace Orchard.Blogs.Commands {
public class BlogCommands : DefaultOrchardCommandHandler { public class BlogCommands : DefaultOrchardCommandHandler {
@@ -58,8 +59,8 @@ namespace Orchard.Blogs.Commands {
public bool Homepage { get; set; } public bool Homepage { get; set; }
[CommandName("blog create")] [CommandName("blog create")]
[CommandHelp("blog create /Slug:<slug> /Title:<title> [/Owner:<username>] [/Description:<description>] [/MenuText:<menu text>] [/Homepage:true|false]\r\n\t" + "Creates a new Blog")] [CommandHelp("blog create /Title:<title> [/Owner:<username>] [/Description:<description>] [/MenuText:<menu text>] [/Homepage:true|false]\r\n\t" + "Creates a new Blog")]
[OrchardSwitches("Slug,Title,Owner,Description,MenuText,Homepage")] [OrchardSwitches("Title,Owner,Description,MenuText,Homepage")]
public void Create() { public void Create() {
if (String.IsNullOrEmpty(Owner)) { if (String.IsNullOrEmpty(Owner)) {
Owner = _siteService.GetSiteSettings().SuperUser; Owner = _siteService.GetSiteSettings().SuperUser;
@@ -78,10 +79,7 @@ namespace Orchard.Blogs.Commands {
var blog = _contentManager.New("Blog"); var blog = _contentManager.New("Blog");
blog.As<ICommonPart>().Owner = owner; blog.As<ICommonPart>().Owner = owner;
blog.As<RoutePart>().Slug = Slug; blog.As<TitlePart>().Title = Title;
blog.As<RoutePart>().Path = Slug;
blog.As<RoutePart>().Title = Title;
blog.As<RoutePart>().PromoteToHomePage = Homepage;
if (!String.IsNullOrEmpty(Description)) { if (!String.IsNullOrEmpty(Description)) {
blog.As<BlogPart>().Description = Description; blog.As<BlogPart>().Description = Description;
} }

View File

@@ -24,7 +24,6 @@ namespace Orchard.Blogs.Controllers {
private readonly IBlogPostService _blogPostService; private readonly IBlogPostService _blogPostService;
private readonly IContentManager _contentManager; private readonly IContentManager _contentManager;
private readonly ITransactionManager _transactionManager; private readonly ITransactionManager _transactionManager;
private readonly IBlogPathConstraint _blogPathConstraint;
private readonly ISiteService _siteService; private readonly ISiteService _siteService;
public BlogAdminController( public BlogAdminController(
@@ -33,7 +32,6 @@ namespace Orchard.Blogs.Controllers {
IBlogPostService blogPostService, IBlogPostService blogPostService,
IContentManager contentManager, IContentManager contentManager,
ITransactionManager transactionManager, ITransactionManager transactionManager,
IBlogPathConstraint blogPathConstraint,
ISiteService siteService, ISiteService siteService,
IShapeFactory shapeFactory) { IShapeFactory shapeFactory) {
Services = services; Services = services;
@@ -41,7 +39,6 @@ namespace Orchard.Blogs.Controllers {
_blogPostService = blogPostService; _blogPostService = blogPostService;
_contentManager = contentManager; _contentManager = contentManager;
_transactionManager = transactionManager; _transactionManager = transactionManager;
_blogPathConstraint = blogPathConstraint;
_siteService = siteService; _siteService = siteService;
T = NullLocalizer.Instance; T = NullLocalizer.Instance;
Shape = shapeFactory; Shape = shapeFactory;
@@ -81,8 +78,6 @@ namespace Orchard.Blogs.Controllers {
} }
_contentManager.Publish(blog.ContentItem); _contentManager.Publish(blog.ContentItem);
_blogPathConstraint.AddPath(blog.As<IRoutableAspect>().Path);
return Redirect(Url.BlogForAdmin(blog)); return Redirect(Url.BlogForAdmin(blog));
} }
@@ -136,7 +131,6 @@ namespace Orchard.Blogs.Controllers {
} }
_contentManager.Publish(blog); _contentManager.Publish(blog);
_blogPathConstraint.AddPath(blog.As<IRoutableAspect>().Path);
Services.Notifier.Information(T("Blog information updated")); Services.Notifier.Information(T("Blog information updated"));
return Redirect(Url.BlogsForAdmin()); return Redirect(Url.BlogsForAdmin());

View File

@@ -13,6 +13,8 @@ using Orchard.Services;
using Orchard.Themes; using Orchard.Themes;
using Orchard.UI.Navigation; using Orchard.UI.Navigation;
using Orchard.Settings; using Orchard.Settings;
using Orchard.ContentManagement;
using Orchard.Blogs.Models;
namespace Orchard.Blogs.Controllers { namespace Orchard.Blogs.Controllers {
@@ -65,22 +67,13 @@ namespace Orchard.Blogs.Controllers {
return View((object)viewModel); return View((object)viewModel);
} }
public ActionResult Item(string blogPath, PagerParameters pagerParameters) { public ActionResult Item(int blogId, PagerParameters pagerParameters) {
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
var correctedPath = _blogPathConstraint.FindPath(blogPath);
if (correctedPath == null)
return HttpNotFound();
var blogPart = _blogService.Get(correctedPath); var blogPart = _blogService.Get(blogId, VersionOptions.Published).As<BlogPart>();
if (blogPart == null) if (blogPart == null)
return HttpNotFound(); return HttpNotFound();
// primary action run for a home paged item shall not pass
if (!RouteData.DataTokens.ContainsKey("ParentActionViewContext")
&& blogPart.Id == _routableHomePageProvider.GetHomePageId(_workContextAccessor.GetContext().CurrentSite.HomePage)) {
return HttpNotFound();
}
_feedManager.Register(blogPart); _feedManager.Register(blogPart);
var blogPosts = _blogPostService.Get(blogPart, pager.GetStartIndex(), pager.PageSize) var blogPosts = _blogPostService.Get(blogPart, pager.GetStartIndex(), pager.PageSize)
.Select(b => _services.ContentManager.BuildDisplay(b, "Summary")); .Select(b => _services.ContentManager.BuildDisplay(b, "Summary"));

View File

@@ -38,7 +38,8 @@ namespace Orchard.Blogs {
cfg => cfg cfg => cfg
.WithPart("BlogPart") .WithPart("BlogPart")
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("RoutePart") .WithPart("TitlePart")
.WithPart("AutoroutePart")
.WithPart("MenuPart") .WithPart("MenuPart")
.WithPart("AdminMenuPart", p => p.WithSetting("AdminMenuPartTypeSettings.DefaultPosition", "2")) .WithPart("AdminMenuPart", p => p.WithSetting("AdminMenuPartTypeSettings.DefaultPosition", "2"))
); );
@@ -49,7 +50,8 @@ namespace Orchard.Blogs {
.WithPart("CommonPart", p => p .WithPart("CommonPart", p => p
.WithSetting("DateEditorSettings.ShowDateEditor", "true")) .WithSetting("DateEditorSettings.ShowDateEditor", "true"))
.WithPart("PublishLaterPart") .WithPart("PublishLaterPart")
.WithPart("RoutePart") .WithPart("TitlePart")
.WithPart("AutoroutePart")
.WithPart("BodyPart") .WithPart("BodyPart")
); );
@@ -69,7 +71,7 @@ namespace Orchard.Blogs {
.WithSetting("Stereotype", "Widget") .WithSetting("Stereotype", "Widget")
); );
return 4; return 5;
} }
public int UpdateFrom1() { public int UpdateFrom1() {
@@ -86,5 +88,27 @@ namespace Orchard.Blogs {
ContentDefinitionManager.AlterTypeDefinition("BlogPost", cfg => cfg.WithPart("CommonPart", p => p.WithSetting("DateEditorSettings.ShowDateEditor", "true"))); ContentDefinitionManager.AlterTypeDefinition("BlogPost", cfg => cfg.WithPart("CommonPart", p => p.WithSetting("DateEditorSettings.ShowDateEditor", "true")));
return 4; return 4;
} }
public int UpdateFrom4() {
// TODO: (PH:Autoroute) SQL copy routes and titles and generate aliases for existing items
ContentDefinitionManager.AlterTypeDefinition("Blog",
cfg => cfg
.RemovePart("RoutePart")
.WithPart("TitlePart")
.WithPart("AutoroutePart")
);
ContentDefinitionManager.AlterTypeDefinition("BlogPost",
cfg => cfg
.RemovePart("RoutePart")
.WithPart("TitlePart")
.WithPart("AutoroutePart")
);
return 5;
}
} }
} }

View File

@@ -1,11 +1,14 @@
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.Core.Routable.Models; using Orchard.Core.Routable.Models;
using Orchard.ContentManagement.Aspects;
namespace Orchard.Blogs.Models { namespace Orchard.Blogs.Models {
public class BlogPart : ContentPart<BlogPartRecord> { public class BlogPart : ContentPart<BlogPartRecord> {
// TODO: (PH) This isn't referenced in many places but should use ContentItemMetadata instead?
public string Name { public string Name {
get { return this.As<RoutePart>().Title; }
set { this.As<RoutePart>().Title = value; } get { return this.As<ITitleAspect>().Title; }
} }
public string Description { public string Description {

View File

@@ -13,6 +13,7 @@
<RootNamespace>Orchard.Recipes</RootNamespace> <RootNamespace>Orchard.Recipes</RootNamespace>
<AssemblyName>Orchard.Recipes</AssemblyName> <AssemblyName>Orchard.Recipes</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<UseIISExpress>false</UseIISExpress>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -74,6 +75,10 @@
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project> <Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name> <Name>Orchard.Framework</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\Tools\Orchard\Orchard.csproj">
<Project>{33B1BC8D-E292-4972-A363-22056B207156}</Project>
<Name>Orchard</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.Packaging\Orchard.Packaging.csproj"> <ProjectReference Include="..\Orchard.Packaging\Orchard.Packaging.csproj">
<Project>{DFD137A2-DDB5-4D22-BE0D-FA9AD4C8B059}</Project> <Project>{DFD137A2-DDB5-4D22-BE0D-FA9AD4C8B059}</Project>
<Name>Orchard.Packaging</Name> <Name>Orchard.Packaging</Name>

View File

@@ -9,7 +9,7 @@
<Version>1.0</Version> <Version>1.0</Version>
</Recipe> </Recipe>
<Feature enable="Orchard.Blogs,Orchard.Comments,Orchard.Tags, <Feature enable="Orchard.Blogs,Orchard.Comments,Orchard.Tags,Orchard.Alias,Orchard.Autoroute,
XmlRpc,Orchard.Blogs.RemotePublishing, XmlRpc,Orchard.Blogs.RemotePublishing,
TinyMce,Orchard.Media,Orchard.MediaPicker,Orchard.PublishLater, TinyMce,Orchard.Media,Orchard.MediaPicker,Orchard.PublishLater,
Orchard.jQuery,Orchard.Widgets,Orchard.Widgets.PageLayerHinting, Orchard.jQuery,Orchard.Widgets,Orchard.Widgets.PageLayerHinting,
@@ -22,11 +22,13 @@
<Page ContentTypeSettings.Draftable="True" TypeIndexing.Included="true"> <Page ContentTypeSettings.Draftable="True" TypeIndexing.Included="true">
<TagsPart /> <TagsPart />
<LocalizationPart /> <LocalizationPart />
<AutoroutePart />
</Page> </Page>
<BlogPost ContentTypeSettings.Draftable="True" TypeIndexing.Included="true"> <BlogPost ContentTypeSettings.Draftable="True" TypeIndexing.Included="true">
<CommentsPart /> <CommentsPart />
<TagsPart /> <TagsPart />
<LocalizationPart /> <LocalizationPart />
<AutoroutePart />
</BlogPost> </BlogPost>
</Types> </Types>
<Parts> <Parts>
@@ -47,12 +49,14 @@
layer create Anonymous /LayerRule:"not authenticated" layer create Anonymous /LayerRule:"not authenticated"
layer create Disabled /LayerRule:"false" layer create Disabled /LayerRule:"false"
layer create TheHomepage /LayerRule:"url '~/'" layer create TheHomepage /LayerRule:"url '~/'"
blog create /Slug:"blog" /Title:"Blog" /Homepage:true /Description:"This is your Orchard Blog."
widget create HtmlWidget /Title:"First Leader Aside" /Zone:"TripelFirst" /Position:"5" /Layer:"TheHomepage" /Identity:"SetupHtmlWidget1" /UseLoremIpsumText:true widget create HtmlWidget /Title:"First Leader Aside" /Zone:"TripelFirst" /Position:"5" /Layer:"TheHomepage" /Identity:"SetupHtmlWidget1" /UseLoremIpsumText:true
widget create HtmlWidget /Title:"Second Leader Aside" /Zone:"TripelSecond" /Position:"5" /Layer:"TheHomepage" /Identity:"SetupHtmlWidget2" /UseLoremIpsumText:true widget create HtmlWidget /Title:"Second Leader Aside" /Zone:"TripelSecond" /Position:"5" /Layer:"TheHomepage" /Identity:"SetupHtmlWidget2" /UseLoremIpsumText:true
widget create HtmlWidget /Title:"Third Leader Aside" /Zone:"TripelThird" /Position:"5" /Layer:"TheHomepage" /Identity:"SetupHtmlWidget3" /UseLoremIpsumText:true widget create HtmlWidget /Title:"Third Leader Aside" /Zone:"TripelThird" /Position:"5" /Layer:"TheHomepage" /Identity:"SetupHtmlWidget3" /UseLoremIpsumText:true
menuitem create /MenuPosition:"1" /MenuText:"Home" /Url:"" /OnMainMenu:true menuitem create /MenuPosition:"1" /MenuText:"Home" /Url:"" /OnMainMenu:true
site setting set baseurl site setting set baseurl
theme activate "The Theme Machine" theme activate "The Theme Machine"
autoroute pattern create "my-page" "{Content.Slug}" /AssignTo:Page,Blog
autoroute pattern create "my-blog/my-blog-post" "{Content.Container.Slug}/{Content.Slug}" /AssignTo:BlogPost
blog create /Title:"Blog" /Homepage:true /Description:"This is your Orchard Blog."
</Command> </Command>
</Orchard> </Orchard>