mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-21 03:14:10 +08:00
Adding new information in shape tracing
--HG-- branch : dev
This commit is contained in:
@@ -137,6 +137,12 @@
|
||||
<ItemGroup>
|
||||
<Content Include="web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\CommentAuthor.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\CommentMetadata.cshtml" />
|
||||
</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.
|
||||
|
@@ -46,6 +46,7 @@
|
||||
<Reference Include="System.ComponentModel.DataAnnotations">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Web.DynamicData" />
|
||||
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
@@ -86,12 +87,15 @@
|
||||
<Compile Include="Services\UrlAlternatesFactory.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\ShapeTracing.Wrapper.cshtml" />
|
||||
<Content Include="Views\ShapeTracingWrapper.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Controllers\" />
|
||||
<Folder Include="Models\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Views\ShapeTracingMeta.cshtml" />
|
||||
</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.
|
||||
|
@@ -59,7 +59,7 @@
|
||||
function bindTab(selector) {
|
||||
$('li' + selector).click(function () {
|
||||
var _this = $(this);
|
||||
|
||||
|
||||
// toggle the selected class on the tab li
|
||||
_this.parent().children('li').toggleClass('selected', false);
|
||||
_this.toggleClass('selected', true);
|
||||
|
@@ -1,9 +1,29 @@
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using System.Xml;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.DisplayManagement.Shapes;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.FileSystems.WebSite;
|
||||
using Orchard.Themes;
|
||||
|
||||
namespace Orchard.DesignerTools.Services {
|
||||
[OrchardFeature("Orchard.DesignerTools")]
|
||||
public class ShapeTracingFactory : IShapeFactoryEvents {
|
||||
public class ShapeTracingFactory : IShapeFactoryEvents, IShapeDisplayEvents {
|
||||
private readonly WorkContext _workContext;
|
||||
private readonly IShapeTableManager _shapeTableManager;
|
||||
private readonly IThemeManager _themeManager;
|
||||
private readonly IWebSiteFolder _webSiteFolder;
|
||||
|
||||
public ShapeTracingFactory(WorkContext workContext, IShapeTableManager shapeTableManager, IThemeManager themeManager, IWebSiteFolder webSiteFolder) {
|
||||
_workContext = workContext;
|
||||
_shapeTableManager = shapeTableManager;
|
||||
_themeManager = themeManager;
|
||||
_webSiteFolder = webSiteFolder;
|
||||
}
|
||||
|
||||
public void Creating(ShapeCreatingContext context) {
|
||||
}
|
||||
|
||||
@@ -12,10 +32,60 @@ namespace Orchard.DesignerTools.Services {
|
||||
&& context.ShapeType != "DocumentZone"
|
||||
&& context.ShapeType != "PlaceChildContent"
|
||||
&& context.ShapeType != "ContentZone"
|
||||
)
|
||||
{
|
||||
context.Shape.Metadata.Wrappers.Add("ShapeTracing_Wrapper");
|
||||
&& context.ShapeType != "ShapeTracingMeta") {
|
||||
|
||||
var shape = context.Shape;
|
||||
var shapeMetadata = (ShapeMetadata)context.Shape.Metadata;
|
||||
|
||||
var currentTheme = _themeManager.GetRequestTheme(_workContext.HttpContext.Request.RequestContext);
|
||||
|
||||
var shapeTable = _shapeTableManager.GetShapeTable(currentTheme.Id);
|
||||
|
||||
if(!shapeTable.Descriptors.ContainsKey(shapeMetadata.Type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var descriptor = shapeTable.Descriptors[shapeMetadata.Type];
|
||||
|
||||
shapeMetadata.Wrappers.Add("ShapeTracingWrapper");
|
||||
|
||||
shape.Definition = descriptor.BindingSource;
|
||||
|
||||
try {
|
||||
if (_webSiteFolder.FileExists(descriptor.BindingSource)) {
|
||||
shape.DefinitionContent = _webSiteFolder.ReadFile(descriptor.BindingSource);
|
||||
}
|
||||
}
|
||||
catch {
|
||||
// the url might be invalid in case of a code shape
|
||||
}
|
||||
|
||||
shape.Dump = DumpObject(shape);
|
||||
}
|
||||
}
|
||||
|
||||
static string DumpObject(object o) {
|
||||
var dumper = new ObjectDumper(6);
|
||||
var el = dumper.Dump(o, "Model");
|
||||
using (var sw = new StringWriter()) {
|
||||
el.WriteTo(new XmlTextWriter(sw) { Formatting = Formatting.Indented });
|
||||
return sw.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public void Displaying(ShapeDisplayingContext context) {
|
||||
var shapeMetadata = (ShapeMetadata)context.Shape.Metadata;
|
||||
|
||||
if(!shapeMetadata.Wrappers.Contains("ShapeTracingWrapper")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( shapeMetadata.PlacementSource != null && _webSiteFolder.FileExists(shapeMetadata.PlacementSource)) {
|
||||
context.Shape.PlacementContent = _webSiteFolder.ReadFile(shapeMetadata.PlacementSource);
|
||||
}
|
||||
}
|
||||
|
||||
public void Displayed(ShapeDisplayedContext context) {
|
||||
}
|
||||
}
|
||||
}
|
@@ -58,11 +58,11 @@
|
||||
font-family:Segoe;
|
||||
color:black;
|
||||
margin-top:5px;
|
||||
position:fixed;
|
||||
left: 0px;
|
||||
bottom: 0px;
|
||||
width:100%;
|
||||
position:fixed;
|
||||
z-index:999;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
.debug-zones .shapeType-Zone {
|
||||
|
@@ -1,93 +0,0 @@
|
||||
@using Orchard;
|
||||
@using Orchard.DisplayManagement.Descriptors;
|
||||
@using Orchard.DesignerTools.Services;
|
||||
@using System.Xml;
|
||||
|
||||
@{
|
||||
Script.Require("jQueryUI_Tabs");
|
||||
Script.Include("orchard-designertools-shapetracing.js");
|
||||
Style.Include("orchard-designertools-shapetracing.css");
|
||||
|
||||
var workContext = ViewContext.GetWorkContext();
|
||||
var shapeTable = workContext.Resolve<IShapeTableManager>().GetShapeTable(workContext.CurrentTheme.Id);
|
||||
var descriptor = shapeTable.Descriptors[Model.Metadata.Type];
|
||||
}
|
||||
|
||||
@functions {
|
||||
string FormatShapeFilename(string type, string themeId) {
|
||||
return "~/Themes/" + themeId + "/Views/" + type.Replace("__", "-").Replace("_", ".") + ".cshtml";
|
||||
}
|
||||
|
||||
string DumpObject(object o) {
|
||||
var dumper = new ObjectDumper(6);
|
||||
var el = dumper.Dump(o, "Model");
|
||||
using(var sw = new StringWriter()) {
|
||||
el.WriteTo(new XmlTextWriter(sw) { Formatting = Formatting.Indented });
|
||||
return sw.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<div class="shape-tracing wrapper shapeType-@Model.Metadata.Type shapeId-@Model.GetHashCode() " title="@Model.Metadata.Type">
|
||||
@Display(Model.Metadata.ChildContent)
|
||||
|
||||
<div class="shape-tracing meta shapeId-@Model.GetHashCode()" style="display:none">
|
||||
<ul class="debuggerMenu">
|
||||
<li class="shape selected first"><a href="#">Shape</a></li>
|
||||
<li class="model middle"><a href="#">Model</a></li>
|
||||
<li class="placement middle"><a href="#">Placement</a></li>
|
||||
<li class="templates middle"><a href="#">Templates</a></li>
|
||||
<li class="source middle"><a href="#">Source</a></li>
|
||||
<li class="html last"><a href="#">HTML</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="content">
|
||||
<div class="shape">
|
||||
Shape: @Model.Metadata.Type <br />
|
||||
Definition: @descriptor.BindingSource <br />
|
||||
Display Type: @(Model.Metadata.DisplayType ?? "n/a")<br />
|
||||
Position: @(Model.Metadata.Position ?? "n/a") <br />
|
||||
Placement Source: @(Model.Metadata.PlacementSource ?? "n/a") <br />
|
||||
</div>
|
||||
|
||||
<div class="model" style="display:none">
|
||||
<pre>@DumpObject((object)Model)</pre>
|
||||
</div>
|
||||
|
||||
<div class="placement" style="display:none">
|
||||
@if(Model.Metadata.PlacementSource != null) {
|
||||
// System.IO.File.ReadAllText(VirtualPathUtility.GetFileName(Model.Metadata.PlacementSource))
|
||||
}
|
||||
else {
|
||||
<div>n/a</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="templates" style="display:none">
|
||||
<div class="alternates">
|
||||
<span>Alternates</span>
|
||||
@foreach(var alternate in Model.Metadata.Alternates) {
|
||||
var formatted = @FormatShapeFilename(alternate, workContext.CurrentTheme.Id);
|
||||
<div>@formatted</div>
|
||||
}
|
||||
</div>
|
||||
<div class="wrappers">
|
||||
<span >Wrappers</span>
|
||||
@foreach(var wrapper in Model.Metadata.Wrappers) {
|
||||
if(wrapper != "ShapeTracing_Wrapper") {
|
||||
var formatted = @FormatShapeFilename(wrapper, workContext.CurrentTheme.Id);
|
||||
<div>@formatted</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="source" style="display:none">
|
||||
</div>
|
||||
|
||||
<div class="html" style="display:none">
|
||||
<pre>@HttpUtility.HtmlEncode(Display(Model.Metadata.ChildContent))</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,61 @@
|
||||
@functions {
|
||||
string FormatShapeFilename(string type, string themeId) {
|
||||
return "~/Themes/" + themeId + "/Views/" + type.Replace("__", "-").Replace("_", ".") + ".cshtml";
|
||||
}
|
||||
}
|
||||
|
||||
<div class="shape-tracing meta shapeId-@Model.ShapeId" style="display:none">
|
||||
<ul class="debuggerMenu">
|
||||
<li class="shape selected first"><a href="#">Shape</a></li>
|
||||
<li class="model middle"><a href="#">Model</a></li>
|
||||
<li class="placement middle"><a href="#">Placement</a></li>
|
||||
<li class="templates middle"><a href="#">Templates</a></li>
|
||||
<li class="source middle"><a href="#">Source</a></li>
|
||||
<li class="html last"><a href="#">HTML</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="content">
|
||||
<div class="shape">
|
||||
Shape: @Model.ShapeType <br />
|
||||
Definition: @Model.Definition <br />
|
||||
Display Type: @(Model.DisplayType ?? "n/a")<br />
|
||||
Position: @(Model.Position ?? "n/a") <br />
|
||||
Placement Source: @(Model.PlacementSource ?? "n/a") <br />
|
||||
</div>
|
||||
|
||||
<div class="model" style="display:none">
|
||||
<pre>@Model.Dump</pre>
|
||||
</div>
|
||||
|
||||
<div class="placement" style="display:none">
|
||||
<pre>@Model.PlacementContent</pre>
|
||||
</div>
|
||||
|
||||
<div class="templates" style="display:none">
|
||||
<div class="alternates">
|
||||
<span>Alternates</span>
|
||||
@foreach(var alternate in Model.Alternates) {
|
||||
var formatted = @FormatShapeFilename(alternate, WorkContext.CurrentTheme.Id);
|
||||
<div>@formatted</div>
|
||||
}
|
||||
</div>
|
||||
<div class="wrappers">
|
||||
<span >Wrappers</span>
|
||||
@foreach(var wrapper in Model.Wrappers) {
|
||||
if(wrapper != "ShapeTracing_Wrapper") {
|
||||
var formatted = @FormatShapeFilename(wrapper, WorkContext.CurrentTheme.Id);
|
||||
<div>@formatted</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="source" style="display:none">
|
||||
<pre>@Model.DefinitionContent</pre>
|
||||
</div>
|
||||
|
||||
<div class="html" style="display:none">
|
||||
<pre>@HttpUtility.HtmlEncode(Display(Model.ChildContent))</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,31 @@
|
||||
@using Orchard;
|
||||
@using Orchard.DisplayManagement.Descriptors;
|
||||
@using Orchard.DesignerTools.Services;
|
||||
@using System.Xml;
|
||||
|
||||
@{
|
||||
Script.Require("jQueryUI_Tabs");
|
||||
Script.Include("orchard-designertools-shapetracing.js");
|
||||
Style.Include("orchard-designertools-shapetracing.css");
|
||||
}
|
||||
|
||||
<div class="shape-tracing wrapper shapeType-@Model.Metadata.Type shapeId-@Model.GetHashCode() " title="@Model.Metadata.Type">
|
||||
@Display(Model.Metadata.ChildContent)
|
||||
@{
|
||||
Layout.Zones["Tail"].Add(
|
||||
New.ShapeTracingMeta(
|
||||
ShapeType: Model.Metadata.Type,
|
||||
Definition: Model.Definition,
|
||||
DefinitionContent: Model.DefinitionContent,
|
||||
DisplayType: Model.Metadata.DisplayType,
|
||||
Position: Model.Metadata.Position,
|
||||
PlacementSource: Model.Metadata.PlacementSource,
|
||||
Dump: Model.Dump,
|
||||
PlacementContent: Model.PlacementContent,
|
||||
Alternates: Model.Metadata.Alternates,
|
||||
Wrappers: Model.Metadata.Wrappers,
|
||||
ChildContent: Model.Metadata.ChildContent,
|
||||
ShapeId: Model.GetHashCode()
|
||||
));
|
||||
}
|
||||
</div>
|
Reference in New Issue
Block a user