--HG--
branch : dev
This commit is contained in:
Michael Dorian Bach
2010-10-18 19:22:44 -07:00
15 changed files with 86 additions and 62 deletions

View File

@@ -45,11 +45,13 @@ namespace Orchard.Tests.Commands {
var builder = new CommandHandlerDescriptorBuilder();
var descriptor = builder.Build(typeof(PublicMethodsOnly));
Assert.That(descriptor, Is.Not.Null);
Assert.That(descriptor.Commands.Count(), Is.EqualTo(3));
Assert.That(descriptor.Commands.Count(), Is.EqualTo(1));
Assert.That(descriptor.Commands.Single(d => d.Name == "Method"), Is.Not.Null);
}
#pragma warning disable 660,661
public class PublicMethodsOnly {
#pragma warning restore 660,661
public bool Bar { get; set; } // no accessors
public bool Field = true; // no field
@@ -70,14 +72,6 @@ namespace Orchard.Tests.Commands {
return false;
}
public override int GetHashCode() {
throw new NotImplementedException();
}
public override bool Equals(Object obj) {
throw new NotImplementedException();
}
public void Method() {
}
}

View File

@@ -42,8 +42,9 @@ namespace Orchard.Core.Localization.Drivers {
ContentLocalizations = new ContentLocalizationsViewModel(part) { Localizations = localizations }
};
// TODO: andrerod convert to new shape API. Location code kept for reference.
return ContentPartTemplate(model, "Parts/Localization.Translation", TemplatePrefix); //.Location(part.GetLocation("Editor"));
return ContentShape("Parts_Localization_ContentTranslations_Edit", () => {
return shapeHelper.EditorTemplate(TemplateName: "Parts/Localization.ContentTranslations.Edit", Model: model, Prefix: TemplatePrefix);
});
}
protected override DriverResult Editor(LocalizationPart part, IUpdateModel updater, dynamic shapeHelper) {

View File

@@ -1,6 +1,7 @@
<Placement>
<Place Parts_Localization_ContentTranslations="-"/>
<Place Parts_Localization_ContentTranslations_Summary="-"/>
<Place Parts_Localization_ContentTranslations_Edit="Primary:before.1"/>
<Match DisplayType="Detail">
<Place Parts_Localization_ContentTranslations="Content:before.5"/>
</Match>
@@ -8,6 +9,6 @@
<Place Parts_Localization_ContentTranslations_Summary="Content:after.5"/>
</Match>
<Match DisplayType="SummaryAdmin">
<Place Parts_Localization_ContentTranslations_Summary="Content:after.5"/>
<Place Parts_Localization_ContentTranslations_Summary="Meta:after.1"/>
</Match>
</Placement>

View File

@@ -256,7 +256,7 @@
<Content Include="Contents\Views\Admin\Edit.cshtml" />
<Content Include="Contents\Views\Admin\List.cshtml" />
<Content Include="Feeds\Views\Feed.cshtml" />
<Content Include="Localization\Views\EditorTemplates\Parts\Localization.Translation.cshtml" />
<Content Include="Localization\Views\EditorTemplates\Parts\Localization.ContentTranslations.Edit.cshtml" />
<Content Include="Contents\Views\Parts\Contents.Publish.cshtml" />
<Content Include="Contents\Views\Parts\Contents.Publish.SummaryAdmin.cshtml" />
<Content Include="Messaging\Module.txt" />

View File

@@ -1,4 +1,6 @@
@model Orchard.Packaging.ViewModels.PackagingModulesViewModel
@using System.Linq;
@{ Style.Require("PackagingAdmin"); }
<h1>@Html.TitleForPage(T("Browse Gallery - Modules").ToString())</h1>
@@ -10,7 +12,7 @@
<select id="sourceId" name="sourceId">
@Html.SelectOption("", Model.SelectedSource == null, T("Any (show all feeds)").ToString())
@foreach (var source in Model.Sources) {
Html.SelectOption(source.Id, Model.SelectedSource != null && Model.SelectedSource.Id == source.Id, source.FeedTitle);
@Html.SelectOption(source.Id, Model.SelectedSource != null && Model.SelectedSource.Id == source.Id, source.FeedTitle)
}
</select>
<button type="submit">@T("Apply")</button>
@@ -23,7 +25,7 @@
@foreach (var item in Model.Modules) {
<li>
<div class="moduleName">
<h2>@(item.SyndicationItem.Title == null ? T("(No title)").Text : item.SyndicationItem.Title.Text)<span> - @T("Version: {0}", "1.0")</span></h2>
<h2>@(item.SyndicationItem.Title == null ? T("(No title)").Text : item.SyndicationItem.Title.Text)<span> - @T("Version: {0}", item.SyndicationItem.ElementExtensions.ReadElementExtensions<string>("Version", "http://orchardproject.net").FirstOrDefault() ?? T("N/A").Text)</span></h2>
</div>
<div class="related">

View File

@@ -13,7 +13,7 @@
<select id="sourceId" name="sourceId">
@Html.SelectOption("", Model.SelectedSource == null, T("Any (show all feeds)").ToString())
@foreach (var source in Model.Sources) {
Html.SelectOption(source.Id, Model.SelectedSource != null && Model.SelectedSource.Id == source.Id, source.FeedTitle);
@Html.SelectOption(source.Id, Model.SelectedSource != null && Model.SelectedSource.Id == source.Id, source.FeedTitle)
}
</select>
<button type="submit">@T("Apply")</button>

View File

@@ -1,33 +0,0 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%--//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)
var firstSectionItem = menuSection.Items.FirstOrDefault();
var sectionHeaderMarkup = firstSectionItem != null
? Html.ActionLink(menuSection.Text, (string)firstSectionItem.RouteValues["action"], firstSectionItem.RouteValues).ToHtmlString()
: string.Format("<span>{0}</span>", Html.Encode(menuSection.Text));
var classification = "";
if (menuSection == Model.Menu.First())
classification = "first ";
if (menuSection == Model.Menu.Last())
classification += "last ";
%>
<li<%=!string.IsNullOrEmpty(classification) ? string.Format(" class=\"{0}\"", classification.TrimEnd()) : "" %>><h3><%=sectionHeaderMarkup %></h3><ul class="menuItems"><%foreach (var menuItem in menuSection.Items) { %>
<li><%: Html.ActionLink(menuItem.Text, (string)menuItem.RouteValues["action"], menuItem.RouteValues)%></li>
<%} %></ul></li>
<%
}
}%>
</ul>
<% using (this.Capture("end-of-page-scripts")) { %>
<script type="text/javascript">
(function ($) {
$("#navigation h3").expandoControl(function(controller) { return controller.next(); }, { key: "N42", path: "<%:ResolveUrl("~/") %>" });
})(jQuery);
</script>
<% } %>--%>

View File

@@ -1,14 +1,44 @@
<ul id="navigation">
@using System.Web.Routing;
@{
Script.Require("jQuery");
Script.Include("admin.js");
IEnumerable<dynamic> firstLevelMenuItems = Model;
}
<ul id="navigation" role="navigation">
@foreach(var firstLevelMenuItem in Model) {
<li>
<h3><a href="#">@firstLevelMenuItem.Text</a></h3>
IEnumerable<dynamic> secondLevelMenuItems = firstLevelMenuItem;
var firstOfTheSecond = secondLevelMenuItems.FirstOrDefault();
var sectionHeaderMarkup = firstOfTheSecond != null
? Html.ActionLink((string)firstLevelMenuItem.Text, (string)firstOfTheSecond.RouteValues["action"], (RouteValueDictionary)firstOfTheSecond.RouteValues)
: new HtmlString(string.Format("<span>{0}</span>", Html.Encode(firstLevelMenuItem.Text)));
if (firstLevelMenuItem == firstLevelMenuItems.First()) {
firstLevelMenuItem.Classes.Add("first");
}
if (firstLevelMenuItem == firstLevelMenuItems.Last()) {
firstLevelMenuItem.Classes.Add("last");
}
var firstLevelTag = Tag(firstLevelMenuItem, "li");
@firstLevelTag.StartElement
<h3>@sectionHeaderMarkup</h3>
<ul class="menuItems">
@foreach(var secondLevelMenuItem in firstLevelMenuItem) {
@foreach(var secondLevelMenuItem in secondLevelMenuItems) {
<li>
<a href="@secondLevelMenuItem.Href">@secondLevelMenuItem.Text</a>
</li>
}
</ul>
</li>
@firstLevelTag.EndElement
}
</ul>
</ul>
@using(Script.Foot()) {
<script type="text/javascript">
//<![CDATA[
(function ($) {
$("#navigation h3").expandoControl(function(controller) { return controller.next(); }, { key: "N42", path: "@Url.Content("~/")" });
})(jQuery);
//]]>
</script>
}

View File

@@ -68,6 +68,7 @@
<SubType>Designer</SubType>
</Content>
<Content Include="TheThemeMachine\Views\User.cshtml" />
<None Include="TheAdmin\Views\Menu.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="TheAdmin\Styles\images\icons.png" />

View File

@@ -6,6 +6,7 @@ using System.Web.Mvc;
using System.Web.Routing;
using Autofac;
using Orchard.Caching;
using Orchard.Data;
using Orchard.Environment;
using Orchard.Environment.Configuration;
using Orchard.Environment.State;
@@ -48,6 +49,8 @@ namespace Orchard.Commands {
tenant = tenant ?? "Default";
using (var env = CreateStandaloneEnvironment(tenant)) {
var commandManager = env.Resolve<ICommandManager>();
var transactionManager = env.Resolve<ITransactionManager>();
var parameters = new CommandParameters {
Arguments = args,
@@ -56,7 +59,16 @@ namespace Orchard.Commands {
Output = output
};
env.Resolve<ICommandManager>().Execute(parameters);
try {
commandManager.Execute(parameters);
}
catch {
// any database changes in this using(env) scope are invalidated
transactionManager.Cancel();
// exception handling performed below
throw;
}
}
// in effect "pump messages" see PostMessage circa 1980

View File

@@ -42,11 +42,11 @@ namespace Orchard.ContentManagement.Drivers {
}
public ContentShapeResult ContentShape(string shapeType, Func<dynamic, dynamic> factory) {
return ContentShapeImplementation(shapeType, null, ctx=>factory(CreateShape(ctx, shapeType)));
return ContentShapeImplementation(shapeType, null, ctx => factory(CreateShape(ctx, shapeType)));
}
public ContentShapeResult ContentShape(string shapeType, string defaultLocation, Func<dynamic, dynamic> factory) {
return ContentShapeImplementation(shapeType, defaultLocation, factory);
return ContentShapeImplementation(shapeType, defaultLocation, ctx => factory(CreateShape(ctx, shapeType)));
}
private ContentShapeResult ContentShapeImplementation(string shapeType, string defaultLocation, Func<BuildShapeContext, object> shapeBuilder) {

View File

@@ -1,6 +1,7 @@
using System;
using System.Timers;
using Autofac;
using Orchard.Data;
using Orchard.Environment;
using Orchard.Logging;
@@ -57,9 +58,20 @@ namespace Orchard.Tasks {
public void DoWork() {
// makes an inner container, similar to the per-request container
using (var scope = _workContextAccessor.CreateWorkContextScope()) {
// resolve the manager and invoke it
var manager = scope.Resolve<IBackgroundService>();
manager.Sweep();
var transactionManager = scope.Resolve<ITransactionManager>();
try {
// resolve the manager and invoke it
var manager = scope.Resolve<IBackgroundService>();
manager.Sweep();
}
catch {
// any database changes in this using scope are invalidated
transactionManager.Cancel();
// pass exception along to actual handler
throw;
}
}
}

View File

@@ -103,6 +103,10 @@ namespace PackageIndexReferenceImplementation.Controllers {
item.Summary = new TextSyndicationContent(packageProperties.Description);
}
if ( !string.IsNullOrEmpty(packageProperties.Version) ) {
item.ElementExtensions.Add("Version", "http://orchardproject.net", packageProperties.Version);
}
var mediaIdentifier = packageProperties.Identifier + "-" + packageProperties.Version + ".zip";
var mediaUrl = Url.Action("Resource", "Media", new RouteValueDictionary { { "Id", mediaIdentifier }, { "ContentType", "application/x-package" } });

View File

@@ -7,7 +7,7 @@
<configuration>
<appSettings>
<add key="Title" value="Orchard Modules Gallery"/>
<add key="Title" value="Orchard Extensions Gallery"/>
</appSettings>
<system.web>