-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating Orchard.ResourceManagement project
- Loading branch information
1 parent
81d4526
commit ac19c14
Showing
18 changed files
with
1,376 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Orchard.ResourceManagement | ||
{ | ||
public interface IResourceManager | ||
{ | ||
IEnumerable<RequireSettings> GetRequiredResources(string type); | ||
IList<ResourceRequiredContext> BuildRequiredResources(string resourceType); | ||
IList<LinkEntry> GetRegisteredLinks(); | ||
IList<MetaEntry> GetRegisteredMetas(); | ||
IList<String> GetRegisteredHeadScripts(); | ||
IList<String> GetRegisteredFootScripts(); | ||
IEnumerable<IResourceManifest> ResourceProviders { get; } | ||
ResourceManifest DynamicResources { get; } | ||
ResourceDefinition FindResource(RequireSettings settings); | ||
void NotRequired(string resourceType, string resourceName); | ||
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); | ||
void RegisterLink(LinkEntry link); | ||
void SetMeta(MetaEntry meta); | ||
void AppendMeta(MetaEntry meta, string contentSeparator); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Orchard.ResourceManagement | ||
{ | ||
public interface IResourceManifest | ||
{ | ||
ResourceDefinition DefineResource(string resourceType, string resourceName); | ||
string Name { get; } | ||
string BasePath { get; } | ||
IDictionary<string, ResourceDefinition> GetResources(string resourceType); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Orchard.ResourceManagement | ||
{ | ||
public interface IResourceManifestProvider | ||
{ | ||
void BuildManifests(ResourceManifestBuilder builder); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Orchard.ResourceManagement | ||
{ | ||
public interface IResourceManifestState | ||
{ | ||
IEnumerable<IResourceManifest> Manifest { get; set; } | ||
} | ||
|
||
public class ResourceManifestState : IResourceManifestState | ||
{ | ||
public IEnumerable<IResourceManifest> Manifest { get; set; } | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using Microsoft.AspNetCore.Html; | ||
using Microsoft.AspNetCore.Mvc.Rendering; | ||
|
||
namespace Orchard.ResourceManagement | ||
{ | ||
public class LinkEntry | ||
{ | ||
private readonly TagBuilder _builder = new TagBuilder("link"); | ||
|
||
public string Condition { get; set; } | ||
|
||
public string Rel | ||
{ | ||
get | ||
{ | ||
string value; | ||
_builder.Attributes.TryGetValue("rel", out value); | ||
return value; | ||
} | ||
set { SetAttribute("rel", value); } | ||
} | ||
|
||
public string Type | ||
{ | ||
get | ||
{ | ||
string value; | ||
_builder.Attributes.TryGetValue("type", out value); | ||
return value; | ||
} | ||
set { SetAttribute("type", value); } | ||
} | ||
|
||
public string Title | ||
{ | ||
get | ||
{ | ||
string value; | ||
_builder.Attributes.TryGetValue("title", out value); | ||
return value; | ||
} | ||
set { SetAttribute("title", value); } | ||
} | ||
|
||
public string Href | ||
{ | ||
get | ||
{ | ||
string value; | ||
_builder.Attributes.TryGetValue("href", out value); | ||
return value; | ||
} | ||
set { SetAttribute("href", value); } | ||
} | ||
|
||
public IHtmlContent GetTag() | ||
{ | ||
_builder.TagRenderMode = TagRenderMode.SelfClosing; | ||
string tag = _builder.ToString(); | ||
|
||
if (!string.IsNullOrEmpty(Condition)) | ||
{ | ||
return new HtmlString("<!--[if " + Condition + "]>" + tag + "<![endif]-->"); | ||
} | ||
|
||
return new HtmlString(tag); | ||
} | ||
|
||
public LinkEntry AddAttribute(string name, string value) | ||
{ | ||
_builder.MergeAttribute(name, value); | ||
return this; | ||
} | ||
|
||
public LinkEntry SetAttribute(string name, string value) | ||
{ | ||
_builder.MergeAttribute(name, value, true); | ||
return this; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Microsoft.AspNetCore.Html; | ||
using Microsoft.AspNetCore.Mvc.Rendering; | ||
|
||
namespace Orchard.ResourceManagement | ||
{ | ||
public class MetaEntry | ||
{ | ||
private readonly TagBuilder _builder = new TagBuilder("meta"); | ||
|
||
public MetaEntry() | ||
{ | ||
|
||
} | ||
|
||
public MetaEntry(string name = null, string content = null, string httpEquiv = null, string charset = null) | ||
{ | ||
if (!String.IsNullOrEmpty(name)) | ||
{ | ||
Name = name; | ||
} | ||
|
||
if (!String.IsNullOrEmpty(content)) | ||
{ | ||
Content = content; | ||
} | ||
|
||
if (!String.IsNullOrEmpty(httpEquiv)) | ||
{ | ||
HttpEquiv = httpEquiv; | ||
} | ||
|
||
if (!String.IsNullOrEmpty(charset)) | ||
{ | ||
Charset = charset; | ||
} | ||
|
||
} | ||
|
||
public static MetaEntry Combine(MetaEntry meta1, MetaEntry meta2, string contentSeparator) | ||
{ | ||
var newMeta = new MetaEntry(); | ||
Merge(newMeta._builder.Attributes, meta1._builder.Attributes, meta2._builder.Attributes); | ||
if (!String.IsNullOrEmpty(meta1.Content) && !String.IsNullOrEmpty(meta2.Content)) | ||
{ | ||
newMeta.Content = meta1.Content + contentSeparator + meta2.Content; | ||
} | ||
return newMeta; | ||
} | ||
|
||
private static void Merge(IDictionary<string, string> d1, params IDictionary<string, string>[] sources) | ||
{ | ||
foreach (var d in sources) | ||
{ | ||
foreach (var pair in d) | ||
{ | ||
d1[pair.Key] = pair.Value; | ||
} | ||
} | ||
} | ||
|
||
public MetaEntry AddAttribute(string name, string value) | ||
{ | ||
_builder.MergeAttribute(name, value); | ||
return this; | ||
} | ||
public MetaEntry SetAttribute(string name, string value) | ||
{ | ||
_builder.MergeAttribute(name, value, true); | ||
return this; | ||
} | ||
|
||
public string Name | ||
{ | ||
get | ||
{ | ||
string value; | ||
_builder.Attributes.TryGetValue("name", out value); | ||
return value; | ||
} | ||
set { SetAttribute("name", value); } | ||
} | ||
|
||
public string Content | ||
{ | ||
get | ||
{ | ||
string value; | ||
_builder.Attributes.TryGetValue("content", out value); | ||
return value; | ||
} | ||
set { SetAttribute("content", value); } | ||
} | ||
|
||
public string HttpEquiv | ||
{ | ||
get | ||
{ | ||
string value; | ||
_builder.Attributes.TryGetValue("http-equiv", out value); | ||
return value; | ||
} | ||
set { SetAttribute("http-equiv", value); } | ||
} | ||
|
||
public string Charset | ||
{ | ||
get | ||
{ | ||
string value; | ||
_builder.Attributes.TryGetValue("charset", out value); | ||
return value; | ||
} | ||
set { SetAttribute("charset", value); } | ||
} | ||
|
||
public IHtmlContent GetTag() | ||
{ | ||
_builder.TagRenderMode = TagRenderMode.SelfClosing; | ||
return new HtmlString(_builder.ToString()); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/Orchard.ResourceManagement/Orchard.ResourceManagement.xproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
</PropertyGroup> | ||
|
||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>08a15913-72d1-4898-9ba5-228cb79ee5fe</ProjectGuid> | ||
<RootNamespace>Orchard.ResourceManagement</RootNamespace> | ||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> | ||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> | ||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
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: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Orchard.ResourceManagement")] | ||
[assembly: AssemblyTrademark("")] | ||
|
||
// 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("08a15913-72d1-4898-9ba5-228cb79ee5fe")] |
Oops, something went wrong.