mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-22 21:02:08 +08:00
Add view locations formats for non-themed views in custom orchard modules.
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045536
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Web;
|
||||
@@ -25,19 +24,6 @@ namespace Orchard.Web {
|
||||
);
|
||||
}
|
||||
|
||||
static IEnumerable<string> OrchardLocationFormats() {
|
||||
return new[] {
|
||||
"~/Packages/{2}/Views/{1}/{0}.aspx",
|
||||
"~/Packages/{2}/Views/{1}/{0}.ascx",
|
||||
"~/Packages/{2}/Views/Shared/{0}.aspx",
|
||||
"~/Packages/{2}/Views/Shared/{0}.ascx",
|
||||
"~/Core/{2}/Views/{1}/{0}.aspx",
|
||||
"~/Core/{2}/Views/{1}/{0}.ascx",
|
||||
"~/Core/{2}/Views/Shared/{0}.aspx",
|
||||
"~/Core/{2}/Views/Shared/{0}.ascx",
|
||||
};
|
||||
}
|
||||
|
||||
protected void Application_Start() {
|
||||
// This is temporary until MVC2 is officially released.
|
||||
// We want to avoid running against an outdated preview installed in the GAC
|
||||
|
||||
@@ -39,15 +39,47 @@ namespace Orchard.Environment {
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
|
||||
|
||||
public void Activate() {
|
||||
_routePublisher.Publish(_routeProviders.SelectMany(provider => provider.GetRoutes()));
|
||||
_modelBinderPublisher.Publish(_modelBinderProviders.SelectMany(provider => provider.GetModelBinders()));
|
||||
|
||||
AddOrchardLocationsFormats();
|
||||
|
||||
_events.Invoke(x => x.Activated(), Logger);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds view locations formats for non-themed views in custom orchard modules.
|
||||
/// </summary>
|
||||
private void AddOrchardLocationsFormats() {
|
||||
|
||||
IEnumerable<string> orchardMasterLocationFormats = new[] {
|
||||
"~/Packages/{2}/Views/{1}/{0}.master",
|
||||
"~/Packages/{2}/Views/Shared/{0}.master",
|
||||
};
|
||||
|
||||
IEnumerable<string> orchardLocationFormats = new[] {
|
||||
"~/Packages/{2}/Views/{1}/{0}.aspx",
|
||||
"~/Packages/{2}/Views/{1}/{0}.ascx",
|
||||
"~/Packages/{2}/Views/Shared/{0}.aspx",
|
||||
"~/Packages/{2}/Views/Shared/{0}.ascx",
|
||||
};
|
||||
|
||||
var viewEngine = _viewEngines.OfType<VirtualPathProviderViewEngine>().Single();
|
||||
viewEngine.AreaMasterLocationFormats = orchardMasterLocationFormats
|
||||
.Concat(viewEngine.AreaMasterLocationFormats)
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
viewEngine.AreaViewLocationFormats = orchardLocationFormats
|
||||
.Concat(viewEngine.AreaViewLocationFormats)
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
viewEngine.AreaPartialViewLocationFormats = orchardLocationFormats
|
||||
.Concat(viewEngine.AreaPartialViewLocationFormats)
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
|
||||
public void Terminate() {
|
||||
_events.Invoke(x => x.Terminating(), Logger);
|
||||
|
||||
@@ -18,14 +18,14 @@ namespace Orchard.UI.Resources {
|
||||
return;
|
||||
}
|
||||
|
||||
model.Zones.AddAction("head:metas", html => html.ViewContext.HttpContext.Response.Output.Write(_resourceManager.GetMetas()));
|
||||
model.Zones.AddAction("head:styles", html => html.ViewContext.HttpContext.Response.Output.Write(_resourceManager.GetStyles()));
|
||||
model.Zones.AddAction("head:scripts", html => html.ViewContext.HttpContext.Response.Output.Write(_resourceManager.GetHeadScripts()));
|
||||
model.Zones.AddAction("head:metas", html => html.ViewContext.Writer.Write(_resourceManager.GetMetas()));
|
||||
model.Zones.AddAction("head:styles", html => html.ViewContext.Writer.Write(_resourceManager.GetStyles()));
|
||||
model.Zones.AddAction("head:scripts", html => html.ViewContext.Writer.Write(_resourceManager.GetHeadScripts()));
|
||||
model.Zones.AddAction("body:after", html => {
|
||||
html.ViewContext.HttpContext.Response.Output.Write(_resourceManager.GetFootScripts());
|
||||
html.ViewContext.Writer.Write(_resourceManager.GetFootScripts());
|
||||
TextWriter captured;
|
||||
if (LayoutViewContext.From(html.ViewContext).Contents.TryGetValue("end-of-page-scripts", out captured)) {
|
||||
html.ViewContext.HttpContext.Response.Output.Write(captured);
|
||||
html.ViewContext.Writer.Write(captured);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user