mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
Correcting Blog commands
--HG-- branch : dev
This commit is contained in:
@@ -36,6 +36,9 @@ namespace Orchard.Blogs.Commands {
|
|||||||
[OrchardSwitch]
|
[OrchardSwitch]
|
||||||
public string Slug { get; set; }
|
public string Slug { get; set; }
|
||||||
|
|
||||||
|
[OrchardSwitch]
|
||||||
|
public string Owner { get; set; }
|
||||||
|
|
||||||
[OrchardSwitch]
|
[OrchardSwitch]
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
|
|
||||||
@@ -43,17 +46,22 @@ namespace Orchard.Blogs.Commands {
|
|||||||
public string MenuText { get; set; }
|
public string MenuText { get; set; }
|
||||||
|
|
||||||
[CommandName("blog create")]
|
[CommandName("blog create")]
|
||||||
[CommandHelp("blog create /Slug:<slug> /Title:<title> [/MenuText:<menu text>]\r\n\t" + "Creates a new Blog")]
|
[CommandHelp("blog create /Slug:<slug> /Title:<title> /Owner:<username> [/MenuText:<menu text>]\r\n\t" + "Creates a new Blog")]
|
||||||
[OrchardSwitches("Slug,Title,MenuText")]
|
[OrchardSwitches("Slug,Title,Owner,MenuText")]
|
||||||
public string Create() {
|
public string Create() {
|
||||||
var admin = _membershipService.GetUser("admin");
|
var owner = _membershipService.GetUser(Owner);
|
||||||
|
|
||||||
|
if ( owner == null ) {
|
||||||
|
Context.Output.WriteLine();
|
||||||
|
return T("Invalid username: {0}", Owner).Text;
|
||||||
|
}
|
||||||
|
|
||||||
if(!IsSlugValid(Slug)) {
|
if(!IsSlugValid(Slug)) {
|
||||||
return "Invalid Slug provided. Blog creation failed.";
|
return "Invalid Slug provided. Blog creation failed.";
|
||||||
}
|
}
|
||||||
|
|
||||||
var blog = _contentManager.New("Blog");
|
var blog = _contentManager.New("Blog");
|
||||||
blog.As<ICommonPart>().Owner = admin;
|
blog.As<ICommonPart>().Owner = owner;
|
||||||
blog.As<RoutePart>().Slug = Slug;
|
blog.As<RoutePart>().Slug = Slug;
|
||||||
blog.As<RoutePart>().Path = Slug;
|
blog.As<RoutePart>().Path = Slug;
|
||||||
blog.As<RoutePart>().Title = Title;
|
blog.As<RoutePart>().Title = Title;
|
||||||
@@ -68,10 +76,15 @@ namespace Orchard.Blogs.Commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[CommandName("blog import")]
|
[CommandName("blog import")]
|
||||||
[CommandHelp("blog import /Slug:<slug> /FeedUrl:<feed url>\r\n\t" + "Import all items from <feed url> into the blog at the specified <slug>")]
|
[CommandHelp("blog import /Slug:<slug> /FeedUrl:<feed url> /Owner:<username>\r\n\t" + "Import all items from <feed url> into the blog at the specified <slug>")]
|
||||||
[OrchardSwitches("FeedUrl,Slug")]
|
[OrchardSwitches("FeedUrl,Slug,Owner")]
|
||||||
public string Import() {
|
public string Import() {
|
||||||
var admin = _membershipService.GetUser("admin");
|
var owner = _membershipService.GetUser(Owner);
|
||||||
|
|
||||||
|
if(owner == null) {
|
||||||
|
Context.Output.WriteLine();
|
||||||
|
return T("Invalid username: {0}", Owner).Text;
|
||||||
|
}
|
||||||
|
|
||||||
XDocument doc;
|
XDocument doc;
|
||||||
|
|
||||||
@@ -96,7 +109,7 @@ namespace Orchard.Blogs.Commands {
|
|||||||
|
|
||||||
Context.Output.WriteLine("Adding post: {0}...", postName.Substring(0, Math.Min(postName.Length, 40)));
|
Context.Output.WriteLine("Adding post: {0}...", postName.Substring(0, Math.Min(postName.Length, 40)));
|
||||||
var post = _contentManager.New("BlogPost");
|
var post = _contentManager.New("BlogPost");
|
||||||
post.As<ICommonPart>().Owner = admin;
|
post.As<ICommonPart>().Owner = owner;
|
||||||
post.As<ICommonPart>().Container = blog;
|
post.As<ICommonPart>().Container = blog;
|
||||||
var slug = Slugify(postName);
|
var slug = Slugify(postName);
|
||||||
post.As<RoutePart>().Slug = slug;
|
post.As<RoutePart>().Slug = slug;
|
||||||
|
Reference in New Issue
Block a user