Midway through template refactoring. CURRENTLY BROKEN.

--HG--
extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4044388
This commit is contained in:
loudej
2009-12-21 02:42:04 +00:00
parent 8d99ca8bee
commit 40bef93bf1
24 changed files with 99 additions and 176 deletions

View File

@@ -8,7 +8,7 @@ using Orchard.Models.ViewModels;
namespace Orchard.Core.Common.Providers {
public class BodyAspectHandler : ContentHandler {
private const string TemplatePrefix = "Body";
private const string TemplateName = "BodyAspect";
private const string TemplateName = "Parts/Common.Body";
private const string DefaultTextEditorTemplate = "TinyMceTextEditor";
public BodyAspectHandler(IRepository<BodyRecord> bodyRepository) {

View File

@@ -102,7 +102,7 @@ namespace Orchard.Core.Common.Providers {
if (instance.Owner != null)
viewModel.Owner = instance.Owner.UserName;
context.AddEditor(new TemplateViewModel(viewModel, "CommonAspect") { Position = "9" });
context.AddEditor(new TemplateViewModel(viewModel, "CommonAspect") { TemplateName="Parts/Common.Owner", Position = "9" });
}
@@ -132,7 +132,7 @@ namespace Orchard.Core.Common.Providers {
instance.Owner = newOwner;
}
}
context.AddEditor(new TemplateViewModel(viewModel, "CommonAspect") { Position = "9" });
context.AddEditor(new TemplateViewModel(viewModel, "CommonAspect") { TemplateName = "Parts/Common.Owner", Position = "9" });
}
}
}

View File

@@ -127,7 +127,6 @@
<Content Include="Settings\Views\Web.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Settings\Views\Admin\EditorTemplates\SettingsIndexViewModel.ascx" />
<Content Include="XmlRpc\Views\Web.config" />
</ItemGroup>
<ItemGroup>
@@ -136,9 +135,9 @@
<Content Include="Themes\Views\Admin\Index.aspx" />
</ItemGroup>
<ItemGroup>
<Content Include="Common\Views\Shared\DisplayTemplates\BodyAspect.ascx" />
<Content Include="Common\Views\Shared\EditorTemplates\BodyAspect.ascx" />
<Content Include="Common\Views\Shared\EditorTemplates\OwnerEditorViewModel.ascx" />
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.ascx" />
<Content Include="Common\Views\EditorTemplates\Parts\Common.Body.ascx" />
<Content Include="Common\Views\EditorTemplates\Parts\Common.Owner.ascx" />
<Content Include="Themes\Styles\site.css" />
<Content Include="Themes\Views\Admin\Install.aspx" />
<Content Include="Themes\Views\document.aspx" />

View File

@@ -1,20 +0,0 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<SettingsIndexViewModel>" %>
<%@ Import Namespace="Orchard.Core.Settings.ViewModels"%>
<%@ Import Namespace="Orchard.Utility" %>
<fieldset>
<legend>Global Settings</legend>
<fieldset>
<%=Html.LabelFor(x=>x.SiteName) %>
<%=Html.EditorFor(x=>x.SiteName) %>
<%=Html.ValidationMessage("SiteName", "*") %>
</fieldset>
<fieldset>
<%=Html.LabelFor(x => x.SuperUser) %>
<%=Html.EditorFor(x=>x.SuperUser) %>
<%=Html.ValidationMessage("SuperUser", "*") %>
</fieldset>
<%=Html.EditorFor(s=>s.Id) %>
</fieldset>
<% foreach(var e in Model.EditorModel.Editors) { %>
<%=Html.EditorFor(m => e.Model, e.TemplateName, e.Prefix)%>
<% } %>

View File

@@ -71,6 +71,7 @@
<%=Html.Encode(display.Prefix)%></span>
<%=Html.Encode(display.Model.GetType().Name)%>
(<%=Html.Encode(display.Model.GetType().Namespace)%>)
Template:<%=Html.Encode(display.TemplateName ?? "(null)")%>
Prefix:<%=Html.Encode(display.Prefix ?? "(null)")%>
Zone:<%=Html.Encode(display.ZoneName ?? "(null)")%>
Position:<%=Html.Encode(display.Position ?? "(null)")%>
@@ -90,6 +91,7 @@
<%=Html.Encode(editor.Prefix) %></span>
<%=Html.Encode(editor.Model.GetType().Name) %>
(<%=Html.Encode(editor.Model.GetType().Namespace) %>)
Template:<%=Html.Encode(editor.TemplateName ?? "(null)")%>
Prefix:<%=Html.Encode(editor.Prefix ?? "(null)")%>
Zone:<%=Html.Encode(editor.ZoneName ?? "(null)")%>
Position:<%=Html.Encode(editor.Position??"(null)") %>

View File

@@ -45,7 +45,7 @@ namespace Orchard.Sandbox.Models {
});
OnGetDisplayViewModel<SandboxPage>((context, page) =>
context.AddDisplay(new TemplateViewModel(page) { TemplateName = "ContentItemTitle", ZoneName = "title" }));
context.AddDisplay(new TemplateViewModel(page) { TemplateName = "Parts/Sandbox.Page.Title", ZoneName = "title" }));

View File

@@ -79,9 +79,9 @@
<Content Include="Views\Page\Create.aspx" />
<Content Include="Views\Page\Show.aspx" />
<Content Include="Views\Page\Index.aspx" />
<Content Include="Views\Shared\DisplayTemplates\ContentItemTitle.ascx" />
<Content Include="Views\Shared\DisplayTemplates\SandboxPage.ascx" />
<Content Include="Views\Shared\DisplayTemplates\SandboxPageSummary.ascx" />
<Content Include="Views\DisplayTemplates\Parts\Sandbox.Page.Title.ascx" />
<Content Include="Views\DisplayTemplates\Items\Sandbox.Page.ascx" />
<Content Include="Views\DisplayTemplates\Items\Sandbox.Page.Summary.ascx" />
<Content Include="Views\Shared\EditorTemplates\SandboxPage.ascx" />
<Content Include="Views\Shared\EditorTemplates\SandboxSettingsRecord.ascx" />
<Content Include="Web.config" />
@@ -101,6 +101,8 @@
<Folder Include="App_Data\" />
<Folder Include="Content\" />
<Folder Include="Scripts\" />
<Folder Include="Views\EditorTemplates\" />
<Folder Include="Views\Shared\DisplayTemplates\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />

View File

@@ -2,38 +2,10 @@
<%@ Import Namespace="Orchard.Sandbox.ViewModels" %>
<%@ Import Namespace="Orchard.Mvc.Html" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TwoColumns</title>
<link href="<%=ResolveUrl("~/Content/Site2.css") %>" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header">
<div id="innerheader">
<% Html.Include("header"); %>
</div>
</div>
<div id="page">
<div id="sideBar">
<% Html.Include("Navigation"); %>
</div>
<div id="main">
<% Html.RenderPartial("Messages", Model.Messages); %>
<h3>
Create Page</h3>
<%using (Html.BeginForm()) { %>
<ul>
<li>
<%=Html.LabelFor(x => x.Name)%><%=Html.EditorFor(x => x.Name)%></li>
<li>
<input type="submit" name="submit" value="Create" /></li>
</ul>
<%=Html.LabelFor(x => x.Name)%><%=Html.EditorFor(x => x.Name)%>
<input type="submit" name="submit" value="Create" />
<%} %>
</div>
<div id="footer">
<% Html.Include("footer"); %>
</div>
</div>
</body>
</html>

View File

@@ -2,33 +2,9 @@
<%@ Import Namespace="Orchard.Sandbox.ViewModels" %>
<%@ Import Namespace="Orchard.Mvc.Html" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TwoColumns</title>
<link href="<%=ResolveUrl("~/Content/Site2.css") %>" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header">
<div id="innerheader">
<% Html.Include("header"); %>
</div>
</div>
<div id="page">
<div id="sideBar">
<% Html.Include("Navigation"); %>
</div>
<div id="main">
<% Html.RenderPartial("Messages", Model.Messages); %>
<h3>Edit Page</h3>
<h3>
Edit Page</h3>
<%using (Html.BeginForm()) { %>
<%=Html.EditorForItem(m=>m.Page) %>
<%=Html.EditorForItem(Model.Page) %>
<input type="submit" name="submit" value="Save" />
<%} %>
</div>
<div id="footer">
<% Html.Include("footer"); %>
</div>
</div>
</body>
</html>

View File

@@ -2,38 +2,10 @@
<%@ Import Namespace="Orchard.Sandbox.ViewModels" %>
<%@ Import Namespace="Orchard.Mvc.Html" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TwoColumns</title>
<link href="<%=ResolveUrl("~/Content/Site2.css") %>" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header">
<div id="innerheader">
<% Html.Include("header"); %>
</div>
</div>
<div id="page">
<div id="sideBar">
<% Html.Include("Navigation"); %>
</div>
<div id="main">
<% Html.RenderPartial("Messages", Model.Messages); %>
<h3>
Sandbox Pages</h3>
<p><%=Html.ActionLink("Create new page", "create") %></p>
<p>
<%=Html.ActionLink("Create new page", "create") %></p>
<%foreach (var item in Model.Pages) {%>
<%=Html.DisplayForItem(x=>item) %>
<%=Html.DisplayForItem(item) %>
<%}%>
</ul>
</div>
<div id="footer">
<% Html.Include("footer"); %>
</div>
</div>
</body>
</html>

View File

@@ -2,29 +2,4 @@
<%@ Import Namespace="Orchard.Sandbox.ViewModels" %>
<%@ Import Namespace="Orchard.Mvc.Html" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TwoColumns</title>
<link href="<%=ResolveUrl("~/Content/Site2.css") %>" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header">
<div id="innerheader">
<% Html.Include("header"); %>
</div>
</div>
<div id="page">
<div id="sideBar">
<% Html.Include("Navigation"); %>
</div>
<div id="main">
<% Html.RenderPartial("Messages", Model.Messages); %>
<%= Html.DisplayForItem(m => m.Page) %>
</div>
<div id="footer">
<% Html.Include("footer"); %>
</div>
</div>
</body>
</html>
<%= Html.DisplayForItem(Model.Page) %>

View File

@@ -1,16 +1,20 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<BaseViewModel>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels" %>
<%@ Import Namespace="Orchard.Mvc.Html" %>
<% Html.RegisterStyle(ResolveUrl("~/Themes/BlueSky/Styles/site.css")); %>
<div class="page">
<div id="header">
<div id="title"><h1>My MVC Application</h1></div>
<div id="title">
<h1>
My MVC Application</h1>
</div>
<%Html.Zone("header"); Html.Zone("menu"); %>
</div>
<div id="main">
<div id="messages">
<%Html.RenderPartial("messages", Model.Messages); %></div>
<%Html.Zone("content", () => Html.RenderBody());%>
<div id="footer"><%Html.Zone("footer");%></div>
<div id="footer">
<%Html.Zone("footer");%></div>
</div>
</div>

View File

@@ -37,7 +37,7 @@ namespace Orchard.Environment {
shell.Activate();
_current = shell;
ViewEngines.Engines.Insert(0, new LayoutViewEngine(null));
ViewEngines.Engines.Insert(0, LayoutViewEngine.CreateShim());
_controllerBuilder.SetControllerFactory(new OrchardControllerFactory());
ServiceLocator.SetLocator(t => _containerProvider.RequestContainer.Resolve(t));
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Web.Mvc;
using Orchard.Mvc.ViewModels;
@@ -12,11 +13,6 @@ namespace Orchard.Mvc.ViewEngines {
}
public ViewEngineResult FindPartialView(ControllerContext controllerContext, string partialViewName, bool useCache) {
var scope = Scope.From(controllerContext);
if (scope != null && scope.LayoutViewEngine != null) {
return scope.LayoutViewEngine._viewEngines.FindPartialView(controllerContext, partialViewName);
}
return new ViewEngineResult(Enumerable.Empty<string>());
}
@@ -92,6 +88,50 @@ namespace Orchard.Mvc.ViewEngines {
return (Scope)context.HttpContext.Items[typeof(Scope)];
}
}
public static IViewEngine CreateShim() {
return new Shim();
}
class Shim : IViewEngine {
public ViewEngineResult FindPartialView(ControllerContext controllerContext, string partialViewName, bool useCache) {
var scope = Scope.From(controllerContext);
if (scope != null && scope.LayoutViewEngine != null) {
var result = scope.LayoutViewEngine._viewEngines.FindPartialView(controllerContext, partialViewName);
Monitor(result, partialViewName);
return result;
}
return new ViewEngineResult(Enumerable.Empty<string>());
}
public ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache) {
var scope = Scope.From(controllerContext);
if (scope != null && scope.LayoutViewEngine != null) {
var result = scope.LayoutViewEngine._viewEngines.FindView(controllerContext, viewName, masterName);
Monitor(result, viewName);
return result;
}
return new ViewEngineResult(Enumerable.Empty<string>());
}
private static void Monitor(ViewEngineResult result, string viewName) {
if (result.View == null) {
Trace.WriteLine("Unable to find " + viewName);
foreach (var search in result.SearchedLocations) {
Trace.WriteLine(" location " + search);
}
}
}
public void ReleaseView(ControllerContext controllerContext, IView view) {
throw new NotImplementedException();
}
}
}

View File

@@ -57,11 +57,12 @@ namespace Orchard.Mvc.ViewEngines {
var requestViewEngines = new ViewEngineCollection(
themeViewEngines
.Concat(packageViewEngines)
.Concat(_viewEngines.Where(x => x.GetType().Assembly != typeof(LayoutViewEngine).Assembly))
.ToArray());
var layoutViewEngine = new LayoutViewEngine(requestViewEngines);
viewResultBase.ViewEngineCollection = new ViewEngineCollection();
viewResultBase.ViewEngineCollection = new ViewEngineCollection(_viewEngines.ToList());
viewResultBase.ViewEngineCollection.Insert(0, layoutViewEngine);
}