mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -35,7 +35,7 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to create blogs")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to create blogs")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
var blog = Services.ContentManager.New<Blog>(BlogDriver.ContentType.Name);
|
var blog = Services.ContentManager.New<BlogPart>(BlogPartDriver.ContentType.Name);
|
||||||
if (blog == null)
|
if (blog == null)
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't create blog")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't create blog")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
model.Blog = Services.ContentManager.UpdateEditorModel(Services.ContentManager.New<Blog>(BlogDriver.ContentType.Name), this);
|
model.Blog = Services.ContentManager.UpdateEditorModel(Services.ContentManager.New<BlogPart>(BlogPartDriver.ContentType.Name), this);
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return View(model);
|
return View(model);
|
||||||
@@ -116,12 +116,12 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
|
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
|
||||||
Blog blog = _blogService.Get(blogSlug);
|
BlogPart blogPart = _blogService.Get(blogSlug);
|
||||||
|
|
||||||
if (blog == null)
|
if (blogPart == null)
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
_blogService.Delete(blog);
|
_blogService.Delete(blogPart);
|
||||||
|
|
||||||
Services.Notifier.Information(T("Blog was successfully deleted"));
|
Services.Notifier.Information(T("Blog was successfully deleted"));
|
||||||
|
|
||||||
@@ -141,14 +141,14 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
|
|
||||||
//TODO: (erikpo) Should move the slug parameter and get call and null check up into a model binder
|
//TODO: (erikpo) Should move the slug parameter and get call and null check up into a model binder
|
||||||
public ActionResult Item(string blogSlug) {
|
public ActionResult Item(string blogSlug) {
|
||||||
Blog blog = _blogService.Get(blogSlug);
|
BlogPart blogPart = _blogService.Get(blogSlug);
|
||||||
|
|
||||||
if (blog == null)
|
if (blogPart == null)
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
//TODO: (erikpo) Need to make templatePath be more convention based so if my controller name has "Admin" in it then "Admin/{type}" is assumed
|
//TODO: (erikpo) Need to make templatePath be more convention based so if my controller name has "Admin" in it then "Admin/{type}" is assumed
|
||||||
var model = new BlogForAdminViewModel {
|
var model = new BlogForAdminViewModel {
|
||||||
Blog = Services.ContentManager.BuildDisplayModel(blog, "DetailAdmin")
|
Blog = Services.ContentManager.BuildDisplayModel(blogPart, "DetailAdmin")
|
||||||
};
|
};
|
||||||
|
|
||||||
return View(model);
|
return View(model);
|
||||||
|
@@ -61,9 +61,9 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
public ActionResult LiveWriterManifest(string blogSlug) {
|
public ActionResult LiveWriterManifest(string blogSlug) {
|
||||||
Logger.Debug("Live Writer Manifest requested");
|
Logger.Debug("Live Writer Manifest requested");
|
||||||
|
|
||||||
Blog blog = _blogService.Get(blogSlug);
|
BlogPart blogPart = _blogService.Get(blogSlug);
|
||||||
|
|
||||||
if (blog == null)
|
if (blogPart == null)
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
const string manifestUri = "http://schemas.microsoft.com/wlw/manifest/weblog";
|
const string manifestUri = "http://schemas.microsoft.com/wlw/manifest/weblog";
|
||||||
@@ -86,9 +86,9 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
public ActionResult Rsd(string blogSlug) {
|
public ActionResult Rsd(string blogSlug) {
|
||||||
Logger.Debug("RSD requested");
|
Logger.Debug("RSD requested");
|
||||||
|
|
||||||
Blog blog = _blogService.Get(blogSlug);
|
BlogPart blogPart = _blogService.Get(blogSlug);
|
||||||
|
|
||||||
if (blog == null)
|
if (blogPart == null)
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
const string manifestUri = "http://archipelago.phrasewise.com/rsd";
|
const string manifestUri = "http://archipelago.phrasewise.com/rsd";
|
||||||
@@ -106,7 +106,7 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
new XAttribute("name", "MetaWeblog"),
|
new XAttribute("name", "MetaWeblog"),
|
||||||
new XAttribute("preferred", true),
|
new XAttribute("preferred", true),
|
||||||
new XAttribute("apiLink", url),
|
new XAttribute("apiLink", url),
|
||||||
new XAttribute("blogID", blog.Id))));
|
new XAttribute("blogID", blogPart.Id))));
|
||||||
|
|
||||||
var doc = new XDocument(new XElement(
|
var doc = new XDocument(new XElement(
|
||||||
XName.Get("rsd", manifestUri),
|
XName.Get("rsd", manifestUri),
|
||||||
|
@@ -31,9 +31,9 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
if (!Services.Authorizer.Authorize(Permissions.EditBlogPost, T("Not allowed to create blog post")))
|
if (!Services.Authorizer.Authorize(Permissions.EditBlogPost, T("Not allowed to create blog post")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
var blogPost = Services.ContentManager.New<BlogPost>(BlogPostDriver.ContentType.Name);
|
var blogPost = Services.ContentManager.New<BlogPostPart>(BlogPostDriver.ContentType.Name);
|
||||||
|
|
||||||
if (blogPost.Blog == null)
|
if (blogPost.BlogPart == null)
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
var model = new CreateBlogPostViewModel {
|
var model = new CreateBlogPostViewModel {
|
||||||
@@ -48,9 +48,9 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
if (!Services.Authorizer.Authorize(Permissions.EditBlogPost, T("Couldn't create blog post")))
|
if (!Services.Authorizer.Authorize(Permissions.EditBlogPost, T("Couldn't create blog post")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
var blogPost = Services.ContentManager.New<BlogPost>(BlogPostDriver.ContentType.Name);
|
var blogPost = Services.ContentManager.New<BlogPostPart>(BlogPostDriver.ContentType.Name);
|
||||||
|
|
||||||
if (blogPost.Blog == null)
|
if (blogPost.BlogPart == null)
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
Services.ContentManager.Create(blogPost, VersionOptions.Draft);
|
Services.ContentManager.Create(blogPost, VersionOptions.Draft);
|
||||||
@@ -142,13 +142,13 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ActionResult RedirectToEdit(int id) {
|
ActionResult RedirectToEdit(int id) {
|
||||||
return RedirectToEdit(Services.ContentManager.GetLatest<BlogPost>(id));
|
return RedirectToEdit(Services.ContentManager.GetLatest<BlogPostPart>(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionResult RedirectToEdit(IContent item) {
|
ActionResult RedirectToEdit(IContent item) {
|
||||||
if (item == null || item.As<BlogPost>() == null)
|
if (item == null || item.As<BlogPostPart>() == null)
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
return RedirectToAction("Edit", new { BlogSlug = item.As<BlogPost>().Blog.Slug, PostId = item.ContentItem.Id });
|
return RedirectToAction("Edit", new { BlogSlug = item.As<BlogPostPart>().BlogPart.Slug, PostId = item.ContentItem.Id });
|
||||||
}
|
}
|
||||||
|
|
||||||
[ValidateAntiForgeryTokenOrchard]
|
[ValidateAntiForgeryTokenOrchard]
|
||||||
|
@@ -37,43 +37,43 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
|
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
|
||||||
Blog blog = _blogService.Get(blogSlug);
|
BlogPart blogPart = _blogService.Get(blogSlug);
|
||||||
|
|
||||||
if (blog == null)
|
if (blogPart == null)
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
//TODO: (erikpo) Look up the current user and their permissions to this blog post and determine if they should be able to view it or not.
|
//TODO: (erikpo) Look up the current user and their permissions to this blog post and determine if they should be able to view it or not.
|
||||||
VersionOptions versionOptions = VersionOptions.Published;
|
VersionOptions versionOptions = VersionOptions.Published;
|
||||||
BlogPost post = _blogPostService.Get(blog, postSlug, versionOptions);
|
BlogPostPart postPart = _blogPostService.Get(blogPart, postSlug, versionOptions);
|
||||||
|
|
||||||
if (post == null)
|
if (postPart == null)
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
var model = new BlogPostViewModel {
|
var model = new BlogPostViewModel {
|
||||||
Blog = blog,
|
BlogPart = blogPart,
|
||||||
BlogPost = _services.ContentManager.BuildDisplayModel(post, "Detail")
|
BlogPost = _services.ContentManager.BuildDisplayModel(postPart, "Detail")
|
||||||
};
|
};
|
||||||
|
|
||||||
_feedManager.Register(blog);
|
_feedManager.Register(blogPart);
|
||||||
|
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult ListByArchive(string blogSlug, string archiveData) {
|
public ActionResult ListByArchive(string blogSlug, string archiveData) {
|
||||||
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
|
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
|
||||||
Blog blog = _blogService.Get(blogSlug);
|
BlogPart blogPart = _blogService.Get(blogSlug);
|
||||||
|
|
||||||
if (blog == null)
|
if (blogPart == null)
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
var archive = new ArchiveData(archiveData);
|
var archive = new ArchiveData(archiveData);
|
||||||
var model = new BlogPostArchiveViewModel {
|
var model = new BlogPostArchiveViewModel {
|
||||||
Blog = blog,
|
BlogPart = blogPart,
|
||||||
ArchiveData = archive,
|
ArchiveData = archive,
|
||||||
BlogPosts = _blogPostService.Get(blog, archive).Select(b => _services.ContentManager.BuildDisplayModel(b, "Summary"))
|
BlogPosts = _blogPostService.Get(blogPart, archive).Select(b => _services.ContentManager.BuildDisplayModel(b, "Summary"))
|
||||||
};
|
};
|
||||||
|
|
||||||
_feedManager.Register(blog);
|
_feedManager.Register(blogPart);
|
||||||
|
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
|
@@ -9,17 +9,17 @@ namespace Orchard.Blogs.DataMigrations {
|
|||||||
public class BlogsDataMigration : DataMigrationImpl {
|
public class BlogsDataMigration : DataMigrationImpl {
|
||||||
|
|
||||||
public int Create() {
|
public int Create() {
|
||||||
//CREATE TABLE Orchard_Blogs_BlogArchiveRecord (Id integer, Year INTEGER, Month INTEGER, PostCount INTEGER, Blog_id INTEGER, primary key (Id));
|
//CREATE TABLE Orchard_Blogs_BlogPartArchiveRecord (Id integer, Year INTEGER, Month INTEGER, PostCount INTEGER, Blog_id INTEGER, primary key (Id));
|
||||||
SchemaBuilder.CreateTable("BlogArchiveRecord", table => table
|
SchemaBuilder.CreateTable("BlogPartArchiveRecord", table => table
|
||||||
.Column<int>("Id", column => column.PrimaryKey().Identity())
|
.Column<int>("Id", column => column.PrimaryKey().Identity())
|
||||||
.Column<int>("Year")
|
.Column<int>("Year")
|
||||||
.Column<int>("Month")
|
.Column<int>("Month")
|
||||||
.Column<int>("PostCount")
|
.Column<int>("PostCount")
|
||||||
.Column<int>("Blog_id")
|
.Column<int>("BlogPart_id")
|
||||||
);
|
);
|
||||||
|
|
||||||
//CREATE TABLE Orchard_Blogs_BlogRecord (Id INTEGER not null, Description TEXT, PostCount INTEGER, primary key (Id));
|
//CREATE TABLE Orchard_Blogs_BlogPartRecord (Id INTEGER not null, Description TEXT, PostCount INTEGER, primary key (Id));
|
||||||
SchemaBuilder.CreateTable("BlogRecord", table => table
|
SchemaBuilder.CreateTable("BlogPartRecord", table => table
|
||||||
.ContentPartRecord()
|
.ContentPartRecord()
|
||||||
.Column<string>("Description")
|
.Column<string>("Description")
|
||||||
.Column<int>("PostCount")
|
.Column<int>("PostCount")
|
||||||
@@ -31,14 +31,14 @@ namespace Orchard.Blogs.DataMigrations {
|
|||||||
public int UpdateFrom1() {
|
public int UpdateFrom1() {
|
||||||
ContentDefinitionManager.AlterTypeDefinition("Blog",
|
ContentDefinitionManager.AlterTypeDefinition("Blog",
|
||||||
cfg => cfg
|
cfg => cfg
|
||||||
.WithPart("Blog")
|
.WithPart("BlogPart")
|
||||||
.WithPart("CommonAspect")
|
.WithPart("CommonAspect")
|
||||||
.WithPart("IsRoutable")
|
.WithPart("IsRoutable")
|
||||||
);
|
);
|
||||||
|
|
||||||
ContentDefinitionManager.AlterTypeDefinition("BlogPost",
|
ContentDefinitionManager.AlterTypeDefinition("BlogPost",
|
||||||
cfg => cfg
|
cfg => cfg
|
||||||
.WithPart("BlogPost")
|
.WithPart("BlogPostPart")
|
||||||
.WithPart("CommonAspect")
|
.WithPart("CommonAspect")
|
||||||
.WithPart("PublishLaterPart")
|
.WithPart("PublishLaterPart")
|
||||||
.WithPart("IsRoutable")
|
.WithPart("IsRoutable")
|
||||||
@@ -49,7 +49,7 @@ namespace Orchard.Blogs.DataMigrations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int UpdateFrom2() {
|
public int UpdateFrom2() {
|
||||||
ContentDefinitionManager.AlterPartDefinition(typeof(Blog).Name, cfg => cfg
|
ContentDefinitionManager.AlterPartDefinition(typeof(BlogPart).Name, cfg => cfg
|
||||||
.WithLocation(new Dictionary<string, ContentLocation> {
|
.WithLocation(new Dictionary<string, ContentLocation> {
|
||||||
{"Editor", new ContentLocation { Zone = "primary", Position = "1" }}
|
{"Editor", new ContentLocation { Zone = "primary", Position = "1" }}
|
||||||
}));
|
}));
|
||||||
|
@@ -13,7 +13,7 @@ using Orchard.Mvc.ViewModels;
|
|||||||
|
|
||||||
namespace Orchard.Blogs.Drivers {
|
namespace Orchard.Blogs.Drivers {
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class BlogDriver : ContentItemDriver<Blog> {
|
public class BlogPartDriver : ContentItemDriver<BlogPart> {
|
||||||
public IOrchardServices Services { get; set; }
|
public IOrchardServices Services { get; set; }
|
||||||
|
|
||||||
public readonly static ContentType ContentType = new ContentType {
|
public readonly static ContentType ContentType = new ContentType {
|
||||||
@@ -24,7 +24,7 @@ namespace Orchard.Blogs.Drivers {
|
|||||||
private readonly IContentManager _contentManager;
|
private readonly IContentManager _contentManager;
|
||||||
private readonly IBlogPostService _blogPostService;
|
private readonly IBlogPostService _blogPostService;
|
||||||
|
|
||||||
public BlogDriver(IOrchardServices services, IContentManager contentManager, IBlogPostService blogPostService) {
|
public BlogPartDriver(IOrchardServices services, IContentManager contentManager, IBlogPostService blogPostService) {
|
||||||
Services = services;
|
Services = services;
|
||||||
_contentManager = contentManager;
|
_contentManager = contentManager;
|
||||||
_blogPostService = blogPostService;
|
_blogPostService = blogPostService;
|
||||||
@@ -39,50 +39,50 @@ namespace Orchard.Blogs.Drivers {
|
|||||||
|
|
||||||
protected override string Prefix { get { return ""; } }
|
protected override string Prefix { get { return ""; } }
|
||||||
|
|
||||||
protected override string GetDisplayText(Blog item) {
|
protected override string GetDisplayText(BlogPart item) {
|
||||||
return item.Name;
|
return item.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override RouteValueDictionary GetDisplayRouteValues(Blog blog) {
|
public override RouteValueDictionary GetDisplayRouteValues(BlogPart blogPart) {
|
||||||
return new RouteValueDictionary {
|
return new RouteValueDictionary {
|
||||||
{"Area", "Orchard.Blogs"},
|
{"Area", "Orchard.Blogs"},
|
||||||
{"Controller", "Blog"},
|
{"Controller", "Blog"},
|
||||||
{"Action", "Item"},
|
{"Action", "Item"},
|
||||||
{"blogSlug", blog.Slug}
|
{"blogSlug", blogPart.Slug}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override RouteValueDictionary GetEditorRouteValues(Blog blog) {
|
public override RouteValueDictionary GetEditorRouteValues(BlogPart blogPart) {
|
||||||
return new RouteValueDictionary {
|
return new RouteValueDictionary {
|
||||||
{"Area", "Orchard.Blogs"},
|
{"Area", "Orchard.Blogs"},
|
||||||
{"Controller", "Blog"},
|
{"Controller", "Blog"},
|
||||||
{"Action", "Edit"},
|
{"Action", "Edit"},
|
||||||
{"blogSlug", blog.Slug}
|
{"blogSlug", blogPart.Slug}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DriverResult Display(Blog blog, string displayType) {
|
protected override DriverResult Display(BlogPart blogPart, string displayType) {
|
||||||
|
|
||||||
IEnumerable<ContentItemViewModel<BlogPost>> blogPosts = null;
|
IEnumerable<ContentItemViewModel<BlogPostPart>> blogPosts = null;
|
||||||
if (displayType.StartsWith("DetailAdmin")) {
|
if (displayType.StartsWith("DetailAdmin")) {
|
||||||
blogPosts = _blogPostService.Get(blog, VersionOptions.Latest)
|
blogPosts = _blogPostService.Get(blogPart, VersionOptions.Latest)
|
||||||
.Select(bp => _contentManager.BuildDisplayModel(bp, "SummaryAdmin"));
|
.Select(bp => _contentManager.BuildDisplayModel(bp, "SummaryAdmin"));
|
||||||
}
|
}
|
||||||
else if (displayType.StartsWith("Detail")) {
|
else if (displayType.StartsWith("Detail")) {
|
||||||
blogPosts = _blogPostService.Get(blog)
|
blogPosts = _blogPostService.Get(blogPart)
|
||||||
.Select(bp => _contentManager.BuildDisplayModel(bp, "Summary"));
|
.Select(bp => _contentManager.BuildDisplayModel(bp, "Summary"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Combined(
|
return Combined(
|
||||||
ContentItemTemplate("Items/Blogs.Blog").LongestMatch(displayType, "Summary", "DetailAdmin", "SummaryAdmin"),
|
ContentItemTemplate("Items/Blogs.Blog").LongestMatch(displayType, "Summary", "DetailAdmin", "SummaryAdmin"),
|
||||||
ContentPartTemplate(blog, "Parts/Blogs.Blog.Manage").Location("manage"),
|
ContentPartTemplate(blogPart, "Parts/Blogs.Blog.Manage").Location("manage"),
|
||||||
ContentPartTemplate(blog, "Parts/Blogs.Blog.Metadata").Location("metadata"),
|
ContentPartTemplate(blogPart, "Parts/Blogs.Blog.Metadata").Location("metadata"),
|
||||||
ContentPartTemplate(blog, "Parts/Blogs.Blog.Description").Location("primary"),
|
ContentPartTemplate(blogPart, "Parts/Blogs.Blog.Description").Location("primary"),
|
||||||
blogPosts == null
|
blogPosts == null
|
||||||
? null
|
? null
|
||||||
: ContentPartTemplate(
|
: ContentPartTemplate(
|
||||||
new ListContentsViewModel {
|
new ListContentsViewModel {
|
||||||
ContainerId = blog.Id,
|
ContainerId = blogPart.Id,
|
||||||
Entries = blogPosts.Select(bp => new ListContentsViewModel.Entry {
|
Entries = blogPosts.Select(bp => new ListContentsViewModel.Entry {
|
||||||
ContentItem = bp.Item.ContentItem,
|
ContentItem = bp.Item.ContentItem,
|
||||||
ContentItemMetadata = _contentManager.GetItemMetadata(bp.Item.ContentItem),
|
ContentItemMetadata = _contentManager.GetItemMetadata(bp.Item.ContentItem),
|
||||||
@@ -93,16 +93,16 @@ namespace Orchard.Blogs.Drivers {
|
|||||||
"").LongestMatch(displayType, "DetailAdmin").Location("primary"));
|
"").LongestMatch(displayType, "DetailAdmin").Location("primary"));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DriverResult Editor(Blog blog) {
|
protected override DriverResult Editor(BlogPart blogPart) {
|
||||||
var location = blog.GetLocation("Editor");
|
var location = blogPart.GetLocation("Editor");
|
||||||
return Combined(
|
return Combined(
|
||||||
ContentItemTemplate("Items/Blogs.Blog"),
|
ContentItemTemplate("Items/Blogs.Blog"),
|
||||||
ContentPartTemplate(blog, "Parts/Blogs.Blog.Fields").Location(location));
|
ContentPartTemplate(blogPart, "Parts/Blogs.Blog.Fields").Location(location));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DriverResult Editor(Blog blog, IUpdateModel updater) {
|
protected override DriverResult Editor(BlogPart blogPart, IUpdateModel updater) {
|
||||||
updater.TryUpdateModel(blog, Prefix, null, null);
|
updater.TryUpdateModel(blogPart, Prefix, null, null);
|
||||||
return Editor(blog);
|
return Editor(blogPart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -7,7 +7,7 @@ using Orchard.Localization;
|
|||||||
|
|
||||||
namespace Orchard.Blogs.Drivers {
|
namespace Orchard.Blogs.Drivers {
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class BlogPostDriver : ContentItemDriver<BlogPost> {
|
public class BlogPostDriver : ContentItemDriver<BlogPostPart> {
|
||||||
public IOrchardServices Services { get; set; }
|
public IOrchardServices Services { get; set; }
|
||||||
|
|
||||||
public readonly static ContentType ContentType = new ContentType {
|
public readonly static ContentType ContentType = new ContentType {
|
||||||
@@ -28,54 +28,54 @@ namespace Orchard.Blogs.Drivers {
|
|||||||
|
|
||||||
protected override string Prefix { get { return ""; } }
|
protected override string Prefix { get { return ""; } }
|
||||||
|
|
||||||
protected override string GetDisplayText(BlogPost post) {
|
protected override string GetDisplayText(BlogPostPart postPart) {
|
||||||
return post.Title;
|
return postPart.Title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override RouteValueDictionary GetDisplayRouteValues(BlogPost post) {
|
public override RouteValueDictionary GetDisplayRouteValues(BlogPostPart postPart) {
|
||||||
if (post.Blog == null)
|
if (postPart.BlogPart == null)
|
||||||
return new RouteValueDictionary();
|
return new RouteValueDictionary();
|
||||||
|
|
||||||
return new RouteValueDictionary {
|
return new RouteValueDictionary {
|
||||||
{"Area", "Orchard.Blogs"},
|
{"Area", "Orchard.Blogs"},
|
||||||
{"Controller", "BlogPost"},
|
{"Controller", "BlogPost"},
|
||||||
{"Action", "Item"},
|
{"Action", "Item"},
|
||||||
{"blogSlug", post.Blog.Slug},
|
{"blogSlug", postPart.BlogPart.Slug},
|
||||||
{"postSlug", post.Slug},
|
{"postSlug", postPart.Slug},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override RouteValueDictionary GetEditorRouteValues(BlogPost post) {
|
public override RouteValueDictionary GetEditorRouteValues(BlogPostPart postPart) {
|
||||||
if (post.Blog == null)
|
if (postPart.BlogPart == null)
|
||||||
return new RouteValueDictionary();
|
return new RouteValueDictionary();
|
||||||
|
|
||||||
return new RouteValueDictionary {
|
return new RouteValueDictionary {
|
||||||
{"Area", "Orchard.Blogs"},
|
{"Area", "Orchard.Blogs"},
|
||||||
{"Controller", "BlogPostAdmin"},
|
{"Controller", "BlogPostAdmin"},
|
||||||
{"Action", "Edit"},
|
{"Action", "Edit"},
|
||||||
{"blogSlug", post.Blog.Slug},
|
{"blogSlug", postPart.BlogPart.Slug},
|
||||||
{"postId", post.Id},
|
{"postId", postPart.Id},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override RouteValueDictionary GetCreateRouteValues(BlogPost post) {
|
public override RouteValueDictionary GetCreateRouteValues(BlogPostPart postPart) {
|
||||||
if (post.Blog == null)
|
if (postPart.BlogPart == null)
|
||||||
return new RouteValueDictionary();
|
return new RouteValueDictionary();
|
||||||
|
|
||||||
return new RouteValueDictionary {
|
return new RouteValueDictionary {
|
||||||
{"Area", "Orchard.Blogs"},
|
{"Area", "Orchard.Blogs"},
|
||||||
{"Controller", "BlogPostAdmin"},
|
{"Controller", "BlogPostAdmin"},
|
||||||
{"Action", "Create"},
|
{"Action", "Create"},
|
||||||
{"blogSlug", post.Blog.Slug},
|
{"blogSlug", postPart.BlogPart.Slug},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DriverResult Editor(BlogPost post) {
|
protected override DriverResult Editor(BlogPostPart postPart) {
|
||||||
return ContentItemTemplate("Items/Blogs.BlogPost");
|
return ContentItemTemplate("Items/Blogs.BlogPost");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DriverResult Editor(BlogPost post, IUpdateModel updater) {
|
protected override DriverResult Editor(BlogPostPart postPart, IUpdateModel updater) {
|
||||||
return Editor(post);
|
return Editor(postPart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -4,9 +4,9 @@ using Orchard.Core.Feeds;
|
|||||||
|
|
||||||
namespace Orchard.Blogs.Extensions {
|
namespace Orchard.Blogs.Extensions {
|
||||||
public static class FeedManagerExtensions {
|
public static class FeedManagerExtensions {
|
||||||
public static void Register(this IFeedManager feedManager, Blog blog) {
|
public static void Register(this IFeedManager feedManager, BlogPart blogPart) {
|
||||||
feedManager.Register(blog.Name, "rss", new RouteValueDictionary { { "containerid", blog.Id } });
|
feedManager.Register(blogPart.Name, "rss", new RouteValueDictionary { { "containerid", blogPart.Id } });
|
||||||
feedManager.Register(blog.Name + " - Comments", "rss", new RouteValueDictionary { { "commentedoncontainer", blog.Id } });
|
feedManager.Register(blogPart.Name + " - Comments", "rss", new RouteValueDictionary { { "commentedoncontainer", blogPart.Id } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace Orchard.Blogs.Extensions {
|
|
||||||
public static class UriExtensions {
|
|
||||||
public static string ToRootString(this Uri uri) {
|
|
||||||
return string.Format("{0}://{1}{2}", uri.Scheme, uri.Host, uri.Port != 80 ? ":" + uri.Port : "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -52,48 +52,48 @@ namespace Orchard.Blogs.Extensions {
|
|||||||
return urlHelper.Action("Remove", "BlogAdmin", new {blogSlug, area = "Orchard.Blogs"});
|
return urlHelper.Action("Remove", "BlogAdmin", new {blogSlug, area = "Orchard.Blogs"});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BlogPost(this UrlHelper urlHelper, BlogPost blogPost) {
|
public static string BlogPost(this UrlHelper urlHelper, BlogPostPart blogPostPart) {
|
||||||
return urlHelper.BlogPost(blogPost.Blog.Slug, blogPost.Slug);
|
return urlHelper.BlogPost(blogPostPart.BlogPart.Slug, blogPostPart.Slug);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BlogPost(this UrlHelper urlHelper, string blogSlug, string postSlug) {
|
public static string BlogPost(this UrlHelper urlHelper, string blogSlug, string postSlug) {
|
||||||
return urlHelper.Action("Item", "BlogPost", new {blogSlug, postSlug, area = "Orchard.Blogs"});
|
return urlHelper.Action("Item", "BlogPost", new {blogSlug, postSlug, area = "Orchard.Blogs"});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BlogPostCreate(this UrlHelper urlHelper, Blog blog) {
|
public static string BlogPostCreate(this UrlHelper urlHelper, BlogPart blogPart) {
|
||||||
return urlHelper.BlogPostCreate(blog.Slug);
|
return urlHelper.BlogPostCreate(blogPart.Slug);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BlogPostCreate(this UrlHelper urlHelper, string blogSlug) {
|
public static string BlogPostCreate(this UrlHelper urlHelper, string blogSlug) {
|
||||||
return urlHelper.Action("Create", "BlogPostAdmin", new {blogSlug, area = "Orchard.Blogs"});
|
return urlHelper.Action("Create", "BlogPostAdmin", new {blogSlug, area = "Orchard.Blogs"});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BlogPostEdit(this UrlHelper urlHelper, BlogPost blogPost) {
|
public static string BlogPostEdit(this UrlHelper urlHelper, BlogPostPart blogPostPart) {
|
||||||
return urlHelper.BlogPostEdit(blogPost.Blog.Slug, blogPost.Id);
|
return urlHelper.BlogPostEdit(blogPostPart.BlogPart.Slug, blogPostPart.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BlogPostEdit(this UrlHelper urlHelper, string blogSlug, int postId) {
|
public static string BlogPostEdit(this UrlHelper urlHelper, string blogSlug, int postId) {
|
||||||
return urlHelper.Action("Edit", "BlogPostAdmin", new {blogSlug, postId, area = "Orchard.Blogs"});
|
return urlHelper.Action("Edit", "BlogPostAdmin", new {blogSlug, postId, area = "Orchard.Blogs"});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BlogPostDelete(this UrlHelper urlHelper, BlogPost blogPost) {
|
public static string BlogPostDelete(this UrlHelper urlHelper, BlogPostPart blogPostPart) {
|
||||||
return urlHelper.BlogPostDelete(blogPost.Blog.Slug, blogPost.Id);
|
return urlHelper.BlogPostDelete(blogPostPart.BlogPart.Slug, blogPostPart.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BlogPostDelete(this UrlHelper urlHelper, string blogSlug, int postId) {
|
public static string BlogPostDelete(this UrlHelper urlHelper, string blogSlug, int postId) {
|
||||||
return urlHelper.Action("Delete", "BlogPostAdmin", new {blogSlug, postId, area = "Orchard.Blogs"});
|
return urlHelper.Action("Delete", "BlogPostAdmin", new {blogSlug, postId, area = "Orchard.Blogs"});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BlogPostPublish(this UrlHelper urlHelper, BlogPost blogPost) {
|
public static string BlogPostPublish(this UrlHelper urlHelper, BlogPostPart blogPostPart) {
|
||||||
return urlHelper.BlogPostPublish(blogPost.Blog.Slug, blogPost.Id);
|
return urlHelper.BlogPostPublish(blogPostPart.BlogPart.Slug, blogPostPart.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BlogPostPublish(this UrlHelper urlHelper, string blogSlug, int postId) {
|
public static string BlogPostPublish(this UrlHelper urlHelper, string blogSlug, int postId) {
|
||||||
return urlHelper.Action("Publish", "BlogPostAdmin", new { blogSlug, postId, area = "Orchard.Blogs" });
|
return urlHelper.Action("Publish", "BlogPostAdmin", new { blogSlug, postId, area = "Orchard.Blogs" });
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BlogPostUnpublish(this UrlHelper urlHelper, BlogPost blogPost) {
|
public static string BlogPostUnpublish(this UrlHelper urlHelper, BlogPostPart blogPostPart) {
|
||||||
return urlHelper.BlogPostUnpublish(blogPost.Blog.Slug, blogPost.Id);
|
return urlHelper.BlogPostUnpublish(blogPostPart.BlogPart.Slug, blogPostPart.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BlogPostUnpublish(this UrlHelper urlHelper, string blogSlug, int postId) {
|
public static string BlogPostUnpublish(this UrlHelper urlHelper, string blogSlug, int postId) {
|
||||||
|
@@ -15,19 +15,19 @@ namespace Orchard.Blogs.Filters {
|
|||||||
|
|
||||||
var blogViewModel = filterContext.Controller.ViewData.Model as BlogViewModel;
|
var blogViewModel = filterContext.Controller.ViewData.Model as BlogViewModel;
|
||||||
if (blogViewModel != null) {
|
if (blogViewModel != null) {
|
||||||
blogViewModel.Zones.AddRenderPartial("sidebar", "Archives", new BlogArchivesViewModel { Blog = blogViewModel.Blog.Item, Archives = _blogPostService.GetArchives(blogViewModel.Blog.Item) });
|
blogViewModel.Zones.AddRenderPartial("sidebar", "Archives", new BlogArchivesViewModel { BlogPart = blogViewModel.Blog.Item, Archives = _blogPostService.GetArchives(blogViewModel.Blog.Item) });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var blogPostViewModel = filterContext.Controller.ViewData.Model as BlogPostViewModel;
|
var blogPostViewModel = filterContext.Controller.ViewData.Model as BlogPostViewModel;
|
||||||
if (blogPostViewModel != null) {
|
if (blogPostViewModel != null) {
|
||||||
blogPostViewModel.Zones.AddRenderPartial("sidebar", "Archives", new BlogArchivesViewModel { Blog = blogPostViewModel.Blog, Archives = _blogPostService.GetArchives(blogPostViewModel.Blog) });
|
blogPostViewModel.Zones.AddRenderPartial("sidebar", "Archives", new BlogArchivesViewModel { BlogPart = blogPostViewModel.BlogPart, Archives = _blogPostService.GetArchives(blogPostViewModel.BlogPart) });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var blogPostArchiveViewModel = filterContext.Controller.ViewData.Model as BlogPostArchiveViewModel;
|
var blogPostArchiveViewModel = filterContext.Controller.ViewData.Model as BlogPostArchiveViewModel;
|
||||||
if (blogPostArchiveViewModel != null) {
|
if (blogPostArchiveViewModel != null) {
|
||||||
blogPostArchiveViewModel.Zones.AddRenderPartial("sidebar", "Archives", new BlogArchivesViewModel { Blog = blogPostArchiveViewModel.Blog, Archives = _blogPostService.GetArchives(blogPostArchiveViewModel.Blog) });
|
blogPostArchiveViewModel.Zones.AddRenderPartial("sidebar", "Archives", new BlogArchivesViewModel { BlogPart = blogPostArchiveViewModel.BlogPart, Archives = _blogPostService.GetArchives(blogPostArchiveViewModel.BlogPart) });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,25 +11,25 @@ using Orchard.Data;
|
|||||||
namespace Orchard.Blogs.Handlers {
|
namespace Orchard.Blogs.Handlers {
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class BlogArchiveHandler : ContentHandler {
|
public class BlogArchiveHandler : ContentHandler {
|
||||||
public BlogArchiveHandler(IRepository<BlogArchiveRecord> blogArchiveRepository, IRepository<CommonRecord> commonRepository) {
|
public BlogArchiveHandler(IRepository<BlogPartArchiveRecord> blogArchiveRepository, IRepository<CommonRecord> commonRepository) {
|
||||||
OnPublished<BlogPost>((context, bp) => RecalculateBlogArchive(blogArchiveRepository, commonRepository, bp));
|
OnPublished<BlogPostPart>((context, bp) => RecalculateBlogArchive(blogArchiveRepository, commonRepository, bp));
|
||||||
OnRemoved<BlogPost>((context, bp) => RecalculateBlogArchive(blogArchiveRepository, commonRepository, bp));
|
OnRemoved<BlogPostPart>((context, bp) => RecalculateBlogArchive(blogArchiveRepository, commonRepository, bp));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void RecalculateBlogArchive(IRepository<BlogArchiveRecord> blogArchiveRepository, IRepository<CommonRecord> commonRepository, BlogPost blogPost) {
|
private static void RecalculateBlogArchive(IRepository<BlogPartArchiveRecord> blogArchiveRepository, IRepository<CommonRecord> commonRepository, BlogPostPart blogPostPart) {
|
||||||
blogArchiveRepository.Flush();
|
blogArchiveRepository.Flush();
|
||||||
|
|
||||||
//INFO: (erikpo) Remove all current blog archive records
|
//INFO: (erikpo) Remove all current blog archive records
|
||||||
var blogArchiveRecords =
|
var blogArchiveRecords =
|
||||||
from bar in blogArchiveRepository.Table
|
from bar in blogArchiveRepository.Table
|
||||||
where bar.Blog == blogPost.Blog.Record
|
where bar.BlogPart == blogPostPart.BlogPart.Record
|
||||||
select bar;
|
select bar;
|
||||||
blogArchiveRecords.ToList().ForEach(blogArchiveRepository.Delete);
|
blogArchiveRecords.ToList().ForEach(blogArchiveRepository.Delete);
|
||||||
|
|
||||||
//INFO: (erikpo) Get all blog posts for the current blog
|
//INFO: (erikpo) Get all blog posts for the current blog
|
||||||
var postsQuery =
|
var postsQuery =
|
||||||
from bpr in commonRepository.Table
|
from bpr in commonRepository.Table
|
||||||
where bpr.ContentItemRecord.ContentType.Name == BlogPostDriver.ContentType.Name && bpr.Container.Id == blogPost.Blog.Record.Id
|
where bpr.ContentItemRecord.ContentType.Name == BlogPostDriver.ContentType.Name && bpr.Container.Id == blogPostPart.BlogPart.Record.Id
|
||||||
orderby bpr.PublishedUtc
|
orderby bpr.PublishedUtc
|
||||||
select bpr;
|
select bpr;
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ namespace Orchard.Blogs.Handlers {
|
|||||||
|
|
||||||
//INFO: (erikpo) Create the new blog archive records based on the in memory values
|
//INFO: (erikpo) Create the new blog archive records based on the in memory values
|
||||||
foreach (KeyValuePair<DateTime, int> item in inMemoryBlogArchives) {
|
foreach (KeyValuePair<DateTime, int> item in inMemoryBlogArchives) {
|
||||||
blogArchiveRepository.Create(new BlogArchiveRecord {Blog = blogPost.Blog.Record, Year = item.Key.Year, Month = item.Key.Month, PostCount = item.Value});
|
blogArchiveRepository.Create(new BlogPartArchiveRecord {BlogPart = blogPostPart.BlogPart.Record, Year = item.Key.Year, Month = item.Key.Month, PostCount = item.Value});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ using Orchard.Data;
|
|||||||
namespace Orchard.Blogs.Handlers {
|
namespace Orchard.Blogs.Handlers {
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class BlogHandler : ContentHandler {
|
public class BlogHandler : ContentHandler {
|
||||||
public BlogHandler(IRepository<BlogRecord> repository) {
|
public BlogHandler(IRepository<BlogPartRecord> repository) {
|
||||||
Filters.Add(StorageFilter.For(repository));
|
Filters.Add(StorageFilter.For(repository));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,7 @@ namespace Orchard.Blogs.Handlers {
|
|||||||
_orchardServices = orchardServices;
|
_orchardServices = orchardServices;
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
|
|
||||||
Action<Blog> updateBlogPostCount =
|
Action<BlogPart> updateBlogPostCount =
|
||||||
(blog => {
|
(blog => {
|
||||||
// Ensure we get the "right" set of published posts for the blog
|
// Ensure we get the "right" set of published posts for the blog
|
||||||
blog.ContentItem.ContentManager.Flush();
|
blog.ContentItem.ContentManager.Flush();
|
||||||
@@ -28,10 +28,10 @@ namespace Orchard.Blogs.Handlers {
|
|||||||
blog.PostCount = postsCount;
|
blog.PostCount = postsCount;
|
||||||
});
|
});
|
||||||
|
|
||||||
OnInitializing<BlogPost>((context, bp) => {
|
OnInitializing<BlogPostPart>((context, bp) => {
|
||||||
var blogSlug = requestContext.RouteData.Values.ContainsKey("blogSlug") ? requestContext.RouteData.Values["blogSlug"] as string : null;
|
var blogSlug = requestContext.RouteData.Values.ContainsKey("blogSlug") ? requestContext.RouteData.Values["blogSlug"] as string : null;
|
||||||
if (!string.IsNullOrEmpty(blogSlug)) {
|
if (!string.IsNullOrEmpty(blogSlug)) {
|
||||||
bp.Blog = blogService.Get(blogSlug);
|
bp.BlogPart = blogService.Get(blogSlug);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,19 +41,19 @@ namespace Orchard.Blogs.Handlers {
|
|||||||
if (!string.IsNullOrEmpty(containerId)) {
|
if (!string.IsNullOrEmpty(containerId)) {
|
||||||
int cId;
|
int cId;
|
||||||
if (int.TryParse(containerId, out cId)) {
|
if (int.TryParse(containerId, out cId)) {
|
||||||
bp.Blog = context.ContentItem.ContentManager.Get(cId).As<Blog>();
|
bp.BlogPart = context.ContentItem.ContentManager.Get(cId).As<BlogPart>();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
OnCreated<BlogPost>((context, bp) => updateBlogPostCount(bp.Blog));
|
OnCreated<BlogPostPart>((context, bp) => updateBlogPostCount(bp.BlogPart));
|
||||||
OnPublished<BlogPost>((context, bp) => updateBlogPostCount(bp.Blog));
|
OnPublished<BlogPostPart>((context, bp) => updateBlogPostCount(bp.BlogPart));
|
||||||
OnVersioned<BlogPost>((context, bp1, bp2) => updateBlogPostCount(bp2.Blog));
|
OnVersioned<BlogPostPart>((context, bp1, bp2) => updateBlogPostCount(bp2.BlogPart));
|
||||||
OnRemoved<BlogPost>((context, bp) => updateBlogPostCount(bp.Blog));
|
OnRemoved<BlogPostPart>((context, bp) => updateBlogPostCount(bp.BlogPart));
|
||||||
|
|
||||||
OnRemoved<Blog>(
|
OnRemoved<BlogPart>(
|
||||||
(context, b) =>
|
(context, b) =>
|
||||||
blogPostService.Get(context.ContentItem.As<Blog>()).ToList().ForEach(
|
blogPostService.Get(context.ContentItem.As<BlogPart>()).ToList().ForEach(
|
||||||
blogPost => context.ContentManager.Remove(blogPost.ContentItem)));
|
blogPost => context.ContentManager.Remove(blogPost.ContentItem)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@ using Orchard.ContentManagement;
|
|||||||
using Orchard.Core.Routable.Models;
|
using Orchard.Core.Routable.Models;
|
||||||
|
|
||||||
namespace Orchard.Blogs.Models {
|
namespace Orchard.Blogs.Models {
|
||||||
public class Blog : ContentPart<BlogRecord> {
|
public class BlogPart : ContentPart<BlogPartRecord> {
|
||||||
[HiddenInput(DisplayValue = false)]
|
[HiddenInput(DisplayValue = false)]
|
||||||
public int Id { get { return ContentItem.Id; } }
|
public int Id { get { return ContentItem.Id; } }
|
||||||
|
|
@@ -1,7 +1,7 @@
|
|||||||
namespace Orchard.Blogs.Models {
|
namespace Orchard.Blogs.Models {
|
||||||
public class BlogArchiveRecord {
|
public class BlogPartArchiveRecord {
|
||||||
public virtual int Id { get; set; }
|
public virtual int Id { get; set; }
|
||||||
public virtual BlogRecord Blog { get; set; }
|
public virtual BlogPartRecord BlogPart { get; set; }
|
||||||
public virtual int Year { get; set; }
|
public virtual int Year { get; set; }
|
||||||
public virtual int Month { get; set; }
|
public virtual int Month { get; set; }
|
||||||
public virtual int PostCount { get; set; }
|
public virtual int PostCount { get; set; }
|
@@ -1,7 +1,7 @@
|
|||||||
using Orchard.ContentManagement.Records;
|
using Orchard.ContentManagement.Records;
|
||||||
|
|
||||||
namespace Orchard.Blogs.Models {
|
namespace Orchard.Blogs.Models {
|
||||||
public class BlogRecord : ContentPartRecord {
|
public class BlogPartRecord : ContentPartRecord {
|
||||||
public virtual string Description { get; set; }
|
public virtual string Description { get; set; }
|
||||||
public virtual int PostCount { get; set; }
|
public virtual int PostCount { get; set; }
|
||||||
}
|
}
|
@@ -7,7 +7,7 @@ using Orchard.Core.Routable.Models;
|
|||||||
using Orchard.Security;
|
using Orchard.Security;
|
||||||
|
|
||||||
namespace Orchard.Blogs.Models {
|
namespace Orchard.Blogs.Models {
|
||||||
public class BlogPost : ContentPart {
|
public class BlogPostPart : ContentPart {
|
||||||
[HiddenInput(DisplayValue = false)]
|
[HiddenInput(DisplayValue = false)]
|
||||||
public int Id {
|
public int Id {
|
||||||
get { return ContentItem.Id; }
|
get { return ContentItem.Id; }
|
||||||
@@ -28,8 +28,8 @@ namespace Orchard.Blogs.Models {
|
|||||||
set { this.As<BodyAspect>().Text = value; }
|
set { this.As<BodyAspect>().Text = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Blog Blog {
|
public BlogPart BlogPart {
|
||||||
get { return this.As<ICommonAspect>().Container.As<Blog>(); }
|
get { return this.As<ICommonAspect>().Container.As<BlogPart>(); }
|
||||||
set { this.As<ICommonAspect>().Container = value; }
|
set { this.As<ICommonAspect>().Container = value; }
|
||||||
}
|
}
|
||||||
|
|
@@ -69,7 +69,7 @@
|
|||||||
<Compile Include="Commands\BlogCommands.cs" />
|
<Compile Include="Commands\BlogCommands.cs" />
|
||||||
<Compile Include="Controllers\BlogAdminController.cs" />
|
<Compile Include="Controllers\BlogAdminController.cs" />
|
||||||
<Compile Include="DataMigrations\BlogsDataMigration.cs" />
|
<Compile Include="DataMigrations\BlogsDataMigration.cs" />
|
||||||
<Compile Include="Drivers\BlogDriver.cs" />
|
<Compile Include="Drivers\BlogPartDriver.cs" />
|
||||||
<Compile Include="Controllers\BlogPostAdminController.cs" />
|
<Compile Include="Controllers\BlogPostAdminController.cs" />
|
||||||
<Compile Include="Controllers\BlogPostController.cs" />
|
<Compile Include="Controllers\BlogPostController.cs" />
|
||||||
<Compile Include="Drivers\BlogPostDriver.cs" />
|
<Compile Include="Drivers\BlogPostDriver.cs" />
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
<Compile Include="Filters\ArchivesFilter.cs" />
|
<Compile Include="Filters\ArchivesFilter.cs" />
|
||||||
<Compile Include="Models\ArchiveData.cs" />
|
<Compile Include="Models\ArchiveData.cs" />
|
||||||
<Compile Include="Handlers\BlogArchiveHandler.cs" />
|
<Compile Include="Handlers\BlogArchiveHandler.cs" />
|
||||||
<Compile Include="Models\BlogArchiveRecord.cs" />
|
<Compile Include="Models\BlogPartArchiveRecord.cs" />
|
||||||
<Compile Include="Permissions.cs" />
|
<Compile Include="Permissions.cs" />
|
||||||
<Compile Include="Routing\IBlogSlugConstraint.cs" />
|
<Compile Include="Routing\IBlogSlugConstraint.cs" />
|
||||||
<Compile Include="Routing\IsArchiveConstraint.cs" />
|
<Compile Include="Routing\IsArchiveConstraint.cs" />
|
||||||
@@ -87,11 +87,11 @@
|
|||||||
<Compile Include="Services\BlogHomePageProvider.cs" />
|
<Compile Include="Services\BlogHomePageProvider.cs" />
|
||||||
<Compile Include="Services\BlogService.cs" />
|
<Compile Include="Services\BlogService.cs" />
|
||||||
<Compile Include="Controllers\BlogController.cs" />
|
<Compile Include="Controllers\BlogController.cs" />
|
||||||
<Compile Include="Models\Blog.cs" />
|
<Compile Include="Models\BlogPart.cs" />
|
||||||
<Compile Include="Handlers\BlogHandler.cs" />
|
<Compile Include="Handlers\BlogHandler.cs" />
|
||||||
<Compile Include="Models\BlogPost.cs" />
|
<Compile Include="Models\BlogPostPart.cs" />
|
||||||
<Compile Include="Handlers\BlogPostHandler.cs" />
|
<Compile Include="Handlers\BlogPostHandler.cs" />
|
||||||
<Compile Include="Models\BlogRecord.cs" />
|
<Compile Include="Models\BlogPartRecord.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Routes.cs" />
|
<Compile Include="Routes.cs" />
|
||||||
<Compile Include="Services\BlogPostService.cs" />
|
<Compile Include="Services\BlogPostService.cs" />
|
||||||
|
@@ -14,44 +14,44 @@ namespace Orchard.Blogs.Services {
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class BlogPostService : IBlogPostService {
|
public class BlogPostService : IBlogPostService {
|
||||||
private readonly IContentManager _contentManager;
|
private readonly IContentManager _contentManager;
|
||||||
private readonly IRepository<BlogArchiveRecord> _blogArchiveRepository;
|
private readonly IRepository<BlogPartArchiveRecord> _blogArchiveRepository;
|
||||||
private readonly IPublishingTaskManager _publishingTaskManager;
|
private readonly IPublishingTaskManager _publishingTaskManager;
|
||||||
|
|
||||||
public BlogPostService(IContentManager contentManager, IRepository<BlogArchiveRecord> blogArchiveRepository, IPublishingTaskManager publishingTaskManager) {
|
public BlogPostService(IContentManager contentManager, IRepository<BlogPartArchiveRecord> blogArchiveRepository, IPublishingTaskManager publishingTaskManager) {
|
||||||
_contentManager = contentManager;
|
_contentManager = contentManager;
|
||||||
_blogArchiveRepository = blogArchiveRepository;
|
_blogArchiveRepository = blogArchiveRepository;
|
||||||
_publishingTaskManager = publishingTaskManager;
|
_publishingTaskManager = publishingTaskManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlogPost Get(Blog blog, string slug) {
|
public BlogPostPart Get(BlogPart blogPart, string slug) {
|
||||||
return Get(blog, slug, VersionOptions.Published);
|
return Get(blogPart, slug, VersionOptions.Published);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlogPost Get(Blog blog, string slug, VersionOptions versionOptions) {
|
public BlogPostPart Get(BlogPart blogPart, string slug, VersionOptions versionOptions) {
|
||||||
return
|
return
|
||||||
_contentManager.Query(versionOptions, BlogPostDriver.ContentType.Name).Join<RoutableRecord>().Where(rr => rr.Slug == slug).
|
_contentManager.Query(versionOptions, BlogPostDriver.ContentType.Name).Join<RoutableRecord>().Where(rr => rr.Slug == slug).
|
||||||
Join<CommonRecord>().Where(cr => cr.Container == blog.Record.ContentItemRecord).List().
|
Join<CommonRecord>().Where(cr => cr.Container == blogPart.Record.ContentItemRecord).List().
|
||||||
SingleOrDefault().As<BlogPost>();
|
SingleOrDefault().As<BlogPostPart>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlogPost Get(int id) {
|
public BlogPostPart Get(int id) {
|
||||||
return Get(id, VersionOptions.Published);
|
return Get(id, VersionOptions.Published);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlogPost Get(int id, VersionOptions versionOptions) {
|
public BlogPostPart Get(int id, VersionOptions versionOptions) {
|
||||||
return _contentManager.Get<BlogPost>(id, versionOptions);
|
return _contentManager.Get<BlogPostPart>(id, versionOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<BlogPost> Get(Blog blog) {
|
public IEnumerable<BlogPostPart> Get(BlogPart blogPart) {
|
||||||
return Get(blog, VersionOptions.Published);
|
return Get(blogPart, VersionOptions.Published);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<BlogPost> Get(Blog blog, VersionOptions versionOptions) {
|
public IEnumerable<BlogPostPart> Get(BlogPart blogPart, VersionOptions versionOptions) {
|
||||||
return GetBlogQuery(blog, versionOptions).List().Select(ci => ci.As<BlogPost>());
|
return GetBlogQuery(blogPart, versionOptions).List().Select(ci => ci.As<BlogPostPart>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<BlogPost> Get(Blog blog, ArchiveData archiveData) {
|
public IEnumerable<BlogPostPart> Get(BlogPart blogPart, ArchiveData archiveData) {
|
||||||
var query = GetBlogQuery(blog, VersionOptions.Published);
|
var query = GetBlogQuery(blogPart, VersionOptions.Published);
|
||||||
|
|
||||||
if (archiveData.Day > 0) {
|
if (archiveData.Day > 0) {
|
||||||
var dayDate = new DateTime(archiveData.Year, archiveData.Month, archiveData.Day);
|
var dayDate = new DateTime(archiveData.Year, archiveData.Month, archiveData.Day);
|
||||||
@@ -70,13 +70,13 @@ namespace Orchard.Blogs.Services {
|
|||||||
query = query.Where(cr => cr.CreatedUtc >= yearDate && cr.CreatedUtc < yearDate.AddYears(1));
|
query = query.Where(cr => cr.CreatedUtc >= yearDate && cr.CreatedUtc < yearDate.AddYears(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return query.List().Select(ci => ci.As<BlogPost>());
|
return query.List().Select(ci => ci.As<BlogPostPart>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<KeyValuePair<ArchiveData, int>> GetArchives(Blog blog) {
|
public IEnumerable<KeyValuePair<ArchiveData, int>> GetArchives(BlogPart blogPart) {
|
||||||
var query =
|
var query =
|
||||||
from bar in _blogArchiveRepository.Table
|
from bar in _blogArchiveRepository.Table
|
||||||
where bar.Blog == blog.Record
|
where bar.BlogPart == blogPart.Record
|
||||||
orderby bar.Year descending, bar.Month descending
|
orderby bar.Year descending, bar.Month descending
|
||||||
select bar;
|
select bar;
|
||||||
|
|
||||||
@@ -87,30 +87,30 @@ namespace Orchard.Blogs.Services {
|
|||||||
bar.PostCount));
|
bar.PostCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Delete(BlogPost blogPost) {
|
public void Delete(BlogPostPart blogPostPart) {
|
||||||
_publishingTaskManager.DeleteTasks(blogPost.ContentItem);
|
_publishingTaskManager.DeleteTasks(blogPostPart.ContentItem);
|
||||||
_contentManager.Remove(blogPost.ContentItem);
|
_contentManager.Remove(blogPostPart.ContentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Publish(BlogPost blogPost) {
|
public void Publish(BlogPostPart blogPostPart) {
|
||||||
_publishingTaskManager.DeleteTasks(blogPost.ContentItem);
|
_publishingTaskManager.DeleteTasks(blogPostPart.ContentItem);
|
||||||
_contentManager.Publish(blogPost.ContentItem);
|
_contentManager.Publish(blogPostPart.ContentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Publish(BlogPost blogPost, DateTime scheduledPublishUtc) {
|
public void Publish(BlogPostPart blogPostPart, DateTime scheduledPublishUtc) {
|
||||||
_publishingTaskManager.Publish(blogPost.ContentItem, scheduledPublishUtc);
|
_publishingTaskManager.Publish(blogPostPart.ContentItem, scheduledPublishUtc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Unpublish(BlogPost blogPost) {
|
public void Unpublish(BlogPostPart blogPostPart) {
|
||||||
_contentManager.Unpublish(blogPost.ContentItem);
|
_contentManager.Unpublish(blogPostPart.ContentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime? GetScheduledPublishUtc(BlogPost blogPost) {
|
public DateTime? GetScheduledPublishUtc(BlogPostPart blogPostPart) {
|
||||||
var task = _publishingTaskManager.GetPublishTask(blogPost.ContentItem);
|
var task = _publishingTaskManager.GetPublishTask(blogPostPart.ContentItem);
|
||||||
return (task == null ? null : task.ScheduledUtc);
|
return (task == null ? null : task.ScheduledUtc);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IContentQuery<ContentItem, CommonRecord> GetBlogQuery(ContentPart<BlogRecord> blog, VersionOptions versionOptions) {
|
private IContentQuery<ContentItem, CommonRecord> GetBlogQuery(ContentPart<BlogPartRecord> blog, VersionOptions versionOptions) {
|
||||||
return
|
return
|
||||||
_contentManager.Query(versionOptions, BlogPostDriver.ContentType.Name).Join<CommonRecord>().Where(
|
_contentManager.Query(versionOptions, BlogPostDriver.ContentType.Name).Join<CommonRecord>().Where(
|
||||||
cr => cr.Container == blog.Record.ContentItemRecord).OrderByDescending(cr => cr.CreatedUtc);
|
cr => cr.Container == blog.Record.ContentItemRecord).OrderByDescending(cr => cr.CreatedUtc);
|
||||||
|
@@ -18,31 +18,31 @@ namespace Orchard.Blogs.Services {
|
|||||||
_blogSlugConstraint = blogSlugConstraint;
|
_blogSlugConstraint = blogSlugConstraint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Blog Get(string slug) {
|
public BlogPart Get(string slug) {
|
||||||
return _contentManager.Query<Blog, BlogRecord>()
|
return _contentManager.Query<BlogPart, BlogPartRecord>()
|
||||||
.Join<RoutableRecord>().Where(rr => rr.Slug == slug)
|
.Join<RoutableRecord>().Where(rr => rr.Slug == slug)
|
||||||
.List().FirstOrDefault();
|
.List().FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Blog> Get() {
|
public IEnumerable<BlogPart> Get() {
|
||||||
return _contentManager.Query<Blog, BlogRecord>()
|
return _contentManager.Query<BlogPart, BlogPartRecord>()
|
||||||
.Join<RoutableRecord>()
|
.Join<RoutableRecord>()
|
||||||
.OrderBy(br => br.Title)
|
.OrderBy(br => br.Title)
|
||||||
.List();
|
.List();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Create(Blog blog) {
|
public void Create(BlogPart blogPart) {
|
||||||
_contentManager.Create(blog.ContentItem);
|
_contentManager.Create(blogPart.ContentItem);
|
||||||
_blogSlugConstraint.AddSlug(blog.Slug);
|
_blogSlugConstraint.AddSlug(blogPart.Slug);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Edit(Blog blog) {
|
public void Edit(BlogPart blogPart) {
|
||||||
_blogSlugConstraint.AddSlug(blog.Slug);
|
_blogSlugConstraint.AddSlug(blogPart.Slug);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Delete(Blog blog) {
|
public void Delete(BlogPart blogPart) {
|
||||||
_contentManager.Remove(blog.ContentItem);
|
_contentManager.Remove(blogPart.ContentItem);
|
||||||
_blogSlugConstraint.RemoveSlug(blog.Slug);
|
_blogSlugConstraint.RemoveSlug(blogPart.Slug);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -5,18 +5,18 @@ using Orchard.ContentManagement;
|
|||||||
|
|
||||||
namespace Orchard.Blogs.Services {
|
namespace Orchard.Blogs.Services {
|
||||||
public interface IBlogPostService : IDependency {
|
public interface IBlogPostService : IDependency {
|
||||||
BlogPost Get(Blog blog, string slug);
|
BlogPostPart Get(BlogPart blogPart, string slug);
|
||||||
BlogPost Get(Blog blog, string slug, VersionOptions versionOptions);
|
BlogPostPart Get(BlogPart blogPart, string slug, VersionOptions versionOptions);
|
||||||
BlogPost Get(int id);
|
BlogPostPart Get(int id);
|
||||||
BlogPost Get(int id, VersionOptions versionOptions);
|
BlogPostPart Get(int id, VersionOptions versionOptions);
|
||||||
IEnumerable<BlogPost> Get(Blog blog);
|
IEnumerable<BlogPostPart> Get(BlogPart blogPart);
|
||||||
IEnumerable<BlogPost> Get(Blog blog, VersionOptions versionOptions);
|
IEnumerable<BlogPostPart> Get(BlogPart blogPart, VersionOptions versionOptions);
|
||||||
IEnumerable<BlogPost> Get(Blog blog, ArchiveData archiveData);
|
IEnumerable<BlogPostPart> Get(BlogPart blogPart, ArchiveData archiveData);
|
||||||
IEnumerable<KeyValuePair<ArchiveData, int>> GetArchives(Blog blog);
|
IEnumerable<KeyValuePair<ArchiveData, int>> GetArchives(BlogPart blogPart);
|
||||||
void Delete(BlogPost blogPost);
|
void Delete(BlogPostPart blogPostPart);
|
||||||
void Publish(BlogPost blogPost);
|
void Publish(BlogPostPart blogPostPart);
|
||||||
void Publish(BlogPost blogPost, DateTime scheduledPublishUtc);
|
void Publish(BlogPostPart blogPostPart, DateTime scheduledPublishUtc);
|
||||||
void Unpublish(BlogPost blogPost);
|
void Unpublish(BlogPostPart blogPostPart);
|
||||||
DateTime? GetScheduledPublishUtc(BlogPost blogPost);
|
DateTime? GetScheduledPublishUtc(BlogPostPart blogPostPart);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -3,10 +3,10 @@ using Orchard.Blogs.Models;
|
|||||||
|
|
||||||
namespace Orchard.Blogs.Services {
|
namespace Orchard.Blogs.Services {
|
||||||
public interface IBlogService : IDependency {
|
public interface IBlogService : IDependency {
|
||||||
Blog Get(string slug);
|
BlogPart Get(string slug);
|
||||||
IEnumerable<Blog> Get();
|
IEnumerable<BlogPart> Get();
|
||||||
void Create(Blog blog);
|
void Create(BlogPart blogPart);
|
||||||
void Edit(Blog blog);
|
void Edit(BlogPart blogPart);
|
||||||
void Delete(Blog blog);
|
void Delete(BlogPart blogPart);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -130,7 +130,7 @@ namespace Orchard.Blogs.Services {
|
|||||||
var user = _membershipService.ValidateUser(userName, password);
|
var user = _membershipService.ValidateUser(userName, password);
|
||||||
_authorizationService.CheckAccess(StandardPermissions.AccessFrontEnd, user, null);
|
_authorizationService.CheckAccess(StandardPermissions.AccessFrontEnd, user, null);
|
||||||
|
|
||||||
var blog = _contentManager.Get<Blog>(Convert.ToInt32(blogId));
|
var blog = _contentManager.Get<BlogPart>(Convert.ToInt32(blogId));
|
||||||
if (blog == null)
|
if (blog == null)
|
||||||
throw new ArgumentException();
|
throw new ArgumentException();
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ namespace Orchard.Blogs.Services {
|
|||||||
var user = _membershipService.ValidateUser(userName, password);
|
var user = _membershipService.ValidateUser(userName, password);
|
||||||
_authorizationService.CheckAccess(Permissions.EditBlogPost, user, null);
|
_authorizationService.CheckAccess(Permissions.EditBlogPost, user, null);
|
||||||
|
|
||||||
var blog = _contentManager.Get<Blog>(Convert.ToInt32(blogId));
|
var blog = _contentManager.Get<BlogPart>(Convert.ToInt32(blogId));
|
||||||
if (blog == null)
|
if (blog == null)
|
||||||
throw new ArgumentException();
|
throw new ArgumentException();
|
||||||
|
|
||||||
@@ -159,8 +159,8 @@ namespace Orchard.Blogs.Services {
|
|||||||
var description = content.Optional<string>("description");
|
var description = content.Optional<string>("description");
|
||||||
var slug = content.Optional<string>("wp_slug");
|
var slug = content.Optional<string>("wp_slug");
|
||||||
|
|
||||||
var blogPost = _contentManager.New<BlogPost>(BlogPostDriver.ContentType.Name);
|
var blogPost = _contentManager.New<BlogPostPart>(BlogPostDriver.ContentType.Name);
|
||||||
blogPost.Blog = blog;
|
blogPost.BlogPart = blog;
|
||||||
blogPost.Title = title;
|
blogPost.Title = title;
|
||||||
blogPost.Slug = slug;
|
blogPost.Slug = slug;
|
||||||
blogPost.Text = description;
|
blogPost.Text = description;
|
||||||
@@ -237,14 +237,14 @@ namespace Orchard.Blogs.Services {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static XRpcStruct CreateBlogStruct(BlogPost blogPost, UrlHelper urlHelper) {
|
private static XRpcStruct CreateBlogStruct(BlogPostPart blogPostPart, UrlHelper urlHelper) {
|
||||||
var url = urlHelper.AbsoluteAction(() => urlHelper.BlogPost(blogPost));
|
var url = urlHelper.AbsoluteAction(() => urlHelper.BlogPost(blogPostPart));
|
||||||
return new XRpcStruct()
|
return new XRpcStruct()
|
||||||
.Set("postid", blogPost.Id)
|
.Set("postid", blogPostPart.Id)
|
||||||
.Set("dateCreated", blogPost.CreatedUtc)
|
.Set("dateCreated", blogPostPart.CreatedUtc)
|
||||||
.Set("title", blogPost.Title)
|
.Set("title", blogPostPart.Title)
|
||||||
.Set("wp_slug", blogPost.Slug)
|
.Set("wp_slug", blogPostPart.Slug)
|
||||||
.Set("description", blogPost.Text)
|
.Set("description", blogPostPart.Text)
|
||||||
.Set("link", url)
|
.Set("link", url)
|
||||||
.Set("permaLink", url);
|
.Set("permaLink", url);
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@ namespace Orchard.Blogs.ViewModels {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class AdminBlogEntry {
|
public class AdminBlogEntry {
|
||||||
public ContentItemViewModel<Blog> ContentItemViewModel { get; set; }
|
public ContentItemViewModel<BlogPart> ContentItemViewModel { get; set; }
|
||||||
public int TotalPostCount { get; set; }
|
public int TotalPostCount { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -3,7 +3,7 @@ using Orchard.Blogs.Models;
|
|||||||
|
|
||||||
namespace Orchard.Blogs.ViewModels {
|
namespace Orchard.Blogs.ViewModels {
|
||||||
public class BlogArchivesViewModel {
|
public class BlogArchivesViewModel {
|
||||||
public Blog Blog { get; set; }
|
public BlogPart BlogPart { get; set; }
|
||||||
public IEnumerable<KeyValuePair<ArchiveData, int>> Archives { get; set; }
|
public IEnumerable<KeyValuePair<ArchiveData, int>> Archives { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -3,7 +3,7 @@ using Orchard.Mvc.ViewModels;
|
|||||||
|
|
||||||
namespace Orchard.Blogs.ViewModels {
|
namespace Orchard.Blogs.ViewModels {
|
||||||
public class BlogEditViewModel : BaseViewModel {
|
public class BlogEditViewModel : BaseViewModel {
|
||||||
public ContentItemViewModel<Blog> Blog { get; set; }
|
public ContentItemViewModel<BlogPart> Blog { get; set; }
|
||||||
public bool PromoteToHomePage { get; set; }
|
public bool PromoteToHomePage { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -3,6 +3,6 @@ using Orchard.Mvc.ViewModels;
|
|||||||
|
|
||||||
namespace Orchard.Blogs.ViewModels {
|
namespace Orchard.Blogs.ViewModels {
|
||||||
public class BlogForAdminViewModel : BaseViewModel {
|
public class BlogForAdminViewModel : BaseViewModel {
|
||||||
public ContentItemViewModel<Blog> Blog { get; set; }
|
public ContentItemViewModel<BlogPart> Blog { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -4,8 +4,8 @@ using Orchard.Mvc.ViewModels;
|
|||||||
|
|
||||||
namespace Orchard.Blogs.ViewModels {
|
namespace Orchard.Blogs.ViewModels {
|
||||||
public class BlogPostArchiveViewModel : BaseViewModel {
|
public class BlogPostArchiveViewModel : BaseViewModel {
|
||||||
public Blog Blog { get; set; }
|
public BlogPart BlogPart { get; set; }
|
||||||
public ArchiveData ArchiveData { get; set; }
|
public ArchiveData ArchiveData { get; set; }
|
||||||
public IEnumerable<ContentItemViewModel<BlogPost>> BlogPosts { get; set; }
|
public IEnumerable<ContentItemViewModel<BlogPostPart>> BlogPosts { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -3,6 +3,6 @@ using Orchard.Mvc.ViewModels;
|
|||||||
|
|
||||||
namespace Orchard.Blogs.ViewModels {
|
namespace Orchard.Blogs.ViewModels {
|
||||||
public class BlogPostEditViewModel : BaseViewModel {
|
public class BlogPostEditViewModel : BaseViewModel {
|
||||||
public ContentItemViewModel<BlogPost> BlogPost { get; set; }
|
public ContentItemViewModel<BlogPostPart> BlogPost { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -3,7 +3,7 @@ using Orchard.Mvc.ViewModels;
|
|||||||
|
|
||||||
namespace Orchard.Blogs.ViewModels {
|
namespace Orchard.Blogs.ViewModels {
|
||||||
public class BlogPostViewModel : BaseViewModel {
|
public class BlogPostViewModel : BaseViewModel {
|
||||||
public Blog Blog { get; set; }
|
public BlogPart BlogPart { get; set; }
|
||||||
public ContentItemViewModel<BlogPost> BlogPost { get; set; }
|
public ContentItemViewModel<BlogPostPart> BlogPost { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -3,6 +3,6 @@ using Orchard.Mvc.ViewModels;
|
|||||||
|
|
||||||
namespace Orchard.Blogs.ViewModels {
|
namespace Orchard.Blogs.ViewModels {
|
||||||
public class BlogViewModel : BaseViewModel {
|
public class BlogViewModel : BaseViewModel {
|
||||||
public ContentItemViewModel<Blog> Blog { get; set; }
|
public ContentItemViewModel<BlogPart> Blog { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -4,6 +4,6 @@ using Orchard.Mvc.ViewModels;
|
|||||||
|
|
||||||
namespace Orchard.Blogs.ViewModels {
|
namespace Orchard.Blogs.ViewModels {
|
||||||
public class BlogsViewModel : BaseViewModel {
|
public class BlogsViewModel : BaseViewModel {
|
||||||
public IEnumerable<ContentItemViewModel<Blog>> Blogs { get; set; }
|
public IEnumerable<ContentItemViewModel<BlogPart>> Blogs { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -3,6 +3,6 @@ using Orchard.Mvc.ViewModels;
|
|||||||
|
|
||||||
namespace Orchard.Blogs.ViewModels {
|
namespace Orchard.Blogs.ViewModels {
|
||||||
public class CreateBlogPostViewModel : BaseViewModel {
|
public class CreateBlogPostViewModel : BaseViewModel {
|
||||||
public ContentItemViewModel<BlogPost> BlogPost { get; set; }
|
public ContentItemViewModel<BlogPostPart> BlogPost { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -3,7 +3,7 @@ using Orchard.Mvc.ViewModels;
|
|||||||
|
|
||||||
namespace Orchard.Blogs.ViewModels {
|
namespace Orchard.Blogs.ViewModels {
|
||||||
public class CreateBlogViewModel : BaseViewModel {
|
public class CreateBlogViewModel : BaseViewModel {
|
||||||
public ContentItemViewModel<Blog> Blog { get; set; }
|
public ContentItemViewModel<BlogPart> Blog { get; set; }
|
||||||
public bool PromoteToHomePage { get; set; }
|
public bool PromoteToHomePage { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -22,13 +22,13 @@
|
|||||||
<li class="previous">
|
<li class="previous">
|
||||||
<h4><%=year %> <span>(<%=yearMonths.Sum(ym => ym.Value) %>)</span></h4><%
|
<h4><%=year %> <span>(<%=yearMonths.Sum(ym => ym.Value) %>)</span></h4><%
|
||||||
} %>
|
} %>
|
||||||
<%: Html.UnorderedList(yearMonths, (t, i) => Html.Link(string.Format("{0:MMMM} ({1})", t.Key.ToDateTime(), t.Value), Url.BlogArchiveMonth(Model.Blog.Slug, t.Key.Year, t.Key.Month)), "archiveMonthList") %>
|
<%: Html.UnorderedList(yearMonths, (t, i) => Html.Link(string.Format("{0:MMMM} ({1})", t.Key.ToDateTime(), t.Value), Url.BlogArchiveMonth(Model.BlogPart.Slug, t.Key.Year, t.Key.Month)), "archiveMonthList") %>
|
||||||
</li><%
|
</li><%
|
||||||
} %>
|
} %>
|
||||||
</ul><%
|
</ul><%
|
||||||
}
|
}
|
||||||
else { %>
|
else { %>
|
||||||
<%: Html.UnorderedList(Model.Archives, (t, i) => Html.Link(string.Format("{0:MMMM yyyy} ({1})", t.Key.ToDateTime(), t.Value), Url.BlogArchiveMonth(Model.Blog.Slug, t.Key.Year, t.Key.Month)), "archiveMonthList") %><%
|
<%: Html.UnorderedList(Model.Archives, (t, i) => Html.Link(string.Format("{0:MMMM yyyy} ({1})", t.Key.ToDateTime(), t.Value), Url.BlogArchiveMonth(Model.BlogPart.Slug, t.Key.Year, t.Key.Month)), "archiveMonthList") %><%
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { %>
|
else { %>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<BlogPostViewModel>" %>
|
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<BlogPostViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.Blogs.ViewModels"%>
|
<%@ Import Namespace="Orchard.Blogs.ViewModels"%>
|
||||||
<% Html.AddTitleParts(Model.Blog.Name); %>
|
<% Html.AddTitleParts(Model.BlogPart.Name); %>
|
||||||
<%: Html.DisplayForItem(m => m.BlogPost) %>
|
<%: Html.DisplayForItem(m => m.BlogPost) %>
|
||||||
|
@@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
<div class="archive-trail">
|
<div class="archive-trail">
|
||||||
<%: T("Archives").ToString()
|
<%: T("Archives").ToString()
|
||||||
%> / <%: Html.Link(Model.ArchiveData.Year.ToString(), Url.BlogArchiveYear(Model.Blog.Slug, Model.ArchiveData.Year))
|
%> / <%: Html.Link(Model.ArchiveData.Year.ToString(), Url.BlogArchiveYear(Model.BlogPart.Slug, Model.ArchiveData.Year))
|
||||||
%><%=Model.ArchiveData.Month > 0 ? string.Format(" / {0}", Html.Link(Model.ArchiveData.ToDateTime().ToString("MMMM"), Url.BlogArchiveMonth(Model.Blog.Slug, Model.ArchiveData.Year, Model.ArchiveData.Month))) : ""
|
%><%=Model.ArchiveData.Month > 0 ? string.Format(" / {0}", Html.Link(Model.ArchiveData.ToDateTime().ToString("MMMM"), Url.BlogArchiveMonth(Model.BlogPart.Slug, Model.ArchiveData.Year, Model.ArchiveData.Month))) : ""
|
||||||
%><%=Model.ArchiveData.Day > 0 ? string.Format(" / {0}", Html.Link(Model.ArchiveData.Day.ToString(), Url.BlogArchiveDay(Model.Blog.Slug, Model.ArchiveData.Year, Model.ArchiveData.Month, Model.ArchiveData.Day))) : ""
|
%><%=Model.ArchiveData.Day > 0 ? string.Format(" / {0}", Html.Link(Model.ArchiveData.Day.ToString(), Url.BlogArchiveDay(Model.BlogPart.Slug, Model.ArchiveData.Year, Model.ArchiveData.Month, Model.ArchiveData.Day))) : ""
|
||||||
%>
|
%>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<Blog>>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
|
||||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||||
@@ -17,5 +17,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>--%>
|
</form>--%>
|
||||||
<div class="manage"><a href="<%: Url.BlogPostCreate(Model.Item) %>" class="add button primaryAction"><%: T("New Post")%></a></div>
|
<div class="manage"><a href="<%: Url.BlogPostCreate(Model.Item) %>" class="add button primaryAction"><%: T("New Post")%></a></div>
|
||||||
<% Html.Zone("primary");
|
<% Html.Zone("primary"); %>
|
||||||
Html.ZonesAny(); %>
|
|
@@ -1,4 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<Blog>>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
|
||||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<Blog>>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
|
||||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<Blog>>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
|
||||||
<%@ Import Namespace="Orchard.UI.Resources"%>
|
<%@ Import Namespace="Orchard.UI.Resources"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPost>>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPostPart>>" %>
|
||||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPost>>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPostPart>>" %>
|
||||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||||
<h1><%: Html.TitleForPage(Model.Item.Title)%></h1>
|
<h1><%: Html.TitleForPage(Model.Item.Title)%></h1>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Blog>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogPart>" %>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||||
<div class="blogdescription">
|
<div class="blogdescription">
|
||||||
<p><%: Model.Description %></p>
|
<p><%: Model.Description %></p>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Blog>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogPart>" %>
|
||||||
<%@ Import Namespace="Orchard.Blogs"%>
|
<%@ Import Namespace="Orchard.Blogs"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Models"%><%
|
<%@ Import Namespace="Orchard.Blogs.Models"%><%
|
||||||
|
@@ -1,2 +1,2 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Blog>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogPart>" %>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
@@ -1,4 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ContentItemViewModel<Blog>>" %>
|
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
|
||||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||||
<% Html.AddTitleParts(Model.Item.Name); %>
|
<% Html.AddTitleParts(Model.Item.Name); %>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPost>>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPostPart>>" %>
|
||||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||||
<% Html.AddTitleParts(Model.Item.Title); %>
|
<% Html.AddTitleParts(Model.Item.Title); %>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Blog>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogPart>" %>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<%: Html.LabelFor(m => m.Description) %>
|
<%: Html.LabelFor(m => m.Description) %>
|
||||||
|
@@ -101,6 +101,10 @@
|
|||||||
<Content Include="Refresh.html" />
|
<Content Include="Refresh.html" />
|
||||||
<Content Include="Themes\TheAdmin\Scripts\admin.js" />
|
<Content Include="Themes\TheAdmin\Scripts\admin.js" />
|
||||||
<Content Include="Themes\TheAdmin\Styles\ie.css" />
|
<Content Include="Themes\TheAdmin\Styles\ie.css" />
|
||||||
|
<Content Include="Themes\TheAdmin\Styles\images\menuClosed.gif" />
|
||||||
|
<Content Include="Themes\TheAdmin\Styles\images\menuClosedHover.gif" />
|
||||||
|
<Content Include="Themes\TheAdmin\Styles\images\menuOpen.gif" />
|
||||||
|
<Content Include="Themes\TheAdmin\Styles\images\menuOpenHover.gif" />
|
||||||
<Content Include="Web.config">
|
<Content Include="Web.config">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Content>
|
</Content>
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BaseViewModel>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BaseViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||||
<ul id="navigation" role="navigation">
|
<ul id="navigation" role="navigation">
|
||||||
|
<%--//todo: get the settings from the cookie to class-ify parts of the menu that should be closed on load--%>
|
||||||
<%if (Model.Menu != null) {
|
<%if (Model.Menu != null) {
|
||||||
foreach (var menuSection in Model.Menu) {
|
foreach (var menuSection in Model.Menu) {
|
||||||
// todo: (heskew) need some help(er)
|
// todo: (heskew) need some help(er)
|
||||||
@@ -24,8 +25,8 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<% using (this.Capture("end-of-page-scripts")) { %>
|
<% using (this.Capture("end-of-page-scripts")) { %>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function () {
|
(function ($) {
|
||||||
$("#navigation h3").expandoControl(function(controller) { return controller.next(); }, { key: "N42", path: "<%:ResolveUrl("~/Admin") %>" });
|
$("#navigation h3").expandoControl(function(controller) { return controller.next(); }, { key: "N42", path: "<%:ResolveUrl("~/") %>" });
|
||||||
});
|
})(jQuery);
|
||||||
</script>
|
</script>
|
||||||
<% } %>
|
<% } %>
|
Reference in New Issue
Block a user