--HG--
branch : dev
This commit is contained in:
Andre Rodrigues
2010-10-14 12:57:23 -07:00
75 changed files with 306 additions and 355 deletions

View File

@@ -34,6 +34,7 @@ namespace Orchard.Core.Tests.Body {
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
builder.RegisterInstance(new Mock<IAuthorizer>().Object);
builder.RegisterInstance(new Mock<INotifier>().Object);
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();

View File

@@ -49,7 +49,7 @@ namespace Orchard.Core.Tests.Common.Providers {
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
builder.RegisterType<ShapeHelperFactory>().As<IShapeHelperFactory>();
builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();
builder.RegisterType<DefaultContentDisplay>().As<IContentDisplay>();
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
_authn = new Mock<IAuthenticationService>();
_authz = new Mock<IAuthorizationService>();

View File

@@ -17,7 +17,6 @@ using Orchard.Core.Feeds.Models;
using Orchard.Core.Feeds.Rss;
using Orchard.Core.Feeds.StandardBuilders;
using Orchard.Core.Routable.Models;
using Orchard.Mvc.Results;
using Orchard.Tests.Modules;
using Orchard.Tests.Stubs;
@@ -36,7 +35,7 @@ namespace Orchard.Core.Tests.Feeds.Controllers {
var result = controller.Index("no-such-format");
Assert.That(result, Is.Not.Null);
Assert.That(result, Is.TypeOf<NotFoundResult>());
Assert.That(result, Is.TypeOf<HttpNotFoundResult>());
}
[Test]

View File

@@ -44,6 +44,7 @@ namespace Orchard.Core.Tests.Routable.Services {
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
builder.RegisterInstance(new Mock<IAuthorizer>().Object);
builder.RegisterInstance(new Mock<INotifier>().Object);
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
builder.RegisterType<ThingHandler>().As<IContentHandler>();

View File

@@ -39,6 +39,7 @@ namespace Orchard.Core.Tests.Scheduling {
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
builder.RegisterType<ShapeHelperFactory>().As<IShapeHelperFactory>();
builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
builder.RegisterType<ScheduledTaskExecutor>().As<IBackgroundTask>().Named("ScheduledTaskExecutor", typeof(IBackgroundTask));
builder.RegisterInstance(_handler).As<IScheduledTaskHandler>();

View File

@@ -43,6 +43,7 @@ namespace Orchard.Core.Tests.Scheduling {
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
builder.RegisterType<ShapeHelperFactory>().As<IShapeHelperFactory>();
builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
builder.RegisterType<ScheduledTaskManager>().As<IScheduledTaskManager>();

View File

@@ -52,6 +52,7 @@ namespace Orchard.Tests.ContentManagement {
builder.RegisterType<DefaultContentManager>().As<IContentManager>().SingleInstance();
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
builder.RegisterType<AlphaHandler>().As<IContentHandler>();
builder.RegisterType<BetaHandler>().As<IContentHandler>();

View File

@@ -62,6 +62,7 @@ namespace Orchard.Tests.ContentManagement {
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterInstance(_contentDefinitionManager.Object);
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
builder.RegisterType<AlphaHandler>().As<IContentHandler>();
builder.RegisterType<BetaHandler>().As<IContentHandler>();

View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq;
using NUnit.Framework;
using Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy;

View File

@@ -12,6 +12,6 @@
</Match>
<Match DisplayType="SummaryAdmin">
<Place Parts_Common_Body_Summary="-"
Parts_PublishLater_Metadata_SummaryAdmin="Metadata:1"/>
Parts_Common_Metadata_SummaryAdmin="Meta:5"/>
</Match>
</Placement>

View File

@@ -6,4 +6,4 @@
string bodyHtml = Model.Html.ToString();
var body = new HtmlString(Html.Excerpt(bodyHtml, 200).ToString().Replace(Environment.NewLine, "</p>" + Environment.NewLine + "<p>"));
}
<p>@body @Html.ItemDisplayLink(T("[more]").ToString(), contentItem)</p>
<p>@body @Html.ItemDisplayLink(T("[more]").ToString(), contentItem)</p>

View File

@@ -15,7 +15,6 @@ using Orchard.Data;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Mvc.Results;
using Orchard.UI.Notify;
namespace Orchard.Core.Contents.Controllers {
@@ -47,7 +46,7 @@ namespace Orchard.Core.Contents.Controllers {
public ActionResult List(ListContentsViewModel model) {
if (model.ContainerId != null && _contentManager.GetLatest((int)model.ContainerId) == null)
return new NotFoundResult();
return HttpNotFound();
const int pageSize = 20;
var skip = (Math.Max(model.Page ?? 0, 1) - 1) * pageSize;
@@ -57,7 +56,7 @@ namespace Orchard.Core.Contents.Controllers {
if (!string.IsNullOrEmpty(model.TypeName)) {
var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(model.TypeName);
if (contentTypeDefinition == null)
return new NotFoundResult();
return HttpNotFound();
model.TypeDisplayName = !string.IsNullOrWhiteSpace(contentTypeDefinition.DisplayName)
? contentTypeDefinition.DisplayName
@@ -249,7 +248,7 @@ namespace Orchard.Core.Contents.Controllers {
var contentItem = _contentManager.Get(id, VersionOptions.Latest);
if (contentItem == null)
return new NotFoundResult();
return HttpNotFound();
if (!Services.Authorizer.Authorize(Permissions.EditContent, contentItem, T("Cannot edit content")))
return new HttpUnauthorizedResult();
@@ -264,7 +263,7 @@ namespace Orchard.Core.Contents.Controllers {
var contentItem = _contentManager.Get(id, VersionOptions.DraftRequired);
if (contentItem == null)
return new NotFoundResult();
return HttpNotFound();
if (!Services.Authorizer.Authorize(Permissions.EditContent, contentItem, T("Couldn't edit content")))
return new HttpUnauthorizedResult();
@@ -313,7 +312,7 @@ namespace Orchard.Core.Contents.Controllers {
public ActionResult Publish(int id, string returnUrl) {
var contentItem = _contentManager.GetLatest(id);
if (contentItem == null)
return new NotFoundResult();
return HttpNotFound();
if (!Services.Authorizer.Authorize(Permissions.PublishContent, contentItem, T("Couldn't publish content")))
return new HttpUnauthorizedResult();
@@ -332,7 +331,7 @@ namespace Orchard.Core.Contents.Controllers {
public ActionResult Unpublish(int id, string returnUrl) {
var contentItem = _contentManager.GetLatest(id);
if (contentItem == null)
return new NotFoundResult();
return HttpNotFound();
if (!Services.Authorizer.Authorize(Permissions.PublishContent, contentItem, T("Couldn't unpublish content")))
return new HttpUnauthorizedResult();

View File

@@ -10,7 +10,7 @@ namespace Orchard.Core.Contents.Drivers {
ContentShape("Parts_Contents_Publish_Summary",
() => shapeHelper.Parts_Contents_Publish_Summary(ContentPart: part)),
ContentShape("Parts_Contents_Publish_SummaryAdmin",
() => shapeHelper.Parts_Contents_Publish_SummaryAdmin(ContentPart: part))
() => shapeHelper.Parts_Contents_Publish_SummaryAdmin(ContentPart: part))
);
}
}

View File

@@ -3,9 +3,9 @@
<Place Parts_Contents_Publish_Summary="-"/>
<Place Parts_Contents_Publish_SummaryAdmin="-"/>
<Match DisplayType="Detail">
<Place Parts_Contents_Publish="Primary:5"/>
<Place Parts_Contents_Publish="Content:5"/>
</Match>
<Match DisplayType="SummaryAdmin">
<Place Parts_Contents_Publish_SummaryAdmin="Secondary:5"/>
<Place Parts_Contents_Publish_SummaryAdmin="Related:5"/>
</Match>
</Placement>

View File

@@ -8,9 +8,14 @@ namespace Orchard.Core.Contents {
.OnDisplaying(displaying => {
ContentItem contentItem = displaying.Shape.ContentItem;
if (contentItem != null) {
//Content-BlogPost
displaying.ShapeMetadata.Alternates.Add("Items_Content__" + contentItem.ContentType);
//Content-42
displaying.ShapeMetadata.Alternates.Add("Items_Content__" + contentItem.Id);
//Content.Summary
displaying.ShapeMetadata.Alternates.Add("Items_Content_" + displaying.ShapeMetadata.DisplayType);
//Content.Summary-Page
displaying.ShapeMetadata.Alternates.Add("Items_Content_" + displaying.ShapeMetadata.DisplayType + "__" + contentItem.ContentType);
}
});
@@ -18,6 +23,7 @@ namespace Orchard.Core.Contents {
.OnDisplaying(displaying => {
ContentItem contentItem = displaying.Shape.ContentItem;
if (contentItem != null) {
//Content.Editor-Page
displaying.ShapeMetadata.Alternates.Add("Items_Content_Editor__" + contentItem.ContentType);
}
});

View File

@@ -3,8 +3,6 @@ using System.Linq;
using System.Web.Mvc;
using Orchard.Core.Feeds.Models;
using Orchard.Logging;
using Orchard.Mvc.Results;
using Orchard.Themes;
namespace Orchard.Core.Feeds.Controllers {
public class FeedController : Controller {
@@ -34,7 +32,7 @@ namespace Orchard.Core.Feeds.Controllers {
.FirstOrDefault();
if (bestFormatterMatch == null || bestFormatterMatch.FeedBuilder == null)
return new NotFoundResult();
return HttpNotFound();
context.Builder = bestFormatterMatch.FeedBuilder;
@@ -45,7 +43,7 @@ namespace Orchard.Core.Feeds.Controllers {
.FirstOrDefault();
if (bestQueryMatch == null || bestQueryMatch.FeedQuery == null)
return new NotFoundResult();
return HttpNotFound();
return context.Builder.Process(context, () => {
bestQueryMatch.FeedQuery.Execute(context);

View File

@@ -10,7 +10,6 @@ using Orchard.Core.Routable.Models;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.Localization.Services;
using Orchard.Mvc.Results;
using Orchard.UI.Notify;
namespace Orchard.Core.Localization.Controllers {
@@ -43,7 +42,7 @@ namespace Orchard.Core.Localization.Controllers {
// only support translations from the site culture, at the moment at least
if (contentItem == null)
return new NotFoundResult();
return HttpNotFound();
if (!contentItem.Is<LocalizationPart>() || contentItem.As<LocalizationPart>().MasterContentItem != null) {
var metadata = _contentManager.GetItemMetadata(contentItem);
@@ -79,7 +78,7 @@ namespace Orchard.Core.Localization.Controllers {
var contentItem = _contentManager.Get(id, VersionOptions.Latest);
if (contentItem == null)
return new NotFoundResult();
return HttpNotFound();
var model = new AddLocalizationViewModel();
TryUpdateModel(model);

View File

@@ -22,13 +22,14 @@ namespace Orchard.Core.Localization.Drivers {
}
protected override DriverResult Display(LocalizationPart part, string displayType, dynamic shapeHelper) {
var masterId = part.MasterContentItem != null
? part.MasterContentItem.Id
: part.Id;
return Combined(
ContentShape("Parts_Localization_ContentTranslations",
() => shapeHelper.Parts_Localization_ContentTranslations(ContentPart: part, Localizations: GetDisplayLocalizations(part))),
() => shapeHelper.Parts_Localization_ContentTranslations(ContentPart: part, MasterId: masterId, Localizations: GetDisplayLocalizations(part))),
ContentShape("Parts_Localization_ContentTranslations_Summary",
() => shapeHelper.Parts_Localization_ContentTranslations_Summary(ContentPart: part, Localizations: GetDisplayLocalizations(part))),
ContentShape("Parts_Localization_ContentTranslations_SummaryAdmin",
() => shapeHelper.Parts_Localization_ContentTranslations_SummaryAdmin(ContentPart: part, Localizations: GetDisplayLocalizations(part)))
() => shapeHelper.Parts_Localization_ContentTranslations_Summary(ContentPart: part, MasterId: masterId, Localizations: GetDisplayLocalizations(part)))
);
}

View File

@@ -1,14 +1,13 @@
<Placement>
<Place Parts_Localization_ContentTranslations="-"/>
<Place Parts_Localization_ContentTranslations_Summary="-"/>
<Place Parts_Localization_ContentTranslations_SummaryAdmin="-"/>
<Match DisplayType="Detail">
<Place Parts_Localization_ContentTranslations="Primary:5"/>
<Place Parts_Localization_ContentTranslations="Content:before.5"/>
</Match>
<Match DisplayType="Summary">
<Place Parts_Localization_ContentTranslations_Summary="Primary:5"/>
<Place Parts_Localization_ContentTranslations_Summary="Content:after.5"/>
</Match>
<Match DisplayType="SummaryAdmin">
<Place Parts_Localization_ContentTranslations_SummaryAdmin="Primary:5"/>
<Place Parts_Localization_ContentTranslations_Summary="Content:after.5"/>
</Match>
</Placement>

View File

@@ -1 +1,17 @@
@model Orchard.Core.Localization.ViewModels.ContentLocalizationsViewModel
@using Orchard.Core.Contents;
@using Orchard.Core.Localization.Models;
@{
Style.Require("LocalizationAdmin");
IEnumerable<LocalizationPart> localizations = Model.Localizations;
var localizationLinks = Html.UnorderedList(localizations, (c, i) => Html.ItemEditLink(c.Culture.Culture, c), "localizations");
}
@if (localizations.Count() > 0 || AuthorizedFor(Permissions.PublishContent)) {
<div class="content-localization">
@if (localizations.Count() > 0) {
<div class="content-localizations"><h4>@T("Translations:")</h4>@localizationLinks</div>
}
@if (AuthorizedFor(Permissions.PublishContent)) {
<div class="add-localization">@Html.ActionLink(T("+ New translation").Text, "Translate", "Admin", new { area = "Localization", id = Model.MasterId }, null)</div>
}
</div>
}

View File

@@ -1,12 +0,0 @@
@using Orchard.Core.Localization.Models;
@{
Style.Require("LocalizationAdmin");
IEnumerable<LocalizationPart> localizations = Model.Localizations;
var localizationLinks = Html.UnorderedList(localizations, (c, i) => Html.ItemEditLink(c.Culture.Culture, c), "localizations");
}
<div class="content-localization">
@if (localizations.Count() > 0) {
<div class="content-localizations"><h4>@T("Translations:")</h4>@localizationLinks</div>
}
<div class="add-localization">@Html.ActionLink(T("+ New translation").Text, "translate", "admin", new { area = "Localization", id = Model.MasterId }, null)</div>
</div>

View File

@@ -297,7 +297,6 @@
<Content Include="Reports\Views\Admin\Index.cshtml" />
<Content Include="Localization\Module.txt" />
<Content Include="Localization\Views\Admin\Translate.cshtml" />
<Content Include="Localization\Views\Parts\Localization.ContentTranslations.SummaryAdmin.cshtml" />
<Content Include="Localization\Views\CultureSelection.cshtml" />
<Content Include="Routable\Module.txt" />
<Content Include="Routable\Scripts\jquery.slugify.js" />

View File

@@ -1 +1,10 @@
@model Orchard.Core.PublishLater.ViewModels.PublishLaterViewModel
@using Orchard.ContentManagement;
@using Orchard.Core.Common.Models;
@using Orchard.Core.PublishLater.Models;
@{
PublishLaterPart publishLaterPart = Model.ContentPart;
DateTime? versionPublishedUtc = publishLaterPart.As<CommonPart>() == null ? null : publishLaterPart.As<CommonPart>().VersionPublishedUtc;
}
@if (publishLaterPart.IsPublished() && versionPublishedUtc.HasValue) {
@T("Published: {0}", Html.DateTimeRelative(versionPublishedUtc.Value, T))
}

View File

@@ -3,7 +3,6 @@ using JetBrains.Annotations;
using Orchard.Core.Routable.Models;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.Mvc.Results;
using Orchard.Services;
using Orchard.ContentManagement;
@@ -35,7 +34,7 @@ namespace Orchard.Core.Routable.Services {
public ActionResult GetHomePage(int itemId) {
var contentItem = _contentManager.Get(itemId, VersionOptions.Published);
if (contentItem == null || !contentItem.Is<RoutePart>())
return new NotFoundResult();
return new HttpNotFoundResult();
var model = _contentManager.BuildDisplay(contentItem);

View File

@@ -9,7 +9,6 @@ using Orchard.ContentManagement.Aspects;
using Orchard.Data;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.Mvc.Results;
using Orchard.UI.Admin;
using Orchard.UI.Notify;
@@ -50,7 +49,7 @@ namespace Orchard.Blogs.Controllers {
var blog = Services.ContentManager.New<BlogPart>("Blog");
if (blog == null)
return new NotFoundResult();
return HttpNotFound();
var model = Services.ContentManager.BuildEditor(blog);
return View(model);
@@ -58,11 +57,12 @@ namespace Orchard.Blogs.Controllers {
[HttpPost, ActionName("Create")]
public ActionResult CreatePOST() {
var blog = Services.ContentManager.New<BlogPart>("Blog");
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't create blog")))
return new HttpUnauthorizedResult();
var blog = Services.ContentManager.New<BlogPart>("Blog");
_contentManager.Create(blog, VersionOptions.Draft);
var model = _contentManager.UpdateEditor(blog, this);
@@ -83,10 +83,9 @@ namespace Orchard.Blogs.Controllers {
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to edit blog")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
var blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
return HttpNotFound();
var model = Services.ContentManager.BuildEditor(blog);
return View(model);
@@ -94,13 +93,13 @@ namespace Orchard.Blogs.Controllers {
[HttpPost, ActionName("Edit")]
public ActionResult EditPOST(string blogSlug) {
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't edit blog")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
var blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
return HttpNotFound();
var model = Services.ContentManager.UpdateEditor(blog, this);
if (!ModelState.IsValid)
@@ -113,14 +112,14 @@ namespace Orchard.Blogs.Controllers {
[HttpPost]
public ActionResult Remove(string blogSlug) {
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't delete blog")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
BlogPart blogPart = _blogService.Get(blogSlug);
if (blogPart == null)
return new NotFoundResult();
return HttpNotFound();
_blogService.Delete(blogPart);
@@ -132,7 +131,7 @@ namespace Orchard.Blogs.Controllers {
var list = Shape.List();
list.AddRange(_blogService.Get()
.Select(b => {
var blog = Services.ContentManager.BuildDisplay(b, "SummaryAdmin.Blog");
var blog = Services.ContentManager.BuildDisplay(b, "SummaryAdmin");
blog.TotalPostCount = _blogPostService.Get(b, VersionOptions.Latest).Count();
return blog;
}));
@@ -143,15 +142,13 @@ namespace Orchard.Blogs.Controllers {
return View(viewModel);
}
//TODO: (erikpo) Should move the slug parameter and get call and null check up into a model binder
public ActionResult Item(string blogSlug) {
BlogPart blogPart = _blogService.Get(blogSlug);
if (blogPart == null)
return new NotFoundResult();
return HttpNotFound();
//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 = Services.ContentManager.BuildDisplay(blogPart, "Blog_Admin");
var model = Services.ContentManager.BuildDisplay(blogPart, "DetailAdmin");
return View(model);
}

View File

@@ -1,4 +1,3 @@
using System;
using System.Linq;
using System.Web;
using System.Web.Mvc;
@@ -10,7 +9,6 @@ using Orchard.Blogs.Services;
using Orchard.Blogs.ViewModels;
using Orchard.DisplayManagement;
using Orchard.Logging;
using Orchard.Mvc.Results;
using Orchard.Themes;
namespace Orchard.Blogs.Controllers {
@@ -36,7 +34,7 @@ namespace Orchard.Blogs.Controllers {
protected ILogger Logger { get; set; }
public ActionResult List() {
var blogs = _blogService.Get().Select(b => _services.ContentManager.BuildDisplay(b, "Summary.Blog"));
var blogs = _blogService.Get().Select(b => _services.ContentManager.BuildDisplay(b, "Summary"));
var list = Shape.List();
list.AddRange(blogs);
@@ -53,13 +51,13 @@ namespace Orchard.Blogs.Controllers {
var correctedSlug = _blogSlugConstraint.FindSlug(blogSlug);
if (correctedSlug == null)
return new NotFoundResult();
return HttpNotFound();
BlogPart blog = _blogService.Get(correctedSlug);
if (blog == null)
return new NotFoundResult();
return HttpNotFound();
var blogPosts = _blogPostService.Get(blog, (page - 1)*pageSize, pageSize).Select(b => _services.ContentManager.BuildDisplay(b, "Summary.BlogPost"));
var blogPosts = _blogPostService.Get(blog, (page - 1)*pageSize, pageSize).Select(b => _services.ContentManager.BuildDisplay(b, "Summary"));
var list = Shape.List();
list.AddRange(blogPosts);
@@ -81,7 +79,7 @@ namespace Orchard.Blogs.Controllers {
BlogPart blogPart = _blogService.Get(blogSlug);
if (blogPart == null)
return new NotFoundResult();
return HttpNotFound();
const string manifestUri = "http://schemas.microsoft.com/wlw/manifest/weblog";
@@ -106,7 +104,7 @@ namespace Orchard.Blogs.Controllers {
BlogPart blogPart = _blogService.Get(blogSlug);
if (blogPart == null)
return new NotFoundResult();
return HttpNotFound();
const string manifestUri = "http://archipelago.phrasewise.com/rsd";

View File

@@ -6,7 +6,6 @@ using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.Localization;
using Orchard.Mvc.AntiForgery;
using Orchard.Mvc.Results;
using Orchard.UI.Admin;
using Orchard.UI.Notify;
@@ -32,7 +31,7 @@ namespace Orchard.Blogs.Controllers {
var blogPost = Services.ContentManager.New<BlogPostPart>("BlogPost");
if (blogPost.BlogPart == null)
return new NotFoundResult();
return HttpNotFound();
var model = Services.ContentManager.BuildEditor(blogPost);
@@ -46,7 +45,7 @@ namespace Orchard.Blogs.Controllers {
var blogPost = Services.ContentManager.New<BlogPostPart>("BlogPost");
if (blogPost.BlogPart == null)
return new NotFoundResult();
return HttpNotFound();
Services.ContentManager.Create(blogPost, VersionOptions.Draft);
var model = Services.ContentManager.UpdateEditor(blogPost, this);
@@ -71,11 +70,11 @@ namespace Orchard.Blogs.Controllers {
var blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
return HttpNotFound();
var post = _blogPostService.Get(postId, VersionOptions.Latest);
if (post == null)
return new NotFoundResult();
return HttpNotFound();
var model = Services.ContentManager.BuildEditor(post);
@@ -89,12 +88,12 @@ namespace Orchard.Blogs.Controllers {
var blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
return HttpNotFound();
// Get draft (create a new version if needed)
var blogPost = _blogPostService.Get(postId, VersionOptions.DraftRequired);
if (blogPost == null)
return new NotFoundResult();
return HttpNotFound();
// Validate form input
var model = Services.ContentManager.UpdateEditor(blogPost, this);
@@ -142,7 +141,7 @@ namespace Orchard.Blogs.Controllers {
ActionResult RedirectToEdit(IContent item) {
if (item == null || item.As<BlogPostPart>() == null)
return new NotFoundResult();
return HttpNotFound();
return RedirectToAction("Edit", new { BlogSlug = item.As<BlogPostPart>().BlogPart.Slug, PostId = item.ContentItem.Id });
}
@@ -154,11 +153,11 @@ namespace Orchard.Blogs.Controllers {
var blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
return HttpNotFound();
var post = _blogPostService.Get(postId, VersionOptions.Latest);
if (post == null)
return new NotFoundResult();
return HttpNotFound();
_blogPostService.Delete(post);
Services.Notifier.Information(T("Blog post was successfully deleted"));
@@ -173,11 +172,11 @@ namespace Orchard.Blogs.Controllers {
var blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
return HttpNotFound();
var post = _blogPostService.Get(postId, VersionOptions.Latest);
if (post == null)
return new NotFoundResult();
return HttpNotFound();
_blogPostService.Publish(post);
Services.Notifier.Information(T("Blog post successfully published."));
@@ -192,11 +191,11 @@ namespace Orchard.Blogs.Controllers {
var blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
return HttpNotFound();
var post = _blogPostService.Get(postId, VersionOptions.Latest);
if (post == null)
return new NotFoundResult();
return HttpNotFound();
_blogPostService.Unpublish(post);
Services.Notifier.Information(T("Blog post successfully unpublished."));

View File

@@ -7,7 +7,6 @@ using Orchard.ContentManagement;
using Orchard.Core.Feeds;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.Mvc.Results;
using Orchard.Security;
using Orchard.Themes;
@@ -44,14 +43,14 @@ namespace Orchard.Blogs.Controllers {
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
var blogPart = _blogService.Get(blogSlug);
if (blogPart == null)
return new NotFoundResult();
return HttpNotFound();
//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.
var postPart = _blogPostService.Get(blogPart, postSlug, VersionOptions.Published);
if (postPart == null)
return new NotFoundResult();
return HttpNotFound();
var model = _services.ContentManager.BuildDisplay(postPart, "Detail.BlogPost");
var model = _services.ContentManager.BuildDisplay(postPart);
return View(model);
}
@@ -61,12 +60,12 @@ namespace Orchard.Blogs.Controllers {
BlogPart blogPart = _blogService.Get(blogSlug);
if (blogPart == null)
return new NotFoundResult();
return HttpNotFound();
var archive = new ArchiveData(archiveData);
var list = Shape.List();
list.AddRange(_blogPostService.Get(blogPart, archive).Select(b => _services.ContentManager.BuildDisplay(b, "Summary.BlogPost")));
list.AddRange(_blogPostService.Get(blogPart, archive).Select(b => _services.ContentManager.BuildDisplay(b, "Summary")));
_feedManager.Register(blogPart);

View File

@@ -1,12 +1,10 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using JetBrains.Annotations;
using Orchard.Blogs.Extensions;
using Orchard.Blogs.Models;
using Orchard.Blogs.Services;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.ContentsLocation.Models;
using Orchard.Core.Feeds;
using Orchard.DisplayManagement;
using Orchard.Localization;
@@ -35,40 +33,32 @@ namespace Orchard.Blogs.Drivers {
protected override string Prefix { get { return ""; } }
protected override DriverResult Display(BlogPart part, string displayType, dynamic shapeHelper) {
var driverResults = new List<DriverResult>();
var metadata = shapeHelper.Parts_Blogs_Blog_Manage(ContentPart: part);
driverResults.Add(ContentShape(metadata).Location("manage"));
var description = shapeHelper.Parts_Blogs_Blog_Description(ContentPart: part);
driverResults.Add(ContentShape(description).Location("manage", "after"));
if (displayType.StartsWith("Admin")) {
var list = shapeHelper.List();
list.AddRange(_blogPostService.Get(part, VersionOptions.Latest)
.Select(bp => _contentManager.BuildDisplay(bp, "BlogPost_SummaryAdmin")));
var blogPostList = shapeHelper.Parts_Blogs_BlogPost_List_Admin(ContentPart: part, BlogPosts: list);
var contentShape = ContentShape(blogPostList).Location("Primary");
driverResults.Add(contentShape);
}
else if (!displayType.Contains("Summary")) {
var list = shapeHelper.List();
list.AddRange(_blogPostService.Get(part)
.Select(bp => _contentManager.BuildDisplay(bp, "BlogPost_Summary")));
var blogPostList = shapeHelper.Parts_Blogs_BlogPost_List(ContentPart: part, BlogPosts: list);
var contentShape = ContentShape(blogPostList).Location("Primary");
driverResults.Add(contentShape);
_feedManager.Register(part);
}
return Combined(driverResults.ToArray());
return Combined(
ContentShape("Parts_Blogs_Blog_Manage",
() => shapeHelper.Parts_Blogs_Blog_Manage(ContentPart: part)),
ContentShape("Parts_Blogs_Blog_Description",
() => shapeHelper.Parts_Blogs_Blog_Description(ContentPart: part, Description: part.Description)),
ContentShape("Parts_Blogs_BlogPost_List",
() => {
_feedManager.Register(part);
var list = shapeHelper.List();
list.AddRange(_blogPostService.Get(part)
.Select(bp => _contentManager.BuildDisplay(bp, "Summary")));
return shapeHelper.Parts_Blogs_BlogPost_List(ContentPart: part, ContentItems: list);
}),
ContentShape("Parts_Blogs_BlogPost_List_Admin",
() => {
var list = shapeHelper.List();
list.AddRange(_blogPostService.Get(part, VersionOptions.Latest)
.Select(bp => _contentManager.BuildDisplay(bp, "SummaryAdmin")));
return shapeHelper.Parts_Blogs_BlogPost_List_Admin(ContentPart: part, ContentItems: list);
})
);
}
protected override DriverResult Editor(BlogPart blogPart, dynamic shapeHelper) {
var location = blogPart.GetLocation("Editor");
return Combined(
ContentPartTemplate(blogPart, "Parts/Blogs.Blog.Fields").Location(location));
return ContentShape("Parts_Blogs_Blog_Fields",
() => shapeHelper.EditorTemplate(TemplateName: "Parts/Blogs.Blog.Fields", Model: blogPart, Prefix: Prefix));
}
protected override DriverResult Editor(BlogPart blogPart, IUpdateModel updater, dynamic shapeHelper) {

View File

@@ -132,20 +132,15 @@
<Content Include="Views\Blog\List.cshtml" />
<Content Include="Views\Parts\Blogs.Blog.Manage.cshtml" />
<Content Include="Views\Parts\Blogs.Blog.Description.cshtml" />
<Content Include="Views\Parts\Common.Metadata.Admin.Blog.cshtml" />
<Content Include="Views\EditorTemplates\Parts\Blogs.Blog.Fields.cshtml" />
<Content Include="Views\Parts\Blogs.BlogPost.List.Admin.cshtml">
<SubType>Code</SubType>
</Content>
<Content Include="Views\Items\Content.Blog.Admin.cshtml" />
<Content Include="Views\Items\Content.Blog.cshtml" />
<Content Include="Views\Items\Content.Detail.BlogPost.cshtml" />
<Content Include="Views\Items\Content.Edit.Blog.cshtml">
<SubType>Code</SubType>
</Content>
<Content Include="Views\Items\Content.Summary.Blog.cshtml" />
<Content Include="Views\Items\Content.Summary.BlogPost.cshtml" />
<Content Include="Views\Items\Content.SummaryAdmin.Blog.cshtml" />
<Content Include="Views\Items\Blog.cshtml" />
<Content Include="Views\Items\BlogPost.cshtml" />
<Content Include="Views\Items\Blog.Summary.cshtml" />
<Content Include="Views\Items\BlogPost.Summary.cshtml" />
<Content Include="Views\Items\Blog.SummaryAdmin.cshtml" />
<Content Include="Web.config" />
<Content Include="Views\Web.config" />
</ItemGroup>
@@ -159,38 +154,18 @@
<Name>Orchard.Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="Views\Parts\Common.Metadata.Blog.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Parts\Localization.ContentTranslations.Summary.BlogPost.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Parts\Common.Body.Summary.BlogPost.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Parts\Tags.ShowTags.Summary.BlogPost.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Parts\PublishLater.Metadata.Detail.BlogPost.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Parts\Common.Metadata.Detail.BlogPost.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Parts\Localization.ContentTranslations.Detail.BlogPost.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Parts\Common.Body.Detail.BlogPost.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Parts\Tags.ShowTags.Detail.BlogPost.cshtml" />
</ItemGroup>
<ItemGroup>
<None Include="App_Data\Localization\fr-FR\orchard.module.po" />
<None Include="Placement.info">
<SubType>Designer</SubType>
</None>
<None Include="Views\DisplayTemplates\Parts\Blogs.BlogArchives.cshtml" />
<None Include="Views\EditorTemplates\Parts\Blogs.RecentBlogPosts.cshtml" />
<None Include="Views\EditorTemplates\Parts\Blogs.BlogArchives.cshtml" />
<None Include="Views\Items\Blog.DetailAdmin.cshtml" />
<None Include="Views\Items\Blog.Editor.cshtml" />
<None Include="Views\Items\BlogPost.Editor.cshtml" />
<None Include="Views\Items\BlogPost.SummaryAdmin.cshtml" />
<None Include="Views\Parts\Blogs.BlogPost.List.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

View File

@@ -0,0 +1,23 @@
<Placement>
<Place Parts_Blogs_Blog_Manage="-"/>
<Place Parts_Blogs_Blog_Description="-"/>
<Place Parts_Blogs_BlogPost_List="-"/>
<Place Parts_Blogs_BlogPost_List_Admin="-"/>
<Place Parts_Blogs_Blog_Fields="Primary:2"/>
<Match ContentType="Blog">
<Match DisplayType="Detail">
<Place Parts_Blogs_BlogPost_List="Content:5" />
</Match>
<Match DisplayType="DetailAdmin">
<Place Parts_Blogs_BlogPost_List_Admin="Content:5"
Parts_Blogs_Blog_Manage="Manage"
Parts_Blogs_Blog_Description="Manage:after"/>
</Match>
<Match DisplayType="Summary">
<Place Parts_Blogs_Blog_Description="Content:before"/>
</Match>
<Match DisplayType="SummaryAdmin">
<Place Parts_Blogs_Blog_Description="Content:before"/>
</Match>
</Match>
</Placement>

View File

@@ -1,8 +1,23 @@
@using Orchard.Blogs.Extensions;
@using Orchard.Core.Contents.ViewModels;
@using Orchard.Utility.Extensions;
<h1>@Html.TitleForPage(T("Manage Blogs").ToString())</h1>
@if (Model.ContentItems.Items.Count > 0) {
<div class="actions"><a class="add button primaryAction" href="@Url.BlogCreate()">@T("New Blog")</a></div>
@Display(Model.ContentItems)
using(Html.BeginFormAntiForgeryPost(Url.Action("List", "Admin", new { area = "Contents", id = "" }))) {
<fieldset class="bulk-actions">
<label for="publishActions">@T("Actions:")</label>
<select id="publishActions" name="Options.BulkAction">
@Html.SelectOption(ContentsBulkAction.None, ContentsBulkAction.None, T("Choose action...").ToString())
@Html.SelectOption(ContentsBulkAction.None, ContentsBulkAction.Remove, T("Remove").ToString())
</select>
@Html.Hidden("returnUrl", ViewContext.RequestContext.HttpContext.Request.ToUrlString())
<button type="submit" name="submit.BulkEdit" value="yes">@T("Apply")</button>
</fieldset>
<fieldset class="contentItems bulk-items">
@Display(Model.ContentItems)
</fieldset>
}
} else {
<div class="info message">@T("There are no blogs for you to see. Want to <a href=\"{0}\">add one</a>?", Url.BlogCreate())</div>
}

View File

@@ -1,7 +1,6 @@
@using Orchard.Blogs.Extensions;
@using Orchard.Blogs.Models;
<h1><a href="@Url.BlogForAdmin((string)Model.Slug)">@Html.TitleForPage((string)Model.Title)</a></h1>
@Display(Model.manage)
@Display(Model.Manage)
<div class="manage"><a href="@Url.BlogPostCreate((BlogPart)Model.ContentItem.Get(typeof(BlogPart)))" class="add button primaryAction">@T("New Post")</a></div>
@Display(Model.metadata)
@Display(Model.Primary)
@Display(Model.Content)

View File

@@ -0,0 +1,6 @@
@using Orchard.Mvc.Html;
@{
Html.AddTitleParts((string)Model.Title);
}
@Display(Model.Primary)
<fieldset><input class="button primaryAction" type="submit" value="@T("Add")" /></fieldset>

View File

@@ -0,0 +1,10 @@
@using Orchard.Blogs.Extensions;
@using Orchard.Blogs.Models;
<h2>@Html.Link((string)Model.Title, Url.Blog((string)Model.Slug))</h2>
<div class="blog metadata">
@T.Plural("1 post", "{0} posts", (int)Model.PostCount)
@if (Model.Meta != null) {
@T(" | ")@Display(Model.Meta)
}
</div>
@Display(Model.Content)

View File

@@ -1,21 +1,28 @@
@using Orchard.Blogs.Extensions;
@using Orchard.Blogs.Models;
<div class="summary">
@using Orchard.ContentManagement;
@using Orchard.Utility.Extensions;
@{
ContentItem contentItem = Model.ContentItem;
var returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString();
}
<div class="summary" itemscope="itemscope" itemid="@contentItem.Id" itemtype="http://orchardproject.net/data/ContentItem">
<div class="properties">
<input type="checkbox" value="@contentItem.Id" name="itemIds"/>
<h3>@Html.Link((string)Model.Title, Url.BlogForAdmin((string)Model.Slug))</h3>
@if (Model.Meta != null) {
<div class="metadata">@Display(Model.Meta)</div>
}
@* <p>[list of authors] [modify blog access]</p> *@
</div>
<div class="related">
<a href="@Url.Blog((string)Model.Slug)" title="@T("View")">@T("View")</a>@T(" | ")
<a href="@Url.BlogForAdmin((string)Model.Slug)" title="@T("List Posts")">@T("List Posts")</a>@T(" | ")
<a href="@Url.BlogPostCreate((BlogPart)Model.ContentItem.Get(typeof(BlogPart)))" title="@T("New Post")">@T("New Post")</a>@T(" | ")
<a href="@Url.BlogEdit((string)Model.Slug)" title="@T("Edit")">@T("Edit")</a>@T(" | ")
@* todo: (heskew) this is a bit too verbose. need template helpers for all ibuttons *@
@using (Html.BeginFormAntiForgeryPost(Url.BlogRemove((string)Model.Slug), FormMethod.Post, new { @class = "inline link" })) {
<button type="submit" class="linkButton" title="@T("Remove")">@T("Remove")</button>
}
<a href="Url.BlogRemove((string)Model.Slug)" title="@T("Remove")" itemprop="RemoveUrl UnsafeUrl">@T("Remove")</a>
</div>
<div class="properties">
<h3>@Html.Link((string)Model.Title, Url.BlogForAdmin((string)Model.Slug))</h3>
<p>@Display(Model.meta)</p>
@* <p>[list of authors] [modify blog access]</p> *@
<p>@Model.Description</p>
</div>
<div style="clear:both;"></div>
@if (Model.Content != null) {
<div class="primary">@Display(Model.Content)</div>
}
</div>

View File

@@ -5,4 +5,4 @@
@using Orchard.Core.Common.ViewModels;
<h2>@Html.Link((string)Model.Title, Url.BlogPost((BlogPostPart)Model.ContentItem.Get(typeof(BlogPostPart))))</h2>
<div class="meta">@Html.PublishedState(new CommonMetadataViewModel((CommonPart)Model.ContentItem.Get(typeof(CommonPart))), T) | @Display(Model.meta)</div>
<div class="content">@Display(Model.Primary)</div>
<div class="content">@Display(Model.Content)</div>

View File

@@ -6,17 +6,16 @@
ContentItem contentItem = Model.ContentItem;
var returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString();
}
<div class="summary" itemscope="itemscope" itemid="@contentItem.Id" itemtype="http://orchardproject.net/data/ContentItem">
<div class="properties">
<input type="checkbox" value="@contentItem.Id" name="itemIds"/>
<h3>@Html.Link((string)Model.Title, Url.BlogPost((BlogPostPart)Model.ContentItem.Get(typeof(BlogPostPart))))</h3>
<div class="metadata">@Display(Model.metadata)</div>
<h3>@Html.Link((string)Model.Title, Url.BlogPostEdit((BlogPostPart)Model.ContentItem.Get(typeof(BlogPostPart))))</h3>
<div class="metadata">@Display(Model.Meta)</div> <!-- was: metadata -->
</div>
<div class="related">@Display(Model.secondary)
@Html.Link(T("Edit").Text, Url.BlogPost((BlogPostPart)Model.ContentItem.Get(typeof(BlogPostPart)))) @T(" | ")
<div class="related">@Display(Model.Related) <!-- was: secondary -->
@Html.Link(T("Edit").Text, Url.BlogPostEdit((BlogPostPart)Model.ContentItem.Get(typeof(BlogPostPart)))) @T(" | ")
@Html.Link(T("Remove").Text, Url.Action("Remove", "Admin", new { area = "Contents", id = contentItem.Id, returnUrl }), new { itemprop = "RemoveUrl UnsafeUrl" })
<br />@Display(Model.meta)
<br />@Display(Model.Secondary) <!-- was: meta -->
</div>
<div class="primary">@Display(Model.Primary)</div>
</div>
<div class="primary">@Display(Model.Content)</div>
</div>

View File

@@ -0,0 +1,9 @@
<h1>@Html.TitleForPage((string)Model.Title)</h1>
@if (Model.Meta != null) {
<div class="metadata">
@Display(Model.Meta)
</div>
}
<div class="content">
@Display(Model.Content)
</div>

View File

@@ -1,3 +0,0 @@
<h1>@Html.TitleForPage((string)Model.Title)</h1>
@Display(Model.metadata)
@Display(Model.Primary)

View File

@@ -1,4 +0,0 @@
@Html.AddTitleParts(Model.Title)
@Display(Model.Primary)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!111 Content.Edit.Blog !!!!!!!!!!!!!!!!!!!!!!!!11
<fieldset><input class="button primaryAction" type="submit" value="@T("Add")" /></fieldset>

View File

@@ -1,7 +0,0 @@
@using Orchard.Blogs.Extensions;
@using Orchard.Blogs.Models;
<h2>@Html.Link((string)Model.Title, Url.Blog((string)Model.Slug))</h2>
@if (!string.IsNullOrEmpty((string)Model.Description)) {
<p>@Model.Description</p>
}
<div class="blog metadata">@T.Plural("1 post", "{0} posts", (int)Model.PostCount) | @Display(Model.meta)</div>

View File

@@ -1,3 +1,5 @@
<div class="blog-description">
@if (HasText(Model.Description)) {
<div class="blog-description">
<p>@Model.Description</p>
</div>
</div>
}

View File

@@ -1,22 +1,22 @@
@using Orchard.Core.Contents.ViewModels;
@using Orchard.Utility.Extensions;
@if (Model.Items.Count > 0) {
@if (Model.ContentItems.Items.Count > 0) {
using (Html.BeginFormAntiForgeryPost(Url.Action("List", "Admin", new { area = "Contents", id = "" }))) {
<fieldset class="bulk-actions">
<label for="publishActions">@T("Actions:")</label>
<select id="publishActions" name="Options.BulkAction">
@Html.SelectOption(ContentsBulkAction.None, ContentsBulkAction.None, T("Choose action...").ToString())
@Html.SelectOption(ContentsBulkAction.None, ContentsBulkAction.PublishNow, T("Publish Now").ToString())
@Html.SelectOption(ContentsBulkAction.None, ContentsBulkAction.Unpublish, T("Unpublish").ToString())
@Html.SelectOption(ContentsBulkAction.None, ContentsBulkAction.Remove, T("Remove").ToString())
</select>
@Html.Hidden("returnUrl", ViewContext.RequestContext.HttpContext.Request.ToUrlString())
<button type="submit" name="submit.BulkEdit" value="yes">@T("Apply")</button>
</fieldset>
<fieldset class="contentItems bulk-items">
@Display(Model.BlogPosts)
</fieldset>
<fieldset class="bulk-actions">
<label for="publishActions">@T("Actions:")</label>
<select id="publishActions" name="Options.BulkAction">
@Html.SelectOption(ContentsBulkAction.None, ContentsBulkAction.None, T("Choose action...").ToString())
@Html.SelectOption(ContentsBulkAction.None, ContentsBulkAction.PublishNow, T("Publish Now").ToString())
@Html.SelectOption(ContentsBulkAction.None, ContentsBulkAction.Unpublish, T("Unpublish").ToString())
@Html.SelectOption(ContentsBulkAction.None, ContentsBulkAction.Remove, T("Remove").ToString())
</select>
@Html.Hidden("returnUrl", ViewContext.RequestContext.HttpContext.Request.ToUrlString())
<button type="submit" name="submit.BulkEdit" value="yes">@T("Apply")</button>
</fieldset>
<fieldset class="contentItems bulk-items">
@Display(Model.ContentItems)
</fieldset>
}
} else {
<div class="info message">@T("There are no posts for this blog.")</div>
<div class="info message">@T("There are no posts for this blog.")</div>
}

View File

@@ -1,7 +1,9 @@
@{
IEnumerable<object> blogPosts = Model.BlogPosts;
}
@Display(blogPosts)
@Display(ContentItems)
@if (blogPosts == null || blogPosts.Count() < 1) {
<p>@T("There are no posts for this blog.")</p>
}
}
hi

View File

@@ -1,9 +0,0 @@
@using Orchard.ContentManagement;
@using Orchard.Core.Common.ViewModels;
@*doing excerpt generation on the way out for now so we don't stick ourselves with needing to regen excerpts for existing data
also, doing this here, inline, until we have a pluggable processing model (both in and out)
also, ...this is ugly *@
@{
var body = new HtmlString(Html.Excerpt((string)Model.Html.ToString(), 200).ToString().Replace(Environment.NewLine, "</p>" + Environment.NewLine + "<p>"));
}
<p>@body @Html.ItemDisplayLink(T("[more]").ToString(), (IContent)Model.ContentPart.ContentItem)</p>

View File

@@ -1,5 +0,0 @@
@using Orchard.Core.Common.Extensions;
@if (Model.Creator != null) {
<div class="metadata">
<div class="posted">@T("Published by {0} {1}", (string)Model.ContentPart.Creator.UserName, Html.PublishedWhen((DateTime?)Model.ContentPart.VersionPublishedUtc, T))</div>
</div>}

View File

@@ -1,13 +0,0 @@
@using Orchard.Core.Localization.Models;
@{
Style.Require("Localization");
IEnumerable<LocalizationPart> localizations = Model.Localizations;
}
@if (localizations != null && localizations.Count() > 0) {
<div class="content-localization">
<div class="content-localizations">
<h4>@T("Translations:")</h4>
@Html.UnorderedList(localizations, (c, i) => Html.ItemDisplayLink(c.Culture.Culture, c), "localizations")
</div>
</div>
}

View File

@@ -1,16 +0,0 @@
@{
var tagsHtml = new List<IHtmlString>();
foreach(var t in Model.Tags) {
if (tagsHtml.Any()) {
tagsHtml.Add(new HtmlString(", "));
}
tagsHtml.Add(Html.ActionLink((string)t.TagName, "Search", "Home", new { area = "Orchard.Tags", tagName = (string)t.TagName }, new { }));
}
}
@if (tagsHtml.Any()) {
<p class="tags">
<span>@T("Tags:")</span>
@foreach(var htmlString in tagsHtml) { @htmlString }
</p>
}

View File

@@ -1,16 +0,0 @@
@{
var tagsHtml = new List<IHtmlString>();
foreach(var t in Model.Tags) {
if (tagsHtml.Any()) {
tagsHtml.Add(new HtmlString(", "));
}
tagsHtml.Add(Html.ActionLink((string)t.TagName, "Search", "Home", new { area = "Orchard.Tags", tagName = (string)t.TagName }, new { }));
}
}
@if (tagsHtml.Any()) {
<p class="tags">
<span>@T("Tags:")</span>
@foreach(var htmlString in tagsHtml) { @htmlString }
</p>
}

View File

@@ -12,7 +12,7 @@ namespace Orchard.Comments.Drivers {
return null;
if (displayType.StartsWith("Detail"))
return ContentShape(shapeHelper.Parts_Comments_Comments(ContentPart: part)).Location(part.GetLocation("Detail"));
return ContentShape(shapeHelper.Parts_Comments_Comments(ContentPart: part)).Location("Content:10");
if (displayType == "SummaryAdmin")
return ContentShape(shapeHelper.Parts_Comments_CountAdmin(ContentPart: part, CommentCount: part.Comments.Count, PendingCount: part.PendingComments.Count))

View File

@@ -1,5 +1,5 @@
@model Orchard.Comments.ViewModels.CommentCountViewModel
@using Orchard.Comments.ViewModels;
@using Orchard.Comments.Models;
@using Orchard.Comments.Extensions;
<span class="commentcount">@Html.CommentSummaryLinks(T, Model.Item, Model.CommentCount, Model.PendingCount)</span>
@using Orchard.Comments.ViewModels;
@using Orchard.ContentManagement;
<span class="commentcount">@Html.CommentSummaryLinks(T, (ContentItem)Model.ContentPart.ContentItem, (int)Model.CommentCount, (int)Model.PendingCount)</span>

View File

@@ -7,7 +7,6 @@ using Orchard.ContentTypes.Services;
using Orchard.ContentTypes.ViewModels;
using Orchard.Core.Contents.Settings;
using Orchard.Localization;
using Orchard.Mvc.Results;
using Orchard.UI.Notify;
namespace Orchard.ContentTypes.Controllers {
@@ -72,7 +71,7 @@ namespace Orchard.ContentTypes.Controllers {
var typeViewModel = _contentDefinitionService.GetType(id);
if (typeViewModel == null)
return new NotFoundResult();
return HttpNotFound();
return View(typeViewModel);
}
@@ -85,7 +84,7 @@ namespace Orchard.ContentTypes.Controllers {
var typeViewModel = _contentDefinitionService.GetType(id);
if (typeViewModel == null)
return new NotFoundResult();
return HttpNotFound();
if (!TryUpdateModel(typeViewModel))
return View(typeViewModel);
@@ -109,7 +108,7 @@ namespace Orchard.ContentTypes.Controllers {
var typeViewModel = _contentDefinitionService.GetType(id);
if (typeViewModel == null)
return new NotFoundResult();
return HttpNotFound();
var viewModel = new AddPartsViewModel {
Type = typeViewModel,
@@ -129,7 +128,7 @@ namespace Orchard.ContentTypes.Controllers {
var typeViewModel = _contentDefinitionService.GetType(id);
if (typeViewModel == null)
return new NotFoundResult();
return HttpNotFound();
var viewModel = new AddPartsViewModel();
if (!TryUpdateModel(viewModel))
@@ -159,7 +158,7 @@ namespace Orchard.ContentTypes.Controllers {
if (typeViewModel == null
|| !TryUpdateModel(viewModel)
|| !typeViewModel.Parts.Any(p => p.PartDefinition.Name == viewModel.Name))
return new NotFoundResult();
return HttpNotFound();
viewModel.Type = typeViewModel;
return View(viewModel);
@@ -176,7 +175,7 @@ namespace Orchard.ContentTypes.Controllers {
if (typeViewModel == null
|| !TryUpdateModel(viewModel)
|| !typeViewModel.Parts.Any(p => p.PartDefinition.Name == viewModel.Name))
return new NotFoundResult();
return HttpNotFound();
_contentDefinitionService.RemovePartFromType(viewModel.Name, typeViewModel.Name);
@@ -230,7 +229,7 @@ namespace Orchard.ContentTypes.Controllers {
var partViewModel = _contentDefinitionService.GetPart(id);
if (partViewModel == null)
return new NotFoundResult();
return HttpNotFound();
return View(partViewModel);
}
@@ -243,7 +242,7 @@ namespace Orchard.ContentTypes.Controllers {
var partViewModel = _contentDefinitionService.GetPart(id);
if (partViewModel == null)
return new NotFoundResult();
return HttpNotFound();
if (!TryUpdateModel(partViewModel))
return View(partViewModel);
@@ -272,7 +271,7 @@ namespace Orchard.ContentTypes.Controllers {
if (typeViewModel != null)
partViewModel = new EditPartViewModel(new ContentPartDefinition(id));
else
return new NotFoundResult();
return HttpNotFound();
}
var viewModel = new AddFieldViewModel {
@@ -298,7 +297,7 @@ namespace Orchard.ContentTypes.Controllers {
_contentDefinitionService.AddPartToType(partViewModel.Name, typeViewModel.Name);
}
else {
return new NotFoundResult();
return HttpNotFound();
}
}
@@ -334,7 +333,7 @@ namespace Orchard.ContentTypes.Controllers {
if (partViewModel == null
|| !TryUpdateModel(viewModel)
|| !partViewModel.Fields.Any(p => p.Name == viewModel.Name))
return new NotFoundResult();
return HttpNotFound();
viewModel.Part = partViewModel;
return View(viewModel);
@@ -351,7 +350,7 @@ namespace Orchard.ContentTypes.Controllers {
if (partViewModel == null
|| !TryUpdateModel(viewModel)
|| !partViewModel.Fields.Any(p => p.Name == viewModel.Name))
return new NotFoundResult();
return HttpNotFound();
_contentDefinitionService.RemoveFieldFromPart(viewModel.Name, partViewModel.Name);

View File

@@ -107,6 +107,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="Views\DisplayTemplates\Parts\Experimental.ShowDebugLink.ascx" />
<Content Include="Views\DumpShapeTable.cshtml" />
<None Include="Views\HackScript.cshtml" />
<None Include="Views\HackStyle.cshtml" />
<None Include="Views\ThinBorder.cshtml" />

View File

@@ -7,12 +7,16 @@ namespace Orchard.Experimental {
}
public void Created(ShapeCreatedContext context) {
if (context.ShapeType != "Layout" && context.ShapeType != "DocumentZone")
if (context.ShapeType != "Layout" && context.ShapeType != "DocumentZone") {
context.Shape.Metadata.Wrappers.Add("ThinBorder");
}
if (context.ShapeType == "Header") {
context.Shape.Metadata.Wrappers.Add("HackScript");
context.Shape.Metadata.Wrappers.Add("HackStyle");
}
if (context.ShapeType == "Layout") {
context.Shape.Metadata.Wrappers.Add("DumpShapeTable");
}
}
}
}

View File

@@ -1,9 +1,10 @@
@using Orchard;
@using Orchard.DisplayManagement.Descriptors;
@Display(Model.Metadata.ChildContent)
@{
var workContext = ViewContext.GetWorkContext();
var shapeTable = workContext.Resolve<IShapeTableManager>().GetShapeTable(workContext.CurrentTheme.ThemeName);
<!--
<ul>
@foreach(var descriptor in shapeTable.Descriptors) {
<li>@descriptor.Key : @descriptor.Value.BindingSource
@@ -15,4 +16,5 @@
</li>
}
</ul>
}
-->
}

View File

@@ -4,8 +4,6 @@ using System.Web.Mvc;
using Orchard.Data.Migration;
using Orchard.Localization;
using Orchard.Modules.ViewModels;
using Orchard.Mvc.Results;
using Orchard.Packaging;
using Orchard.Packaging.Services;
using Orchard.Reports.Services;
using Orchard.UI.Notify;
@@ -97,7 +95,7 @@ namespace Orchard.Modules.Controllers {
return new HttpUnauthorizedResult();
if (string.IsNullOrEmpty(id))
return new NotFoundResult();
return HttpNotFound();
_moduleService.EnableFeatures(new[] { id }, force != null && (bool)force);
@@ -110,7 +108,7 @@ namespace Orchard.Modules.Controllers {
return new HttpUnauthorizedResult();
if (string.IsNullOrEmpty(id))
return new NotFoundResult();
return HttpNotFound();
_moduleService.DisableFeatures(new[] { id }, force != null && (bool)force);
@@ -123,7 +121,7 @@ namespace Orchard.Modules.Controllers {
return new HttpUnauthorizedResult();
if (string.IsNullOrEmpty(id))
return new NotFoundResult();
return HttpNotFound();
try {
_reportsCoordinator.Register("Data Migration", "Upgrade " + id, "Orchard installation");

View File

@@ -5,7 +5,6 @@ using Orchard.Environment.Configuration;
using Orchard.Localization;
using Orchard.MultiTenancy.Services;
using Orchard.MultiTenancy.ViewModels;
using Orchard.Mvc.Results;
using Orchard.UI.Notify;
namespace Orchard.MultiTenancy.Controllers {
@@ -76,7 +75,7 @@ namespace Orchard.MultiTenancy.Controllers {
var tenant = _tenantService.GetTenants().FirstOrDefault(ss => ss.Name == name);
if (tenant == null)
return new NotFoundResult();
return HttpNotFound();
return View(new TenantEditViewModel {
Name = tenant.Name,
@@ -100,7 +99,7 @@ namespace Orchard.MultiTenancy.Controllers {
var tenant = _tenantService.GetTenants().FirstOrDefault(ss => ss.Name == viewModel.Name);
if (tenant == null)
return new NotFoundResult();
return HttpNotFound();
_tenantService.UpdateTenant(
new ShellSettings {

View File

@@ -229,6 +229,7 @@ namespace Orchard.Setup.Services {
htmlWidget.As<WidgetPart>().Zone = "Content";
htmlWidget.As<WidgetPart>().Position = "5";
htmlWidget.As<BodyPart>().Text = "<p>Congratulations, you've successfully set-up your Orchard site.</p><p>This is the home page of your new site. We've taken the liberty to write here about a few things you could look at next in order to get familiar with the application. Once you feel confident you don't need this anymore, just click <a href=\"/Admin/Contents/Edit/7\">Edit</a> to go into edit mode and replace this with whatever you want on your home page to make it your own.</p><p>One thing you could do (but you don't have to) is go into <a href=\"Admin/Settings\">Manage Settings</a> (follow the <a href=\"Admin\">Admin</a> link and then look for it under \"Settings\" in the menu on the left) and check that everything is configured the way you want.</p><p>You probably want to make the site your own. One of the ways you can do that is by clicking <a href=\"Admin/Themes\">Manage Themes</a> in the admin menu. A theme is a packaged look and feel that affects the whole site.</p><p>Next, you can start playing with the content types that we installed. For example, go ahead and click <a href=\"Admin/Pages/Create\">Add New Page</a> in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to <a href=\"Admin/Navigation\">Manage Menu</a>. You can also click <a href=\"Admin/Blogs/Create\">Add New Blog</a> and start posting by clicking \"Add New Post\".</p><p>Finally, Orchard has been designed to be extended. It comes with a few built-in modules such as pages and blogs or themes. You can install new themes by going to <a href=\"Admin/Themes\">Manage Themes</a> and clicking <a href=\"Admin/Themes/Install\">Install a new Theme</a>. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please <a href=\"http://www.orchardproject.net/\">consider participating</a>.</p><p>--The Orchard Crew</p>";
htmlWidget.As<CommonPart>().Owner = user;
contentManager.Publish(htmlWidget);
// and three more for the third aside...really need this elsewhere...

View File

@@ -5,7 +5,6 @@ using System.Web.Mvc;
using Orchard.Data.Migration;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.Mvc.Results;
using Orchard.Reports.Services;
using Orchard.Security;
using Orchard.Themes.Preview;
@@ -176,7 +175,7 @@ namespace Orchard.Themes.Controllers {
return new HttpUnauthorizedResult();
if (string.IsNullOrEmpty(themeName))
return new NotFoundResult();
return HttpNotFound();
try {
_reportsCoordinator.Register("Data Migration", "Upgrade " + themeName, "Orchard installation");

View File

@@ -14,7 +14,6 @@ using Orchard.Settings;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.Users.Models;
using Orchard.Mvc.Results;
namespace Orchard.Users.Controllers {
[HandleError, Themed]
@@ -96,7 +95,7 @@ namespace Orchard.Users.Controllers {
// ensure users can register
var registrationSettings = CurrentSite.As<RegistrationSettingsPart>();
if ( !registrationSettings.UsersCanRegister ) {
return new NotFoundResult();
return HttpNotFound();
}
ViewData["PasswordLength"] = MinPasswordLength;
@@ -109,7 +108,7 @@ namespace Orchard.Users.Controllers {
// ensure users can register
var registrationSettings = CurrentSite.As<RegistrationSettingsPart>();
if ( !registrationSettings.UsersCanRegister ) {
return new NotFoundResult();
return HttpNotFound();
}
ViewData["PasswordLength"] = MinPasswordLength;

View File

@@ -5,7 +5,6 @@ using System.Linq;
using Orchard.ContentManagement;
using Orchard.Core.Contents.Controllers;
using Orchard.Localization;
using Orchard.Mvc.Results;
using Orchard.UI.Admin;
using Orchard.UI.Notify;
using Orchard.Widgets.Models;
@@ -99,7 +98,7 @@ namespace Orchard.Widgets.Controllers {
try {
WidgetPart widgetPart = Services.ContentManager.New<WidgetPart>(widgetType);
if (widgetPart == null)
return new NotFoundResult();
return HttpNotFound();
dynamic model = Services.ContentManager.BuildEditor(widgetPart);
return View(model);
@@ -119,7 +118,7 @@ namespace Orchard.Widgets.Controllers {
int widgetPosition = _widgetsService.GetWidgets(layerId).Count() + 1;
WidgetPart widgetPart = _widgetsService.CreateWidget(layerId, widgetType, "", widgetPosition.ToString(), "");
if (widgetPart == null)
return new NotFoundResult();
return HttpNotFound();
var model = Services.ContentManager.UpdateEditor(widgetPart, this);
if (!ModelState.IsValid) {
@@ -143,7 +142,7 @@ namespace Orchard.Widgets.Controllers {
try {
LayerPart layerPart = Services.ContentManager.New<LayerPart>("Layer");
if (layerPart == null)
return new NotFoundResult();
return HttpNotFound();
dynamic model = Services.ContentManager.BuildEditor(layerPart);
return View(model);
@@ -162,7 +161,7 @@ namespace Orchard.Widgets.Controllers {
try {
LayerPart layerPart = _widgetsService.CreateLayer("", "", "");
if (layerPart == null)
return new NotFoundResult();
return HttpNotFound();
var model = Services.ContentManager.UpdateEditor(layerPart, this);
if (!ModelState.IsValid) {
@@ -186,7 +185,7 @@ namespace Orchard.Widgets.Controllers {
try {
LayerPart layerPart = _widgetsService.GetLayer(id);
if (layerPart == null) {
return new NotFoundResult();
return HttpNotFound();
}
dynamic model = Services.ContentManager.BuildEditor(layerPart);
@@ -207,7 +206,7 @@ namespace Orchard.Widgets.Controllers {
try {
LayerPart layerPart = _widgetsService.GetLayer(id);
if (layerPart == null)
return new NotFoundResult();
return HttpNotFound();
var model = Services.ContentManager.UpdateEditor(layerPart, this);
if (!ModelState.IsValid) {
@@ -276,7 +275,7 @@ namespace Orchard.Widgets.Controllers {
try {
widgetPart = _widgetsService.GetWidget(id);
if (widgetPart == null)
return new NotFoundResult();
return HttpNotFound();
var model = Services.ContentManager.UpdateEditor(widgetPart, this);
if (!ModelState.IsValid) {
@@ -305,7 +304,7 @@ namespace Orchard.Widgets.Controllers {
try {
widgetPart = _widgetsService.GetWidget(id);
if (widgetPart == null)
return new NotFoundResult();
return HttpNotFound();
_widgetsService.DeleteWidget(widgetPart.Id);
Services.Notifier.Information(T("Widget was successfully deleted"));

View File

@@ -29,7 +29,7 @@ namespace Orchard.Widgets {
var zoneName = contentItem.As<WidgetPart>().Zone;
displaying.ShapeMetadata.Alternates.Add("Items_Widget__" + contentItem.ContentType);
displaying.ShapeMetadata.Alternates.Add("Items_Widget__" + zoneName);
//...would like...
//...would like...if '__' was collapsible
//displaying.ShapeMetadata.Alternates.Add("Items_Widget__" + zoneName + "__" + contentItem.ContentType);
}
});

View File

@@ -311,7 +311,6 @@
<Content Include="Themes\TheAdmin\Styles\images\backgroundHeader.gif" />
<Content Include="Themes\TheAdmin\Styles\images\orchardLogo.gif" />
<Content Include="Themes\TheAdmin\Theme.png" />
<Content Include="Themes\TheAdmin\Views\DumpShapeTable.cshtml" />
<Content Include="Themes\TheAdmin\Views\User.cshtml" />
<Content Include="Themes\TheAdmin\Views\Header.cshtml" />
<Content Include="Themes\Web.config" />

View File

@@ -38,11 +38,4 @@
@Display(Model.Navigation)</div>
</div>
<div id="footer" role="contentinfo">
@Display(Model.Footer)</div>
@* tmp *@
<!--
<div style="background:#666;color:#daf2f6;margin:10px;padding:10px;font:12px/18px Consolas,'Lucida Console','Bitstream Vera Sans Mono','DejaVu Sans Mono',monospace;">
@Display.DumpShapeTable()
</div>
-->
@Display(Model.Footer)</div>

View File

@@ -22,9 +22,12 @@
}
Model.Id = "layout-wrapper";
var tag = Tag (Model, "div");
}
<div id="layout-wrapper">
@tag.StartElement
@* needs to be the page title, not page (head) title... *@
@* Adds text and html to the header zone *@
@@ -85,4 +88,4 @@
</footer>
}
</div>
@tag.EndElement

View File

@@ -1,11 +0,0 @@
using System.Net;
using System.Web;
using System.Web.Mvc;
namespace Orchard.Mvc.Results {
public class NotFoundResult : ViewResult {
public override void ExecuteResult(ControllerContext context) {
throw new HttpException((int)HttpStatusCode.NotFound, "Resource not found");
}
}
}

View File

@@ -757,7 +757,6 @@
<Compile Include="Mvc\ModelBinders\IModelBinderPublisher.cs" />
<Compile Include="Mvc\ModelBinders\KeyedListModelBinder.cs" />
<Compile Include="Mvc\ModelBinders\ModelBinderDescriptor.cs" />
<Compile Include="Mvc\Results\NotFoundResult.cs" />
<Compile Include="Mvc\Routes\RouteExtensions.cs" />
<Compile Include="Mvc\ViewEngines\IViewEngineProvider.cs" />
<Compile Include="Mvc\ViewEngines\LayoutViewContext.cs" />