Commits

Chris Nielsen  committed b773f21

Add MinCat.HttpHandler project.

  • Participants
  • Parent commits 92d5aa5

Comments (0)

Files changed (11)

File MinCat.HttpHandler/Content/Web.config.transform

+<configuration>
+	<location path="." inheritInChildApplications="false">
+		<system.web>
+			<httpHandlers>
+
+				<add verb="GET"
+					path="MinCat.ashx"
+					type="MinCat.HttpHandler.Handler, MinCat.HttpHandler" />
+
+			</httpHandlers>
+		</system.web>
+		<system.webServer>
+			<handlers>
+
+				<remove name="MinCat_HttpHandler" />
+				<add verb="GET"
+					path="MinCat.ashx"
+					name="MinCat_HttpHandler"
+					type="MinCat.HttpHandler.Handler, MinCat.HttpHandler" />
+
+			</handlers>
+		</system.webServer>
+	</location>
+</configuration>

File MinCat.HttpHandler/Handler.cs

+namespace MinCat.HttpHandler {
+	using System;
+	using System.Web;
+
+	/// <summary>
+	/// Provides support for expanding MinCat directives from an HttpHandler in
+	/// WebForms projects.
+	/// </summary>
+	public class Handler : IHttpHandler {
+
+		/// <summary>
+		/// Content type for JavaScript files.
+		/// </summary>
+		private const string ContentType = "application/javascript";
+
+		/// <summary>
+		/// Gets a value indicating whether another request can use the
+		/// <see cref="IHttpHandler" /> instance.
+		/// </summary>
+		public bool IsReusable {
+			get { return true; }
+		}
+
+		/// <summary>
+		/// Provides the contents of the JavaScript file at the requested location,
+		/// expanding any MinCat-related directives in the process.
+		/// </summary>
+		/// <param name="context">
+		/// An <see cref="HttpContext" /> object that provides references to the
+		/// intrinsic server objects (for example, Request, Response, Session, and
+		/// Server) used to service HTTP requests.
+		/// </param>
+		public void ProcessRequest(HttpContext context) {
+			var src = context.Request.QueryString["src"];
+			Handler.ProcessRequest(src, context);
+		}
+
+		/// <summary>
+		/// Provides the contents of the JavaScript file at the requested location,
+		/// expanding any MinCat-related directives in the process.
+		/// </summary>
+		/// <param name="src">The location of the JavaScript file.</param>
+		/// <param name="context">
+		/// An <see cref="HttpContext" /> object that provides references to the
+		/// intrinsic server objects (for example, Request, Response, Session, and
+		/// Server) used to service HTTP requests.
+		/// </param>
+		private static void ProcessRequest(string src, HttpContext context) {
+
+			if (string.IsNullOrEmpty(src)) {
+				throw new ArgumentNullException("src");
+			}
+
+			var path = context.Server.MapPath(src);
+
+			var minPath = RootFile.GetMinimizedPath(
+				path,
+				MinCat.Properties.Settings.Default.DefaultOutPath,
+				MinCat.Properties.Settings.Default.DefaultFilePattern);
+
+			var rootFile = new RootFile(path, minPath, HttpRuntime.AppDomainAppPath);
+
+			context.Response.ContentType = Handler.ContentType;
+
+			foreach (var line in rootFile.ReadLines(true)) {
+				context.Response.Output.WriteLine(line);
+			}
+		}
+	}
+}

File MinCat.HttpHandler/MinCat.HttpHandler.csproj

+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <UsingTask TaskName="HgVersionFile" AssemblyFile="..\Resources\MSBuildVersioning.dll" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{5614342E-897A-4CDD-8C9B-21F862139E07}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>MinCat.HttpHandler</RootNamespace>
+    <AssemblyName>MinCat.HttpHandler</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <TargetFrameworkProfile />
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <DocumentationFile>bin\Debug\MinCat.HttpHandler.XML</DocumentationFile>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <CodeAnalysisRuleSet>..\Code Analysis.ruleset</CodeAnalysisRuleSet>
+    <DocumentationFile>bin\Release\MinCat.HttpHandler.XML</DocumentationFile>
+  </PropertyGroup>
+  <PropertyGroup>
+    <SignAssembly>true</SignAssembly>
+    <AssemblyOriginatorKeyFile>MinCat.HttpHandler.snk</AssemblyOriginatorKeyFile>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Web" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Content\Web.config.transform" />
+    <Compile Include="Handler.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Properties\VersionInfo.cs" />
+    <None Include="Properties\VersionInfo.base.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\MinCat\MinCat.csproj">
+      <Project>{31cfd0f2-99c5-4919-8178-73ee4f61be8e}</Project>
+      <Name>MinCat</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="MinCat.HttpHandler.nuspec" />
+    <None Include="MinCat.HttpHandler.snk" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Target Name="BeforeBuild">
+    <HgVersionFile TemplateFile="Properties\VersionInfo.base.cs" DestinationFile="Properties\VersionInfo.cs" />
+  </Target>
+  <Target Name="AfterBuild">
+    <Message Text="Creating NuGet Package" />
+    <MakeDir Directories="..\NuGet\Feed" />
+    <Exec Command="..\NuGet\NuGet.exe pack MinCat.HttpHandler.csproj -Prop Configuration=Release -Verbosity detailed -OutputDirectory ..\NuGet\Feed" Condition="'$(Configuration)' == 'Release'" />
+  </Target>
+</Project>

File MinCat.HttpHandler/MinCat.HttpHandler.nuspec

+<?xml version="1.0"?>
+<package>
+  <metadata>
+    <id>$id$</id>
+    <version>$version$</version>
+    <title>$title$</title>
+    <authors>$author$</authors>
+    <owners>$author$</owners>
+    <licenseUrl>https://bitbucket.org/ChrisNielsen/mincat/wiki/License</licenseUrl>
+    <projectUrl>https://bitbucket.org/ChrisNielsen/mincat</projectUrl>
+    <iconUrl>https://bitbucket.org/ChrisNielsen/mincat/wiki/images/MinCatHandlerIcon32.png</iconUrl>
+    <description>$description$</description>
+    <releaseNotes>https://bitbucket.org/ChrisNielsen/mincat/wiki/ReleaseNotes</releaseNotes>
+    <copyright>Copyright 2012</copyright>
+    <tags>JavaScript CSS Minimize MSBuild</tags>
+  </metadata>
+  <files>
+    <file src="bin\Release\MinCat.dll" target="lib\net40\" />
+    <file src="bin\Release\MinCat.xml" target="lib\net40\" />
+    <file src="Content\Web.config.transform" target="Content\" />
+  </files>
+</package>

File MinCat.HttpHandler/MinCat.HttpHandler.snk

Binary file added.

File MinCat.HttpHandler/Properties/AssemblyInfo.cs

+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: AssemblyTitle("MinCat.HttpHelper")]
+[assembly: AssemblyDescription("MinCat HttpHelper")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Chris Nielsen")]
+[assembly: AssemblyProduct("MinCat.HttpHelper")]
+[assembly: AssemblyCopyright("Copyright © Chris Nielsen 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 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("33039838-f881-47cd-858e-bd23ac3480e0")]
+[assembly: System.CLSCompliant(true)]

File MinCat.HttpHandler/Properties/VersionInfo.base.cs

+using System.Diagnostics.CodeAnalysis;
+using System.Reflection;
+
+[assembly: SuppressMessage(
+	"Microsoft.Usage",
+	"CA2243:AttributeStringLiteralsShouldParseCorrectly",
+	Justification =
+		"Necessary to sync application version with source control.")]
+
+[assembly: AssemblyInformationalVersion("2.1 ($REVID$.$DIRTY$)")]
+[assembly: AssemblyVersion("2.1.$REVNUM$.$DIRTY$")]
+[assembly: AssemblyFileVersion("2.1.$REVNUM$.$DIRTY$")]

File MinCat.MVC/MinCat.MVC.nuspec

     <tags>JavaScript CSS Minimize MSBuild MVC</tags>
   </metadata>
   <files>
-      <file src="bin\Release\MinCat.dll" target="lib\net40\" />
-      <file src="bin\Release\MinCat.xml" target="lib\net40\" />
-      <file src="Content\Views\Web.config.transform" target="Content\Views\" />
+    <file src="bin\Release\MinCat.dll" target="lib\net40\" />
+    <file src="bin\Release\MinCat.xml" target="lib\net40\" />
+    <file src="Content\Views\Web.config.transform" target="Content\Views\" />
   </files>
 </package>
 		TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings
 	EndProjectSection
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinCat.HttpHandler", "MinCat.HttpHandler\MinCat.HttpHandler.csproj", "{5614342E-897A-4CDD-8C9B-21F862139E07}"
+EndProject
 Global
 	GlobalSection(TestCaseManagementSettings) = postSolution
 		CategoryFile = MinCat.vsmdi
 		{3BAE09E5-5955-4E19-B9D5-F7946C50F6C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{3BAE09E5-5955-4E19-B9D5-F7946C50F6C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{3BAE09E5-5955-4E19-B9D5-F7946C50F6C7}.Release|Any CPU.Build.0 = Release|Any CPU
+		{5614342E-897A-4CDD-8C9B-21F862139E07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{5614342E-897A-4CDD-8C9B-21F862139E07}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{5614342E-897A-4CDD-8C9B-21F862139E07}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{5614342E-897A-4CDD-8C9B-21F862139E07}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

File MinCat/Properties/AssemblyInfo.cs

 	"7b654b007cc750f3ed4021852c929cda84de6e1188eeecd92f23" +
 	"daf3e622cfa164069c90bed42dfb37162dd4fc3d57c8b916ce3e" +
 	"e528c9c6")]
+
+[assembly: InternalsVisibleTo("MinCat.HttpHandler, PublicKey=" +
+	"0024000004800000940000000602000000240000525341310004000001" +
+	"000100d77e9b2fcabbaf79f3e113ccfeb0ccba680f77f7b3c92ee7d46a" +
+	"7741ac6243efcefe0027faeb01023aaa2a52a63ddcc969199a28a8696c" +
+	"2e98b1644321f7e9e4a8c1a226369a92bc0c615de6ee7149b87aa8968e" +
+	"6c4e20d57f7819cecc53f76886389217084ca1cd9ec728f8b8bda216aa" +
+	"636732628ca53b12d89ee3a74f8fa0")]

File Resources/icon.xcf

Binary file modified.