More work on the front end content management experience (what little there is atm)

- Wrapped the body aspect itself (oddly, w/out an idea of wrappers for zone items atm) with an injected manage/edit template so any content item w/ a body aspect gets some manage experience
- Changed the Page and Blog Post to not insert their own manage templates

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-03-02 14:07:58 -08:00
parent 6d86a752dc
commit 783b731866
12 changed files with 60 additions and 32 deletions

View File

@@ -1,18 +1,30 @@
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.Common.Models;
using Orchard.Core.Common.ViewModels;
namespace Orchard.Core.Common.Controllers {
public class BodyDriver : ContentPartDriver<BodyAspect> {
public IOrchardServices Services { get; set; }
private const string TemplateName = "Parts/Common.Body";
private const string DefaultTextEditorTemplate = "TinyMceTextEditor";
public BodyDriver(IOrchardServices services) {
Services = services;
}
protected override string Prefix {
get {return "Body";}
}
// \/\/ Haackalicious on many accounts - don't copy what has been done here for the wrapper \/\/
protected override DriverResult Display(BodyAspect part, string displayType) {
var model = new BodyDisplayViewModel { BodyAspect = part };
return ContentPartTemplate(model, TemplateName, Prefix).Location("primary", "5");
return Combined(
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/ManageWrapperPre").Location("primary", "5") : null,
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Manage").Location("primary", "5") : null,
ContentPartTemplate(model, TemplateName, Prefix).Location("primary", "5"),
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/ManageWrapperPost").Location("primary", "5") : null);
}
protected override DriverResult Editor(BodyAspect part) {
@@ -20,7 +32,7 @@ namespace Orchard.Core.Common.Controllers {
return ContentPartTemplate(model, TemplateName, Prefix).Location("primary", "5");
}
protected override DriverResult Editor(BodyAspect part, Orchard.ContentManagement.IUpdateModel updater) {
protected override DriverResult Editor(BodyAspect part, IUpdateModel updater) {
var model = new BodyEditorViewModel { BodyAspect = part, TextEditorTemplate = DefaultTextEditorTemplate };
updater.TryUpdateModel(model, Prefix, null, null);
return ContentPartTemplate(model, TemplateName, Prefix).Location("primary", "5");

View File

@@ -0,0 +1,5 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BodyDisplayViewModel>" %>
<%@ Import Namespace="Orchard.Core.Common.ViewModels"%>
<div class="manage">
<%=Html.ItemEditLink("Edit", Model.BodyAspect.ContentItem) %>
</div>

View File

@@ -0,0 +1,3 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BodyDisplayViewModel>" %>
<%@ Import Namespace="Orchard.Core.Common.ViewModels"%>
</div>

View File

@@ -0,0 +1,3 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BodyDisplayViewModel>" %>
<%@ Import Namespace="Orchard.Core.Common.ViewModels"%>
<div class="managewrapper">

View File

@@ -226,6 +226,9 @@
<Content Include="Themes\Views\DisplayTemplates\Items\ContentItem.ascx" />
</ItemGroup>
<ItemGroup>
<Content Include="Common\Views\DisplayTemplates\Parts\ManageWrapperPost.ascx" />
<Content Include="Common\Views\DisplayTemplates\Parts\ManageWrapperPre.ascx" />
<Content Include="Common\Views\DisplayTemplates\Parts\Manage.ascx" />
<Content Include="Dashboard\Views\Web.config" />
<Content Include="Themes\Styles\special.css" />
</ItemGroup>

View File

@@ -1,3 +1,28 @@
.manage a {
border:1px solid red;
.managewrapper,
.managewrapper .manage {
border:1px dashed #ccc;
}
.managewrapper:hover,
.managewrapper:hover .manage {
border-color:#8f8f8f;
}
.managewrapper {
position:relative;
}
.managewrapper .manage {
border-top:0;
border-right:0;
overflow:hidden;
position:absolute;
right:0;
}
.managewrapper .manage a {
background-color:#fff;
color:#4687ad;
font:14px/14px Segoe UI,Trebuchet,Arial,Sans-Serif;
padding:1px 3px;
}
.managewrapper .manage a:hover {
background-color:#ffac40;
color:#fff;
}

View File

@@ -56,17 +56,16 @@ namespace Orchard.Blogs.Controllers {
protected override RouteValueDictionary GetEditorRouteValues(BlogPost post) {
return new RouteValueDictionary {
{"Area", "Orchard.Blogs"},
{"Controller", "BlogPost"},
{"Controller", "BlogPostAdmin"},
{"Action", "Edit"},
{"blogSlug", post.Blog.Slug},
{"postSlug", post.Slug},
{"postId", post.Id},
};
}
protected override DriverResult Display(BlogPost post, string displayType) {
return Combined(
ContentItemTemplate("Items/Blogs.BlogPost").LongestMatch(displayType, "Summary", "SummaryAdmin"),
ContentPartTemplate(post, "Parts/Blogs.BlogPost.Manage").Location("primary:manage"),
ContentPartTemplate(post, "Parts/Blogs.BlogPost.Metadata").Location("primary:metadata"));
}

View File

@@ -156,9 +156,7 @@
<Content Include="Views\DisplayTemplates\Items\Blogs.Blog.ascx" />
<Content Include="Views\DisplayTemplates\Parts\Blogs.BlogPost.List.ascx" />
<Content Include="Views\DisplayTemplates\Items\Blogs.Blog.Summary.ascx" />
<Content Include="Views\DisplayTemplates\Parts\Blogs.BlogPost.Manage.ascx" />
<Content Include="Views\DisplayTemplates\Parts\Blogs.BlogPost.Metadata.ascx" />
<Content Include="Views\DisplayTemplates\Parts\Blogs.Blog.Manage.ascx" />
<Content Include="Views\DisplayTemplates\Parts\Blogs.Blog.Description.ascx" />
<Content Include="Views\DisplayTemplates\Parts\Blogs.Blog.Metadata.ascx" />
<Content Include="Views\EditorTemplates\Parts\Blogs.BlogPost.Publish.ascx" />

View File

@@ -1,9 +0,0 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogPost>" %>
<%@ Import Namespace="Orchard.Blogs"%>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%><%
if (AuthorizedFor(Permissions.EditOthersBlogPost)) { %>
<div class="manage">
<a href="<%=Url.BlogPostEdit(Model.Blog.Slug, Model.Id) %>" class="edit"><%=_Encoded("Edit") %></a>
</div><%
} %>

View File

@@ -55,14 +55,13 @@ namespace Orchard.Pages.Controllers {
{"Area", "Orchard.Pages"},
{"Controller", "Admin"},
{"Action", "Edit"},
{"pageSlug", page.Slug},
{"id", page.Id},
};
}
protected override DriverResult Display(Page page, string displayType) {
return Combined(
ContentItemTemplate("Items/Pages.Page").LongestMatch(displayType, "Summary", "SummaryAdmin"),
ContentPartTemplate(page, "Parts/Pages.Page.Manage").Location("primary:manage"),
ContentPartTemplate(page, "Parts/Pages.Page.Metadata").Location("primary:metadata"));
}

View File

@@ -120,7 +120,6 @@
<Content Include="Views\DisplayTemplates\Items\Pages.Page.ascx" />
<Content Include="Views\DisplayTemplates\Items\Pages.Page.Summary.ascx" />
<Content Include="Views\DisplayTemplates\Parts\Pages.Page.Metadata.ascx" />
<Content Include="Views\DisplayTemplates\Parts\Pages.Page.Manage.ascx" />
<Content Include="Views\EditorTemplates\Items\Pages.Page.ascx" />
<Content Include="Views\EditorTemplates\Parts\Pages.Page.Publish.ascx" />
<Content Include="Views\Admin\Create.ascx" />

View File

@@ -1,9 +0,0 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Pages.Models.Page>" %>
<%@ Import Namespace="Orchard.Pages"%>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Mvc.Html" %><%
if (AuthorizedFor(Permissions.EditOthersPages)) { %>
<div class="manage">
<a href="<%=Url.Action("Edit", "Admin", new {id = Model.Id, area = "Orchard.Pages"}) %>" class="edit"><%=_Encoded("Edit")%></a>
</div><%
} %>