mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixing some issues that showed up in testing
Built-in zones need to be created with names Binding and shape dictionary is now compare-ordinal-case-insensive ZoneName is quirky - because it is an actual property some of the inline assignment mechanisms don't work as expected. Main content area is salmon --HG-- branch : dev
This commit is contained in:
@@ -18,8 +18,8 @@ namespace Orchard.Tests.DisplayManagement {
|
||||
|
||||
protected override void Register(Autofac.ContainerBuilder builder) {
|
||||
_defaultShapeTable = new ShapeTable {
|
||||
Descriptors = new Dictionary<string, ShapeDescriptor>(),
|
||||
Bindings = new Dictionary<string, ShapeBinding>()
|
||||
Descriptors = new Dictionary<string, ShapeDescriptor>(StringComparer.OrdinalIgnoreCase),
|
||||
Bindings = new Dictionary<string, ShapeBinding>(StringComparer.OrdinalIgnoreCase)
|
||||
};
|
||||
_workContext = new TestWorkContext {
|
||||
CurrentTheme = new Theme { ThemeName = "Hello" }
|
||||
@@ -322,5 +322,26 @@ namespace Orchard.Tests.DisplayManagement {
|
||||
Assert.That(resultNormally.ToString(), Is.EqualTo("alpha"));
|
||||
Assert.That(resultWithOverride.ToString(), Is.EqualTo("beta"));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ShapeTypeAndBindingNamesAreNotCaseSensitive() {
|
||||
var displayManager = _container.Resolve<IDisplayManager>();
|
||||
|
||||
var shapeFoo = new Shape {
|
||||
Metadata = new ShapeMetadata {
|
||||
Type = "foo"
|
||||
}
|
||||
};
|
||||
var descriptorFoo = new ShapeDescriptor {
|
||||
ShapeType = "Foo",
|
||||
};
|
||||
AddBinding(descriptorFoo, "Foo", ctx => new HtmlString("alpha"));
|
||||
AddShapeDescriptor(descriptorFoo);
|
||||
|
||||
var result = displayManager.Execute(CreateDisplayContext(shapeFoo));
|
||||
|
||||
Assert.That(result.ToString(), Is.EqualTo("alpha"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,12 +36,14 @@ namespace Orchard.Core.Shapes {
|
||||
.OnCreating(creating => creating.Behaviors.Add(new ZoneHoldingBehavior(name => CreateZone(creating, name))))
|
||||
.OnCreated(created => {
|
||||
var layout = created.Shape;
|
||||
layout.Head = created.New.DocumentZone();
|
||||
layout.Body = created.New.DocumentZone();
|
||||
layout.Tail = created.New.DocumentZone();
|
||||
layout.Content = created.New.Zone();
|
||||
layout.Head = created.New.DocumentZone(ZoneName: "Head");
|
||||
layout.Body = created.New.DocumentZone(ZoneName: "Body");
|
||||
layout.Tail = created.New.DocumentZone(ZoneName: "Tail");
|
||||
|
||||
layout.Body.Add(created.New.PlaceChildContent(Source: layout));
|
||||
|
||||
layout.Content = created.New.Zone();
|
||||
layout.Content.ZoneName = "Content";
|
||||
layout.Content.Add(created.New.PlaceChildContent(Source: layout));
|
||||
});
|
||||
|
||||
@@ -51,7 +53,7 @@ namespace Orchard.Core.Shapes {
|
||||
builder.Describe("Zone")
|
||||
.OnCreating(creating => creating.BaseType = typeof(Zone))
|
||||
.OnDisplaying(displaying => {
|
||||
var zone = displaying.Shape;
|
||||
var zone = displaying.Shape;
|
||||
zone.Classes.Add("zone-" + zone.ZoneName.ToLower());
|
||||
zone.Classes.Add("zone");
|
||||
zone.Metadata.Alternates.Add("Zone__" + zone.ZoneName);
|
||||
@@ -67,8 +69,9 @@ namespace Orchard.Core.Shapes {
|
||||
|
||||
builder.Describe("MenuItem")
|
||||
.OnDisplaying(displaying => {
|
||||
var menu = displaying.Shape.Menu;
|
||||
menu.Metadata.Alternates.Add("MenuItem__" + menu.MenuName);
|
||||
var menuItem = displaying.Shape;
|
||||
var menu = menuItem.Menu;
|
||||
menuItem.Metadata.Alternates.Add("MenuItem__" + menu.MenuName);
|
||||
});
|
||||
|
||||
// 'List' shapes start with several empty collections
|
||||
|
@@ -142,7 +142,7 @@
|
||||
<None Include="Themes\Classic\Views\Menu-Main.cshtml">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="Themes\Classic\Views\Zone-Navigation.cshtml" />
|
||||
<None Include="Themes\Classic\Views\Zone-Content.cshtml" />
|
||||
<None Include="Themes\TheThemeMachine\Views\TempFeatured.cshtml">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
|
@@ -2,9 +2,9 @@
|
||||
// Model is Model.Menu from the layout (Layout.Menu)
|
||||
var tag = Tag(Model, "ul");
|
||||
}
|
||||
<nav>2
|
||||
[@tag.StartElement
|
||||
<nav>
|
||||
@tag.StartElement
|
||||
@* see MenuItem shape template *@
|
||||
@DisplayChildren(Model)
|
||||
@tag.EndElement]
|
||||
[@DisplayChildren(Model)]
|
||||
@tag.EndElement
|
||||
</nav>
|
7
src/Orchard.Web/Themes/Classic/Views/Zone-Content.cshtml
Normal file
7
src/Orchard.Web/Themes/Classic/Views/Zone-Content.cshtml
Normal file
@@ -0,0 +1,7 @@
|
||||
@{
|
||||
Model.Attributes.Add("style", "background:salmon;");
|
||||
var tag = Tag(Model, "div");
|
||||
}
|
||||
@tag.StartElement
|
||||
@DisplayChildren(Model)
|
||||
@tag.EndElement
|
@@ -1,6 +0,0 @@
|
||||
@{
|
||||
var tag = Tag(Model, "div");
|
||||
}
|
||||
@tag.StartElement
|
||||
@DisplayChildren(Model)
|
||||
@tag.EndElement
|
@@ -32,7 +32,7 @@ namespace Orchard.DisplayManagement.Descriptors {
|
||||
var alterations = builderFactory.BuildAlterations()
|
||||
.Where(alteration => IsModuleOrRequestedTheme(alteration, themeName));
|
||||
|
||||
var descriptors = alterations.GroupBy(alteration => alteration.ShapeType)
|
||||
var descriptors = alterations.GroupBy(alteration => alteration.ShapeType, StringComparer.OrdinalIgnoreCase)
|
||||
.Select(group => group.Aggregate(
|
||||
new ShapeDescriptor { ShapeType = group.Key },
|
||||
(descriptor, alteration) => {
|
||||
@@ -41,8 +41,8 @@ namespace Orchard.DisplayManagement.Descriptors {
|
||||
}));
|
||||
|
||||
return new ShapeTable {
|
||||
Descriptors = descriptors.ToDictionary(sd => sd.ShapeType),
|
||||
Bindings = descriptors.SelectMany(sd => sd.Bindings).ToDictionary(kv => kv.Key, kv => kv.Value),
|
||||
Descriptors = descriptors.ToDictionary(sd => sd.ShapeType, StringComparer.OrdinalIgnoreCase),
|
||||
Bindings = descriptors.SelectMany(sd => sd.Bindings).ToDictionary(kv => kv.Key, kv => kv.Value, StringComparer.OrdinalIgnoreCase),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user