Permalink
Browse files

Updated to use SignalR 2.0.0 and OWIN

  • Loading branch information...
1 parent 5374b9a commit b52cb68a01ff6d5e13301d559dc200dfbeb64de4 Felix Jorkowski committed Oct 31, 2013
Showing with 8,821 additions and 6,209 deletions.
  1. +26 −17 NodeAssets.AspNet/Assets.cs
  2. +6 −5 NodeAssets.AspNet/AssetsConfiguration.cs
  3. +4 −3 NodeAssets.AspNet/IAssets.cs
  4. +6 −4 NodeAssets.AspNet/IAssetsConfiguration.cs
  5. +17 −21 NodeAssets.AspNet/NodeAssets.AspNet.csproj
  6. +4 −4 NodeAssets.AspNet/NodeAssets.AspNet.nuspec
  7. +13 −0 NodeAssets.AspNet/NodeAssetsOwinExtension.cs
  8. +106 −0 NodeAssets.AspNet/Routes/DefaultHandler.cs
  9. +0 −66 NodeAssets.AspNet/Routes/DefaultHttpHandler.cs
  10. +0 −22 NodeAssets.AspNet/Routes/DefaultRouteHandler.cs
  11. +0 −41 NodeAssets.AspNet/Routes/EncodingHelper.cs
  12. +0 −22 NodeAssets.AspNet/Routes/MvcIgnoredRoute.cs
  13. +7 −7 NodeAssets.AspNet/packages.config
  14. +3 −1 NodeAssets.Compilers.CoffeeSharp/NodeAssets.Compilers.CoffeeSharp.csproj
  15. +4 −4 NodeAssets.Compilers.CoffeeSharp/NodeAssets.Compilers.CoffeeSharp.nuspec
  16. +1 −1 NodeAssets.Compilers.CoffeeSharp/packages.config
  17. +5 −6 NodeAssets.Compilers.Minify/NodeAssets.Compilers.Minify.csproj
  18. +6 −6 NodeAssets.Compilers.Minify/NodeAssets.Compilers.Minify.nuspec
  19. +2 −1 NodeAssets.Compilers.Minify/packages.config
  20. +5 −3 NodeAssets.Compilers.Node/Commands/NodeExecutor.cs
  21. +2 −2 NodeAssets.Compilers.Node/CompilerConfigurationExtensions.cs
  22. +3 −1 NodeAssets.Compilers.Node/NodeAssets.Compilers.Node.csproj
  23. +5 −5 NodeAssets.Compilers.Node/NodeAssets.Compilers.Node.nuspec
  24. +5 −3 NodeAssets.Compilers.Sass/NodeAssets.Compilers.Sass.csproj
  25. +6 −6 NodeAssets.Compilers.Sass/NodeAssets.Compilers.Sass.nuspec
  26. +3 −3 NodeAssets.Compilers.Sass/packages.config
  27. +3 −1 NodeAssets.Compilers.Typescript/NodeAssets.Compilers.Typescript.csproj
  28. +4 −4 NodeAssets.Compilers.Typescript/NodeAssets.Compilers.Typescript.nuspec
  29. +7 −2 NodeAssets.Compilers.Typescript/TypescriptCompiler.cs
  30. +4 −1 NodeAssets.Core/NodeAssets.Core.csproj
  31. +4 −4 NodeAssets.Core/NodeAssets.Core.nuspec
  32. +1 −1 NodeAssets.Core/Pile.cs
  33. +0 −28 NodeAssets.Example/Global.asax.cs
  34. +1 −6 NodeAssets.Example/Models/AccountModels.cs
  35. BIN NodeAssets.Example/Node/node.exe
  36. +65 −29 NodeAssets.Example/NodeAssets.Example.csproj
  37. +3 −0 NodeAssets.Example/NodeAssets.Example.csproj.user
  38. +2,670 −0 NodeAssets.Example/Scripts/jquery-2.0.3.intellisense.js
  39. +4,497 −5,265 NodeAssets.Example/Scripts/{jquery-1.9.1.js → jquery-2.0.3.js}
  40. +6 −0 NodeAssets.Example/Scripts/jquery-2.0.3.min.js
  41. +1 −0 NodeAssets.Example/Scripts/jquery-2.0.3.min.map
  42. +1,160 −553 NodeAssets.Example/Scripts/{jquery.signalR-1.0.0.js → jquery.signalR-2.0.0.js}
  43. +8 −0 NodeAssets.Example/Scripts/jquery.signalR-2.0.0.min.js
  44. +50 −0 NodeAssets.Example/Startup1.cs
  45. +8 −8 NodeAssets.Example/Views/Web.config
  46. +19 −14 NodeAssets.Example/Web.config
  47. +12 −6 NodeAssets.Example/packages.config
  48. +2 −2 NodeAssets.Test/Compilers/CoffeeCompilerTest.cs
  49. +1 −1 NodeAssets.Test/Compilers/CssoCompilerTest.cs
  50. +1 −1 NodeAssets.Test/Compilers/LessCompilerTest.cs
  51. +1 −1 NodeAssets.Test/Compilers/StylusCompilerTest.cs
  52. +10 −3 NodeAssets.Test/Compilers/TypescriptCompilerTest.cs
  53. +1 −1 NodeAssets.Test/Compilers/UglifyJSCompilerTest.cs
  54. +1 −1 NodeAssets.Test/Core/Commands/NodeExecutorTest.cs
  55. +8 −1 NodeAssets.Test/Data/examplets.js
  56. BIN NodeAssets.Test/Node/node.exe
  57. +16 −12 NodeAssets.Test/NodeAssets.Test.csproj
  58. +6 −0 NodeAssets.Test/NodeAssets.Test.csproj.user
  59. +6 −6 NodeAssets.Test/packages.config
  60. +6 −4 NodeAssets.sln
  61. BIN UpgradeLog.htm
@@ -1,16 +1,18 @@
using Microsoft.AspNet.SignalR;
+using Microsoft.Owin;
using NodeAssets.AspNet;
using NodeAssets.AspNet.Routes;
using NodeAssets.AspNet.Scripts;
using NodeAssets.Core;
using NodeAssets.Core.SourceManager;
+using Owin;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
+using System.Threading.Tasks;
using System.Web;
-using System.Web.Routing;
namespace NodeAssets
{
@@ -38,19 +40,12 @@ public static string Css(bool includeGlobal, params string[] otherAssets)
return _assets.FindCssAssets(includeGlobal, otherAssets);
}
- public static void SetupRoutes(RouteCollection routes)
- {
- if (_assets == null) { throw new InvalidOperationException("You must initialise your assests first"); }
-
- _assets.PrepareRoutes(routes);
- }
-
private const string Global = "global";
private readonly IAssetsConfiguration _config;
private readonly ISourceManager _jsManager;
private readonly ISourceManager _cssManager;
- private readonly Func<string, FileInfo, IRouteHandler> _routeHandler;
+ private readonly Func<string, FileInfo, Func<IOwinContext, Task>> _routeHandler;
private IPile _jsPile;
private IPile _cssPile;
@@ -66,7 +61,7 @@ public Assets(IAssetsConfiguration config)
if(config.RouteHandlerFunction == null)
{
- _routeHandler = (pile, file) => new DefaultRouteHandler(pile, file, config);
+ _routeHandler = (pile, file) => new DefaultHandler(file, config).Execute;
}
else
{
@@ -173,26 +168,33 @@ public string FindCssAssets(bool includeGlobal, params string[] otherAssets)
return builder.ToString();
}
- public void PrepareRoutes(RouteCollection routes)
+ public IAppBuilder MapNodeAssets(IAppBuilder appBuilder, ConnectionConfiguration configuration = null)
{
+ // NOTE: All the routes are based off 'Map' so we dont have to use middleware etc
if (_config.IsLiveCss)
{
- routes.MapConnection<LiveCssConnection>(_config.Namespace, "/" + _config.Namespace);
+ var config = configuration ?? new ConnectionConfiguration();
+ appBuilder.Map("/" + _config.Namespace, map =>
+ {
+ map.RunSignalR<LiveCssConnection>(config);
+ });
}
// Add js routes
if (_jsManager != null && _jsPile != null)
{
var pileManager = _jsManager.FindDestinationPile();
- HandleRoutes(pileManager, routes);
+ HandleRoutes(pileManager, appBuilder);
}
// Add css routes
if (_cssManager != null && _cssPile != null)
{
var pileManager = _cssManager.FindDestinationPile();
- HandleRoutes(pileManager, routes);
+ HandleRoutes(pileManager, appBuilder);
}
+
+ return appBuilder;
}
private IEnumerable<string> CombineUrls(IPile piles, bool global, IEnumerable<string> other)
@@ -259,17 +261,24 @@ private string WrapInCssTag(string src, string id)
return "<link id=\"" + id + "\" href=\"" + src + "\" rel=\"stylesheet\" type=\"text/css\" />";
}
- private void HandleRoutes(IPile destPile, RouteCollection routes)
+ private void HandleRoutes(IPile destPile, IAppBuilder appBuilder)
{
+ var pathDict = new List<string>();
foreach (var pile in destPile.FindAllPiles())
{
var files = destPile.FindFiles(pile).ToList();
if (!files.Any()) { continue; }
foreach (var file in files)
{
- // multiple routes for the same pile
- routes.Add(new MvcIgnoredRoute(FindFilePath(destPile, pile, file, true), _routeHandler(pile, file)));
+ // Avoid doubling up on paths (Can happen when combining)
+ var path = "/" + FindFilePath(destPile, pile, file, true);
+ if (!pathDict.Contains(path))
+ {
+ var runFunc = _routeHandler(pile, file);
+ appBuilder.Map(path, map => map.Run(runFunc));
+ pathDict.Add(path);
+ }
}
}
}
@@ -1,7 +1,8 @@
-using System;
-using System.IO;
-using System.Web.Routing;
+using Microsoft.Owin;
using NodeAssets.Core;
+using System;
+using System.IO;
+using System.Threading.Tasks;
namespace NodeAssets.AspNet
{
@@ -38,7 +39,7 @@ public IAssetsConfiguration LiveCss(bool live = true, string signalRNamespace =
return this;
}
- public IAssetsConfiguration SetRouteHandlerFunction(Func<string, FileInfo, IAssetsConfiguration, IRouteHandler> routeHandler)
+ public IAssetsConfiguration SetRouteHandlerFunction(Func<string, FileInfo, IAssetsConfiguration, Func<IOwinContext, Task>> routeHandler)
{
RouteHandlerFunction = routeHandler;
return this;
@@ -50,6 +51,6 @@ public IAssetsConfiguration SetRouteHandlerFunction(Func<string, FileInfo, IAsse
public string Namespace { get; private set; }
public ICompilerConfiguration CompilerConfiguration { get; private set; }
public ISourceManagerConfiguration SourceConfiguration { get; private set; }
- public Func<string, FileInfo, IAssetsConfiguration, IRouteHandler> RouteHandlerFunction { get; private set; }
+ public Func<string, FileInfo, IAssetsConfiguration, Func<IOwinContext, Task>> RouteHandlerFunction { get; private set; }
}
}
@@ -1,6 +1,7 @@
-using System;
-using System.Web.Routing;
+using Microsoft.AspNet.SignalR;
using NodeAssets.Core;
+using Owin;
+using System;
namespace NodeAssets
{
@@ -12,6 +13,6 @@ public interface IAssets
string FindJsAssets(bool includeGlobal, params string[] piles);
string FindCssAssets(bool includeGlobal, params string[] piles);
- void PrepareRoutes(RouteCollection routes);
+ IAppBuilder MapNodeAssets(IAppBuilder appBuilder, ConnectionConfiguration configuration = null);
}
}
@@ -1,7 +1,9 @@
-using System;
+using Microsoft.Owin;
+using NodeAssets.Core;
+using System;
using System.IO;
+using System.Threading.Tasks;
using System.Web.Routing;
-using NodeAssets.Core;
namespace NodeAssets.AspNet
{
@@ -12,7 +14,7 @@ public interface IAssetsConfiguration
IAssetsConfiguration LiveCss(bool live = true, string signalRNamespace = "nodeassets");
IAssetsConfiguration Cache(bool cache = true);
IAssetsConfiguration Compress(bool compress = true);
- IAssetsConfiguration SetRouteHandlerFunction(Func<string, FileInfo, IAssetsConfiguration, IRouteHandler> routeHandler);
+ IAssetsConfiguration SetRouteHandlerFunction(Func<string, FileInfo, IAssetsConfiguration, Func<IOwinContext, Task>> routeHandler);
ICompilerConfiguration CompilerConfiguration { get; }
ISourceManagerConfiguration SourceConfiguration { get; }
@@ -21,6 +23,6 @@ public interface IAssetsConfiguration
bool UseCache { get; }
bool UseCompress { get; }
- Func<string, FileInfo, IAssetsConfiguration, IRouteHandler> RouteHandlerFunction { get; }
+ Func<string, FileInfo, IAssetsConfiguration, Func<IOwinContext, Task>> RouteHandlerFunction { get; }
}
}
@@ -10,10 +10,11 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NodeAssets.AspNet</RootNamespace>
<AssemblyName>NodeAssets.AspNet</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\NodeAssets\</SolutionDir>
<RestorePackages>true</RestorePackages>
+ <TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -23,6 +24,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -31,30 +33,26 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Microsoft.AspNet.SignalR.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Microsoft.AspNet.SignalR.Core.1.0.0\lib\net40\Microsoft.AspNet.SignalR.Core.dll</HintPath>
+ <Reference Include="Microsoft.AspNet.SignalR.Core">
+ <HintPath>..\packages\Microsoft.AspNet.SignalR.Core.2.0.0\lib\net45\Microsoft.AspNet.SignalR.Core.dll</HintPath>
</Reference>
- <Reference Include="Microsoft.AspNet.SignalR.Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Microsoft.AspNet.SignalR.Owin.1.0.0\lib\net40\Microsoft.AspNet.SignalR.Owin.dll</HintPath>
+ <Reference Include="Microsoft.AspNet.SignalR.SystemWeb">
+ <HintPath>..\packages\Microsoft.AspNet.SignalR.SystemWeb.2.0.0\lib\net45\Microsoft.AspNet.SignalR.SystemWeb.dll</HintPath>
</Reference>
- <Reference Include="Microsoft.AspNet.SignalR.SystemWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Microsoft.AspNet.SignalR.SystemWeb.1.0.0\lib\net40\Microsoft.AspNet.SignalR.SystemWeb.dll</HintPath>
+ <Reference Include="Microsoft.Owin">
+ <HintPath>..\packages\Microsoft.Owin.2.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
</Reference>
- <Reference Include="Microsoft.Owin.Host.SystemWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Microsoft.Owin.Host.SystemWeb.1.0.0\lib\net40\Microsoft.Owin.Host.SystemWeb.dll</HintPath>
+ <Reference Include="Microsoft.Owin.Host.SystemWeb">
+ <HintPath>..\packages\Microsoft.Owin.Host.SystemWeb.2.0.1\lib\net45\Microsoft.Owin.Host.SystemWeb.dll</HintPath>
</Reference>
- <Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <Private>True</Private>
- <HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
+ <Reference Include="Microsoft.Owin.Security">
+ <HintPath>..\packages\Microsoft.Owin.Security.2.0.1\lib\net45\Microsoft.Owin.Security.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
- <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
+ <HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Owin">
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
@@ -74,11 +72,9 @@
<Compile Include="LiveCssConnection.cs" />
<Compile Include="Assets.cs" />
<Compile Include="AssetsConfiguration.cs" />
+ <Compile Include="NodeAssetsOwinExtension.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Routes\DefaultHttpHandler.cs" />
- <Compile Include="Routes\DefaultRouteHandler.cs" />
- <Compile Include="Routes\EncodingHelper.cs" />
- <Compile Include="Routes\MvcIgnoredRoute.cs" />
+ <Compile Include="Routes\DefaultHandler.cs" />
<Compile Include="Routes\QValue.cs" />
<Compile Include="Scripts\ScriptFinder.cs" />
</ItemGroup>
@@ -2,18 +2,18 @@
<package >
<metadata>
<id>NodeAssets.AspNet</id>
- <version>1.0.0</version>
+ <version>2.0.0</version>
<authors>Felix Jorkowski (jorkowski.com)</authors>
<owners>Felix Jorkowski (jorkowski.com)</owners>
<licenseUrl>http://www.opensource.org/licenses/MIT</licenseUrl>
<projectUrl>https://github.com/ajorkowski/NodeAssets</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>The Asp.Net component of node assests, provides a complete assest manager solution including compilation from coffee/styles, minification, combination, compression, and also a refresh-on-change css live updater</description>
- <releaseNotes>Updated to use SignalR 1.0.0, starting proper versioning</releaseNotes>
+ <releaseNotes>Updated to use SignalR 2.0.0 and Owin</releaseNotes>
<copyright>Copyright 2013</copyright>
- <tags>Asset Manager .NET MVC3 MVC4 NodeJS</tags>
+ <tags>Asset Manager OWIN NodeJS</tags>
<dependencies>
- <dependency id="NodeAssets.Core" version="0.0.9" />
+ <dependency id="NodeAssets.Core" version="2.0.0" />
<dependency id="Microsoft.AspNet.SignalR.SystemWeb" version="1.0.0" />
</dependencies>
</metadata>
@@ -0,0 +1,13 @@
+using Microsoft.AspNet.SignalR;
+using NodeAssets;
+
+namespace Owin
+{
+ public static class NodeAssetsOwinExtension
+ {
+ public static IAppBuilder MapNodeAssets(this IAppBuilder builder, IAssets assets, ConnectionConfiguration liveCssConfig = null)
+ {
+ return assets.MapNodeAssets(builder, liveCssConfig);
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit b52cb68

Please sign in to comment.