Removed dup theme resource definitions. Fix base path on razor views.

--HG--
branch : dev
This commit is contained in:
Dave Reed
2010-09-21 11:35:52 -07:00
parent 45cba60180
commit a8bc2712c6
10 changed files with 64 additions and 87 deletions

View File

@@ -232,6 +232,7 @@
<Compile Include="Settings\Models\SiteSettingsPart.cs" /> <Compile Include="Settings\Models\SiteSettingsPart.cs" />
<Compile Include="Settings\Services\SiteService.cs" /> <Compile Include="Settings\Services\SiteService.cs" />
<Compile Include="Settings\ViewModels\SiteSettingsPartViewModel.cs" /> <Compile Include="Settings\ViewModels\SiteSettingsPartViewModel.cs" />
<Compile Include="Shapes\CoreShapesResourceManifest.cs" />
<Compile Include="Shapes\CoreShapes.cs" /> <Compile Include="Shapes\CoreShapes.cs" />
<Compile Include="XmlRpc\Controllers\HomeController.cs" /> <Compile Include="XmlRpc\Controllers\HomeController.cs" />
<Compile Include="XmlRpc\Controllers\LiveWriterController.cs" /> <Compile Include="XmlRpc\Controllers\LiveWriterController.cs" />

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Orchard.UI.Resources;
namespace Orchard.Core.Shapes {
public class CoreShapesResourceManifest : ResourceManifest {
public CoreShapesResourceManifest() {
DefineScript("ShapesBase").SetUrl("base.js").SetDependencies("jQuery");
DefineStyle("Shapes").SetUrl("site.css"); // todo: missing
DefineStyle("ShapesSpecial").SetUrl("special.css");
}
}
}

View File

@@ -63,7 +63,7 @@ namespace Orchard.Setup {
builder.RegisterType<DefaultCommandManager>().As<ICommandManager>().InstancePerLifetimeScope(); builder.RegisterType<DefaultCommandManager>().As<ICommandManager>().InstancePerLifetimeScope();
builder.RegisterType<HelpCommand>().As<ICommandHandler>().InstancePerLifetimeScope(); builder.RegisterType<HelpCommand>().As<ICommandHandler>().InstancePerLifetimeScope();
builder.RegisterType<DefaultWorkContextAccessor>().As<IWorkContextAccessor>().InstancePerMatchingLifetimeScope("shell"); builder.RegisterType<DefaultWorkContextAccessor>().As<IWorkContextAccessor>().InstancePerMatchingLifetimeScope("shell");
builder.RegisterType<ThemesResourceManifest>().As<IResourceManifest>().InstancePerLifetimeScope(); builder.RegisterType<CoreShapesResourceManifest>().As<IResourceManifest>().InstancePerLifetimeScope();
builder.RegisterType<ResourceManager>().As<IResourceManager>().InstancePerLifetimeScope(); builder.RegisterType<ResourceManager>().As<IResourceManager>().InstancePerLifetimeScope();
builder.RegisterType<ResourceFilter>().As<IFilterProvider>().InstancePerLifetimeScope(); builder.RegisterType<ResourceFilter>().As<IFilterProvider>().InstancePerLifetimeScope();

View File

@@ -8,11 +8,40 @@ namespace Orchard.Themes {
public class ThemesResourceManifest : ResourceManifest { public class ThemesResourceManifest : ResourceManifest {
public ThemesResourceManifest() { public ThemesResourceManifest() {
DefineStyle("ThemesAdmin").SetUrl("admin.css"); DefineStyle("ThemesAdmin").SetUrl("admin.css");
// todo: used by core\shapes -- move it? // todo: used by core\shapes -- move it?
DefineScript("Switchable").SetUrl("jquery.switchable.js").SetDependencies("jQuery"); DefineScript("Switchable").SetUrl("jquery.switchable.js").SetDependencies("jQuery");
DefineStyle("Switchable").SetUrl("jquery.switchable.css"); DefineStyle("Switchable").SetUrl("jquery.switchable.css");
// Resources for the built-in themes (under the orchard.web/themes directory)
// The manifest would normally go there rather than here, but orchard.web/themes
// is not registered with AutoFac.
DefineStyle("Admin").SetUrl("~/modules/orchard.themes/styles/admin.css");
DefineStyle("Classic").SetUrl("~/themes/classic/styles/site.css");
DefineStyle("Classic_Blog").SetUrl("~/themes/classic/styles/blog.css");
DefineStyle("ClassicDark").SetUrl("~/themes/classicdark/styles/site.css");
DefineStyle("ClassicDark_Blog").SetUrl("~/themes/classicdark/styles/blog.css");
DefineStyle("Contoso").SetUrl("~/themes/contoso/styles/site.css");
DefineStyle("Contoso_Search").SetUrl("~/themes/contoso/styles/search.css");
// todo: include and define the min.js version too
// todo: move EasySlider to common location
DefineScript("EasySlider").SetUrl("~/themes/contoso/scripts/easySlider.js").SetDependencies("jQuery");
DefineStyle("Corporate").SetUrl("~/themes/corporate/styles/site.css");
DefineStyle("Green").SetUrl("~/themes/green/styles/site.css");
DefineStyle("Green_Blog").SetUrl("~/themes/green/styles/blog.css");
DefineStyle("Green_YUI").SetUrl("~/themes/green/styles/yui.css");
DefineStyle("SafeMode").SetUrl("~/themes/safemode/styles/site.css");
DefineStyle("TheAdmin").SetUrl("~/themes/theadmin/styles/site.css");
DefineStyle("TheAdmin_IE").SetUrl("~/themes/theadmin/styles/ie.css");
DefineStyle("TheAdmin_IE6").SetUrl("~/themes/theadmin/styles/ie6.css");
DefineScript("TheAdmin").SetUrl("~/themes/theadmin/scripts/admin.js").SetDependencies("jQuery");
} }
} }
} }

View File

@@ -94,7 +94,6 @@
<DependentUpon>Global.asax</DependentUpon> <DependentUpon>Global.asax</DependentUpon>
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Themes\ThemesResourceManifest.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Default.aspx" /> <Content Include="Default.aspx" />

View File

@@ -2,7 +2,7 @@
@{ @{
Script.Require("jQuery", "1.4.2"); Script.Require("jQuery", "1.4.2");
Script.Require("ShapesBase"); Script.Require("ShapesBase");
Style.Require("SafeMode"); Style.Require("SafeMode").Define(d => d.SetUrl("site.css"));
RegisterLink(new LinkEntry { Condition = "lte IE 6", Rel = "stylesheet", Type="text/css", Href = Href("../Styles/ie6.css")}.AddAttribute("media", "screen, projection")); RegisterLink(new LinkEntry { Condition = "lte IE 6", Rel = "stylesheet", Type="text/css", Href = Href("../Styles/ie6.css")}.AddAttribute("media", "screen, projection"));
} }
<div id="header"> <div id="header">

View File

@@ -1,39 +0,0 @@
using Orchard.UI.Resources;
namespace Orchard.Themes {
public class ThemesResourceManifest : ResourceManifest {
public ThemesResourceManifest() {
DefineStyle("Admin").SetUrl("~/modules/orchard.themes/styles/admin.css");
DefineScript("ShapesBase").SetUrl("~/core/shapes/scripts/base.js").SetDependencies("jQuery");
DefineStyle("Shapes").SetUrl("~/core/shapes/styles/site.css"); // todo: missing
DefineStyle("ShapesSpecial").SetUrl("~/core/shapes/styles/special.css");
DefineStyle("Classic").SetUrl("~/themes/classic/styles/site.css");
DefineStyle("Classic_Blog").SetUrl("~/themes/classic/styles/blog.css");
DefineStyle("ClassicDark").SetUrl("~/themes/classicdark/styles/site.css");
DefineStyle("ClassicDark_Blog").SetUrl("~/themes/classicdark/styles/blog.css");
DefineStyle("Contoso").SetUrl("~/themes/contoso/styles/site.css");
DefineStyle("Contoso_Search").SetUrl("~/themes/contoso/styles/search.css");
// todo: include and define the min.js version too
// todo: move EasySlider to common location
DefineScript("EasySlider").SetUrl("~/themes/contoso/scripts/easySlider.js").SetDependencies("jQuery");
DefineStyle("Corporate").SetUrl("~/themes/corporate/styles/site.css");
DefineStyle("Green").SetUrl("~/themes/green/styles/site.css");
DefineStyle("Green_Blog").SetUrl("~/themes/green/styles/blog.css");
DefineStyle("Green_YUI").SetUrl("~/themes/green/styles/yui.css");
DefineStyle("SafeMode").SetUrl("~/themes/safemode/styles/site.css");
DefineStyle("TheAdmin").SetUrl("~/themes/theadmin/styles/site.css");
DefineStyle("TheAdmin_IE").SetUrl("~/themes/theadmin/styles/ie.css");
DefineStyle("TheAdmin_IE6").SetUrl("~/themes/theadmin/styles/ie6.css");
DefineScript("TheAdmin").SetUrl("~/themes/theadmin/scripts/admin.js").SetDependencies("jQuery");
}
}
}

View File

@@ -195,7 +195,7 @@ namespace Orchard.UI.Resources {
url = Path.ChangeExtension(url, nearestCulture + "." + Path.GetExtension(url)); url = Path.ChangeExtension(url, nearestCulture + "." + Path.GetExtension(url));
} }
} }
if (!Uri.IsWellFormedUriString(url, UriKind.Absolute) && !VirtualPathUtility.IsAbsolute(url) && !VirtualPathUtility.IsAppRelative(url)) { if (!Uri.IsWellFormedUriString(url, UriKind.Absolute) && !VirtualPathUtility.IsAbsolute(url) && !VirtualPathUtility.IsAppRelative(url) && !String.IsNullOrEmpty(BasePath)) {
// relative urls are relative to the base path of the module that defined the manifest // relative urls are relative to the base path of the module that defined the manifest
url = VirtualPathUtility.Combine(BasePath, url); url = VirtualPathUtility.Combine(BasePath, url);
} }

View File

@@ -50,42 +50,4 @@ namespace Orchard.UI.Resources {
internal class DynamicResourceManifest : ResourceManifest { internal class DynamicResourceManifest : ResourceManifest {
} }
public class ThemesResourceManifest : ResourceManifest {
public ThemesResourceManifest() {
// todo: wrong place to define all these resources.
// But the ResourceManifest defined in Orchard.Web/themes is not loading for some reason
DefineStyle("Admin").SetUrl("~/modules/orchard.themes/styles/admin.css");
DefineScript("ShapesBase").SetUrl("~/core/shapes/scripts/base.js").SetDependencies("jQuery");
DefineStyle("Shapes").SetUrl("~/core/shapes/styles/site.css"); // todo: missing
DefineStyle("ShapesSpecial").SetUrl("~/core/shapes/styles/special.css");
DefineStyle("Classic").SetUrl("~/themes/classic/styles/site.css");
DefineStyle("Classic_Blog").SetUrl("~/themes/classic/styles/blog.css");
DefineStyle("ClassicDark").SetUrl("~/themes/classicdark/styles/site.css");
DefineStyle("ClassicDark_Blog").SetUrl("~/themes/classicdark/styles/blog.css");
DefineStyle("Contoso").SetUrl("~/themes/contoso/styles/site.css");
DefineStyle("Contoso_Search").SetUrl("~/themes/contoso/styles/search.css");
// todo: include and define the min.js version too
// todo: move EasySlider to common location?
DefineScript("EasySlider").SetUrl("~/themes/contoso/scripts/easySlider.js").SetDependencies("jQuery");
DefineStyle("Corporate").SetUrl("~/themes/corporate/styles/site.css");
DefineStyle("Green").SetUrl("~/themes/green/styles/site.css");
DefineStyle("Green_Blog").SetUrl("~/themes/green/styles/blog.css");
DefineStyle("Green_YUI").SetUrl("~/themes/green/styles/yui.css");
DefineStyle("SafeMode").SetUrl("~/themes/safemode/styles/site.css");
DefineStyle("TheAdmin").SetUrl("~/themes/theadmin/styles/site.css");
DefineStyle("TheAdmin_IE").SetUrl("~/themes/theadmin/styles/ie.css");
DefineStyle("TheAdmin_IE6").SetUrl("~/themes/theadmin/styles/ie6.css");
DefineScript("TheAdmin").SetUrl("~/themes/theadmin/scripts/admin.js").SetDependencies("jQuery");
}
}
} }

View File

@@ -5,13 +5,23 @@ using System.Text;
using System.Web.Mvc; using System.Web.Mvc;
using System.Web.UI; using System.Web.UI;
using JetBrains.Annotations; using JetBrains.Annotations;
using Microsoft.WebPages;
namespace Orchard.UI.Resources { namespace Orchard.UI.Resources {
public class ResourceRegister { public class ResourceRegister {
private readonly TemplateControl _templateContainer; private string _baseVirtualPath;
public ResourceRegister(IViewDataContainer container, IResourceManager resourceManager, string resourceType) { public ResourceRegister(IViewDataContainer container, IResourceManager resourceManager, string resourceType) {
_templateContainer = container as TemplateControl; var templateControl = container as TemplateControl;
if (templateControl != null) {
_baseVirtualPath = templateControl.AppRelativeVirtualPath;
}
else {
var webPage = container as WebPageBase;
if (webPage != null) {
_baseVirtualPath = webPage.VirtualPath;
}
}
ResourceManager = resourceManager; ResourceManager = resourceManager;
ResourceType = resourceType; ResourceType = resourceType;
} }
@@ -26,8 +36,8 @@ namespace Orchard.UI.Resources {
public virtual RequireSettings Require(string resourceName, string minimumVersion) { public virtual RequireSettings Require(string resourceName, string minimumVersion) {
var settings = ResourceManager.Require(ResourceType, resourceName) var settings = ResourceManager.Require(ResourceType, resourceName)
.WithMinimumVersion(minimumVersion); .WithMinimumVersion(minimumVersion);
if (_templateContainer != null) { if (_baseVirtualPath != null) {
settings.WithBasePath(ResourceDefinition.GetBasePathFromViewPath(ResourceType, _templateContainer.AppRelativeVirtualPath)); settings.WithBasePath(ResourceDefinition.GetBasePathFromViewPath(ResourceType, _baseVirtualPath));
} }
return settings; return settings;
} }