Converting experimental to razor.

--HG--
branch : dev
This commit is contained in:
Andre Rodrigues
2010-10-18 13:27:24 -07:00
parent 84a058ba85
commit 7a9d2ba5c3
25 changed files with 245 additions and 244 deletions

View File

@@ -7,8 +7,12 @@ using Orchard.Experimental.ViewModels;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Records;
using Orchard.DisplayManagement;
using Orchard.Themes;
using Orchard.UI.Admin;
namespace Orchard.Experimental.Controllers {
[Themed, Admin]
public class ContentController : Controller {
private readonly IRepository<ContentTypeRecord> _contentTypeRepository;
private readonly IContentManager _contentManager;
@@ -43,7 +47,7 @@ namespace Orchard.Experimental.Controllers {
model.DisplayShape = _contentManager.BuildDisplay(model.Item, "Detail");
model.EditorShape = _contentManager.BuildEditor(model.Item);
return View(Shape.Model(model));
return View(model);
}
static IEnumerable<Type> AllTypes(Type type) {

View File

@@ -9,8 +9,8 @@ using Orchard.UI.Notify;
using Orchard.UI.Admin;
namespace Orchard.Experimental.Controllers {
[Themed]
[Admin]
[Themed, Admin]
public class HomeController : Controller {
private readonly INotifier _notifier;

View File

@@ -4,9 +4,11 @@ using System.Xml;
using System.Xml.Linq;
using Orchard.ContentManagement.MetaData;
using Orchard.Experimental.ViewModels;
using Orchard.Themes;
using Orchard.UI.Admin;
namespace Orchard.Experimental.Controllers {
[ValidateInput(false)]
[ValidateInput(false), Themed, Admin]
public class MetadataController : Controller {
private readonly IContentDefinitionManager _contentDefinitionManager;
private readonly IContentDefinitionWriter _contentDefinitionWriter;

View File

@@ -93,20 +93,20 @@
</ItemGroup>
<ItemGroup>
<Content Include="Module.txt" />
<Content Include="Views\Commands\Execute.ascx" />
<Content Include="Views\Content\Details.aspx" />
<Content Include="Views\Content\Index.aspx" />
<Content Include="Views\DefinitionTemplates\ExperimentalSettings.aspx" />
<Content Include="Views\EditorTemplates\Parts\Experimental.ShowDebugLink.ascx" />
<Content Include="Views\Home\Index.aspx" />
<Content Include="Views\Home\Simple.aspx" />
<Content Include="Views\Home\_RenderableAction.ascx" />
<Content Include="Views\Metadata\Index.aspx" />
<None Include="Views\Commands\Execute.cshtml" />
<None Include="Views\Content\Details.cshtml" />
<None Include="Views\Content\Index.cshtml" />
<None Include="Views\DefinitionTemplates\ExperimentalSettings.cshtml" />
<None Include="Views\EditorTemplates\Parts\Experimental.ShowDebugLink.cshtml" />
<None Include="Views\Home\Index.cshtml" />
<None Include="Views\Home\Simple.cshtml" />
<None Include="Views\Home\_RenderableAction.cshtml" />
<None Include="Views\Metadata\Index.cshtml" />
<Content Include="Web.config" />
<Content Include="Views\Web.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\DisplayTemplates\Parts\Experimental.ShowDebugLink.ascx" />
<None Include="Views\Parts\Experimental.ShowDebugLink.cshtml" />
<Content Include="Views\DumpShapeTable.cshtml" />
<Content Include="Views\HackScript.cshtml" />
<Content Include="Views\HackStyle.cshtml" />
@@ -133,6 +133,7 @@
<ItemGroup>
<Content Include="Views\ShapeTable\ShapeTable.cshtml" />
</ItemGroup>
<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.

View File

@@ -28,11 +28,15 @@ namespace Orchard.Experimental.ViewModels {
ZoneName = x.ZoneName,
});
#else
return null;
return new List<TemplateViewModel>();
#endif
}
}
public IEnumerable<TemplateViewModel> Displays {
get { return new List<TemplateViewModel>(); }
}
public object Locate(Type type) {
return Item.ContentItem.Get(type);
}

View File

@@ -1,19 +0,0 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Experimental.ViewModels.CommandsExecuteViewModel>" %>
<h1>
<%: Html.TitleForPage(T("Command line").ToString()) %></h1>
<div>
<% using (Html.BeginFormAntiForgeryPost(Url.Action("Execute"))) {%>
<%:Html.ValidationSummary()%>
<ul>
<%for (int index = 0; index != (Model.History ?? new string[0]).Length; ++index) {%><li>
<%:Model.History[index]%>
<%:Html.HiddenFor(m => m.History[index])%>
</li>
<%
}%></ul>
<%:Html.LabelFor(m => m.CommandLine)%>
<%:Html.TextBoxFor(m => m.CommandLine, new { style = "width:100%;" })%>
<%:Html.ValidationMessageFor(m => m.CommandLine)%>
<pre><%: Model.Results%></pre>
<%}%>
</div>

View File

@@ -0,0 +1,20 @@
<h1>
@Html.TitleForPage(T("Command line").ToString())
</h1>
<div>
@using (Html.BeginFormAntiForgeryPost(Url.Action("Execute"))) {
Html.ValidationSummary()
<ul>
@for (int index = 0; index != (Model.History ?? new string[0]).Length; ++index) {
<li>
@Model.History[index]
@Html.HiddenFor(m => m.History[index])
</li>
}
</ul>
@Html.LabelFor(m => m.CommandLine)
@Html.TextBoxFor(m => m.CommandLine, new { style = "width:100%;" })
@Html.ValidationMessageFor(m => m.CommandLine)
<pre>@Model.Results</pre>
}
</div>

View File

@@ -1,107 +0,0 @@
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<ContentDetailsViewModel>" %>
<%@ Import Namespace="Orchard.Experimental.ViewModels"%>
<%@ Import Namespace="Orchard.ContentManagement"%>
<%@ Import Namespace="System.Reflection" %>
<h1><%: Html.TitleForPage(T("{0} Content Type", Model.Item.ContentItem.ContentType).ToString(), T("Content").ToString())%></h1>
<h2><%: T("Content Item")%></h2>
<p>
<%: T("Id:")%>
<%=Model.Item.ContentItem.Id %><br />
<%: T("Version:")%>
<%=Model.Item.ContentItem.Version %><br />
<%: T("ContentType:")%>
<%=Model.Item.ContentItem.ContentType %><br />
<%: T("DisplayText:")%>
<%: Html.ItemDisplayText(Model.Item) %><br />
<%: T("Links:")%>
<%: Html.ItemDisplayLink(T("view").ToString(), Model.Item) %> <%: Html.ItemEditLink(T("edit").ToString(), Model.Item) %>
</p>
<h2><%: T("Content Item Parts")%></h2>
<ul>
<%foreach (var partType in Model.PartTypes.OrderBy(x => x.Name)) {%>
<li><span style="font-weight: bold;">
<%if (partType.IsGenericType) {%><%: partType.Name +" "+partType.GetGenericArguments().First().Name %>
<%: " (" + partType.GetGenericArguments().First().Namespace + ")" %><%}
else {%><%: partType.Name %>
<%: " (" + partType.Namespace + ")" %><%
}
%></span>
<ul style="margin-left: 20px">
<%foreach (var prop in partType.GetProperties().Where(x => x.DeclaringType == partType)) {
var value = prop.GetValue(Model.Locate(partType), null);%>
<li style="font-weight: normal;">
<%: prop.Name %>:
<%: value %>
<%var valueItem = value as ContentItem;
if (valueItem == null && value is IContent) {
valueItem = (value as IContent).ContentItem;
}
if (valueItem != null) {
%><%: Html.ActionLink(T("{0} #{1} v{2}", valueItem.ContentType, valueItem.Id, valueItem.Version).ToString(), "details", new { valueItem.Id }, new { })%><%
}
%>
<ul style="margin-left: 20px">
<%if (value == null || prop.PropertyType.IsPrimitive || prop.PropertyType == typeof(string) || prop.PropertyType == typeof(DateTime?)) { }
else if (typeof(IEnumerable).IsAssignableFrom(prop.PropertyType)) {
foreach (var item in value as IEnumerable) {
%>
<li><%: item.GetType().Name %>:<%: item %></li>
<%
}
}
else {%>
<%foreach (var prop2 in value.GetType().GetProperties().Where(x => x.GetIndexParameters().Count() == 0)) {%>
<li>
<%: prop2.Name %>
<%: prop2.GetValue(value, null) %></li>
<%} %>
<%} %>
</ul>
</li>
<%} %>
</ul>
</li>
<%}%>
</ul>
<h3>Displays</h3>
<ul>
<%foreach (var display in Model.Displays) {%>
<li><span style="font-weight: bold">
<%: display.Prefix %></span>
<%: display.Model.GetType().Name %>
(<%: display.Model.GetType().Namespace %>)
Template:<%: display.TemplateName ?? "(null)" %>
Prefix:<%: display.Prefix ?? "(null)" %>
Zone:<%: display.ZoneName ?? "(null)" %>
Position:<%: display.Position ?? "(null)" %>
<div style="margin-left: 20px; border: solid 1px black;">
<%: Html.DisplayFor(x => display.Model, display.TemplateName, display.Prefix)%>
</div>
</li>
<%
}%>
</ul>
<h3>Editors</h3>
<ul>
<%foreach (var editor in Model.Editors) {%>
<li><span style="font-weight: bold">
<%: editor.Prefix %></span>
<%: editor.Model.GetType().Name %>
(<%: editor.Model.GetType().Namespace %>)
Template:<%: editor.TemplateName ?? "(null)" %>
Prefix:<%: editor.Prefix ?? "(null)" %>
Zone:<%: editor.ZoneName ?? "(null)" %>
Position:<%: editor.Position??"(null)" %>
<div style="margin-left: 20px; border: solid 1px black;">
<%: Html.EditorFor(x=>editor.Model, editor.TemplateName, editor.Prefix) %>
</div>
</li>
<%
}%>
</ul>

View File

@@ -0,0 +1,103 @@
@model ContentDetailsViewModel
@using Orchard.Experimental.ViewModels;
@using Orchard.ContentManagement;
@using System.Collections;
<h1>@Html.TitleForPage(T("{0} Content Type", Model.Item.ContentItem.ContentType).ToString(), T("Content").ToString())</h1>
<h2>@T("Content Item")</h2>
<p>@T("Id:") @Model.Item.ContentItem.Id<br />
@T("Version:") @Model.Item.ContentItem.Version<br />
@T("ContentType:") @Model.Item.ContentItem.ContentType<br />
@T("DisplayText:") @Html.ItemDisplayText(Model.Item)<br />
@T("Links:") @Html.ItemDisplayLink(T("view").ToString(), Model.Item) @Html.ItemEditLink(T("edit").ToString(), Model.Item)
</p>
<h2>@T("Content Item Parts")</h2>
<ul>
@foreach (var partType in Model.PartTypes.OrderBy(x => x.Name)) {
<li>
<span style="font-weight: bold;">
@if (partType.IsGenericType) {
@:@partType.Name @partType.GetGenericArguments().First().Name (@partType.GetGenericArguments().First().Namespace)
}
else {
@:@partType.Name (@partType.Namespace)
}
</span>
<ul style="margin-left: 20px">
@foreach (var prop in partType.GetProperties().Where(x => x.DeclaringType == partType)) {
var value = prop.GetValue(Model.Locate(partType), null);
<li style="font-weight: normal;">
@prop.Name
@value
@{var valueItem = value as ContentItem; }
@if (valueItem == null && value is IContent) {
valueItem = (value as IContent).ContentItem;
}
@if (valueItem != null) {
Html.ActionLink(T("{0} #{1} v{2}", valueItem.ContentType, valueItem.Id, valueItem.Version).ToString(), "details", new { valueItem.Id }, new { });
}
<ul style="margin-left: 20px">
@if (value == null || prop.PropertyType.IsPrimitive || prop.PropertyType == typeof(string) || prop.PropertyType == typeof(DateTime?)) { }
else if (typeof(IEnumerable).IsAssignableFrom(prop.PropertyType)) {
foreach (var item in value as IEnumerable) {
<li>@item.GetType().Name : @item</li>
}
}
else {
foreach (var prop2 in value.GetType().GetProperties().Where(x => x.GetIndexParameters().Count() == 0)) {
<li>
@prop2.Name
@prop2.GetValue(value, null)
</li>
}
}
</ul>
</li>
}
</ul>
</li>
}
</ul>
<h3>Displays</h3>
<ul>
@foreach (var display in Model.Displays) {
<li>
<span style="font-weight: bold">@display.Prefix</span>
@display.Model.GetType().Name
(@display.Model.GetType().Namespace)
Template: @display.TemplateName ?? "(null)"
Prefix: @display.Prefix ?? "(null)"
Zone: @display.ZoneName ?? "(null)"
Position: @display.Position ?? "(null)"
<div style="margin-left: 20px; border: solid 1px black;">
@Html.DisplayFor(x => display.Model, display.TemplateName, display.Prefix)
</div>
</li>
}
</ul>
<h3>Editors</h3>
<ul>
@foreach (var editor in Model.Editors) {
<li>
<span style="font-weight: bold">@editor.Prefix</span>
@editor.Model.GetType().Name
(@editor.Model.GetType().Namespace)
Template: @editor.TemplateName ?? "(null)"
Prefix: @editor.Prefix ?? "(null)"
Zone: @editor.ZoneName ?? "(null)"
Position: @editor.Position ?? "(null)"
<div style="margin-left: 20px; border: solid 1px black;">
@Html.EditorFor(x=>editor.Model, editor.TemplateName, editor.Prefix)
</div>
</li>
}
</ul>

View File

@@ -1,19 +0,0 @@
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<ContentIndexViewModel>" %>
<%@ Import Namespace="Orchard.Experimental.ViewModels"%>
<h1><%: Html.TitleForPage(T("Content").ToString()) %></h1>
<h2><%: T("Content Types")%></h2>
<ul>
<%foreach(var item in Model.Types.OrderBy(x=>x.Name)){%>
<li><%: item.Name %></li>
<%}%>
</ul>
<h2><%: T("Content Items")%></h2>
<ul>
<%foreach(var item in Model.Items.OrderBy(x=>x.Id)){%>
<li>
<%: Html.ActionLink(T("{0}: {1}", item.Id, item.ContentType).ToString(), "details", "content", new{item.Id},new{}) %>
<%: Html.ItemDisplayLink(T("view").ToString(), item) %>
<%: Html.ItemEditLink(T("edit").ToString(), item) %>
</li>
<%}%>
</ul>

View File

@@ -0,0 +1,23 @@
@model ContentIndexViewModel
@using Orchard.Experimental.ViewModels;
<h1>@Html.TitleForPage(T("Content").ToString())</h1>
<h2>@T("Content Types")</h2>
<ul>
@foreach(var item in Model.Types.OrderBy(x=>x.Name)) {
<li>@item.Name</li>
}
</ul>
<h2>@T("Content Items")</h2>
<ul>
@foreach(var item in Model.Items.OrderBy(x=>x.Id)) {
<li>
@Html.ActionLink(T("{0}: {1}", item.Id, item.ContentType).ToString(), "details", "content", new{item.Id},new{})
@Html.ItemDisplayLink(T("view").ToString(), item)
@Html.ItemEditLink(T("edit").ToString(), item)
</li>
}
</ul>

View File

@@ -1,6 +0,0 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Experimental.Settings.ExperimentalSettings>" %>
<fieldset>
<%:Html.EditorFor(m=>m.ShowDebugLinks) %>
<label for="<%:Html.FieldIdFor(m => m.ShowDebugLinks) %>" class="forcheckbox"><%:T("Show debug links") %></label>
<%:Html.ValidationMessageFor(m=>m.ShowDebugLinks) %>
</fieldset>

View File

@@ -0,0 +1,6 @@
@model Orchard.Experimental.Settings.ExperimentalSettings
<fieldset>
@Html.EditorFor(m=>m.ShowDebugLinks)
<label for="@Html.FieldIdFor(m => m.ShowDebugLinks)" class="forcheckbox">@T("Show debug links")</label>
@Html.ValidationMessageFor(m=>m.ShowDebugLinks)
</fieldset>

View File

@@ -1,6 +0,0 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ShowDebugLink>" %>
<%@ Import Namespace="Orchard.Experimental.Models" %>
<div class="debug message"><%=T(
"Experimental: displaying {0}",
Html.ActionLink(T("{0} #{1} v{2}", Model.ContentItem.ContentType, Model.ContentItem.Id, Model.ContentItem.Version).ToString(), "details", "content", new { area = "Orchard.Experimental", Model.ContentItem.Id, Model.ContentItem.Version }, new { })
) %></div>

View File

@@ -1,8 +0,0 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ShowDebugLink>" %>
<%@ Import Namespace="Orchard.Experimental.Models" %>
<% if (Model.ContentItem.Id > 0) { %>
<div class="debug message"><%=T(
"Experimental: editing {0}",
Html.ActionLink(T("{0} #{1} v{2}", Model.ContentItem.ContentType, Model.ContentItem.Id, Model.ContentItem.Version).ToString(), "details", "content", new { area = "Orchard.Experimental", Model.ContentItem.Id, Model.ContentItem.Version }, new { })
) %></div>
<% } %>

View File

@@ -0,0 +1,6 @@
@model Orchard.Experimental.Models.ShowDebugLink
@if (Model.ContentItem.Id > 0) {
<div class="debug message">
@T("Experimental: editing {0}", Html.ActionLink(T("{0} #{1} v{2}", Model.ContentItem.ContentType, Model.ContentItem.Id, Model.ContentItem.Version).ToString(), "details", "content", new { area = "Orchard.Experimental", Model.ContentItem.Id, Model.ContentItem.Version }, new { }))
</div>
}

View File

@@ -1,6 +0,0 @@
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<BaseViewModel>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<h1><%: Html.TitleForPage(T("Experimental").ToString()) %></h1>
<p><%: Html.ActionLink(T("Contents").ToString(), "Index", "Content") %></p>
<p><%: Html.ActionLink(T("Metadata").ToString(), "Index", "Metadata") %></p>
<p><%: Html.ActionLink(T("Test Unauthorized Request").ToString(), "NotAuthorized", "Home")%></p>

View File

@@ -0,0 +1,4 @@
<h1>@Html.TitleForPage(T("Experimental").ToString())</h1>
<p>@Html.ActionLink(T("Contents").ToString(), "Index", "Content")</p>
<p>@Html.ActionLink(T("Metadata").ToString(), "Index", "Metadata")</p>
<p>@Html.ActionLink(T("Test Unauthorized Request").ToString(), "NotAuthorized", "Home")</p>

View File

@@ -1,12 +0,0 @@
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<Simple>" %>
<%@ Import Namespace="Orchard.Experimental.Models" %>
<h1>
<%= H(Model.Title) %></h1>
<p>
Quantity:
<%= Model.Quantity %></p>
<div style="border: solid 1px #ccc;">
<% Html.RenderAction("_RenderableAction"); %></div>
<p>
<%: Html.ActionLink("Test Messages", "SimpleMessage")%></p>

View File

@@ -0,0 +1,6 @@
<h1>@H(Model.Title)</h1>
<p>Quantity: @Model.Quantity</p>
<div style="border: solid 1px #ccc;">
@Html.RenderAction("_RenderableAction")
</div>
<p>@Html.ActionLink("Test Messages", "SimpleMessage")</p>

View File

@@ -1,2 +0,0 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<string>" %>
<h3><%=H(Model)%></h3>

View File

@@ -0,0 +1 @@
<h3>@H(Model)</h3>

View File

@@ -1,44 +0,0 @@
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<Orchard.Experimental.ViewModels.MetadataIndexViewModel>" %>
<%@ Import Namespace="Orchard.Experimental.ViewModels" %>
<style title="text/css">
ul
{
margin-left: 12px;
}
</style>
<h1>
Metadata</h1>
<h2>
Content Type Definitions</h2>
<ul>
<%foreach (var type in Model.TypeDefinitions) {%>
<li>
<%:type.Name %>
<ul>
<%foreach (var part in type.Parts) {%>
<li>
<%:part.PartDefinition.Name %></li>
<%
}%>
</ul>
</li>
<%
}%>
</ul>
<h2>
Content Part Definitions</h2>
<ul>
<%foreach (var part in Model.PartDefinitions) {%>
<li>
<%:part.Name %></li>
<%
}%>
</ul>
<h2>
Exported as xml</h2>
<% using (Html.BeginFormAntiForgeryPost()) { %>
<%:Html.TextAreaFor(m=>m.ExportText, new{style="width:100%;height:640px;"}) %>
<br />
<input class="button primaryAction" type="submit" value="<%: T("Merge Changes") %>" />
<%} %>

View File

@@ -0,0 +1,45 @@
@model MetadataIndexViewModel
@using Orchard.Experimental.ViewModels;
<style title="text/css">
ul
{
margin-left: 12px;
}
</style>
<h1>Metadata</h1>
<h2>Content Type Definitions</h2>
<ul>
@foreach (var type in Model.TypeDefinitions) {
<li>
@type.Name
<ul>
@foreach (var part in type.Parts) {
<li>
@part.PartDefinition.Name
</li>
}
</ul>
</li>
}
</ul>
<h2>Content Part Definitions</h2>
<ul>
@foreach (var part in Model.PartDefinitions) {
<li>
@part.Name
</li>
}
</ul>
<h2>Exported as xml</h2>
@using (Html.BeginFormAntiForgeryPost()) {
@Html.TextAreaFor(m=>m.ExportText, new{style="width:100%;height:640px;"})
<br />
<input class="button primaryAction" type="submit" value="@T("Merge Changes")" />
}

View File

@@ -0,0 +1,5 @@
@using Orchard.Experimental.Models;
<div class="debug message">
Experimental: displaying @Html.ActionLink(T("{0} #{1} v{2}", Model.ContentItem.ContentType, Model.ContentItem.Id, Model.ContentItem.Version).ToString(), "details", "content", new { area = "Orchard.Experimental", Model.ContentItem.Id, Model.ContentItem.Version }, new { }))
</div>