--HG--
branch : dev
This commit is contained in:
Louis DeJardin
2010-03-01 18:03:15 -08:00
18 changed files with 281 additions and 117 deletions

View File

@@ -1,4 +1,12 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<AdminViewModel>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<h1><%=Html.TitleForPage(T("Orchard Admin").ToString())%></h1>
<p><%=T("Insert admin text here -> &middot;") %></p>
<h1><%=Html.TitleForPage(T("Welcome to the Orchard administration dashboard").ToString())%></h1>
<p>
<%=_Encoded("This is the place where you can manage your web site, its appearance and its contents. Please take a moment to explore the different menu items on the left of the screen to familiarize yourself with the features of the application. For example, try to change the theme through the “Manage Themes” menu entry. You can also create new pages and manage existing ones through the “Manage Pages” menu entry or create blogs through “Manage Blogs”.") %></p>
<p>
<%=_Encoded("Have fun!") %><br />
<%=_Encoded("The Orchard Team") %>
</p>

View File

@@ -227,6 +227,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="Dashboard\Views\Web.config" />
<Content Include="Themes\Styles\special.css" />
</ItemGroup>
<ItemGroup>
<Folder Include="Scheduling\Controllers\" />

View File

@@ -0,0 +1,3 @@
.manage a {
border:1px solid red;
}

View File

@@ -1,2 +1,6 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<% Html.RegisterScript("jquery-1.4.1.js"); // <- change to .min.js for use on a real site :) %>
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %><%
// a CSS file for styling things (e.g. content item edit buttons) for users with elevated privileges (in this case, anyone who is authenticated)
if (Request.IsAuthenticated) { Html.RegisterStyle("special.css"); }
Html.RegisterScript("jquery-1.4.1.js"); // <- change to .min.js for use on a real site :)
%>

View File

@@ -17,6 +17,8 @@ using Orchard.UI.Notify;
namespace Orchard.Blogs.Controllers {
[UsedImplicitly]
public class BlogDriver : ContentItemDriver<Blog> {
public IOrchardServices Services { get; set; }
public readonly static ContentType ContentType = new ContentType {
Name = "blog",
DisplayName = "Blog"
@@ -26,14 +28,13 @@ namespace Orchard.Blogs.Controllers {
private readonly IBlogService _blogService;
private readonly IBlogPostService _blogPostService;
private readonly IRoutableService _routableService;
private readonly IOrchardServices _orchardServices;
public BlogDriver(IContentManager contentManager, IBlogService blogService, IBlogPostService blogPostService, IRoutableService routableService, IOrchardServices orchardServices) {
public BlogDriver(IOrchardServices services, IContentManager contentManager, IBlogService blogService, IBlogPostService blogPostService, IRoutableService routableService) {
Services = services;
_contentManager = contentManager;
_blogService = blogService;
_blogPostService = blogPostService;
_routableService = routableService;
_orchardServices = orchardServices;
T = NullLocalizer.Instance;
}
@@ -81,7 +82,7 @@ namespace Orchard.Blogs.Controllers {
return Combined(
ContentItemTemplate("Items/Blogs.Blog").LongestMatch(displayType, "Summary", "DetailAdmin", "SummaryAdmin"),
ContentPartTemplate(blog, "Parts/Blogs.Blog.Manage").Location("primary:manage"),
Services.Authorizer.Authorize(Permissions.ManageBlogs) ? ContentPartTemplate(blog, "Parts/Blogs.Blog.Manage").Location("primary:manage") : null,
ContentPartTemplate(blog, "Parts/Blogs.Blog.Metadata").Location("primary:metadata"),
ContentPartTemplate(blog, "Parts/Blogs.Blog.Description").Location("primary"),
blogPosts == null ? null : ContentPartTemplate(blogPosts, "Parts/Blogs.BlogPost.List", "").Location("primary"));
@@ -134,7 +135,7 @@ namespace Orchard.Blogs.Controllers {
blog.Slug = _routableService.GenerateUniqueSlug(blog.Slug, slugsLikeThis);
if (originalSlug != blog.Slug)
_orchardServices.Notifier.Warning(T("Slugs in conflict. \"{0}\" is already set for a previously created blog so this blog now has the slug \"{1}\"",
Services.Notifier.Warning(T("Slugs in conflict. \"{0}\" is already set for a previously created blog so this blog now has the slug \"{1}\"",
originalSlug, blog.Slug));
}
}

View File

@@ -15,19 +15,19 @@ using Orchard.UI.Notify;
namespace Orchard.Blogs.Controllers {
[UsedImplicitly]
public class BlogPostDriver : ContentItemDriver<BlogPost> {
public IOrchardServices Services { get; set; }
private readonly IBlogPostService _blogPostService;
private readonly IRoutableService _routableService;
private readonly IOrchardServices _orchardServices;
public readonly static ContentType ContentType = new ContentType {
Name = "blogpost",
DisplayName = "Blog Post"
};
public BlogPostDriver(IBlogService blogService, IBlogPostService blogPostService, IRoutableService routableService, IOrchardServices orchardServices) {
public BlogPostDriver(IOrchardServices services, IBlogService blogService, IBlogPostService blogPostService, IRoutableService routableService) {
Services = services;
_blogPostService = blogPostService;
_routableService = routableService;
_orchardServices = orchardServices;
T = NullLocalizer.Instance;
}
@@ -66,7 +66,7 @@ namespace Orchard.Blogs.Controllers {
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"),
Services.Authorizer.Authorize(Permissions.EditOthersBlogPost) ? ContentPartTemplate(post, "Parts/Blogs.BlogPost.Manage").Location("primary:manage") : null,
ContentPartTemplate(post, "Parts/Blogs.BlogPost.Metadata").Location("primary:metadata"));
}
@@ -114,7 +114,7 @@ namespace Orchard.Blogs.Controllers {
//todo: (heskew) need better messages
if (slugsLikeThis.Count() > 0) {
//todo: (heskew) need better messages
_orchardServices.Notifier.Warning(T("A different blog post is already published with this same slug."));
Services.Notifier.Warning(T("A different blog post is already published with this same slug."));
if (post.ContentItem.VersionRecord == null || post.ContentItem.VersionRecord.Published)
{
@@ -123,7 +123,7 @@ namespace Orchard.Blogs.Controllers {
post.Slug = _routableService.GenerateUniqueSlug(post.Slug, slugsLikeThis);
if (originalSlug != post.Slug)
_orchardServices.Notifier.Warning(T("Slugs in conflict. \"{0}\" is already set for a previously created blog post so this post now has the slug \"{1}\"",
Services.Notifier.Warning(T("Slugs in conflict. \"{0}\" is already set for a previously created blog post so this post now has the slug \"{1}\"",
originalSlug, post.Slug));
}
}

View File

@@ -98,6 +98,7 @@
<Compile Include="Services\BlogPostService.cs" />
<Compile Include="Services\IBlogPostService.cs" />
<Compile Include="Services\IBlogService.cs" />
<Compile Include="Services\XmlRpcHandler.cs" />
<Compile Include="ViewModels\AdminBlogsViewModel.cs" />
<Compile Include="ViewModels\BlogArchivesViewModel.cs" />
<Compile Include="ViewModels\BlogPostArchiveViewModel.cs" />

View File

@@ -0,0 +1,138 @@
using System;
using Orchard.Core.XmlRpc;
using Orchard.Core.XmlRpc.Models;
using Orchard.Logging;
namespace Orchard.Blogs.Services {
public class XmlRpcHandler : IXmlRpcHandler {
private readonly IBlogService _blogService;
public XmlRpcHandler(IBlogService blogService) {
_blogService = blogService;
Logger = NullLogger.Instance;
}
public ILogger Logger { get; set; }
public void Process(XmlRpcContext context) {
var uriBuilder = new UriBuilder(context.HttpContext.Request.Url) {
Path =
context.HttpContext.Request.
ApplicationPath,
Query = string.Empty
};
if (context.Request.MethodName == "blogger.getUsersBlogs") {
var a = new XRpcArray();
foreach (var blog in _blogService.Get()) {
a.Add(new XRpcStruct()
.Set("url", uriBuilder.Path + blog.Slug)
.Set("blogid", blog.Id)
.Set("blogName", blog.Name));
}
context.Response = new XRpcMethodResponse().Add(a);
}
if (context.Request.MethodName == "metaWeblog.newPost") {
var result = MetaWeblogNewPost(
Convert.ToString(context.Request.Params[0].Value),
Convert.ToString(context.Request.Params[1].Value),
Convert.ToString(context.Request.Params[2].Value),
(XRpcStruct)context.Request.Params[3].Value,
Convert.ToBoolean(context.Request.Params[4].Value));
context.Response = new XRpcMethodResponse().Add(result);
}
if (context.Request.MethodName == "metaWeblog.getPost") {
var result = MetaWeblogGetPost(
Convert.ToInt32(context.Request.Params[0].Value),
Convert.ToString(context.Request.Params[1].Value),
Convert.ToString(context.Request.Params[2].Value));
context.Response = new XRpcMethodResponse().Add(result);
}
if (context.Request.MethodName == "metaWeblog.editPost") {
var result = MetaWeblogEditPost(
Convert.ToInt32(context.Request.Params[0].Value),
Convert.ToString(context.Request.Params[1].Value),
Convert.ToString(context.Request.Params[2].Value),
(XRpcStruct)context.Request.Params[3].Value,
Convert.ToBoolean(context.Request.Params[4].Value));
context.Response = new XRpcMethodResponse().Add(result);
}
}
private int MetaWeblogNewPost(
string blogId,
string user,
string password,
XRpcStruct content,
bool publish) {
//var title = content.Optional<string>("title");
//var description = content.Optional<string>("description");
//var pageRevision = _pageManager.CreatePage(new CreatePageParams(title, null, "TwoColumns"));
//pageRevision.Contents.First().Content = description;
//if (publish) {
// if (string.IsNullOrEmpty(pageRevision.Slug))
// pageRevision.Slug = "slug" + pageRevision.Page.Id;
// _pageManager.Publish(pageRevision, new PublishOptions());
//}
//return pageRevision.Page.Id;
return 1;
}
private XRpcStruct MetaWeblogGetPost(
int postId,
string user,
string password) {
//var pageRevision = _pageManager.GetLastRevision(postId);
//var url = "http://localhost/orchard/" + pageRevision.Slug;
//return new XRpcStruct()
// .Set("userid", 37)
// .Set("postid", pageRevision.Page.Id)
// .Set("description", pageRevision.Contents.First().Content)
// .Set("title", pageRevision.Title)
// .Set("link", url)
// .Set("permaLink", url);
throw new NotImplementedException();
}
private bool MetaWeblogEditPost(
int postId,
string user,
string password,
XRpcStruct content,
bool publish) {
//var pageRevision = _pageManager.AcquireDraft(postId);
//var title = content.Optional<string>("title");
//var description = content.Optional<string>("description");
//pageRevision.Title = title;
//pageRevision.Contents.First().Content = description;
//if (publish) {
// if (string.IsNullOrEmpty(pageRevision.Slug))
// pageRevision.Slug = "slug" + postId;
// _pageManager.Publish(pageRevision, new PublishOptions());
//}
//return true;
throw new NotImplementedException();
}
}
}

View File

@@ -1,74 +1,63 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPost>>" %>
<%@ Import Namespace="Orchard.Themes"%>
<%@ Import Namespace="Orchard.Extensions"%>
<%@ Import Namespace="Orchard.ContentManagement"%>
<%@ Import Namespace="Orchard.Core.Common.Models"%>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<div class="summary">
<div class="properties">
<h3><%=Html.Link(Html.Encode(Model.Item.Title), Url.BlogPostEdit(Model.Item.Blog.Slug, Model.Item.Id))%></h3>
<div class="properties">
<h3><%=Html.Link(Html.Encode(Model.Item.Title), Url.BlogPostEdit(Model.Item.Blog.Slug, Model.Item.Id))%></h3>
<ul>
<li>
<%if (Model.IsPublished)
{ %>
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Blogs/Content/Admin/images/online.gif") %>" alt="<%=_Encoded("Online") %>" title="<%=_Encoded("The page is currently online") %>" /><%=_Encoded(" Published")%>
<% }
else
{ %>
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Blogs/Content/Admin/images/offline.gif") %>" alt="<%=_Encoded("Offline") %>" title="<%=_Encoded("The page is currently offline") %>" /><%=_Encoded(" Not Published")%>
<% } %>
&nbsp;&#124;&nbsp;
<li><%
if (Model.Item.HasPublished) { %>
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Blogs/Content/Admin/images/online.gif") %>" alt="<%=_Encoded("Online") %>" title="<%=_Encoded("The page is currently online") %>" /><%=_Encoded(" Published")%><%
}
else { %>
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Blogs/Content/Admin/images/offline.gif") %>" alt="<%=_Encoded("Offline") %>" title="<%=_Encoded("The page is currently offline") %>" /><%=_Encoded(" Not Published")%><%
} %>&nbsp;&#124;&nbsp;
</li>
<li>
<% if (Model.IsDraft) { %>
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Blogs/Content/Admin/images/draft.gif") %>" alt="<%=_Encoded("Draft") %>" title="<%=_Encoded("The post has a draft") %>" /><%=Html.PublishedState(Model.Item)%>
<% }
else
{ %>
<%=_Encoded("No draft")%>
<% } %>
&nbsp;&#124;&nbsp;
<li><%
if (Model.Item.HasDraft) { %>
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Blogs/Content/Admin/images/draft.gif") %>" alt="<%=_Encoded("Draft") %>" title="<%=_Encoded("The post has a draft") %>" /><%=Html.PublishedState(Model.Item)%><%
}
else { %>
<%=_Encoded("No draft")%><%
} %>&nbsp;&#124;&nbsp;
</li>
<%--This should show publised date, last modified, or scheduled.
<li>
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Blogs/Content/Admin/images/scheduled.gif") %>" alt="<%=_Encoded("Scheduled") %>" title="<%=_Encoded("The post is scheduled for publishing") %>" /><%=_Encoded("Scheduled")%>
&nbsp;&#124;&nbsp;
</li>--%>
<li>
<%=_Encoded("By {0}", Model.Item.Creator.UserName)%>
</li>
</ul>
<li><%
if (Model.Item.ScheduledPublishUtc.HasValue && Model.Item.ScheduledPublishUtc.Value > DateTime.UtcNow) { %>
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Blogs/Content/Admin/images/scheduled.gif") %>" alt="<%=_Encoded("Scheduled") %>" title="<%=_Encoded("The post is scheduled for publishing") %>" /><%=_Encoded("Scheduled")%>
<%=Html.DateTime(Model.Item.ScheduledPublishUtc.Value, "M/d/yyyy h:mm tt")%><%
}
else if (Model.Item.IsPublished) { %>
<%=_Encoded("Published: ") + Html.PublishedWhen(Model.Item) %><%
}
else { %>
<%=_Encoded("Last modified: {todo}") %><%
} %>&nbsp;&#124;&nbsp;
</li>
<li><%=_Encoded("By {0}", Model.Item.Creator.UserName)%></li>
</ul>
</div>
<div class="related">
<%if (Model.IsPublished){ %>
<a href="<%=Url.BlogPost(Model.Item.Blog.Slug, Model.Item.Slug) %>" title="<%=_Encoded("View Post")%>"><%=_Encoded("View")%></a><%=_Encoded(" | ")%>
<% } %>
<a href="<%=Url.BlogPostEdit(Model.Item.Blog.Slug, Model.Item.Id) %>" title="<%=_Encoded("Edit Post")%>"><%=_Encoded("Edit")%></a><%=_Encoded(" | ")%>
<%if (Model.Item.ContentItem.VersionRecord.Published == false) { // todo: (heskew) be smart about this and maybe have other contextual actions - including view/preview for view up there ^^
using (Html.BeginFormAntiForgeryPost(Url.BlogPostPublish(Model.Item.Blog.Slug, Model.Item.Id), FormMethod.Post, new { @class = "inline" })) { %>
<div class="related"><%
if (Model.Item.HasPublished){ %>
<a href="<%=Url.BlogPost(Model.Item.Blog.Slug, Model.Item.Slug) %>" title="<%=_Encoded("View Post")%>"><%=_Encoded("View")%></a><%=_Encoded(" | ")%><%
if (Model.Item.HasDraft) { %>
<a href="#" title="<%=_Encoded("Publish Draft")%>"><%=_Encoded("Publish Draft")%></a><%=_Encoded(" | ")%><%
} %>
<a href="#" title="<%=_Encoded("Unpublish Post")%>"><%=_Encoded("Unpublish")%></a><%=_Encoded(" | ")%><%
}
else { %>
<a href="#" title="<%=_Encoded("Publish Post")%>"><%=_Encoded("Publish")%></a><%=_Encoded(" | ")%><%
} %>
<a href="<%=Url.BlogPostEdit(Model.Item.Blog.Slug, Model.Item.Id) %>" title="<%=_Encoded("Edit Post")%>"><%=_Encoded("Edit")%></a><%=_Encoded(" | ")%><%--
if (Model.Item.ContentItem.VersionRecord.Published == false) { // todo: (heskew) be smart about this and maybe have other contextual actions - including view/preview for view up there ^^
using (Html.BeginFormAntiForgeryPost(Url.BlogPostPublish(Model.Item.Blog.Slug, Model.Item.Id), FormMethod.Post, new { @class = "inline" })) { %>
<button type="submit" class="linkButton" title="<%=_Encoded("Publish") %>"><%=_Encoded("Publish")%></button><%=_Encoded(" | ")%><%
}
} %>
<% using (Html.BeginFormAntiForgeryPost(Url.BlogPostDelete(Model.Item.Blog.Slug, Model.Item.Id), FormMethod.Post, new { @class = "inline" })) { %>
<button type="submit" class="linkButton" title="<%=_Encoded("Delete") %>"><%=_Encoded("Delete") %></button>
<%
} %>
}
}--%><%
using (Html.BeginFormAntiForgeryPost(Url.BlogPostDelete(Model.Item.Blog.Slug, Model.Item.Id), FormMethod.Post, new { @class = "inline" })) { %>
<button type="submit" class="linkButton" title="<%=_Encoded("Delete") %>"><%=_Encoded("Delete") %></button><%
} %>
<br /><%Html.Zone("meta");%>
</div>
<div style="clear:both;"></div>
</div>

View File

@@ -10,10 +10,11 @@
<div class="secondary">
<% Html.Zone("secondary");%>
<fieldset>
<input class="button primaryAction" type="submit" name="submit.Save" value="<%=_Encoded("Save") %>"/>
<% if (Model.IsDraft) { %>
<%=Html.ActionLink(T("Discard Draft").ToString(), "DiscardDraft", new { Area = "Orchard.Blogs", Controller = "BlogPostAdmin", id=Model.Item.Id }, new { @class = "button" })%>
<% } %>
<input class="button primaryAction" type="submit" name="submit.Save" value="<%=_Encoded("Save") %>"/><%
//TODO: (erikpo) In the future, remove the HasPublished check so the user can delete the content item from here if the choose to
if (Model.Item.HasDraft && Model.Item.HasPublished) { %>
<%=Html.ActionLink(T("Discard Draft").ToString(), "DiscardDraft", new { Area = "Orchard.Blogs", Controller = "BlogPostAdmin", id=Model.Item.Id }, new { @class = "button" })%><%
} %>
</fieldset>
</div>
</div>

View File

@@ -13,19 +13,19 @@ using Orchard.UI.Notify;
namespace Orchard.Pages.Controllers {
public class PageDriver : ContentItemDriver<Page> {
public IOrchardServices Services { get; set; }
private readonly IPageService _pageService;
private readonly IRoutableService _routableService;
private readonly IOrchardServices _orchardServices;
public readonly static ContentType ContentType = new ContentType {
Name = "page",
DisplayName = "Page"
};
public PageDriver(IPageService pageService, IRoutableService routableService, IOrchardServices orchardServices) {
public PageDriver(IOrchardServices services, IPageService pageService, IRoutableService routableService) {
Services = services;
_pageService = pageService;
_routableService = routableService;
_orchardServices = orchardServices;
T = NullLocalizer.Instance;
}
@@ -62,7 +62,7 @@ namespace Orchard.Pages.Controllers {
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"),
Services.Authorizer.Authorize(Permissions.EditOthersPages) ? ContentPartTemplate(page, "Parts/Pages.Page.Manage").Location("primary:manage") : null,
ContentPartTemplate(page, "Parts/Pages.Page.Metadata").Location("primary:metadata"));
}
@@ -108,7 +108,7 @@ namespace Orchard.Pages.Controllers {
if (slugsLikeThis.Count() > 0) {
//todo: (heskew) need better messages
_orchardServices.Notifier.Warning(T("A different page is already published with this same slug."));
Services.Notifier.Warning(T("A different page is already published with this same slug."));
if (page.ContentItem.VersionRecord == null || page.ContentItem.VersionRecord.Published) {
var originalSlug = page.Slug;
@@ -117,7 +117,7 @@ namespace Orchard.Pages.Controllers {
//todo: (heskew) need better messages
if (originalSlug != page.Slug)
_orchardServices.Notifier.Warning(T("Slugs in conflict. \"{0}\" is already set for a previously published page so this page now has the slug \"{1}\"",
Services.Notifier.Warning(T("Slugs in conflict. \"{0}\" is already set for a previously published page so this page now has the slug \"{1}\"",
originalSlug, page.Slug));
}
}

View File

@@ -10,10 +10,11 @@
<div class="secondary">
<% Html.Zone("secondary");%>
<fieldset>
<input class="button primaryAction" type="submit" name="submit.Save" value="<%=_Encoded("Save") %>"/>
<% if (Model.IsDraft) { %>
<%=Html.ActionLink(T("Discard Draft").ToString(), "DiscardDraft", new { Area = "Orchard.Pages", Controller = "Admin", Model.Item.Id }, new { @class = "button" })%>
<% } %>
<input class="button primaryAction" type="submit" name="submit.Save" value="<%=_Encoded("Save") %>"/><%
//TODO: (erikpo) In the future, remove the HasPublished check so the user can delete the content item from here if the choose to
if (Model.Item.HasDraft && Model.Item.HasPublished) { %>
<%=Html.ActionLink(T("Discard Draft").ToString(), "DiscardDraft", new { Area = "Orchard.Pages", Controller = "Admin", Model.Item.Id }, new { @class = "button" })%><%
} %>
</fieldset>
</div>
</div>

View File

@@ -1,12 +1,15 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPost>>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<h1><%=Html.TitleForPage(Model.Item.Title)%></h1>
<div class="metadata">
<%-- Sorry, Jon. I need to figure out how we can make this markup possible with the recent metadata/manage split.
We can still do it this way but there's isn't yet a story for UI conditional on permissions.
What I have in this template is as close as I can get at the moment. --%>
<%--<div class="metadata">
<% if (Model.Item.Creator != null) {
%><div class="posted"><%=_Encoded("Posted by {0} {1}", Model.Item.Creator.UserName, Html.PublishedWhen(Model.Item)) %> | <a href="<%=Url.BlogPostEdit(Model.Item.Blog.Slug, Model.Item.Id) %>" class="ibutton edit"><%=_Encoded("Edit") %></a></div><%
%><div class="posted"><%=_Encoded("Posted by {0} {1}", Model.Item.Creator.UserName, Html.PublishedWhen(Model.Item)) %><% -- | <a href="<%=Url.BlogPostEdit(Model.Item.Blog.Slug, Model.Item.Id) %>" class="ibutton edit"><%=_Encoded("Edit") %></a>-- %></div><%
} %>
</div>
<% Html.Zone("primary");
--%>
<% Html.Zone("primary", ":metadata :manage"); // <- flipping metadata and manage to get closer to the desired markup
Html.ZonesAny(); %>

View File

@@ -0,0 +1,6 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<Orchard.Pages.Models.Page>>" %>
<%@ Import Namespace="Orchard.Mvc.Html"%>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<h1><%=Html.TitleForPage(Model.Item.Title)%></h1>
<% Html.Zone("primary");
Html.ZonesAny(); %>

View File

@@ -274,9 +274,9 @@ a:hover, a:active, a:focus {
#main h2, #main h3 {
margin:.5em 0;
}
/*#main p {
#main p {
margin:0 0 1.5em;
}*/
}
#main .main.actions {
margin:0 0 1.4em;
}
@@ -754,6 +754,9 @@ table.items, textarea, input.text, input.text-box,
.properties {
float:left;
}
.orchard-blogs #main p {
margin:0;
}
#main .contentItems .properties h3 {
border-bottom:none;
margin:0;

View File

@@ -116,9 +116,18 @@ namespace Orchard.Mvc.Html {
return value.HasValue ? htmlHelper.DateTime(value.Value) : defaultIfNull;
}
//TODO: (erikpo) This format should come from a site setting
public static string DateTime(this HtmlHelper htmlHelper, DateTime? value, string defaultIfNull, string customFormat) {
return value.HasValue ? htmlHelper.DateTime(value.Value, customFormat) : defaultIfNull;
}
public static string DateTime(this HtmlHelper htmlHelper, DateTime value) {
return value.ToString("MMM d yyyy h:mm tt");
//TODO: (erikpo) This default format should come from a site setting
return htmlHelper.DateTime(value, "MMM d yyyy h:mm tt");
}
public static string DateTime(this HtmlHelper htmlHelper, DateTime value, string customFormat) {
//TODO: (erikpo) In the future, convert this to "local" time before calling ToString
return value.ToString(customFormat);
}
#endregion

View File

@@ -36,16 +36,6 @@ namespace Orchard.Mvc.ViewModels {
public string TemplateName { get; set; }
public string Prefix { get; set; }
public ZoneCollection Zones { get; private set; }
public bool IsPublished {
get { return Item != null && Item.VersionRecord != null && Item.VersionRecord.Published; }
}
public bool IsLatest {
get { return Item != null && Item.VersionRecord != null && Item.VersionRecord.Latest; }
}
public bool IsDraft {
get { return IsLatest && !IsPublished; }
}
}
public class ContentItemViewModel<TPart> : ContentItemViewModel where TPart : IContent {

View File

@@ -1,13 +1,12 @@
using System;
using JetBrains.Annotations;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.Localization;
using Orchard.Security.Permissions;
using Orchard.UI.Notify;
namespace Orchard.Security {
public interface IAuthorizer : IDependency {
bool Authorize(Permission permission);
bool Authorize(Permission permission, LocalizedString message);
bool Authorize(Permission permission, IContent content, LocalizedString message);
}
@@ -27,6 +26,10 @@ namespace Orchard.Security {
protected virtual IUser CurrentUser { get; [UsedImplicitly] private set; }
public Localizer T { get; set; }
public bool Authorize(Permission permission) {
return Authorize(permission, null, null);
}
public bool Authorize(Permission permission, LocalizedString message) {
return Authorize(permission, null, message);
}
@@ -35,14 +38,17 @@ namespace Orchard.Security {
if (_authorizationService.TryCheckAccess(permission, CurrentUser, content))
return true;
if (CurrentUser == null) {
_notifier.Error(T("{0}. Anonymous users do not have {1} permission.",
message, permission.Name));
}
else {
_notifier.Error(T("{0}. Current user, {2}, does not have {1} permission.",
message, permission.Name, CurrentUser.UserName));
if (message != null) {
if (CurrentUser == null) {
_notifier.Error(T("{0}. Anonymous users do not have {1} permission.",
message, permission.Name));
}
else {
_notifier.Error(T("{0}. Current user, {2}, does not have {1} permission.",
message, permission.Name, CurrentUser.UserName));
}
}
return false;
}