Skip to content

Commit

Permalink
Creating Orchard.ResourceManagement project
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienros committed Jul 22, 2016
1 parent 81d4526 commit ac19c14
Show file tree
Hide file tree
Showing 18 changed files with 1,376 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Orchard.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Orchard.Web", "src\Orchard.Web\Orchard.Web.xproj", "{07D91819-4C81-434F-8DE4-51D2B5A4EDA8}"
EndProject
Expand Down Expand Up @@ -129,6 +129,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Orchard.DeferredTasks", "sr
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Orchard.Recipes.Abstractions", "src\Orchard.Recipes.Abstractions\Orchard.Recipes.Abstractions.xproj", "{7CAD05EF-1081-4479-872E-E67444023605}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Orchard.ResourceManagement", "src\Orchard.ResourceManagement\Orchard.ResourceManagement.xproj", "{08A15913-72D1-4898-9BA5-228CB79EE5FE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -335,6 +337,10 @@ Global
{7CAD05EF-1081-4479-872E-E67444023605}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7CAD05EF-1081-4479-872E-E67444023605}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7CAD05EF-1081-4479-872E-E67444023605}.Release|Any CPU.Build.0 = Release|Any CPU
{08A15913-72D1-4898-9BA5-228CB79EE5FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{08A15913-72D1-4898-9BA5-228CB79EE5FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{08A15913-72D1-4898-9BA5-228CB79EE5FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{08A15913-72D1-4898-9BA5-228CB79EE5FE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -395,5 +401,6 @@ Global
{A8539F3F-9EF5-4A51-AABB-EEE8C915746E} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{F148F38F-BF15-48BD-BA67-0EF9FCAACA40} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{7CAD05EF-1081-4479-872E-E67444023605} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{08A15913-72D1-4898-9BA5-228CB79EE5FE} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
EndGlobalSection
EndGlobal
27 changes: 27 additions & 0 deletions src/Orchard.ResourceManagement/IResourceManager.cs
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);
}
}
12 changes: 12 additions & 0 deletions src/Orchard.ResourceManagement/IResourceManifest.cs
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);
}
}
7 changes: 7 additions & 0 deletions src/Orchard.ResourceManagement/IResourceManifestProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Orchard.ResourceManagement
{
public interface IResourceManifestProvider
{
void BuildManifests(ResourceManifestBuilder builder);
}
}
16 changes: 16 additions & 0 deletions src/Orchard.ResourceManagement/IResourceManifestState.cs
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; }

}

}
81 changes: 81 additions & 0 deletions src/Orchard.ResourceManagement/LinkEntry.cs
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;
}
}
}
124 changes: 124 additions & 0 deletions src/Orchard.ResourceManagement/MetaEntry.cs
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 src/Orchard.ResourceManagement/Orchard.ResourceManagement.xproj
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>
19 changes: 19 additions & 0 deletions src/Orchard.ResourceManagement/Properties/AssemblyInfo.cs
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")]
Loading

0 comments on commit ac19c14

Please sign in to comment.