mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Adding some sophistication to rendering
Doing some work with Zone, MenuItem, Menu shapes Adjusting some shape usage in the TheAdmin theme --HG-- branch : theming
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<AdminViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %>
|
||||
|
||||
<h1><%: Html.TitleForPage(T("Welcome to Orchard").ToString())%></h1>
|
||||
<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>
|
||||
|
@@ -130,6 +130,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Views\Document.cshtml" />
|
||||
<None Include="Views\Zone.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
|
@@ -1,4 +1,8 @@
|
||||
@using Orchard.Mvc.Html
|
||||
@{
|
||||
Model.Body.Add(Model.Metadata.ChildContent, "5");
|
||||
}
|
||||
|
||||
<!DOCTYPE html>
|
||||
@//"en" needs to change to the current culture, btw
|
||||
@//all inline styles for tmp reference only
|
||||
@@ -18,7 +22,7 @@
|
||||
<body class="@Html.ClassForPage()">
|
||||
<section>
|
||||
<h1>document template</h1>
|
||||
@Html.RenderOrchardBody()
|
||||
@Display(Model.Body)
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
|
9
src/Orchard.Web/Modules/Orchard.Themes/Views/Zone.cshtml
Normal file
9
src/Orchard.Web/Modules/Orchard.Themes/Views/Zone.cshtml
Normal file
@@ -0,0 +1,9 @@
|
||||
@{
|
||||
var id = Model.Id;
|
||||
if (id == null) {
|
||||
id = (Model.Parent.Id == null ? "" : Model.Parent.Id + "-") + "Zone-" + Model.ZoneName;
|
||||
}
|
||||
}
|
||||
<div id="@id" class="Zone Zone-@Model.ZoneName">
|
||||
@foreach (var item in Model) {@Display(item)}
|
||||
</div><!-- /@id -->
|
@@ -309,7 +309,9 @@
|
||||
<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\Menu.ascx" />
|
||||
<None Include="Themes\TheAdmin\Views\MenuItem.cshtml" />
|
||||
<None Include="Themes\TheAdmin\Views\Menu.cshtml" />
|
||||
<None Include="Themes\TheAdmin\Views\Menu.ascx_" />
|
||||
<Content Include="Themes\TheAdmin\Views\User.ascx" />
|
||||
<Content Include="Themes\TheAdmin\Views\Header.ascx" />
|
||||
<Content Include="Themes\Web.config" />
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %>
|
||||
<div class="zone zone-<%:Model.ZoneName %>">
|
||||
<div class="Zone Zone-<%:Model.ZoneName %>">
|
||||
<%foreach (var item in Model) {%><%:Display(item)%><%}%>
|
||||
</div>
|
||||
</div><!-- Zone-<%:Model.ZoneName %> -->
|
||||
|
@@ -1,17 +1,19 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BaseViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%><%
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %>
|
||||
<%
|
||||
Model.Content.Add(Model.Metadata.ChildContent, "5");
|
||||
|
||||
Html.RegisterStyle("site.css", "1");
|
||||
Html.RegisterStyle("ie.css", "1").WithCondition("if (lte IE 8)").ForMedia("screen, projection");
|
||||
Html.RegisterStyle("ie6.css", "1").WithCondition("if (lte IE 6)").ForMedia("screen, projection");
|
||||
Html.RegisterFootScript("admin.js", "1");
|
||||
Model.Zones.AddRenderPartial("header", "Header", Model);
|
||||
Model.Zones.AddRenderPartial("header:after", "User", Model); // todo: (heskew) should be a user display or widget
|
||||
Model.Zones.AddRenderPartial("menu", "Menu", Model);
|
||||
//Model.Zones.AddRenderPartial("header", "Header", Model);
|
||||
//Model.Zones.AddRenderPartial("header:after", "User", Model); // todo: (heskew) should be a user display or widget
|
||||
//Model.Zones.AddRenderPartial("menu", "Menu", Model);
|
||||
%>
|
||||
<div id="header" role="banner"><% Html.Zone("header"); %></div>
|
||||
<div id="header" role="banner"><%: Display(Model.Header) %></div>
|
||||
<div id="content">
|
||||
<div id="navshortcut"><a href="#menu"><%: T("Skip to navigation") %></a></div>
|
||||
<div id="main" role="main"><% Html.ZoneBody("content"); %></div>
|
||||
<div id="menu"><% Html.Zone("menu"); %></div>
|
||||
<div id="navshortcut"><a href="#Menu-admin"><%: T("Skip to navigation") %></a></div>
|
||||
<div id="main" role="main"><%: Display(Model.Content) %></div>
|
||||
<div id="menu"><%: Display(Model.Navigation) %></div>
|
||||
</div>
|
||||
<div id="footer" role="contentinfo"><% Html.Zone("footer"); %></div>
|
||||
<div id="footer" role="contentinfo"><%: Display(Model.Footer) %></div>
|
||||
|
@@ -1,7 +1,8 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BaseViewModel>" %>
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<ul id="navigation" role="navigation">
|
||||
|
||||
<%--//todo: get the settings from the cookie to class-ify parts of the menu that should be closed on load--%>
|
||||
<%--<ul id="navigation" role="navigation">
|
||||
<%if (Model.Menu != null) {
|
||||
foreach (var menuSection in Model.Menu) {
|
||||
// todo: (heskew) need some help(er)
|
||||
@@ -29,4 +30,4 @@
|
||||
$("#navigation h3").expandoControl(function(controller) { return controller.next(); }, { key: "N42", path: "<%:ResolveUrl("~/") %>" });
|
||||
})(jQuery);
|
||||
</script>
|
||||
<% } %>
|
||||
<% } %>--%>
|
3
src/Orchard.Web/Themes/TheAdmin/Views/Menu.cshtml
Normal file
3
src/Orchard.Web/Themes/TheAdmin/Views/Menu.cshtml
Normal file
@@ -0,0 +1,3 @@
|
||||
<ul id="Menu-@Model.MenuName" class="Menu Menu-@Model.MenuName">
|
||||
@foreach(var item in Model) {@Display(item);}
|
||||
</ul><!-- /Menu-@Model.MenuName -->
|
9
src/Orchard.Web/Themes/TheAdmin/Views/MenuItem.cshtml
Normal file
9
src/Orchard.Web/Themes/TheAdmin/Views/MenuItem.cshtml
Normal file
@@ -0,0 +1,9 @@
|
||||
@{
|
||||
// odd formatting in this file is to cause more attractive results in the output.
|
||||
var items = (IEnumerable<dynamic>)Enumerable.Cast<dynamic>(Model);
|
||||
}
|
||||
<li><a href="@Model.Href">@Model.Text</a>@{ if (items.Any()) {
|
||||
<ul>
|
||||
@foreach(var item in Model) {@Display(item);}
|
||||
</ul>}}
|
||||
</li>
|
@@ -79,6 +79,10 @@ namespace Orchard.DisplayManagement.Implementation {
|
||||
}
|
||||
|
||||
private IHtmlString Process(ShapeDescriptor shapeDescriptor, IShape shape, DisplayContext context) {
|
||||
if (shapeDescriptor == null || shapeDescriptor.Binding == null) {
|
||||
//todo: create result from all child shapes
|
||||
return shape.Metadata.ChildContent ?? new HtmlString("");
|
||||
}
|
||||
return CoerceHtmlString(shapeDescriptor.Binding(context));
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,33 @@
|
||||
namespace Orchard.DisplayManagement.Shapes {
|
||||
public class Shape : IShape {
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.WebPages;
|
||||
|
||||
namespace Orchard.DisplayManagement.Shapes {
|
||||
public class Shape : IShape, IEnumerable {
|
||||
public virtual ShapeMetadata Metadata { get; set; }
|
||||
|
||||
private readonly IList<object> _items = new List<object>();
|
||||
|
||||
|
||||
public virtual Shape Add(object item) {
|
||||
_items.Add(item);
|
||||
return this;
|
||||
}
|
||||
|
||||
public virtual Shape Add(object item, string position) {
|
||||
try {
|
||||
((dynamic) item).Metadata.Position = position;
|
||||
}
|
||||
catch {
|
||||
// need to implemented positioned wrapper for non-shape objects
|
||||
}
|
||||
_items.Add(item); // not messing with position at the moment
|
||||
return this;
|
||||
}
|
||||
|
||||
public virtual IEnumerator GetEnumerator() {
|
||||
return _items.GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ namespace Orchard.Mvc.ViewEngines.Razor {
|
||||
|
||||
}
|
||||
|
||||
public abstract class WebViewPage : WebViewPage<object> {
|
||||
public abstract class WebViewPage : WebViewPage<dynamic> {
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -33,12 +33,17 @@ namespace Orchard.Mvc.ViewEngines.ThemeAwareness {
|
||||
return viewResult;
|
||||
}
|
||||
|
||||
var layoutView = new LayoutView((viewContext, writer, viewDataContainer) => {
|
||||
var buffer = new StringWriter();
|
||||
var layoutView = new LayoutView((viewContext, writer, viewDataContainer) => {
|
||||
var bufferViewContext = new ViewContext(
|
||||
viewContext,
|
||||
viewContext.View,
|
||||
viewContext.ViewData,
|
||||
viewContext.TempData,
|
||||
new StringWriter());
|
||||
|
||||
viewResult.View.Render(viewContext, buffer);
|
||||
viewResult.View.Render(bufferViewContext, bufferViewContext.Writer);
|
||||
|
||||
_workContext.Page.Metadata.ChildContent = new HtmlString(buffer.ToString());
|
||||
_workContext.Page.Metadata.ChildContent = new HtmlString(bufferViewContext.Writer.ToString());
|
||||
|
||||
var display = _displayHelperFactory.CreateHelper(viewContext, viewDataContainer);
|
||||
IHtmlString result = display(_workContext.Page);
|
||||
|
@@ -27,45 +27,21 @@ namespace Orchard.UI {
|
||||
|
||||
public interface IZone : IEnumerable {
|
||||
string ZoneName { get; set; }
|
||||
IZone Add(object item);
|
||||
IZone Add(object item, string position);
|
||||
Shape Add(object item);
|
||||
Shape Add(object item, string position);
|
||||
IZone Add(Action<HtmlHelper> action);
|
||||
IZone Add(Action<HtmlHelper> action, string position);
|
||||
}
|
||||
|
||||
public class Zone : Shape, IZone {
|
||||
private readonly IList<object> _items = new List<object>();
|
||||
|
||||
public virtual string ZoneName { get; set; }
|
||||
|
||||
public virtual IZone Add(object item) {
|
||||
_items.Add(item);
|
||||
return this;
|
||||
public IZone Add(Action<HtmlHelper> action) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public virtual IZone Add(object item, string position) {
|
||||
_items.Add(item); // not messing with position at the moment
|
||||
return this;
|
||||
}
|
||||
|
||||
public virtual IZone Add(Action<HtmlHelper> action) {
|
||||
//throw new NotImplementedException();
|
||||
return this;
|
||||
}
|
||||
|
||||
public virtual IZone Add(Action<HtmlHelper> action, string position) {
|
||||
//throw new NotImplementedException();
|
||||
return this;
|
||||
}
|
||||
|
||||
public virtual IList<object> Items {
|
||||
get {
|
||||
return _items;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IEnumerator GetEnumerator() {
|
||||
return _items.GetEnumerator();
|
||||
public IZone Add(Action<HtmlHelper> action, string position) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,6 @@
|
||||
using System.Web.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Mvc.Filters;
|
||||
using Orchard.UI.Admin;
|
||||
@@ -16,17 +18,37 @@ namespace Orchard.UI.Navigation {
|
||||
}
|
||||
|
||||
public void OnResultExecuting(ResultExecutingContext filterContext) {
|
||||
#if REFACTORING
|
||||
var workContext = _workContextAccessor.GetContext(filterContext);
|
||||
var shape = _shapeHelperFactory.CreateHelper();
|
||||
|
||||
var menuName = "main";
|
||||
if (AdminFilter.IsApplied(filterContext.RequestContext))
|
||||
menuName = "admin";
|
||||
|
||||
//todo: (heskew) does the menu need to be on Page?
|
||||
var shape = _shapeHelperFactory.CreateHelper();
|
||||
_workContextAccessor.GetContext(filterContext).CurrentPage.Zones["Navigation"].Add(shape.Menu(_navigationManager.BuildMenu(menuName)));
|
||||
#endif
|
||||
var menuItems = _navigationManager.BuildMenu(menuName);
|
||||
|
||||
var menuShape = shape.Menu().MenuName(menuName);
|
||||
PopulateMenu(shape, menuShape, menuItems);
|
||||
|
||||
workContext.Page.Navigation.Add(menuShape);
|
||||
}
|
||||
|
||||
public void OnResultExecuted(ResultExecutedContext filterContext) {}
|
||||
private void PopulateMenu(dynamic shape, dynamic parentShape, IEnumerable<MenuItem> menuItems) {
|
||||
foreach (var menuItem in menuItems) {
|
||||
var menuItemShape = shape.MenuItem()
|
||||
.Text(menuItem.Text)
|
||||
.Href(menuItem.Href)
|
||||
.RouteValues(menuItem.RouteValues)
|
||||
.Object(menuItem);
|
||||
|
||||
if (menuItem.Items != null && menuItem.Items.Any()) {
|
||||
PopulateMenu(shape, menuItemShape, menuItem.Items);
|
||||
}
|
||||
|
||||
parentShape.Add(menuItemShape, menuItem.Position);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnResultExecuted(ResultExecutedContext filterContext) { }
|
||||
}
|
||||
}
|
@@ -94,7 +94,7 @@ namespace Orchard.UI.Zones {
|
||||
dynamic parent = _parent;
|
||||
|
||||
dynamic zone = _shapeFactory.Create("Zone", Arguments.Empty());
|
||||
zone.ZoneName = _potentialZoneName;
|
||||
zone.Parent(_parent).ZoneName(_potentialZoneName);
|
||||
parent[_potentialZoneName] = zone;
|
||||
|
||||
if (argsCount == 1)
|
||||
|
Reference in New Issue
Block a user