mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-24 21:43:37 +08:00
Starting to get blogs onto the DisplayForItem model
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4043427
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Blogs.Extensions;
|
||||
using Orchard.Blogs.Models;
|
||||
@@ -8,6 +9,7 @@ using Orchard.Data;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Models;
|
||||
using Orchard.Models.Driver;
|
||||
using Orchard.Models.ViewModels;
|
||||
using Orchard.Mvc.Results;
|
||||
using Orchard.Security;
|
||||
using Orchard.UI.Notify;
|
||||
@@ -51,7 +53,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
if (blog == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
IEnumerable<BlogPost> posts = _blogPostService.Get(blog);
|
||||
var posts = _blogPostService.Get(blog).Select(bp => _contentManager.GetDisplayViewModel(bp, null, "Summary"));
|
||||
|
||||
return View(new BlogViewModel { Blog = blog, Posts = posts });
|
||||
}
|
||||
|
@@ -37,15 +37,6 @@ namespace Orchard.Blogs.Controllers {
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public ActionResult ListByBlog(string blogSlug) {
|
||||
Blog blog = _blogService.Get(blogSlug);
|
||||
|
||||
if (blog == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
return View(_blogPostService.Get(blog));
|
||||
}
|
||||
|
||||
//TODO: (erikpo) Should think about moving the slug parameters and get calls and null checks up into a model binder or action filter
|
||||
public ActionResult Item(string blogSlug, string postSlug) {
|
||||
if (!_authorizer.Authorize(Permissions.ViewPost, T("Couldn't view blog post")))
|
||||
|
@@ -4,7 +4,6 @@ using Orchard.Core.Common.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Models;
|
||||
using Orchard.Models.Driver;
|
||||
using Orchard.Models.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.Models {
|
||||
public class BlogPostProvider : ContentProvider {
|
||||
@@ -18,7 +17,7 @@ namespace Orchard.Blogs.Models {
|
||||
Filters.Add(new ActivatingFilter<RoutableAspect>("blogpost"));
|
||||
Filters.Add(new ActivatingFilter<BodyAspect>("blogpost"));
|
||||
Filters.Add(new StorageFilter<BlogPostRecord>(repository));
|
||||
Filters.Add(new ContentItemTemplates<BlogPost>("BlogPost", "ForList"));
|
||||
Filters.Add(new ContentItemTemplates<BlogPost>("BlogPost", "Summary"));
|
||||
|
||||
OnLoaded<BlogPost>((context, bp) => bp.Blog = contentManager.Get<Blog>(bp.Record.Blog.Id));
|
||||
|
||||
|
@@ -110,12 +110,11 @@
|
||||
<Content Include="Views\Blog\DisplayTemplates\BlogForAdmin.ascx" />
|
||||
<Content Include="Views\Blog\List.aspx" />
|
||||
<Content Include="Views\Blog\ListForAdmin.aspx" />
|
||||
<Content Include="Views\Models\DisplayTemplates\BlogPostForList.ascx" />
|
||||
<Content Include="Views\Models\DisplayTemplates\BlogPostSummary.ascx" />
|
||||
<Content Include="Views\Shared\BlogPostPreview.ascx" />
|
||||
<Content Include="Views\BlogPost\EditorTemplates\CreateBlogPostViewModel.ascx" />
|
||||
<Content Include="Views\BlogPost\Item.aspx" />
|
||||
<Content Include="Views\Blog\Create.aspx" />
|
||||
<Content Include="Views\BlogPost\ListByBlog.aspx" />
|
||||
<Content Include="Views\Blog\DisplayTemplates\Blog.ascx" />
|
||||
<Content Include="Views\Blog\Edit.aspx" />
|
||||
<Content Include="Views\Blog\EditorTemplates\BlogEditViewModel.ascx" />
|
||||
|
@@ -1,10 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.Models.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class BlogViewModel : BaseViewModel {
|
||||
public Blog Blog { get; set; }
|
||||
public IEnumerable<BlogPost> Posts { get; set; }
|
||||
public IEnumerable<ItemDisplayViewModel<BlogPost>> Posts { get; set; }
|
||||
}
|
||||
}
|
@@ -10,13 +10,6 @@
|
||||
<asp:Content ContentPlaceHolderID="MainContent" runat="server">
|
||||
<div class="manage"><a href="<%=Url.BlogEdit(Model.Blog.Slug) %>" class="ibutton edit">edit</a></div>
|
||||
<h2><%=Html.Encode(Model.Blog.Name) %></h2>
|
||||
<div><%=Html.Encode(Model.Blog.Description) %></div><%
|
||||
//TODO: (erikpo) Move this into a helper
|
||||
if (Model.Posts.Count() > 0) { %>
|
||||
<ul class="posts"><%
|
||||
foreach (BlogPost post in Model.Posts) { %>
|
||||
<li><% Html.RenderPartial("BlogPostPreview", post); %></li><%
|
||||
} %>
|
||||
</ul><%
|
||||
} %>
|
||||
<div><%=Html.Encode(Model.Blog.Description) %></div>
|
||||
<%=Html.UnorderedList(Model.Posts, (bp, i) => Html.DisplayForItem(bp).ToHtmlString(), "posts contentItems") %>
|
||||
</asp:Content>
|
@@ -1,22 +0,0 @@
|
||||
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<BlogViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Blogs.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Core.Common.Models"%>
|
||||
<%@ Import Namespace="Orchard.Models"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%-- todo: (heskew) make master-less when we get into theming --%>
|
||||
<asp:Content ContentPlaceHolderID="MainContent" runat="server">
|
||||
<div class="yui-g">
|
||||
<h2>Posts</h2><%
|
||||
//TODO: (erikpo) Replace this with an Html extension method of some sort (ListForModel?)
|
||||
if (Model.Posts.Count() > 0) { %>
|
||||
<ul><%
|
||||
foreach (BlogPost post in Model.Posts) { %>
|
||||
<li><a href="<%=Url.BlogPost(Model.Blog.Slug, post.As<RoutableAspect>().Slug) %>"><%=Html.Encode(post.As<RoutableAspect>().Title) %></a></li><%
|
||||
} %>
|
||||
</ul><%
|
||||
} %>
|
||||
</div>
|
||||
</asp:Content>
|
@@ -102,7 +102,7 @@ namespace Orchard.Tags.Controllers {
|
||||
var tag = _tagService.GetTagByName(tagName);
|
||||
var items =
|
||||
_tagService.GetTaggedContentItems(tag.Id).Select(
|
||||
ic => _contentManager.GetDisplayViewModel(ic, null, "ForList"));
|
||||
ic => _contentManager.GetDisplayViewModel(ic, null, "SummaryForSearch"));
|
||||
|
||||
var viewModel = new TagsSearchViewModel {
|
||||
TagName = tag.TagName,
|
||||
|
@@ -5,5 +5,5 @@
|
||||
<%-- todo: (heskew) make master-less when we get into theming --%>
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
|
||||
<h2>List of contents tagged with <em><%= Model.TagName %></em></h2>
|
||||
<%=Html.UnorderedList(Model.Items, (c, i) => Html.DisplayForItem(x=>c).ToHtmlString(), "contentItems") %>
|
||||
<%=Html.UnorderedList(Model.Items, (c, i) => Html.DisplayForItem(c).ToHtmlString(), "contentItems") %>
|
||||
</asp:Content>
|
@@ -8,6 +8,9 @@ using Orchard.Models.ViewModels;
|
||||
|
||||
namespace Orchard.Mvc.Html {
|
||||
public static class ItemDisplayExtensions {
|
||||
public static MvcHtmlString DisplayForItem<TModel, TItemViewModel>(this HtmlHelper<TModel> html, TItemViewModel itemViewModel) where TItemViewModel : ItemDisplayViewModel {
|
||||
return html.DisplayForItem(x => itemViewModel);
|
||||
}
|
||||
public static MvcHtmlString DisplayForItem<TModel, TItemViewModel>(this HtmlHelper<TModel> html, Expression<Func<TModel, TItemViewModel>> expression) where TItemViewModel : ItemDisplayViewModel {
|
||||
|
||||
var metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
|
||||
|
Reference in New Issue
Block a user