--HG--
branch : theming
This commit is contained in:
Sebastien Ros
2010-09-09 17:03:26 -07:00
26 changed files with 201 additions and 143 deletions

View File

@@ -5,5 +5,5 @@
//also, ...this is ugly--%>
<%: new HtmlString(string.Format(
"<p>{0} {1}</p>",
Html.Excerpt(Model.Text, 200).ToString().Replace(Environment.NewLine, "</p>" + Environment.NewLine + "<p>"),
Html.Excerpt(Model.Html.ToString(), 200).ToString().Replace(Environment.NewLine, "</p>" + Environment.NewLine + "<p>"),
Html.ItemDisplayLink(T("[more]").ToString(), Model.BodyPart.ContentItem))) %>

View File

@@ -84,7 +84,7 @@ namespace Orchard.Core.Contents.Controllers {
//-- but resorting to
IEnumerable<ContentItem> contentItems = query.List();
var contentItems = query.List();
switch (model.Options.OrderBy) {
case ContentsOrder.Modified:
contentItems = contentItems.OrderByDescending(ci => ci.VersionRecord.Id);
@@ -108,16 +108,21 @@ namespace Orchard.Core.Contents.Controllers {
contentItems = contentItems.Skip(skip).Take(pageSize).ToList();
//model.Entries = contentItems.Select(BuildEntry).ToList();
//model.Options.SelectedFilter = model.TypeName;
//model.Options.FilterOptions = GetCreatableTypes()
// .Select(ctd => new KeyValuePair<string, string>(ctd.Name, ctd.DisplayName))
// .ToList().OrderBy(kvp => kvp.Key);
model.Options.SelectedFilter = model.TypeName;
model.Options.FilterOptions = GetCreatableTypes()
.Select(ctd => new KeyValuePair<string, string>(ctd.Name, ctd.DisplayName))
.ToList().OrderBy(kvp => kvp.Key);
var list = Shape.List();
foreach (var item in contentItems)
list.Add(Shape.Content(item));
list.AddRange(contentItems);
return View(list);
var viewModel = Shape.ViewModel()
.ContentItems(list)
.Options(model.Options)
.TypeDisplayName(model.TypeDisplayName ?? "");
return View(viewModel);
}
private IEnumerable<ContentTypeDefinition> GetCreatableTypes() {

View File

@@ -1,35 +1,35 @@
@using Orchard.Core.Contents.ViewModels
<h1>@//Html.TitleForPage((string.IsNullOrEmpty(Model.TypeDisplayName) ? T("Manage Content") : T("Manage {0} Content", Model.TypeDisplayName)).ToString())</h1>
<div class="manage">
@//Html.ActionLink(!string.IsNullOrEmpty(Model.TypeDisplayName) ? T("Create New {0}", Model.TypeDisplayName).Text : T("Create New Content").Text, "Create", new { }, new { @class = "button primaryAction" })
@Html.ActionLink((string)(!string.IsNullOrEmpty((string)Model.TypeDisplayName) ? T("Create New {0}", Model.TypeDisplayName).Text : T("Create New Content").Text), "Create", null, new { @class = "button primaryAction" })
</div>
@using (Html.BeginFormAntiForgeryPost()) {
<fieldset class="bulk-actions">
<label for="publishActions">@T("Actions:")</label>
<select id="publishActions" name="@{/*Html.NameOf(m => m.Options.BulkAction)*/}">
@//Html.SelectOption(Model.Options.BulkAction, ContentsBulkAction.None, T("Choose action...").ToString())
@//Html.SelectOption(Model.Options.BulkAction, ContentsBulkAction.PublishNow, T("Publish Now").ToString())
@//Html.SelectOption(Model.Options.BulkAction, ContentsBulkAction.Unpublish, T("Unpublish").ToString())
@//Html.SelectOption(Model.Options.BulkAction, ContentsBulkAction.Remove, T("Remove").ToString())
<select id="publishActions" name="Options.BulkAction">
@Html.SelectOption((ContentsBulkAction)Model.Options.BulkAction, ContentsBulkAction.None, T("Choose action...").ToString())
@Html.SelectOption((ContentsBulkAction)Model.Options.BulkAction, ContentsBulkAction.PublishNow, T("Publish Now").ToString())
@Html.SelectOption((ContentsBulkAction)Model.Options.BulkAction, ContentsBulkAction.Unpublish, T("Unpublish").ToString())
@Html.SelectOption((ContentsBulkAction)Model.Options.BulkAction, ContentsBulkAction.Remove, T("Remove").ToString())
</select>
<button type="submit" name="submit.BulkEdit" value="yes">@T("Apply")</button>
</fieldset>
<fieldset class="bulk-actions">
<label for="filterResults" class="bulk-filter">@T("Show")</label>
<select id="filterResults" name="@{/*Html.NameOf(m => m.Options.SelectedFilter)*/}">
@//Html.SelectOption(Model.Options.SelectedFilter, "", T("any (show all)").ToString())
@{/*foreach(var filterOption in Model.Options.FilterOptions) {
@Html.SelectOption(Model.Options.SelectedFilter, filterOption.Key, filterOption.Value)
}*/}
<select id="filterResults" name="Options.SelectedFilter">
@Html.SelectOption((string)Model.Options.SelectedFilter, "", T("any (show all)").ToString())
@foreach(var filterOption in Model.Options.FilterOptions) {
@Html.SelectOption((String)Model.Options.SelectedFilter, (string)filterOption.Key, (string)filterOption.Value)
}
</select>
<label for="orderResults" class="bulk-order">@T("Ordered by")</label>
<select id="orderResults" name="@{/*Html.NameOf(m => m.Options.OrderBy)*/}">
@//Html.SelectOption(Model.Options.OrderBy, ContentsOrder.Created, T("recently created").ToString())
@//Html.SelectOption(Model.Options.OrderBy, ContentsOrder.Modified, T("recently modified").ToString())
<select id="orderResults" name="Options.OrderBy">
@Html.SelectOption((ContentsOrder)Model.Options.OrderBy, ContentsOrder.Created, T("recently created").ToString())
@Html.SelectOption((ContentsOrder)Model.Options.OrderBy, ContentsOrder.Modified, T("recently modified").ToString())
</select>
<button type="submit" name="submit.Filter" value="yes please">@T("Apply")</button>
</fieldset>
<fieldset class="contentItems bulk-items">
@Display(Model)
@Display(Model.ContentItems)
</fieldset>
}

View File

@@ -1 +0,0 @@
content item -> @Model.ContentType

View File

@@ -0,0 +1,3 @@
content item -> @Model.ContentItem.ContentType
@Display(Model.primary)

View File

@@ -1,32 +1,47 @@
using System.Web.Mvc;
using Orchard.ContentManagement;
using Orchard.Core.Common.Models;
using Orchard.DisplayManagement;
using Orchard.Security;
namespace Orchard.Core.Dashboard.Controllers {
public class AdminController : Controller {
private readonly IShapeHelperFactory _shapeHelperFactory;
private readonly IContentManager _contentManager;
public AdminController(IShapeHelperFactory shapeHelperFactory) {
public AdminController(IShapeHelperFactory shapeHelperFactory, IContentManager contentManager) {
_shapeHelperFactory = shapeHelperFactory;
_contentManager = contentManager;
}
public virtual IUser CurrentUser { get; set; }
public ActionResult Index() {
var shape = _shapeHelperFactory.CreateHelper();
var list = shape.List();
var list2 = shape.List();
list.Id = "the-list";
list.Classes.Add("foo");
list.Attributes["onclick"] = "etc";
list.ItemClasses.Add("yarg");
list.Add(_contentManager.BuildDisplayModel(CurrentUser, "Detail"));
foreach (var contentItem in _contentManager.Query().Join<BodyPartRecord>().List()) {
list.Add(_contentManager.BuildDisplayModel(contentItem, "Summary"));
}
list.Add("one");
list.Add("two");
list.Add(list2);
list.Add(shape.DumpShapeTable());
list.Add("four");
//
//var list2 = shape.List();
list2.Add("three a");
list2.Add("three b");
//list.Id = "the-list";
//list.Classes.Add("foo");
//list.Attributes["onclick"] = "etc";
//list.ItemClasses.Add("yarg");
//list.Add("one");
//list.Add("two");
//list.Add(list2);
//list.Add(shape.DumpShapeTable());
//list.Add("four");
//list2.Add("three a");
//list2.Add("three b");)))
return View(list);
}

View File

@@ -4,4 +4,4 @@
<p><%: T("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><%: T("Have fun!") %><br /><%: T("The Orchard Team") %></p>
<%:Display(Model) %>
<div style="border:1px solid black;" role="experimentation"><%:Display(Model) %></div>

View File

@@ -399,13 +399,12 @@
<Content Include="PublishLater\Views\Web.config" />
<Content Include="ContentsLocation\Views\Web.config" />
<Content Include="Messaging\Views\Web.config" />
<None Include="Contents\Views\Content.cshtml" />
<None Include="Contents\Views\Items\Content.cshtml" />
<None Include="Contents\Views\Item\Display.cshtml" />
<None Include="HomePage\Views\HomePage.cshtml" />
<None Include="Shapes\Views\Document.cshtml" />
<None Include="Shapes\Views\User.cshtml" />
<None Include="Shapes\Views\Header.cshtml" />
<None Include="Shapes\Views\Item.cshtml" />
<None Include="Shapes\Views\Layout.cshtml" />
<None Include="Shapes\Views\Menu.ascx_" />
<None Include="Shapes\Views\Menu.cshtml" />

View File

@@ -1,4 +1,5 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -7,6 +8,7 @@ using System.Web.Mvc;
using System.Web.Mvc.Html;
using Orchard.DisplayManagement;
using Orchard.DisplayManagement.Descriptors;
using Orchard.DisplayManagement.Shapes;
using Orchard.Environment.Extensions.Models;
using Orchard.UI;
using Orchard.UI.Zones;
@@ -21,8 +23,15 @@ namespace Orchard.Core.Shapes {
// the root page shape named 'Layout' is wrapped with 'Document'
// and has an automatic zone creating behavior
builder.Describe.Named("Layout").From(Feature.Descriptor)
.Configure(descriptor => descriptor.Wrappers.Add("Document"))
.OnCreating(creating => creating.Behaviors.Add(new ZoneHoldingBehavior(creating.ShapeFactory)))
.Configure(descriptor => descriptor.Wrappers.Add("Document"));
.OnCreated(created => {
created.Shape.Zones.Content.Add(created.New.PlaceChildContent(Source: created.Shape), "5");
created.Shape.Zones.Body.Add(created.New.PlaceChildContent(Source: created.Shape), "5");
});
builder.Describe.Named("Items_Content").From(Feature.Descriptor)
.OnCreating(creating => creating.Behaviors.Add(new ZoneHoldingBehavior(creating.ShapeFactory)));
// 'Zone' shapes are built on the Zone base class
builder.Describe.Named("Zone").From(Feature.Descriptor)
@@ -31,18 +40,16 @@ namespace Orchard.Core.Shapes {
// 'List' shapes start with several empty collections
builder.Describe.Named("List").From(Feature.Descriptor)
.OnCreated(created => {
created.Shape.Tag = "ol";
created.Shape.Tag = "ul";
created.Shape.Classes = new List<string>();
created.Shape.Attributes = new Dictionary<string, string>();
created.Shape.ItemClasses = new List<string>();
created.Shape.ItemAttributes = new Dictionary<string, string>();
});
}
static object DetermineModel(HtmlHelper Html, object Model) {
bool isNull = ((dynamic)Model) == null;
return isNull ? Html.ViewData.Model : Model;
}
static TagBuilder GetTagBuilder(string tagName, string id, IEnumerable<string> classes, IDictionary<string, string> attributes) {
var tagBuilder = new TagBuilder(tagName);
@@ -66,7 +73,7 @@ namespace Orchard.Core.Shapes {
IEnumerable<string> ItemClasses,
IDictionary<string, string> ItemAttributes) {
var listTagName = string.IsNullOrEmpty(Tag) ? "ol" : Tag;
var listTagName = string.IsNullOrEmpty(Tag) ? "ul" : Tag;
const string itemTagName = "li";
var listTag = GetTagBuilder(listTagName, Id, Classes, Attributes);
@@ -90,20 +97,53 @@ namespace Orchard.Core.Shapes {
Output.Write(listTag.ToString(TagRenderMode.EndTag));
}
[Shape]
public IHtmlString Partial(HtmlHelper Html, string TemplateName, object Model) {
return Html.Partial(TemplateName, DetermineModel(Html, Model));
public IHtmlString PlaceChildContent(dynamic Source) {
return Source.Metadata.ChildContent;
}
[Shape]
public IHtmlString DisplayTemplate(HtmlHelper Html, string TemplateName, object Model, string Prefix) {
return Html.Partial(TemplateName, DetermineModel(Html, Model));
public void Partial(HtmlHelper Html, TextWriter Output, string TemplateName, object Model) {
RenderInternal(Html, Output, TemplateName, Model, null);
}
[Shape]
public IHtmlString EditorTemplate(HtmlHelper Html, string TemplateName, object Model, string Prefix) {
return Html.Partial(TemplateName, DetermineModel(Html, Model));
public void DisplayTemplate(HtmlHelper Html, TextWriter Output, string TemplateName, object Model, string Prefix) {
RenderInternal(Html, Output, "DisplayTemplates/" + TemplateName, Model, Prefix);
}
[Shape]
public void EditorTemplate(HtmlHelper Html, TextWriter Output, string TemplateName, object Model, string Prefix) {
RenderInternal(Html, Output, "EditorTemplates/" + TemplateName, Model, Prefix);
}
static void RenderInternal(HtmlHelper Html, TextWriter Output, string TemplateName, object Model, string Prefix) {
var adjustedViewData = new ViewDataDictionary(Html.ViewDataContainer.ViewData) {
Model = DetermineModel(Html, Model),
TemplateInfo = new TemplateInfo {
HtmlFieldPrefix = DeterminePrefix(Html, Prefix)
}
};
var adjustedViewContext = new ViewContext(Html.ViewContext, Html.ViewContext.View, adjustedViewData, Html.ViewContext.TempData, Output);
var adjustedHtml = new HtmlHelper(adjustedViewContext, new ViewDataContainer(adjustedViewData));
adjustedHtml.RenderPartial(TemplateName);
}
static object DetermineModel(HtmlHelper Html, object Model) {
bool isNull = ((dynamic)Model) == null;
return isNull ? Html.ViewData.Model : Model;
}
static string DeterminePrefix(HtmlHelper Html, string Prefix) {
var actualPrefix = string.IsNullOrEmpty(Prefix)
? Html.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix
: Html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(Prefix);
return actualPrefix;
}
private class ViewDataContainer : IViewDataContainer {
public ViewDataContainer(ViewDataDictionary viewData) { ViewData = viewData; }
public ViewDataDictionary ViewData { get; set; }
}
}

View File

@@ -15,7 +15,6 @@
<script>(function(d){d.className="dyn "+d.className.substring(7,d.length);})(document.documentElement);</script>
</head>
<body>
@{ Model.Body.Add(Model.Metadata.ChildContent, "5"); }
@Display(Model.Body)
</body>
</html>

View File

@@ -1,2 +0,0 @@
<h3>Content item placeholder</h3>
<p>This file will be relocated and specialized</p>

View File

@@ -1,20 +1,17 @@
@// Html.RegisterStyle("site.css");
<div id="page">
<div id="header">
@{
Model.Header.Add(Display.Header(), "5");
Model.Header.Add(Display.User(), "10");
Model.Menu.Add(Display.Menu(), "5");
Model.Header.Add(Model.Navigation, "15");
}
<div id="page">
<!-- should be a header wrapper (and what about a wrapper for the default layout?) -->
<header>
@Display(Model.Header)
@Display(Model.Menu)
</div>
</header>
<div id="main">
<div id="content-wrapper">
<div id="content">
@{
Model.Content.Add(Model.Metadata.ChildContent, "5");
}
@Display(Model.Content)
</div>
</div>
@@ -24,12 +21,10 @@
</div>
</div>
</div>
<!-- should really be a footer wrapper -->
<div id="footer-wrapper">
<div id="footer">
@{
Model.Footer.Add(Display.Footer(), "5");
}
<footer>
@Display(Model.Footer)
</div>
</footer>
</div>
</div>

View File

@@ -128,7 +128,6 @@
<None Include="Views\Home\FormShapes.cshtml" />
<None Include="Views\Home\UsingShapes.cshtml" />
<None Include="Views\Inventory\ShapeTable.cshtml" />
<None Include="Views\Rounded.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />

View File

@@ -1,6 +0,0 @@
<div class="rounded">
@model dynamic
<p>above</p>
@Display(Model.Contents)
<p>below</p>
</div>

View File

@@ -14,6 +14,7 @@ using Orchard.Data.Providers;
using Orchard.Data.Migration;
using Orchard.DisplayManagement;
using Orchard.DisplayManagement.Descriptors;
using Orchard.DisplayManagement.Descriptors.ShapeAttributeStrategy;
using Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy;
using Orchard.DisplayManagement.Implementation;
using Orchard.DisplayManagement.Shapes;
@@ -80,9 +81,11 @@ namespace Orchard.Setup {
builder.RegisterType<ConfiguredEnginesCache>().As<IConfiguredEnginesCache>();
builder.RegisterType<PageWorkContext>().As<IWorkContextStateProvider>();
builder.RegisterType<CoreShapes>().As<IShapeDescriptorBindingStrategy>().WithProperty("Feature", Feature);
builder.RegisterType<CoreShapes>().As<IShapeDescriptorBindingStrategy>().WithProperty("Feature", Feature).WithMetadata("Feature", Feature);
builder.RegisterType<ShapeTemplateBindingStrategy>().As<IShapeDescriptorBindingStrategy>();
builder.RegisterType<BasicShapeTemplateHarvester>().As<IShapeTemplateHarvester>();
builder.RegisterType<ShapeAttributeBindingStrategy>().As<IShapeDescriptorBindingStrategy>();
builder.RegisterModule(new ShapeAttributeBindingModule());
}

View File

@@ -315,7 +315,6 @@
<Content Include="Themes\TheAdmin\Views\User.ascx" />
<Content Include="Themes\TheAdmin\Views\Header.ascx" />
<Content Include="Themes\Web.config" />
<None Include="Themes\TheAdmin\Views\Message.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />

View File

@@ -6,7 +6,6 @@
Model.Header.Add(New.Header());
Model.Header.Add(New.Footer());
Model.Content.Add(Model.Metadata.ChildContent, "5");
%>
<div id="container">

View File

@@ -13,7 +13,6 @@
<script type="text/javascript">document.documentElement.className="dyn";</script>
</head>
<body class="<%: Html.ClassForPage() %>">
<% Model.Body.Add(Model.Metadata.ChildContent, "5"); %>
<%: Display(Model.Body) %>
</body>
</html>

View File

@@ -23,6 +23,5 @@
</div>
</div>
<div id="main">
<% Model.Content.Add(Model.Metadata.ChildContent, "5"); %>
<%: Display(Model.Content) %>
</div>

View File

@@ -4,8 +4,6 @@
<%@ Import Namespace="Orchard" %>
<%@ Import Namespace="Orchard.ContentManagement" %>
<%
Model.Content.Add(Model.Metadata.ChildContent, "5");
// these are just hacked together to fire existing partials... can change
Model.Header.Add(Display.Header());
@@ -13,11 +11,6 @@
var thisUser = Html.Resolve<IAuthenticationService>().GetAuthenticatedUser();
Model.Header.Add(Display.User(CurrentUser: thisUser), "after");
Model.CurrentUser = thisUser;
Model.Header.Add(Display.Partial(TemplateName: "User"), "after");
var userDetail = Html.Resolve<IContentManager>().BuildDisplayModel(thisUser, "Detail");
Model.Content.Add(userDetail);
// </experimentation>
Html.RegisterStyle("site.css", "1");

View File

@@ -370,7 +370,7 @@ namespace Orchard.ContentManagement {
public dynamic BuildDisplayModel<TContent>(TContent content, string displayType) where TContent : IContent {
var shapeHelper = _shapeHelperFactory.CreateHelper();
var itemShape = shapeHelper.Item(ContentItem:content.ContentItem);
var itemShape = shapeHelper.Items_Content(ContentItem:content.ContentItem);
var context = new BuildDisplayModelContext(content, displayType, itemShape, _shapeHelperFactory);
Handlers.Invoke(handler => handler.BuildDisplayShape(context), Logger);
return context.Model;
@@ -378,7 +378,7 @@ namespace Orchard.ContentManagement {
public dynamic BuildEditorModel<TContent>(TContent content) where TContent : IContent {
var shapeHelper = _shapeHelperFactory.CreateHelper();
var itemShape = shapeHelper.Item(ContentItem:content.ContentItem);
var itemShape = shapeHelper.Items_Content(ContentItem: content.ContentItem);
var context = new BuildEditorModelContext(content, itemShape, _shapeHelperFactory);
Handlers.Invoke(handler => handler.BuildEditorShape(context), Logger);
return context.Model;
@@ -386,7 +386,7 @@ namespace Orchard.ContentManagement {
public dynamic UpdateEditorModel<TContent>(TContent content, IUpdateModel updater) where TContent : IContent {
var shapeHelper = _shapeHelperFactory.CreateHelper();
var itemShape = shapeHelper.Item(ContentItem:content.ContentItem);
var itemShape = shapeHelper.Items_Content(ContentItem: content.ContentItem);
var context = new UpdateEditorModelContext(content, updater, itemShape, _shapeHelperFactory);
Handlers.Invoke(handler => handler.UpdateEditorShape(context), Logger);
return context.Model;

View File

@@ -29,21 +29,29 @@ namespace Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy {
var lastDot = info.FileName.IndexOf('.');
if (lastDot <= 0) {
yield return new HarvestShapeHit {
ShapeType = Adjust(info.FileName)
ShapeType = Adjust(info.SubPath, info.FileName)
};
}
else {
yield return new HarvestShapeHit {
ShapeType = Adjust(info.FileName.Substring(0, lastDot)),
ShapeType = Adjust(info.SubPath, info.FileName.Substring(0, lastDot)),
DisplayType = info.FileName.Substring(lastDot + 1)
};
}
}
static string Adjust(string fileName) {
static string Adjust(string subPath, string fileName) {
var leader="";
if (subPath.StartsWith("Views/")) {
leader = subPath.Substring("Views/".Length) + "_";
}
if (leader == "Items_" && !fileName.StartsWith("Content")) {
leader = "Items_Content__";
}
// canonical shape type names must not have - or . to be compatible
// with display and shape api calls
return fileName.Replace('-', '_').Replace('.', '_');
// with display and shape api calls)))
return leader + fileName.Replace("--", "__").Replace("-", "__").Replace('.', '_');
}
}

View File

@@ -1,4 +1,5 @@
using ClaySharp;
using ClaySharp.Implementation;
namespace Orchard.DisplayManagement {
/// <summary>
@@ -8,4 +9,10 @@ namespace Orchard.DisplayManagement {
public interface IShapeFactory : IDependency {
IShape Create(string shapeType, INamedEnumerable<object> parameters);
}
public static class ShapeFactoryExtensions {
public static IShape Create(this IShapeFactory factory, string shapeType) {
return factory.Create(shapeType, Arguments.Empty());
}
}
}

View File

@@ -18,6 +18,7 @@ namespace Orchard.DisplayManagement.Implementation {
public class ShapeCreatingContext {
public IShapeFactory ShapeFactory { get; set; }
public dynamic New { get; set; }
public string ShapeType { get; set; }
public Type BaseType { get; set; }
public IList<IClayBehavior> Behaviors { get; set; }
@@ -26,6 +27,7 @@ namespace Orchard.DisplayManagement.Implementation {
public class ShapeCreatedContext {
public IShapeFactory ShapeFactory { get; set; }
public dynamic New { get; set; }
public string ShapeType { get; set; }
public dynamic Shape { get; set; }
}
@@ -35,10 +37,15 @@ namespace Orchard.DisplayManagement.Implementation {
public class DefaultShapeFactory : IShapeFactory {
private readonly IEnumerable<Lazy<IShapeFactoryEvents>> _events;
private readonly IShapeTableManager _shapeTableManager;
private readonly Lazy<IShapeHelperFactory> _shapeHelperFactory;
public DefaultShapeFactory(IEnumerable<Lazy<IShapeFactoryEvents>> events, IShapeTableManager shapeTableManager) {
public DefaultShapeFactory(
IEnumerable<Lazy<IShapeFactoryEvents>> events,
IShapeTableManager shapeTableManager,
Lazy<IShapeHelperFactory> shapeHelperFactory) {
_events = events;
_shapeTableManager = shapeTableManager;
_shapeHelperFactory = shapeHelperFactory;
}
public IShape Create(string shapeType, INamedEnumerable<object> parameters) {
@@ -47,7 +54,8 @@ namespace Orchard.DisplayManagement.Implementation {
defaultShapeTable.Descriptors.TryGetValue(shapeType, out shapeDescriptor);
var creatingContext = new ShapeCreatingContext {
ShapeFactory = this,
New = _shapeHelperFactory.Value.CreateHelper(),
ShapeFactory=this,
ShapeType = shapeType,
OnCreated = new List<Action<ShapeCreatedContext>>()
};
@@ -93,7 +101,7 @@ namespace Orchard.DisplayManagement.Implementation {
// create the new instance
var createdContext = new ShapeCreatedContext {
ShapeFactory = this,
New = creatingContext.New,
ShapeType = creatingContext.ShapeType,
Shape = ClayActivator.CreateInstance(creatingContext.BaseType, creatingContext.Behaviors)
};

View File

@@ -1,7 +1,5 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Microsoft.WebPages;
namespace Orchard.DisplayManagement.Shapes {
public class Shape : IShape, IEnumerable {
@@ -26,6 +24,11 @@ namespace Orchard.DisplayManagement.Shapes {
return this;
}
public virtual Shape AddRange(IEnumerable<object> items) {
((List<object>)_items).AddRange(items);
return this;
}
public virtual IEnumerator GetEnumerator() {
return _items.GetEnumerator();
}

View File

@@ -6,35 +6,52 @@ WorkContext.Page == Layout shape
==shapes==
.Id
.Classes
.Attributes
Document [:Layout]
Layout
- Zones (meta-property)
- Title
Layout (.Wrappers[Document])
.Zones (meta-property)
.Title
Zone
-ZoneName
.ZoneName
Menu
-MenuName
.MenuName
MenuItem
-Text
-Href
-RouteValues
-Item
Menu
MenuItem
-Item (clr object)
List: ul|ol + li*
-Items (meta-property, bound to shape children or passed in)
.Items (meta-property, bound to shape children or passed in)
.Id
.Classes
.Attributes
.ItemClasses
.ItemAttributes
Items_Content
.Zones (meta-property)
.ContentItem (clr object)
PlaceChildContent
.Source (another shape, presumed rendered)
Partial
.TemplateName
.Model (optional - default use current)
DisplayTemplate
.TemplateName
.Model (optional - default use current)
.Prefix (optional - default use current)
EditorTemplate
.TemplateName
.Model (optional - default use current)
.Prefix (optional - default use current)
Pager
-CurrentPage
@@ -42,34 +59,11 @@ Pager
-Count
?PageSize ?? 1
Shape.Pager(CurrentPage:page, PageSize:10, ItemCount:53)
Shape.Pager(CurrentPage:page, PageCount:6)
Shape.Pager(CurrentPage:page)
x
y
z
List
x
y
z
Items_Content
Items_Content__BlogPost
Items_Content__Page
Items_Content__Product
Parts/Content
Fields/Content
.Items_Content()
.Items_Widget()
.Items_User()
==template discovery strategy==
Items/Content.cshtml -> "Items_Content"
Items/Content-Page.cshtml -> "Items_Content__Page"