--HG--
branch : dev
This commit is contained in:
Sebastien Ros
2011-03-23 21:51:57 -07:00
11 changed files with 283 additions and 70 deletions

View File

@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5C0D5249-AEF5-4BB6-8F5F-057B91AC2D7A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Orchard.Startup</RootNamespace>
<AssemblyName>Orchard.Startup</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Autofac">
<HintPath>..\..\lib\autofac\Autofac.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Web" />
<Reference Include="System.Data.DataSetExtensions" />
</ItemGroup>
<ItemGroup>
<Compile Include="Starter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WarmupHttpModule.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Orchard.Starter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("Orchard")]
[assembly: AssemblyCopyright("Copyright © Outercurve Foundation 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("02319f2f-22ec-448d-b4f2-568fb8502242")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.20")]
[assembly: AssemblyFileVersion("1.0.20")]

View File

@@ -0,0 +1,63 @@
using System;
using System.Threading;
using System.Web;
using Autofac;
using Orchard.Environment;
namespace Orchard.Startup {
public class Starter {
private static IOrchardHost _host;
private static Exception _error;
public static void OnBeginRequest(HttpContext context, Action<ContainerBuilder> registrations) {
if (_error != null) {
// Host startup resulted in an error
// Throw error once, and restart launch; machine state may have changed
// so we need to simulate a "restart".
var error = _error;
LaunchStartupThread(registrations);
throw error;
}
// Only notify if the host has started up
if (_host == null) {
return;
}
context.Items["originalHttpContext"] = context;
_host.BeginRequest();
}
public static void OnEndRequest() {
// Only notify if the host has started up
if (_host != null) {
_host.EndRequest();
}
}
/// <summary>
/// Initializes Orchard's Host in a separate thread
/// </summary>
public static void LaunchStartupThread(Action<ContainerBuilder> registrations) {
_host = null;
_error = null;
ThreadPool.QueueUserWorkItem(
state => {
try {
var host = OrchardStarter.CreateHost(registrations);
host.Initialize();
_host = host;
}
catch (Exception e) {
_error = e;
}
finally {
// Execute pending actions as the host is available
WarmupHttpModule.Signal();
}
});
}
}
}

View File

@@ -6,7 +6,7 @@ using System.Threading;
using System.Web;
using System.Web.Hosting;
namespace Orchard.Web {
namespace Orchard.Startup {
public class WarmupHttpModule : IHttpModule {
private const string WarmupFilesPath = "~/App_Data/Warmup/";
private HttpApplication _context;
@@ -65,7 +65,7 @@ namespace Orchard.Web {
return asyncResult;
}
private void EndBeginRequest(IAsyncResult ar) {
private static void EndBeginRequest(IAsyncResult ar) {
((WarmupAsyncResult)ar).Wait();
}

View File

@@ -1,52 +1,31 @@
using System;
using System.Threading;
using System.Web;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Autofac;
using Orchard.Environment;
using Orchard.Startup;
namespace Orchard.Web {
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : HttpApplication {
private static IOrchardHost _host;
private static Exception _error;
public static void RegisterRoutes(RouteCollection routes) {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
}
protected void Application_Start() {
LaunchStartupThread();
RegisterRoutes(RouteTable.Routes);
Starter.LaunchStartupThread(MvcSingletons);
}
protected void Application_BeginRequest() {
if (_error != null) {
// Host startup resulted in an error
// Throw error once, and restart launch; machine state may have changed
// so we need to simulate a "restart".
var error = _error;
LaunchStartupThread();
throw error;
}
// Only notify if the host has started up
if (_host == null) {
return;
}
Context.Items["originalHttpContext"] = Context;
_host.BeginRequest();
Starter.OnBeginRequest(Context, MvcSingletons);
}
protected void Application_EndRequest() {
// Only notify if the host has started up
if (_host != null) {
_host.EndRequest();
}
Starter.OnEndRequest();
}
static void MvcSingletons(ContainerBuilder builder) {
@@ -54,31 +33,5 @@ namespace Orchard.Web {
builder.Register(ctx => ModelBinders.Binders).SingleInstance();
builder.Register(ctx => ViewEngines.Engines).SingleInstance();
}
/// <summary>
/// Initializes Orchard's Host in a separate thread
/// </summary>
private static void LaunchStartupThread() {
RegisterRoutes(RouteTable.Routes);
_host = null;
_error = null;
ThreadPool.QueueUserWorkItem(
state => {
try {
var host = OrchardStarter.CreateHost(MvcSingletons);
host.Initialize();
_host = host;
}
catch (Exception e) {
_error = e;
}
finally {
// Execute pending actions as the host is available
WarmupHttpModule.Signal();
}
});
}
}
}

View File

@@ -26,6 +26,8 @@
var shapeTracingGhost = $('#shape-tracing-container-ghost');
var shapeTracingOverlay = $('#shape-tracing-overlay');
var shapeTracingEnabled = false;
// store the size of the container when it is closed (default in css)
var initialContainerSize = shapeTracingContainer.height();
var previousSize = 0;
@@ -66,19 +68,33 @@
_this.toggleClass('expanded');
if (_this.hasClass('expanded')) {
shapeTracingContainer.height(Math.max(previousSize, 100, shapeTracingContainer.height()));
enableShapeTracing();
}
else {
// save previous height
previousSize = shapeTracingContainer.height();
shapeTracingContainer.height(initialContainerSize);
disableShapeTracing();
}
syncResize();
});
var disableShapeTracing = function () {
shapeTracingEnabled = false;
selectShape();
}
var enableShapeTracing = function () {
shapeTracingEnabled = true;
}
// add a resizable handle to the container
$('#shape-tracing-resize-handle').addClass('ui-resizable-handle ui-resizable-n');
shapeTracingContainer.resizable({ handles: { n: '#shape-tracing-resize-handle'} });
shapeTracingContainer.resizable({
handles: { n: '#shape-tracing-resize-handle' },
grid: 20 // mitigates the number of calls to syncResize(), and aligns to the line height
});
var shapeNodes = {}; // represents the main index of shape nodes, indexed by id
@@ -175,6 +191,10 @@
var overlayTarget = null;
$('[shape-id]').add(shapeTracingOverlay).mousemove(
function (event) {
if (!shapeTracingEnabled) {
return;
}
event.stopPropagation();
if ($(this).get(0) == shapeTracingOverlay.get(0)) {
@@ -203,7 +223,15 @@
// selects a specific shape in the tree, highlight its elements, and display the information
var selectShape = function (shapeId) {
$('.shape-tracing-selected').removeClass('shape-tracing-selected');
if (!shapeId) {
// remove selection ?
shapeTracingOverlay.hide();
shapeTracingWindowTree.find('.shape-tracing-selected').removeClass('shape-tracing-selected');
$('[shape-id-meta]:visible').toggle(false);
return;
}
shapeTracingWindowTree.find('.shape-tracing-selected').removeClass('shape-tracing-selected');
$('li[tree-shape-id="' + shapeId + '"] > div').add('[shape-id="' + shapeId + '"]').addClass('shape-tracing-selected');
shapeTracingOverlay.hide();
@@ -235,7 +263,8 @@
});
//create an overlay on shape tree nodes
shapeTracingWindowTree.find('[tree-shape-id] div').hover(
shapeTracingWindowTree.find('[tree-shape-id] > div')
.hover(
function () {
var _this = $(this);
$('.shape-tracing-overlay').removeClass('shape-tracing-overlay');
@@ -243,11 +272,8 @@
},
function () {
$('.shape-tracing-overlay').removeClass('shape-tracing-overlay');
}
);
// select shape tree elements when clicked
$('[tree-shape-id] > div').click(function (event) {
})
.click(function (event) {
var shapeId = $(this).parent().get(0).shapeNode.id;
selectShape(shapeId);
@@ -265,10 +291,10 @@
// add the expand/collapse logic to the shape model
// var glyph = $('<span class="expando-glyph-container closed"><span class="expando-glyph"></span>&#8203;</span>');
shapeTracingWindowContent.find('h3').parent(':has(li)').prepend(glyph);
shapeTracingWindowContent.find('.model li:has(ul)').prepend(glyph);
// collapse all sub uls
shapeTracingWindowContent.find('ul ul').toggle(false);
shapeTracingWindowContent.find('.model ul ul').toggle(false);
// tabs events
shapeTracingWindowContent.find('.shape-tracing-tabs > li').click(function () {
@@ -314,6 +340,39 @@
return false;
});
//create an overlay on model nodes
shapeTracingWindowContent.find('.model div.name')
.hover(
function () {
var _this = $(this);
$('.shape-tracing-overlay').removeClass('shape-tracing-overlay');
_this.addClass('shape-tracing-overlay');
},
function () {
$('.shape-tracing-overlay').removeClass('shape-tracing-overlay');
})
.click(function (event) {
// model node is selected
var _this = $(this);
shapeTracingWindowContent.find('.shape-tracing-selected').removeClass('shape-tracing-selected');
_this.addClass('shape-tracing-selected');
// display breadcrumb
var breadcrumb;
_this.parentsUntil('.model').children('.name').each(function () {
if (breadcrumb != null) {
breadcrumb = $(this).text() + '.' + breadcrumb;
}
else {
breadcrumb = $(this).text();
}
});
_this.parents('.model').find('.shape-tracing-breadcrumb').text('@' + breadcrumb);
event.stopPropagation();
});
});
// recursively create a node for the shapes tree

View File

@@ -106,7 +106,7 @@
background-color: #EBEFF9;
}
#shape-tracing-window-tree .shape-tracing-selected {
#shape-tracing-window .shape-tracing-selected {
background:#2c66c3;
color:#fff;
@@ -221,4 +221,31 @@
}
#shape-tracing-window-content .shape-tracing-tabs li.selected a {
color: #3A822E;
}
#shape-tracing-window-content .model ul ul {
margin:0 0 0 18px;
padding:0 0 0 10px;
list-style-type:none;
}
#shape-tracing-window-content .model div {
float:left;
display:block;
}
#shape-tracing-window-content .model div.type, #shape-tracing-window-content .model div.value {
float:right;
display:inline;
width:66%;
}
#shape-tracing-window-content .model li {
clear:both;
}
#shape-tracing-window-content .shape-tracing-breadcrumb
{
margin: 3px 0px;
}

View File

@@ -52,6 +52,7 @@
</div>
<div class="model" style="display:none">
<div class="shape-tracing-breadcrumb">foo</div>
@(new MvcHtmlString(@Model.Dump))
</div>

View File

@@ -127,7 +127,6 @@
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="WarmupHttpModule.cs" />
<Content Include="Config\log4net.config" />
<Content Include="Config\Sample.HostComponents.config">
<SubType>Designer</SubType>
@@ -144,6 +143,10 @@
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Orchard.Startup\Orchard.Startup.csproj">
<Project>{5C0D5249-AEF5-4BB6-8F5F-057B91AC2D7A}</Project>
<Name>Orchard.Startup</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>

View File

@@ -122,7 +122,7 @@
</httpHandlers>
<httpModules>
<add name="WarmupHttpModule" type="Orchard.Web.WarmupHttpModule, Orchard.Web"/>
<add name="WarmupHttpModule" type="Orchard.Startup.WarmupHttpModule, Orchard.Startup"/>
</httpModules>
</system.web>
<!--
@@ -134,7 +134,7 @@
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="WarmupHttpModule" />
<add name="WarmupHttpModule" type="Orchard.Web.WarmupHttpModule, Orchard.Web"/>
<add name="WarmupHttpModule" type="Orchard.Startup.WarmupHttpModule, Orchard.Startup"/>
</modules>
<handlers accessPolicy="Script">
<!-- clear all handlers, prevents executing code file extensions, prevents returning any file contents -->

View File

@@ -114,6 +114,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.ImportExport", "Orc
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Warmup", "Orchard.Web\Modules\Orchard.WarmUp\Orchard.Warmup.csproj", "{9CD5C81F-5828-4384-8474-2E2BE71D5EDD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Startup", "Orchard.Startup\Orchard.Startup.csproj", "{5C0D5249-AEF5-4BB6-8F5F-057B91AC2D7A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
CodeCoverage|Any CPU = CodeCoverage|Any CPU
@@ -604,6 +606,16 @@ Global
{9CD5C81F-5828-4384-8474-2E2BE71D5EDD}.FxCop|Any CPU.ActiveCfg = Release|Any CPU
{9CD5C81F-5828-4384-8474-2E2BE71D5EDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9CD5C81F-5828-4384-8474-2E2BE71D5EDD}.Release|Any CPU.Build.0 = Release|Any CPU
{5C0D5249-AEF5-4BB6-8F5F-057B91AC2D7A}.CodeCoverage|Any CPU.ActiveCfg = Release|Any CPU
{5C0D5249-AEF5-4BB6-8F5F-057B91AC2D7A}.CodeCoverage|Any CPU.Build.0 = Release|Any CPU
{5C0D5249-AEF5-4BB6-8F5F-057B91AC2D7A}.Coverage|Any CPU.ActiveCfg = Release|Any CPU
{5C0D5249-AEF5-4BB6-8F5F-057B91AC2D7A}.Coverage|Any CPU.Build.0 = Release|Any CPU
{5C0D5249-AEF5-4BB6-8F5F-057B91AC2D7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C0D5249-AEF5-4BB6-8F5F-057B91AC2D7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C0D5249-AEF5-4BB6-8F5F-057B91AC2D7A}.FxCop|Any CPU.ActiveCfg = Release|Any CPU
{5C0D5249-AEF5-4BB6-8F5F-057B91AC2D7A}.FxCop|Any CPU.Build.0 = Release|Any CPU
{5C0D5249-AEF5-4BB6-8F5F-057B91AC2D7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C0D5249-AEF5-4BB6-8F5F-057B91AC2D7A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE