mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 19:04:51 +08:00
Added overload to Script/Style/IRM.Include() to allow specifing the debug+release url for common .min versions.
Converted built-in themes to use Include() instead of a manifest for simplification. --HG-- branch : dev
This commit is contained in:
@@ -10,36 +10,9 @@ namespace Orchard.Themes {
|
||||
manifest.DefineScript("Switchable").SetUrl("jquery.switchable.js").SetDependencies("jQuery");
|
||||
manifest.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.
|
||||
manifest.DefineStyle("Admin").SetUrl("~/modules/orchard.themes/styles/admin.css");
|
||||
|
||||
manifest.DefineStyle("Classic").SetUrl("~/themes/classic/styles/site.css");
|
||||
manifest.DefineStyle("Classic_Blog").SetUrl("~/themes/classic/styles/blog.css");
|
||||
|
||||
manifest.DefineStyle("ClassicDark").SetUrl("~/themes/classicdark/styles/site.css");
|
||||
manifest.DefineStyle("ClassicDark_Blog").SetUrl("~/themes/classicdark/styles/blog.css");
|
||||
|
||||
manifest.DefineStyle("Contoso").SetUrl("~/themes/contoso/styles/site.css");
|
||||
manifest.DefineStyle("Contoso_Search").SetUrl("~/themes/contoso/styles/search.css");
|
||||
|
||||
// todo: include and define the min.js version too
|
||||
// todo: move EasySlider to common location
|
||||
// todo: move EasySlider to common location, although it does not appear to be used anywhere right now
|
||||
manifest.DefineScript("EasySlider").SetUrl("~/themes/contoso/scripts/easySlider.js").SetDependencies("jQuery");
|
||||
|
||||
manifest.DefineStyle("Corporate").SetUrl("~/themes/corporate/styles/site.css");
|
||||
|
||||
manifest.DefineStyle("Green").SetUrl("~/themes/green/styles/site.css");
|
||||
manifest.DefineStyle("Green_Blog").SetUrl("~/themes/green/styles/blog.css");
|
||||
manifest.DefineStyle("Green_YUI").SetUrl("~/themes/green/styles/yui.css");
|
||||
|
||||
manifest.DefineStyle("SafeMode").SetUrl("~/themes/safemode/styles/site.css");
|
||||
|
||||
manifest.DefineStyle("TheAdmin").SetUrl("~/themes/theadmin/styles/site.css");
|
||||
manifest.DefineStyle("TheAdmin_IE").SetUrl("~/themes/theadmin/styles/ie.css");
|
||||
manifest.DefineStyle("TheAdmin_IE6").SetUrl("~/themes/theadmin/styles/ie6.css");
|
||||
manifest.DefineScript("TheAdmin").SetUrl("~/themes/theadmin/scripts/admin.js").SetDependencies("jQuery");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
@using Orchard.UI.Resources
|
||||
@{
|
||||
Style.Require("Classic");
|
||||
Style.Require("Classic_Blog");
|
||||
Style.Include("site.css");
|
||||
Style.Include("blog.css");
|
||||
}
|
||||
<div id="wrapper">
|
||||
@// HTML.Include will render a div with a class="user-display"
|
||||
|
@@ -1,7 +1,7 @@
|
||||
@using Orchard.UI.Resources
|
||||
@{
|
||||
Style.Require("ClassicDark");
|
||||
Style.Require("ClassicDark_Blog");
|
||||
Style.Include("site.css");
|
||||
Style.Include("blog.css");
|
||||
}
|
||||
<div id="wrapper">
|
||||
@// HTML.Include will render a div with a class="user-display"
|
||||
|
@@ -3,7 +3,7 @@
|
||||
<%@ Import Namespace="Orchard.UI.Resources" %>
|
||||
|
||||
<%
|
||||
Html.Resolve<IResourceManager>().Require(new RequireSettings { Type = "stylesheet", Name = "Corporate" });
|
||||
Html.Resolve<IResourceManager>().Include("stylesheet", "site.css", null);
|
||||
|
||||
Model.Zones.AddRenderPartial("header", "Header", Model);
|
||||
Model.Zones.AddRenderPartial("menu", "Menu", Model);
|
||||
|
@@ -3,7 +3,7 @@
|
||||
<%@ Import Namespace="Orchard.UI.Resources" %>
|
||||
|
||||
<%
|
||||
Html.Resolve<IResourceManager>().Require(new RequireSettings { Type = "stylesheet", Name = "Corporate" });
|
||||
Html.Resolve<IResourceManager>().Include("stylesheet", "site.css", null);
|
||||
|
||||
Model.Zones.AddRenderPartial("header", "Header", Model);
|
||||
Model.Zones.AddRenderPartial("menu", "Menu", Model);
|
||||
|
@@ -3,7 +3,7 @@
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.UI.Resources" %>
|
||||
<%
|
||||
Style.Require("Green_Archives");
|
||||
Style.Include("site.css");
|
||||
Script.Require("BlogsArchives");
|
||||
%>
|
||||
<div class="archives">
|
||||
|
@@ -3,9 +3,9 @@
|
||||
<%@ Import Namespace="Orchard.UI.Resources" %>
|
||||
|
||||
<%
|
||||
Html.Resolve<IResourceManager>().Require(new RequireSettings { Type = "stylesheet", Name = "Green_YUI" });
|
||||
Html.Resolve<IResourceManager>().Require(new RequireSettings { Type = "stylesheet", Name = "Green" });
|
||||
Html.Resolve<IResourceManager>().Require(new RequireSettings { Type = "stylesheet", Name = "Green_Blog" });
|
||||
Html.Resolve<IResourceManager>().Include("stylesheet", "yui.css", null);
|
||||
Html.Resolve<IResourceManager>().Include("stylesheet", "site.css", null);
|
||||
Html.Resolve<IResourceManager>().Include("stylesheet", "blog.css", null);
|
||||
%>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
@@ -3,9 +3,9 @@
|
||||
<%@ Import Namespace="Orchard.UI.Resources" %>
|
||||
|
||||
<%
|
||||
Html.Resolve<IResourceManager>().Require(new RequireSettings { Type = "stylesheet", Name = "Green_YUI" });
|
||||
Html.Resolve<IResourceManager>().Require(new RequireSettings { Type = "stylesheet", Name = "Green" });
|
||||
Html.Resolve<IResourceManager>().Require(new RequireSettings { Type = "stylesheet", Name = "Green_Blog" });
|
||||
Html.Resolve<IResourceManager>().Include("stylesheet", "yui.css", null);
|
||||
Html.Resolve<IResourceManager>().Include("stylesheet", "site.css", null);
|
||||
Html.Resolve<IResourceManager>().Include("stylesheet", "blog.css", null);
|
||||
%>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Search.ViewModels.SearchViewModel>" %>
|
||||
<% Style.Require("Green_Search"); %>
|
||||
<h1 class="page-title"><%:Html.TitleForPage(T("Search").Text)%></h1><%
|
||||
if (!string.IsNullOrWhiteSpace(Model.Query)) {
|
||||
if (Model.PageOfResults.Count() == 0) { %>
|
||||
|
@@ -6,8 +6,9 @@
|
||||
@using Orchard.ContentManagement
|
||||
|
||||
@{
|
||||
Style.Require("TheAdmin");
|
||||
Script.Require("TheAdmin");
|
||||
Style.Include("site.css");
|
||||
Script.Require("jQuery");
|
||||
Script.Include("admin.js");
|
||||
RegisterLink(new LinkEntry { Condition = "lte IE 8", Rel = "stylesheet", Type = "text/css", Href = Url.Content("../Styles/ie.css") }.AddAttribute("media", "screen, projection"));
|
||||
RegisterLink(new LinkEntry { Condition = "lte IE 6", Rel = "stylesheet", Type = "text/css", Href = Url.Content("../Styles/ie6.css") }.AddAttribute("media", "screen, projection"));
|
||||
// these are just hacked together to fire existing partials... can change
|
||||
|
@@ -1,7 +1,7 @@
|
||||
@using Orchard.UI.Resources
|
||||
@{
|
||||
Style.Require("Classic");
|
||||
Style.Require("Classic_Blog");
|
||||
Style.Include("~/themes/Classic/styles/site.css");
|
||||
Style.Include("~/themes/Classic/styles/blog.css");
|
||||
}
|
||||
<div id="wrapper">
|
||||
@// HTML.Include will render a div with a class="user-display"
|
||||
|
@@ -13,8 +13,8 @@ namespace Orchard.UI.Resources {
|
||||
ResourceManifest DynamicResources { get; }
|
||||
ResourceDefinition FindResource(RequireSettings settings);
|
||||
void NotRequired(string resourceType, string resourceName);
|
||||
RequireSettings Include(string resourceType, string resourcePath);
|
||||
RequireSettings Include(string resourceType, string resourcePath, string relativeFromPath);
|
||||
RequireSettings Include(string resourceType, string resourcePath, string resourceDebugPath);
|
||||
RequireSettings Include(string resourceType, string resourcePath, string resourceDebugPath, string relativeFromPath);
|
||||
RequireSettings Require(string resourceType, string resourceName);
|
||||
void RegisterHeadScript(string script);
|
||||
void RegisterFootScript(string script);
|
||||
|
@@ -20,6 +20,17 @@ namespace Orchard.UI.Resources {
|
||||
private List<String> _footScripts;
|
||||
private IEnumerable<IResourceManifest> _manifests;
|
||||
|
||||
private static string FixPath(string resourcePath, string relativeFromPath) {
|
||||
if (!String.IsNullOrEmpty(resourcePath) && !VirtualPathUtility.IsAbsolute(resourcePath) && !Uri.IsWellFormedUriString(resourcePath, UriKind.Absolute)) {
|
||||
// appears to be a relative path (e.g. 'foo.js' or '../foo.js', not "/foo.js" or "http://..")
|
||||
if (String.IsNullOrEmpty(relativeFromPath)) {
|
||||
throw new InvalidOperationException("ResourcePath cannot be relative unless a base relative path is also provided.");
|
||||
}
|
||||
resourcePath = VirtualPathUtility.ToAbsolute(VirtualPathUtility.Combine(relativeFromPath, resourcePath));
|
||||
}
|
||||
return resourcePath;
|
||||
}
|
||||
|
||||
public ResourceManager(IEnumerable<Meta<IResourceManifestProvider, IFeatureMetadata>> resourceProviders) {
|
||||
_providers = resourceProviders;
|
||||
}
|
||||
@@ -61,11 +72,11 @@ namespace Orchard.UI.Resources {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public virtual RequireSettings Include(string resourceType, string resourcePath) {
|
||||
public virtual RequireSettings Include(string resourceType, string resourcePath, string resourceDebugPath) {
|
||||
return Include(resourceType, resourcePath, null);
|
||||
}
|
||||
|
||||
public virtual RequireSettings Include(string resourceType, string resourcePath, string relativeFromPath) {
|
||||
public virtual RequireSettings Include(string resourceType, string resourcePath, string resourceDebugPath, string relativeFromPath) {
|
||||
if (resourceType == null) {
|
||||
throw new ArgumentNullException("resourceType");
|
||||
}
|
||||
@@ -77,14 +88,9 @@ namespace Orchard.UI.Resources {
|
||||
// ~/ ==> convert to absolute path (e.g. /orchard/..)
|
||||
resourcePath = VirtualPathUtility.ToAbsolute(resourcePath);
|
||||
}
|
||||
else if (!VirtualPathUtility.IsAbsolute(resourcePath) && !Uri.IsWellFormedUriString(resourcePath, UriKind.Absolute)) {
|
||||
// appears to be a relative path (e.g. 'foo.js' or '../foo.js', not "/foo.js" or "http://..")
|
||||
if (String.IsNullOrEmpty(relativeFromPath)) {
|
||||
throw new InvalidOperationException("ResourcePath cannot be relative unless a base relative path is also provided.");
|
||||
}
|
||||
resourcePath = VirtualPathUtility.ToAbsolute(VirtualPathUtility.Combine(relativeFromPath, resourcePath));
|
||||
}
|
||||
return Require(resourceType, resourcePath).Define(d => d.SetUrl(resourcePath));
|
||||
resourcePath = FixPath(resourcePath, relativeFromPath);
|
||||
resourceDebugPath = FixPath(resourceDebugPath, relativeFromPath);
|
||||
return Require(resourceType, resourcePath).Define(d => d.SetUrl(resourcePath, resourceDebugPath));
|
||||
}
|
||||
|
||||
public virtual void RegisterHeadScript(string script) {
|
||||
|
@@ -1,10 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.UI;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.WebPages;
|
||||
|
||||
namespace Orchard.UI.Resources {
|
||||
@@ -33,7 +29,14 @@ namespace Orchard.UI.Resources {
|
||||
if (resourcePath == null) {
|
||||
throw new ArgumentNullException("resourcePath");
|
||||
}
|
||||
return ResourceManager.Include(ResourceType, resourcePath, ResourceDefinition.GetBasePathFromViewPath(ResourceType, _viewVirtualPath));
|
||||
return ResourceManager.Include(ResourceType, resourcePath, null, ResourceDefinition.GetBasePathFromViewPath(ResourceType, _viewVirtualPath));
|
||||
}
|
||||
|
||||
public RequireSettings Include(string resourceDebugPath, string resourcePath) {
|
||||
if (resourcePath == null) {
|
||||
throw new ArgumentNullException("resourcePath");
|
||||
}
|
||||
return ResourceManager.Include(ResourceType, resourcePath, resourceDebugPath, ResourceDefinition.GetBasePathFromViewPath(ResourceType, _viewVirtualPath));
|
||||
}
|
||||
|
||||
public virtual RequireSettings Require(string resourceName) {
|
||||
|
Reference in New Issue
Block a user