mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Working prototype
--HG-- branch : autoroute
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
ab240cad310cbfd08b91690d92225a2cdde3cb42 src/Orchard.Web/Modules/Orchard.Alias
|
||||
5fcf67b97db29312c56443875e69ccdae7fdd4fc src/Orchard.Web/Modules/Orchard.Autoroute
|
||||
257e7ead526630d8f4b95c9b86b1be748b101e5a src/Orchard.Web/Modules/Orchard.Alias
|
||||
2d63c401025c60b636058e76803cd5db329d5584 src/Orchard.Web/Modules/Orchard.Autoroute
|
||||
ec573e5476f7e8a5a61593d6393e9985e9484fcc src/Orchard.Web/Modules/Orchard.Forms
|
||||
0d1100754d594a2977eaab40630f1c46a9e8cf2c src/Orchard.Web/Modules/Orchard.Projections
|
||||
bf1f2857f36786c66013e0dee3c37e94cd26465e src/Orchard.Web/Modules/Orchard.Routable
|
||||
01b83c05050bb731d9f69256bbe8884d458ea1c9 src/Orchard.Web/Modules/Orchard.Rules
|
||||
65057c6a5cd71f7994ba9bcbeece50dbb737620e src/Orchard.Web/Modules/Orchard.TaskLease
|
||||
460f08a0d0befd36a3f7e974d8b782ae3df747e7 src/Orchard.Web/Modules/Orchard.Tokens
|
||||
b90a3f965f76bacd96bbded5670c7aa334a74f23 src/Orchard.Web/Modules/Orchard.Tokens
|
||||
|
@@ -14,6 +14,7 @@ using Orchard.Security;
|
||||
using Orchard.Blogs.Services;
|
||||
using Orchard.Core.Navigation.Services;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Core.Title.Models;
|
||||
|
||||
namespace Orchard.Blogs.Commands {
|
||||
public class BlogCommands : DefaultOrchardCommandHandler {
|
||||
@@ -58,8 +59,8 @@ namespace Orchard.Blogs.Commands {
|
||||
public bool Homepage { get; set; }
|
||||
|
||||
[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")]
|
||||
[OrchardSwitches("Slug,Title,Owner,Description,MenuText,Homepage")]
|
||||
[CommandHelp("blog create /Title:<title> [/Owner:<username>] [/Description:<description>] [/MenuText:<menu text>] [/Homepage:true|false]\r\n\t" + "Creates a new Blog")]
|
||||
[OrchardSwitches("Title,Owner,Description,MenuText,Homepage")]
|
||||
public void Create() {
|
||||
if (String.IsNullOrEmpty(Owner)) {
|
||||
Owner = _siteService.GetSiteSettings().SuperUser;
|
||||
@@ -78,10 +79,7 @@ namespace Orchard.Blogs.Commands {
|
||||
|
||||
var blog = _contentManager.New("Blog");
|
||||
blog.As<ICommonPart>().Owner = owner;
|
||||
blog.As<RoutePart>().Slug = Slug;
|
||||
blog.As<RoutePart>().Path = Slug;
|
||||
blog.As<RoutePart>().Title = Title;
|
||||
blog.As<RoutePart>().PromoteToHomePage = Homepage;
|
||||
blog.As<TitlePart>().Title = Title;
|
||||
if (!String.IsNullOrEmpty(Description)) {
|
||||
blog.As<BlogPart>().Description = Description;
|
||||
}
|
||||
|
@@ -24,7 +24,6 @@ namespace Orchard.Blogs.Controllers {
|
||||
private readonly IBlogPostService _blogPostService;
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly ITransactionManager _transactionManager;
|
||||
private readonly IBlogPathConstraint _blogPathConstraint;
|
||||
private readonly ISiteService _siteService;
|
||||
|
||||
public BlogAdminController(
|
||||
@@ -33,7 +32,6 @@ namespace Orchard.Blogs.Controllers {
|
||||
IBlogPostService blogPostService,
|
||||
IContentManager contentManager,
|
||||
ITransactionManager transactionManager,
|
||||
IBlogPathConstraint blogPathConstraint,
|
||||
ISiteService siteService,
|
||||
IShapeFactory shapeFactory) {
|
||||
Services = services;
|
||||
@@ -41,7 +39,6 @@ namespace Orchard.Blogs.Controllers {
|
||||
_blogPostService = blogPostService;
|
||||
_contentManager = contentManager;
|
||||
_transactionManager = transactionManager;
|
||||
_blogPathConstraint = blogPathConstraint;
|
||||
_siteService = siteService;
|
||||
T = NullLocalizer.Instance;
|
||||
Shape = shapeFactory;
|
||||
@@ -81,8 +78,6 @@ namespace Orchard.Blogs.Controllers {
|
||||
}
|
||||
|
||||
_contentManager.Publish(blog.ContentItem);
|
||||
_blogPathConstraint.AddPath(blog.As<IRoutableAspect>().Path);
|
||||
|
||||
return Redirect(Url.BlogForAdmin(blog));
|
||||
}
|
||||
|
||||
@@ -136,7 +131,6 @@ namespace Orchard.Blogs.Controllers {
|
||||
}
|
||||
|
||||
_contentManager.Publish(blog);
|
||||
_blogPathConstraint.AddPath(blog.As<IRoutableAspect>().Path);
|
||||
Services.Notifier.Information(T("Blog information updated"));
|
||||
|
||||
return Redirect(Url.BlogsForAdmin());
|
||||
|
@@ -13,6 +13,8 @@ using Orchard.Services;
|
||||
using Orchard.Themes;
|
||||
using Orchard.UI.Navigation;
|
||||
using Orchard.Settings;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Blogs.Models;
|
||||
|
||||
namespace Orchard.Blogs.Controllers {
|
||||
|
||||
@@ -65,22 +67,13 @@ namespace Orchard.Blogs.Controllers {
|
||||
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);
|
||||
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)
|
||||
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);
|
||||
var blogPosts = _blogPostService.Get(blogPart, pager.GetStartIndex(), pager.PageSize)
|
||||
.Select(b => _services.ContentManager.BuildDisplay(b, "Summary"));
|
||||
|
@@ -38,7 +38,8 @@ namespace Orchard.Blogs {
|
||||
cfg => cfg
|
||||
.WithPart("BlogPart")
|
||||
.WithPart("CommonPart")
|
||||
.WithPart("RoutePart")
|
||||
.WithPart("TitlePart")
|
||||
.WithPart("AutoroutePart")
|
||||
.WithPart("MenuPart")
|
||||
.WithPart("AdminMenuPart", p => p.WithSetting("AdminMenuPartTypeSettings.DefaultPosition", "2"))
|
||||
);
|
||||
@@ -49,7 +50,8 @@ namespace Orchard.Blogs {
|
||||
.WithPart("CommonPart", p => p
|
||||
.WithSetting("DateEditorSettings.ShowDateEditor", "true"))
|
||||
.WithPart("PublishLaterPart")
|
||||
.WithPart("RoutePart")
|
||||
.WithPart("TitlePart")
|
||||
.WithPart("AutoroutePart")
|
||||
.WithPart("BodyPart")
|
||||
);
|
||||
|
||||
@@ -69,7 +71,7 @@ namespace Orchard.Blogs {
|
||||
.WithSetting("Stereotype", "Widget")
|
||||
);
|
||||
|
||||
return 4;
|
||||
return 5;
|
||||
}
|
||||
|
||||
public int UpdateFrom1() {
|
||||
@@ -86,5 +88,27 @@ namespace Orchard.Blogs {
|
||||
ContentDefinitionManager.AlterTypeDefinition("BlogPost", cfg => cfg.WithPart("CommonPart", p => p.WithSetting("DateEditorSettings.ShowDateEditor", "true")));
|
||||
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;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +1,14 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Routable.Models;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
|
||||
namespace Orchard.Blogs.Models {
|
||||
public class BlogPart : ContentPart<BlogPartRecord> {
|
||||
|
||||
// TODO: (PH) This isn't referenced in many places but should use ContentItemMetadata instead?
|
||||
public string Name {
|
||||
get { return this.As<RoutePart>().Title; }
|
||||
set { this.As<RoutePart>().Title = value; }
|
||||
|
||||
get { return this.As<ITitleAspect>().Title; }
|
||||
}
|
||||
|
||||
public string Description {
|
||||
|
@@ -13,6 +13,7 @@
|
||||
<RootNamespace>Orchard.Recipes</RootNamespace>
|
||||
<AssemblyName>Orchard.Recipes</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<UseIISExpress>false</UseIISExpress>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -74,6 +75,10 @@
|
||||
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
|
||||
<Name>Orchard.Framework</Name>
|
||||
</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">
|
||||
<Project>{DFD137A2-DDB5-4D22-BE0D-FA9AD4C8B059}</Project>
|
||||
<Name>Orchard.Packaging</Name>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<Version>1.0</Version>
|
||||
</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,
|
||||
TinyMce,Orchard.Media,Orchard.MediaPicker,Orchard.PublishLater,
|
||||
Orchard.jQuery,Orchard.Widgets,Orchard.Widgets.PageLayerHinting,
|
||||
@@ -22,11 +22,13 @@
|
||||
<Page ContentTypeSettings.Draftable="True" TypeIndexing.Included="true">
|
||||
<TagsPart />
|
||||
<LocalizationPart />
|
||||
<AutoroutePart />
|
||||
</Page>
|
||||
<BlogPost ContentTypeSettings.Draftable="True" TypeIndexing.Included="true">
|
||||
<CommentsPart />
|
||||
<TagsPart />
|
||||
<LocalizationPart />
|
||||
<AutoroutePart />
|
||||
</BlogPost>
|
||||
</Types>
|
||||
<Parts>
|
||||
@@ -47,12 +49,14 @@
|
||||
layer create Anonymous /LayerRule:"not authenticated"
|
||||
layer create Disabled /LayerRule:"false"
|
||||
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:"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
|
||||
menuitem create /MenuPosition:"1" /MenuText:"Home" /Url:"" /OnMainMenu:true
|
||||
site setting set baseurl
|
||||
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>
|
||||
</Orchard>
|
||||
|
Reference in New Issue
Block a user