mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
Correcting Blog commands
--HG-- branch : dev
This commit is contained in:
@@ -36,6 +36,9 @@ namespace Orchard.Blogs.Commands {
|
||||
[OrchardSwitch]
|
||||
public string Slug { get; set; }
|
||||
|
||||
[OrchardSwitch]
|
||||
public string Owner { get; set; }
|
||||
|
||||
[OrchardSwitch]
|
||||
public string Title { get; set; }
|
||||
|
||||
@@ -43,17 +46,22 @@ namespace Orchard.Blogs.Commands {
|
||||
public string MenuText { get; set; }
|
||||
|
||||
[CommandName("blog create")]
|
||||
[CommandHelp("blog create /Slug:<slug> /Title:<title> [/MenuText:<menu text>]\r\n\t" + "Creates a new Blog")]
|
||||
[OrchardSwitches("Slug,Title,MenuText")]
|
||||
[CommandHelp("blog create /Slug:<slug> /Title:<title> /Owner:<username> [/MenuText:<menu text>]\r\n\t" + "Creates a new Blog")]
|
||||
[OrchardSwitches("Slug,Title,Owner,MenuText")]
|
||||
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)) {
|
||||
return "Invalid Slug provided. Blog creation failed.";
|
||||
}
|
||||
|
||||
var blog = _contentManager.New("Blog");
|
||||
blog.As<ICommonPart>().Owner = admin;
|
||||
blog.As<ICommonPart>().Owner = owner;
|
||||
blog.As<RoutePart>().Slug = Slug;
|
||||
blog.As<RoutePart>().Path = Slug;
|
||||
blog.As<RoutePart>().Title = Title;
|
||||
@@ -68,10 +76,15 @@ namespace Orchard.Blogs.Commands {
|
||||
}
|
||||
|
||||
[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>")]
|
||||
[OrchardSwitches("FeedUrl,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,Owner")]
|
||||
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;
|
||||
|
||||
@@ -96,7 +109,7 @@ namespace Orchard.Blogs.Commands {
|
||||
|
||||
Context.Output.WriteLine("Adding post: {0}...", postName.Substring(0, Math.Min(postName.Length, 40)));
|
||||
var post = _contentManager.New("BlogPost");
|
||||
post.As<ICommonPart>().Owner = admin;
|
||||
post.As<ICommonPart>().Owner = owner;
|
||||
post.As<ICommonPart>().Container = blog;
|
||||
var slug = Slugify(postName);
|
||||
post.As<RoutePart>().Slug = slug;
|
||||
|
Reference in New Issue
Block a user