--HG--
branch : dev
This commit is contained in:
Suha Can
2011-02-10 16:07:51 -08:00
32 changed files with 81 additions and 24 deletions

View File

@@ -2,6 +2,7 @@
using Orchard.ContentManagement;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.Mvc;
using Orchard.Themes;
namespace Orchard.Core.Contents.Controllers {
@@ -24,8 +25,7 @@ namespace Orchard.Core.Contents.Controllers {
public ActionResult Display(int id) {
var contentItem = _contentManager.Get(id, VersionOptions.Published);
dynamic model = _contentManager.BuildDisplay(contentItem);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model);
return new ShapeResult(this, model);
}
// /Contents/Item/Preview/72
@@ -41,8 +41,7 @@ namespace Orchard.Core.Contents.Controllers {
return new HttpUnauthorizedResult();
dynamic model = _contentManager.BuildDisplay(contentItem);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View("Display", (object)model);
return new ShapeResult(this, model);
}
}
}

View File

@@ -5,5 +5,6 @@
<h1>@Html.TitleForPage((string)pageTitle.Text)</h1>
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
@Display(Model)
}

View File

@@ -8,5 +8,6 @@
<h1>@Html.TitleForPage(pageTitle)</h1>
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
@Display(Model)
}

View File

@@ -1 +0,0 @@
@Display(Model)

View File

@@ -335,10 +335,8 @@
<SubType>Designer</SubType>
</Content>
<Content Include="Contents\Views\Content.ControlWrapper.cshtml" />
<Content Include="Contents\Views\Item\Display.cshtml" />
<Content Include="Navigation\Placement.info" />
<Content Include="Routable\Views\Parts.RoutableTitle.cshtml" />
<Content Include="Routable\Views\Item\Display.cshtml" />
<Content Include="Routable\Views\Routable.HomePage.cshtml" />
<Content Include="Contents\Views\Content.Summary.cshtml" />
<Content Include="Shapes\Views\Pager.cshtml" />

View File

@@ -9,6 +9,7 @@ using Orchard.Core.Routable.Services;
using Orchard.Data;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.Mvc;
using Orchard.Services;
using Orchard.Themes;
@@ -59,8 +60,7 @@ namespace Orchard.Core.Routable.Controllers {
}
dynamic model = _contentManager.BuildDisplay(hits.Single());
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model);
return new ShapeResult(this, model);
}
public ActionResult Slugify(string contentType, int? id, int? containerId) {

View File

@@ -1 +0,0 @@
@Display(Model)

View File

@@ -8,6 +8,7 @@ using Orchard.Core.Feeds;
using Orchard.Core.Routable.Services;
using Orchard.DisplayManagement;
using Orchard.Logging;
using Orchard.Mvc;
using Orchard.Services;
using Orchard.Themes;
using Orchard.UI.Navigation;
@@ -92,8 +93,7 @@ namespace Orchard.Blogs.Controllers {
var totalItemCount = _blogPostService.PostCount(blogPart);
blog.Content.Add(Shape.Pager(pager).TotalItemCount(totalItemCount), "Content:after");
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)blog);
return new ShapeResult(this, blog);
}
}
}

View File

@@ -7,6 +7,7 @@ using Orchard.ContentManagement;
using Orchard.Core.Feeds;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.Mvc;
using Orchard.Security;
using Orchard.Themes;
@@ -51,8 +52,7 @@ namespace Orchard.Blogs.Controllers {
return HttpNotFound();
dynamic model = _services.ContentManager.BuildDisplay(postPart);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model);
return new ShapeResult(this, model);
}
public ActionResult ListByArchive(string blogPath, string archiveData) {

View File

@@ -115,9 +115,7 @@
<Content Include="Views\BlogAdmin\List.cshtml" />
<Content Include="Views\BlogPostAdmin\Create.cshtml" />
<Content Include="Views\BlogPostAdmin\Edit.cshtml" />
<Content Include="Views\BlogPost\Item.cshtml" />
<Content Include="Views\BlogPost\ListByArchive.cshtml" />
<Content Include="Views\Blog\Item.cshtml" />
<Content Include="Views\Blog\List.cshtml" />
<Content Include="Views\Parts.Blogs.Blog.Manage.cshtml" />
<Content Include="Views\Parts.Blogs.Blog.Description.cshtml" />

View File

@@ -1 +0,0 @@
@Display(Model)

View File

@@ -1,5 +1,6 @@
<h1>@Html.TitleForPage(T("Create New Blog").ToString())</h1>
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
@Display(Model)
}

View File

@@ -1,5 +1,6 @@
<h1>@Html.TitleForPage(T("Blog Properties").ToString())</h1>
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
@Display(Model)
}

View File

@@ -1,4 +1,5 @@
@{
Html.AddTitleParts(T("Manage Blog").ToString());
}
@Display(Model)
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
@Display(Model)

View File

@@ -1 +0,0 @@
@Display(Model)

View File

@@ -1,5 +1,6 @@
<h1>@Html.TitleForPage(T("Create New Blog Post").ToString())</h1>
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
@Display(Model)
}

View File

@@ -1,5 +1,6 @@
<h1>@Html.TitleForPage(T("Edit Blog Post").ToString())</h1>
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
@Display(Model)
}

View File

@@ -0,0 +1,17 @@
<Placement>
<!-- Customize where the shapes are rendered -->
<!--
<Place Parts_Blogs_BlogArchives="Content:before"/>
<Place Parts_Blogs_RecentBlogPosts="Content:after"/>
<Match ContentType="Blog">
<Match DisplayType="Summary">
<Place Parts_Blogs_Blog_Description="Content:before"
Parts_Blogs_Blog_BlogPostCount="Meta:3"/>
</Match>
</Match>
<Match Path="/About">
<Place Parts_Common_Metadata="-"/>
</Match>
-->
</Placement>

View File

@@ -312,6 +312,9 @@ namespace Orchard.CodeGeneration.Commands {
File.WriteAllBytes(themePath + "Theme.png", File.ReadAllBytes(_codeGenTemplatePath + "Theme.png"));
createdFiles.Add(themePath + "Theme.png");
File.WriteAllText(themePath + "Placement.info", File.ReadAllText(_codeGenTemplatePath + "Placement.info"));
createdFiles.Add(themePath + "Placement.info");
// create new csproj for the theme
if (projectGuid != null) {
var itemGroup = CreateProjectItemGroup(themePath, createdFiles, createdFolders);

View File

@@ -79,6 +79,9 @@
<ItemGroup>
<Content Include="CodeGenerationTemplates\ModuleRootWebConfig.txt" />
</ItemGroup>
<ItemGroup>
<Content Include="CodeGenerationTemplates\Placement.info" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -66,7 +66,7 @@ namespace Orchard.Users.Controllers {
users = users.Where(u => u.RegistrationStatus == UserStatus.Pending);
break;
case UsersFilter.EmailPending:
users = users.Where(u => u.EmailStatus == UserStatus.Approved);
users = users.Where(u => u.EmailStatus == UserStatus.Pending);
break;
}

View File

@@ -1,5 +1,6 @@
<h1>@Html.TitleForPage(T("Add User").ToString()) </h1>
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
@Display(Model)
}

View File

@@ -1,5 +1,6 @@
<h1>@Html.TitleForPage(T("Edit User").ToString()) </h1>
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
@Display(Model)
}

View File

@@ -1,5 +1,6 @@
<h1>@Html.TitleForPage(T("Add Layer").ToString())</h1>
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
@Display(Model)
}

View File

@@ -1,5 +1,6 @@
<h1>@Html.TitleForPage(T("Add Widget").ToString())</h1>
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
@Display(Model)
}

View File

@@ -1,5 +1,6 @@
<h1>@Html.TitleForPage(T("Edit Layer").ToString())</h1>
@using (Html.BeginFormAntiForgeryPost()) {
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
@Display(Model)
}

View File

@@ -1,5 +1,6 @@
<h1>@Html.TitleForPage(T("Edit Widget").ToString())</h1>
@using (Html.BeginFormAntiForgeryPost()) {
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
@Display(Model)
}

View File

@@ -0,0 +1,17 @@
<Placement>
<!-- Customize where the shapes are rendered -->
<!--
<Place Parts_Blogs_BlogArchives="Content:before"/>
<Place Parts_Blogs_RecentBlogPosts="Content:after"/>
<Match ContentType="Blog">
<Match DisplayType="Summary">
<Place Parts_Blogs_Blog_Description="Content:before"
Parts_Blogs_Blog_BlogPostCount="Meta:3"/>
</Match>
</Match>
<Match Path="/About">
<Place Parts_Common_Metadata="-"/>
</Match>
-->
</Placement>

View File

@@ -116,6 +116,9 @@
<SubType>Designer</SubType>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="TheThemeMachine\Placement.info" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Routing;
using ClaySharp.Implementation;
using Orchard.ContentManagement.Handlers;
@@ -100,6 +101,7 @@ namespace Orchard.ContentManagement {
//var theme = workContext.CurrentTheme;
var theme = _themeService.Value.GetRequestTheme(_requestContext);
var shapeTable = _shapeTableManager.GetShapeTable(theme.Id);
var request = _requestContext.HttpContext.Request;
ShapeDescriptor descriptor;
if (shapeTable.Descriptors.TryGetValue(partShapeType, out descriptor)) {
@@ -107,6 +109,7 @@ namespace Orchard.ContentManagement {
ContentType = context.ContentItem.ContentType,
DisplayType = displayType,
Differentiator = differentiator,
Path = request.Path.Substring((request.ApplicationPath ?? "").Length)
};
var location = descriptor.Placement(placementContext);
return location ?? defaultLocation;

View File

@@ -111,5 +111,6 @@ namespace Orchard.DisplayManagement.Descriptors {
public string ContentType { get; set; }
public string DisplayType { get; set; }
public string Differentiator { get; set; }
public string Path { get; set; }
}
}

View File

@@ -98,6 +98,12 @@ namespace Orchard.DisplayManagement.Descriptors.ShapePlacementStrategy {
return ctx => (ctx.DisplayType ?? "").StartsWith(prefix) && predicate(ctx);
}
return ctx => (ctx.DisplayType == expression) && predicate(ctx);
case "Path":
if (expression.EndsWith("*")) {
var prefix = expression.Substring(0, expression.Length - 1);
return ctx => (ctx.Path ?? "").StartsWith(prefix, StringComparison.OrdinalIgnoreCase) && predicate(ctx);
}
return ctx => (ctx.Path.Equals(expression, StringComparison.OrdinalIgnoreCase)) && predicate(ctx);
}
return predicate;
}