├── .gitignore ├── .nuget ├── NuGet.Config ├── NuGet.exe └── NuGet.targets ├── AppHarbor.TransformTester.UnitTest ├── AppHarbor.TransformTester.UnitTest.csproj ├── Properties │ └── AssemblyInfo.cs ├── Transforms │ └── MergeTest.cs └── packages.config ├── AppHarbor.TransformTester.sln └── AppHarbor.TransformTester ├── AppHarbor.TransformTester.csproj ├── Controllers ├── HomeController.cs └── TransformController.cs ├── Global.asax ├── Global.asax.cs ├── Properties └── AssemblyInfo.cs ├── RequireHttpsAttribute.cs ├── Resources.Designer.cs ├── Resources.resx ├── Transforms ├── Merge.cs └── MergeBefore.cs ├── Views ├── Home │ └── Index.cshtml ├── Shared │ ├── Error.cshtml │ └── _Layout.cshtml ├── Web.config └── _ViewStart.cshtml ├── Web.Debug.config ├── Web.Release.config ├── Web.config ├── assets ├── css │ ├── 1140.css │ ├── forms.css │ ├── ie.css │ ├── layout.css │ ├── mobile.css │ ├── site.css │ ├── smallerscreen.css │ ├── typeimg.css │ └── xmlcolors.css └── js │ └── codemirror │ ├── codemirror.js │ ├── editor.js │ ├── mirrorframe.js │ ├── parsexml.js │ ├── select.js │ ├── stringstream.js │ ├── tokenize.js │ ├── tokenizejavascript.js │ ├── undo.js │ ├── unittests.js │ └── util.js └── packages.config /.gitignore: -------------------------------------------------------------------------------- 1 | [Oo]bj 2 | [Bb]in 3 | deploy 4 | deploy/* 5 | *.csproj.user 6 | *.suo 7 | *.cache 8 | TestResults/ 9 | packages/ -------------------------------------------------------------------------------- /.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appharbor/appharbor-transformtester/0af28cd9f509a81b73bf9b623e5a64987b0116b6/.nuget/NuGet.exe -------------------------------------------------------------------------------- /.nuget/NuGet.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildProjectDirectory)\..\ 5 | 6 | 7 | false 8 | 9 | 10 | false 11 | 12 | 13 | false 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) 27 | $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) 28 | $([System.IO.Path]::Combine($(SolutionDir), "packages")) 29 | 30 | 31 | 32 | 33 | $(SolutionDir).nuget 34 | packages.config 35 | $(SolutionDir)packages 36 | 37 | 38 | 39 | 40 | $(NuGetToolsPath)\nuget.exe 41 | @(PackageSource) 42 | 43 | "$(NuGetExePath)" 44 | mono --runtime=v4.0.30319 $(NuGetExePath) 45 | 46 | $(TargetDir.Trim('\\')) 47 | 48 | 49 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" -o "$(PackagesDir)" 50 | $(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols 51 | 52 | 53 | 54 | RestorePackages; 55 | $(BuildDependsOn); 56 | 57 | 58 | 59 | 60 | $(BuildDependsOn); 61 | BuildPackage; 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester.UnitTest/AppHarbor.TransformTester.UnitTest.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {B9C51963-207D-477E-82DA-949637D71A2B} 9 | Library 10 | Properties 11 | AppHarbor.TransformTester.UnitTest 12 | AppHarbor.TransformTester.UnitTest 13 | v4.5 14 | 512 15 | ..\ 16 | true 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | ..\packages\Microsoft.Web.Xdt.1.0.0-alpha\lib\net40\Microsoft.Web.XmlTransform.dll 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | ..\packages\xunit.1.9.1\lib\net20\xunit.dll 48 | 49 | 50 | ..\packages\xunit.extensions.1.9.1\lib\net20\xunit.extensions.dll 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | {8ABFCE9D-669D-42C3-B6F4-24DA052DD239} 63 | AppHarbor.TransformTester 64 | 65 | 66 | 67 | 68 | 75 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester.UnitTest/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("AppHarbor.TransformTester.UnitTest")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("AppHarbor.TransformTester.UnitTest")] 13 | [assembly: AssemblyCopyright("Copyright © 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("7edea99a-c951-4ab7-ab12-8002a82d5c80")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester.UnitTest/Transforms/MergeTest.cs: -------------------------------------------------------------------------------- 1 | using AppHarbor.TransformTester.Transforms; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Xml; 5 | using Xunit; 6 | using Xunit.Extensions; 7 | 8 | namespace AppHarbor.TransformTester.UnitTest.Transforms 9 | { 10 | public class MergeTest 11 | { 12 | [Theory] 13 | [InlineData("", "", "")] 14 | [InlineData("", "", "")] 15 | [InlineData("", "", "")] 16 | [InlineData("", "", "")] 17 | public void Apply_ShouldMerge(string targetXml, string transformXml, string expectedXml) 18 | { 19 | var targetDocument = ArrangeTargetDocument(targetXml); 20 | var transformElement = ArrangeTransformElement(targetDocument, transformXml); 21 | 22 | var merge = new Merge(); 23 | merge.Apply(targetDocument.DocumentElement, transformElement); 24 | 25 | Assert.Equal(expectedXml, targetDocument.OuterXml); 26 | } 27 | 28 | [Theory] 29 | [InlineData("", "", "", new[] { "/foo/baz" })] 30 | [InlineData("", "", "", new[] { "/foo/*" })] 31 | [InlineData("", "", "", new[] { "/foo/*" })] 32 | [InlineData("", "", "", new[] { "/foo/bar/*" })] 33 | public void Apply_ShouldMergeTop(string targetXml, string transformXml, string expectedXml, IList arguments) 34 | { 35 | var targetDocument = ArrangeTargetDocument(targetXml); 36 | var transformElement = ArrangeTransformElement(targetDocument, transformXml); 37 | 38 | var merge = new MergeBefore(); 39 | merge.Apply(targetDocument.DocumentElement, transformElement, arguments); 40 | 41 | Assert.Equal(expectedXml, targetDocument.OuterXml); 42 | } 43 | 44 | private XmlDocument ArrangeTargetDocument(string xml) 45 | { 46 | var document = new XmlDocument(); 47 | document.LoadXml(xml); 48 | 49 | return document; 50 | } 51 | 52 | private XmlElement ArrangeTransformElement(XmlDocument document, string xml) 53 | { 54 | using (var textReader = new StringReader(xml)) 55 | { 56 | using (var xmlReader = new XmlTextReader(textReader)) 57 | { 58 | var node = document.ReadNode(xmlReader); 59 | return (XmlElement)node; 60 | } 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester.UnitTest/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppHarbor.TransformTester", "AppHarbor.TransformTester\AppHarbor.TransformTester.csproj", "{8ABFCE9D-669D-42C3-B6F4-24DA052DD239}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppHarbor.TransformTester.UnitTest", "AppHarbor.TransformTester.UnitTest\AppHarbor.TransformTester.UnitTest.csproj", "{B9C51963-207D-477E-82DA-949637D71A2B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {8ABFCE9D-669D-42C3-B6F4-24DA052DD239}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {8ABFCE9D-669D-42C3-B6F4-24DA052DD239}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {8ABFCE9D-669D-42C3-B6F4-24DA052DD239}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {8ABFCE9D-669D-42C3-B6F4-24DA052DD239}.Release|Any CPU.Build.0 = Release|Any CPU 18 | {B9C51963-207D-477E-82DA-949637D71A2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {B9C51963-207D-477E-82DA-949637D71A2B}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {B9C51963-207D-477E-82DA-949637D71A2B}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {B9C51963-207D-477E-82DA-949637D71A2B}.Release|Any CPU.Build.0 = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/AppHarbor.TransformTester.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 8 | 9 | 2.0 10 | {8ABFCE9D-669D-42C3-B6F4-24DA052DD239} 11 | {E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 12 | Library 13 | Properties 14 | AppHarbor.TransformTester 15 | AppHarbor.TransformTester 16 | v4.5 17 | false 18 | true 19 | 20 | 21 | 22 | 23 | ..\ 24 | true 25 | 26 | 27 | true 28 | full 29 | false 30 | bin\ 31 | DEBUG;TRACE 32 | prompt 33 | 4 34 | 35 | 36 | pdbonly 37 | true 38 | bin\ 39 | TRACE 40 | prompt 41 | 4 42 | 43 | 44 | 45 | ..\packages\Microsoft.Web.Xdt.1.0.0-alpha\lib\net40\Microsoft.Web.XmlTransform.dll 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | Global.asax 75 | 76 | 77 | 78 | 79 | True 80 | True 81 | Resources.resx 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | Web.config 111 | 112 | 113 | Web.config 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | ResXFileCodeGenerator 129 | Resources.Designer.cs 130 | 131 | 132 | 133 | 134 | 135 | 136 | 10.0 137 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 138 | 139 | 140 | 141 | 142 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | True 156 | True 157 | 23370 158 | / 159 | http://localhost:23370/ 160 | False 161 | False 162 | 163 | 164 | False 165 | 166 | 167 | 168 | 169 | 170 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | 3 | namespace AppHarbor.TransformTester.Controllers 4 | { 5 | [RequireHttps] 6 | public class HomeController : Controller 7 | { 8 | public ActionResult Index() 9 | { 10 | ViewBag.DefaultWebConfig = Resources.DefaultWebConfig; 11 | ViewBag.DefaultTransform = Resources.DefaultTransformation; 12 | return View(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/Controllers/TransformController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Web.XmlTransform; 2 | using System.Text; 3 | using System.Web.Mvc; 4 | using System.Xml; 5 | using System.Xml.Linq; 6 | 7 | namespace AppHarbor.TransformTester.Controllers 8 | { 9 | [RequireHttps] 10 | public class TransformController : Controller 11 | { 12 | [HttpPost] 13 | [ValidateInput(false)] 14 | public ActionResult Create(string webConfigXml, string transformXml) 15 | { 16 | try 17 | { 18 | using (var document = new XmlTransformableDocument()) 19 | { 20 | document.PreserveWhitespace = true; 21 | document.LoadXml(webConfigXml); 22 | 23 | using (var transform = new XmlTransformation(transformXml, false, null)) 24 | { 25 | if (transform.Apply(document)) 26 | { 27 | var stringBuilder = new StringBuilder(); 28 | var xmlWriterSettings = new XmlWriterSettings(); 29 | xmlWriterSettings.Indent = true; 30 | xmlWriterSettings.IndentChars = " "; 31 | using (var xmlTextWriter = XmlTextWriter.Create(stringBuilder, xmlWriterSettings)) 32 | { 33 | document.WriteTo(xmlTextWriter); 34 | } 35 | return Content(stringBuilder.ToString(), "text/xml"); 36 | } 37 | else 38 | { 39 | return ErrorXml("Transformation failed for unkown reason"); 40 | } 41 | } 42 | } 43 | } 44 | catch (XmlTransformationException xmlTransformationException) 45 | { 46 | return ErrorXml(xmlTransformationException.Message); 47 | } 48 | catch (XmlException xmlException) 49 | { 50 | return ErrorXml(xmlException.Message); 51 | } 52 | } 53 | 54 | private ContentResult ErrorXml(string errorMessage) 55 | { 56 | return Content( 57 | new XDocument( 58 | new XElement("error", errorMessage) 59 | ).ToString(), "text/xml"); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="AppHarbor.TransformTester.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | using System.Web.Routing; 3 | 4 | namespace AppHarbor.TransformTester 5 | { 6 | public class MvcApplication : System.Web.HttpApplication 7 | { 8 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 9 | { 10 | filters.Add(new HandleErrorAttribute()); 11 | } 12 | 13 | public static void RegisterRoutes(RouteCollection routes) 14 | { 15 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 16 | 17 | routes.MapRoute( 18 | "Home", 19 | "", 20 | new { controller = "Home", action = "Index", id = UrlParameter.Optional } 21 | ); 22 | 23 | routes.MapRoute( 24 | "Transform", 25 | "transform", 26 | new { controller = "Transform", action = "Create", id = UrlParameter.Optional } 27 | ); 28 | } 29 | 30 | protected void Application_Start() 31 | { 32 | AreaRegistration.RegisterAllAreas(); 33 | 34 | RegisterGlobalFilters(GlobalFilters.Filters); 35 | RegisterRoutes(RouteTable.Routes); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /AppHarbor.TransformTester/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("AppHarbor.TransformTester")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("AppHarbor.TransformTester")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("bcee877c-8657-4a14-927e-28a6fba67e8a")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/RequireHttpsAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.Mvc; 3 | using RequireHttpsAttributeBase = System.Web.Mvc.RequireHttpsAttribute; 4 | 5 | namespace AppHarbor.TransformTester 6 | { 7 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)] 8 | public class RequireHttpsAttribute : RequireHttpsAttributeBase 9 | { 10 | public override void OnAuthorization(AuthorizationContext filterContext) 11 | { 12 | if (filterContext == null) 13 | { 14 | throw new ArgumentNullException("filterContext"); 15 | } 16 | 17 | if (filterContext.HttpContext.Request.IsSecureConnection) 18 | { 19 | return; 20 | } 21 | 22 | if (string.Equals(filterContext.HttpContext.Request.Headers["X-Forwarded-Proto"], 23 | "https", 24 | StringComparison.InvariantCultureIgnoreCase)) 25 | { 26 | return; 27 | } 28 | 29 | if (filterContext.HttpContext.Request.IsLocal) 30 | { 31 | return; 32 | } 33 | 34 | HandleNonHttpsRequest(filterContext); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.17626 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace AppHarbor.TransformTester { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AppHarbor.TransformTester.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to <?xml version="1.0"?> 65 | ///<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 66 | /// <xdt:Import assembly="AppHarbor.TransformTester" namespace="AppHarbor.TransformTester.Transforms"/> 67 | /// 68 | /// <configSections xdt:Transform="MergeBefore(/configuration/*)" /> 69 | /// 70 | /// <configSections> 71 | /// <section name="mySection" xdt:Transform="Insert" /> 72 | /// </configSections> 73 | /// 74 | /// <connectionStrings xdt:Transform="Merge" /> 75 | /// 76 | /// <connectionStrings> 77 | /// <add name="bar" connectionString="value" xdt:Transfor [rest of string was truncated]";. 78 | /// 79 | internal static string DefaultTransformation { 80 | get { 81 | return ResourceManager.GetString("DefaultTransformation", resourceCulture); 82 | } 83 | } 84 | 85 | /// 86 | /// Looks up a localized string similar to <?xml version="1.0"?> 87 | ///<configuration> 88 | /// <connectionStrings> 89 | /// <add name="foo" connectionString="value"/> 90 | /// </connectionStrings> 91 | /// <system.web> 92 | /// <customErrors mode="Off"/> 93 | /// </system.web> 94 | ///</configuration>. 95 | /// 96 | internal static string DefaultWebConfig { 97 | get { 98 | return ResourceManager.GetString("DefaultWebConfig", resourceCulture); 99 | } 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | <?xml version="1.0"?> 122 | <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 123 | <xdt:Import assembly="AppHarbor.TransformTester" namespace="AppHarbor.TransformTester.Transforms"/> 124 | 125 | <configSections xdt:Transform="MergeBefore(/configuration/*)" /> 126 | 127 | <configSections> 128 | <section name="mySection" xdt:Transform="Insert" /> 129 | </configSections> 130 | 131 | <connectionStrings xdt:Transform="Merge" /> 132 | 133 | <connectionStrings> 134 | <add name="bar" connectionString="value" xdt:Transform="Insert"/> 135 | </connectionStrings> 136 | 137 | <system.web> 138 | <customErrors mode="On" xdt:Transform="Replace"> 139 | </customErrors> 140 | </system.web> 141 | 142 | </configuration> 143 | 144 | 145 | <?xml version="1.0"?> 146 | <configuration> 147 | <connectionStrings> 148 | <add name="foo" connectionString="value"/> 149 | </connectionStrings> 150 | <system.web> 151 | <customErrors mode="Off"/> 152 | </system.web> 153 | </configuration> 154 | 155 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/Transforms/Merge.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Web.XmlTransform; 2 | using System.Linq; 3 | using System.Xml; 4 | 5 | namespace AppHarbor.TransformTester.Transforms 6 | { 7 | public class Merge : Transform 8 | { 9 | public Merge() 10 | : base(TransformFlags.UseParentAsTargetNode) 11 | { 12 | } 13 | 14 | protected override void Apply() 15 | { 16 | Apply((XmlElement)TargetNode, (XmlElement)TransformNode); 17 | } 18 | 19 | public void Apply(XmlElement targetElement, XmlElement transformElement) 20 | { 21 | var targetChildElement = targetElement.ChildNodes.OfType().FirstOrDefault(x => x.LocalName == transformElement.LocalName); 22 | if (targetChildElement == null) 23 | { 24 | InsertTransformElement(targetElement, transformElement); 25 | return; 26 | } 27 | 28 | foreach (var transformChildElement in transformElement.ChildNodes.OfType()) 29 | { 30 | Apply(targetChildElement, transformChildElement); 31 | } 32 | } 33 | 34 | protected virtual void InsertTransformElement(XmlElement targetElement, XmlElement transformElement) 35 | { 36 | targetElement.AppendChild(transformElement); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/Transforms/MergeBefore.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Xml; 5 | 6 | namespace AppHarbor.TransformTester.Transforms 7 | { 8 | public class MergeBefore : Merge 9 | { 10 | protected override void Apply() 11 | { 12 | Apply((XmlElement)TargetNode, (XmlElement)TransformNode, Arguments); 13 | } 14 | 15 | public void Apply(XmlElement targetElement, XmlElement transformElement, IList arguments) 16 | { 17 | var xpath = arguments.First(); 18 | if (string.IsNullOrEmpty(xpath)) 19 | { 20 | throw new ArgumentException("xpath"); 21 | } 22 | 23 | var targetNode = targetElement.SelectSingleNode(xpath); 24 | Apply((XmlElement)targetNode.ParentNode, transformElement); 25 | } 26 | 27 | protected override void InsertTransformElement(XmlElement targetElement, XmlElement transformElement) 28 | { 29 | targetElement.InsertBefore(transformElement, targetElement.ChildNodes.OfType().FirstOrDefault()); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "Web.config Transformation Tester"; 3 | Layout = "~/Views/Shared/_Layout.cshtml"; 4 | } 5 | 6 |
7 | Fork me on GitHub 8 |
9 |

10 | Web.config Transformation Tester

11 |
12 |
13 |
14 |

15 | This is a simple tool that lets you test 16 | Web.config transformations. Here's the 17 | full syntax-guide at MSDN. 18 |

19 |
20 |
21 |

22 | Paste your web.config into the top text box and your transform into the second one. 23 | Click the 'Transform' button to see the result of the transformation. 24 |

25 |
26 |
27 |

28 | This tool was made for your enjoyment by AppHarbor, 29 | the .NET Platform-as-a-Service. 30 |

31 |
32 |
33 |
34 |
35 |

36 | Web.config

37 | 40 |
41 |
42 |
43 |
44 |   45 |
46 |
47 |
48 |
49 |

50 | Transform (eg. Web.Debug.config)

51 | 54 |
55 |
56 |
57 |
58 |   59 |
60 |
61 |
62 |
63 |   64 |
65 |
66 | 67 |
68 |
69 |   70 |
71 |
72 |
73 |
74 |

75 | Result

76 | 78 |
79 |
80 |
81 | 86 |
87 | 118 |
119 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = null; 3 | } 4 | 5 | 6 | 7 | 8 | Error 9 | 10 | 11 |

12 | Sorry, an error occurred while processing your request. 13 |

14 | 15 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | @ViewBag.Title 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 33 | 34 | 35 | 36 | @RenderBody() 37 | 38 | 39 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/Views/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 39 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } 4 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/assets/css/1140.css: -------------------------------------------------------------------------------- 1 | /* CSS Resets */ 2 | 3 | html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,address,cite,code,del,dfn,em,img,ins,q,small,strong,sub,sup,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{border:0;margin:0;padding:0}article,aside,figure,figure img,figcaption,hgroup,footer,header,nav,section,video,object{display:block}a img{border:0}figure{position:relative}figure img{width:100%} 4 | 5 | 6 | /* The 1140px Grid by Andy Taylor – http://cssgrid.net – http://www.twitter.com/andytlr – http://www.catchingzebra.com */ 7 | 8 | .container { 9 | padding-left: 20px; 10 | padding-right: 20px; 11 | } 12 | 13 | .row { 14 | width: 100%; 15 | max-width: 1140px; 16 | margin: 0 auto; 17 | overflow: hidden; 18 | } 19 | 20 | .onecol, .twocol, .threecol, .fourcol, .fivecol, .sixcol, .sevencol, .eightcol, .ninecol, .tencol, .elevencol { 21 | margin-right: 3.8%; 22 | float: left; 23 | } 24 | 25 | .onecol { 26 | width: 4.85%; 27 | } 28 | 29 | .twocol { 30 | width: 13.5%; 31 | } 32 | 33 | .threecol { 34 | width: 22.15%; 35 | } 36 | 37 | .fourcol { 38 | width: 30.8%; 39 | } 40 | 41 | .fivecol { 42 | width: 39.45%; 43 | } 44 | 45 | .sixcol { 46 | width: 48.1%; 47 | } 48 | 49 | .sevencol { 50 | width: 56.75%; 51 | } 52 | 53 | .eightcol { 54 | width: 65.4%; 55 | } 56 | 57 | .ninecol { 58 | width: 74.05%; 59 | } 60 | 61 | .tencol { 62 | width: 82.7%; 63 | } 64 | 65 | .elevencol { 66 | width: 91.35%; 67 | } 68 | 69 | .twelvecol { 70 | width: 100%; 71 | float: left; 72 | } 73 | 74 | .last { 75 | margin-right: 0px; 76 | } 77 | 78 | img, object, embed { 79 | max-width: 100%; 80 | } -------------------------------------------------------------------------------- /AppHarbor.TransformTester/assets/css/forms.css: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------- 2 | 3 | forms.css 4 | * Sets up some default styling for forms 5 | * Gives you classes to enhance your forms 6 | 7 | Usage: 8 | * For text fields, use class .title or .text 9 | * For inline forms, use .inline (even when using columns) 10 | 11 | -------------------------------------------------------------- */ 12 | 13 | /* 14 | A special hack is included for IE8 since it does not apply padding 15 | correctly on fieldsets 16 | */ 17 | label { font-weight: bold; } 18 | fieldset { padding:0 1.4em 1.4em 1.4em; margin: 0 0 1.5em 0; border: 1px solid #ccc; } 19 | legend { font-weight: bold; font-size:1.2em; margin-top:-0.2em; margin-bottom:1em; } 20 | 21 | fieldset, #IE8#HACK { padding-top:1.4em; } 22 | legend, #IE8#HACK { margin-top:0; margin-bottom:0; } 23 | 24 | /* Form fields 25 | -------------------------------------------------------------- */ 26 | 27 | /* 28 | Attribute selectors are used to differentiate the different types 29 | of input elements, but to support old browsers, you will have to 30 | add classes for each one. ".title" simply creates a large text 31 | field, this is purely for looks. 32 | */ 33 | input[type=text], input[type=password], 34 | input.text, input.title, 35 | textarea { 36 | background-color:#fff; 37 | border:1px solid #bbb; 38 | } 39 | input[type=text]:focus, input[type=password]:focus, 40 | input.text:focus, input.title:focus, 41 | textarea:focus { 42 | border-color:#666; 43 | } 44 | select { background-color:#fff; border-width:1px; border-style:solid; } 45 | 46 | input[type=text], input[type=password], 47 | input.text, input.title, 48 | textarea, select { 49 | margin:0.5em 0; 50 | } 51 | 52 | input.text, 53 | input.title { width: 300px; padding:5px; } 54 | input.title { font-size:1.5em; } 55 | textarea { width: 390px; height: 250px; padding:5px; } 56 | 57 | /* 58 | This is to be used on forms where a variety of elements are 59 | placed side-by-side. Use the p tag to denote a line. 60 | */ 61 | form.inline { line-height:3; } 62 | form.inline p { margin-bottom:0; } 63 | 64 | 65 | /* Success, info, notice and error/alert boxes 66 | -------------------------------------------------------------- */ 67 | 68 | .error, 69 | .alert, 70 | .notice, 71 | .success, 72 | .info { padding: 0.8em; margin-bottom: 1em; border: 2px solid #ddd; } 73 | 74 | .error, .alert { background: #fbe3e4; color: #8a1f11; border-color: #fbc2c4; } 75 | .notice { background: #fff6bf; color: #514721; border-color: #ffd324; } 76 | .success { background: #e6efc2; color: #264409; border-color: #c6d880; } 77 | .info { background: #d5edf8; color: #205791; border-color: #92cae4; } 78 | .error a, .alert a { color: #8a1f11; } 79 | .notice a { color: #514721; } 80 | .success a { color: #264409; } 81 | .info a { color: #205791; } 82 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/assets/css/ie.css: -------------------------------------------------------------------------------- 1 | .onecol { 2 | width: 4.7%; 3 | } 4 | 5 | .twocol { 6 | width: 13.2%; 7 | } 8 | 9 | .threecol { 10 | width: 22.05%; 11 | } 12 | 13 | .fourcol { 14 | width: 30.6%; 15 | } 16 | 17 | .fivecol { 18 | width: 39%; 19 | } 20 | 21 | .sixcol { 22 | width: 48%; 23 | } 24 | 25 | .sevencol { 26 | width: 56.75%; 27 | } 28 | 29 | .eightcol { 30 | width: 61.6%; 31 | } 32 | 33 | .ninecol { 34 | width: 74.05%; 35 | } 36 | 37 | .tencol { 38 | width: 82%; 39 | } 40 | 41 | .elevencol { 42 | width: 91.35%; 43 | } -------------------------------------------------------------------------------- /AppHarbor.TransformTester/assets/css/layout.css: -------------------------------------------------------------------------------- 1 | /* Layout for desktop version */ 2 | 3 | body { 4 | 5 | } 6 | 7 | 8 | /* Layout for mobile version */ 9 | 10 | @media handheld, only screen and (max-width: 767px) { 11 | 12 | .examplecontainer { 13 | 14 | body { 15 | 16 | } 17 | 18 | } 19 | 20 | 21 | /* Provide higher res assets for iPhone 4 */ 22 | 23 | @media only screen and (-webkit-min-device-pixel-ratio: 2) { 24 | 25 | /* An example of how to override an image with one twice the size for iPhone 4. Specify the original pixel size with background-size. 26 | .download { 27 | background: url(../img/downarrow@2x.png) no-repeat; 28 | background-size: 27px 28px; 29 | } 30 | */ 31 | 32 | } -------------------------------------------------------------------------------- /AppHarbor.TransformTester/assets/css/mobile.css: -------------------------------------------------------------------------------- 1 | .row, .body, .container { 2 | width: 100%; 3 | margin-left: 0px; 4 | margin-right: 0px; 5 | padding-left: 0px; 6 | padding-right: 0px; 7 | } 8 | 9 | .onecol, .twocol, .threecol, .fourcol, .fivecol, .sixcol, .sevencol, .eightcol, .ninecol, .tencol, .elevencol, .twelvecol { 10 | width: auto; 11 | float: none; 12 | margin-left: 0px; 13 | margin-right: 0px; 14 | padding-left: 20px; 15 | padding-right: 20px; 16 | } 17 | 18 | /* Type presets */ 19 | 20 | body { 21 | font-size: 16px; 22 | line-height: 24px; 23 | } -------------------------------------------------------------------------------- /AppHarbor.TransformTester/assets/css/site.css: -------------------------------------------------------------------------------- 1 | textarea.code 2 | { 3 | width: 97%; 4 | } 5 | input[type="submit"] 6 | { 7 | width: 100%; 8 | height: 3em; 9 | font-size: 100%; 10 | } 11 | 12 | .CodeMirror-line-numbers{ 13 | width: 2.2em; 14 | color: #aaa; 15 | background-color: #eee; 16 | text-align: right; 17 | padding-right: .3em; 18 | font-size: 10pt; 19 | font-family: monospace; 20 | padding-top: .4em; 21 | line-height: normal; 22 | } 23 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/assets/css/smallerscreen.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 0.8em; /* Makes type a bit smaller at 1024 so layout doesn't look unbalanced */ 3 | line-height: 1.5em; /* As above */ -------------------------------------------------------------------------------- /AppHarbor.TransformTester/assets/css/typeimg.css: -------------------------------------------------------------------------------- 1 | /* Type & image presets */ 2 | 3 | img, object, embed { 4 | margin-bottom: 20px; 5 | } 6 | 7 | body { 8 | font-family: Helvetica Neue, Helvetica, Arial, sans-serif; 9 | font-size: 14px; 10 | line-height: 24px; /* Changing this will break the baseline grid. */ 11 | -webkit-text-size-adjust: none; /* Stops the iPhone scalling type up */ 12 | } 13 | 14 | a { 15 | text-decoration: none; 16 | color: #005698; 17 | font-weight: bold; 18 | border-bottom: 1px solid #adadad; 19 | } 20 | 21 | a:hover { 22 | color: #000; 23 | border-bottom: none; 24 | } 25 | 26 | a img { 27 | display: block; /* Stops image links getting text link styles */ 28 | } 29 | 30 | img { 31 | -webkit-border-radius: 3px; 32 | -moz-border-radius: 3px; 33 | border-radius: 3px; 34 | margin-bottom: 20px; 35 | } 36 | 37 | p, ul, ol, blockquote { 38 | margin-bottom: 24px; /* Changing this will break the baseline grid. */ 39 | } 40 | 41 | li { 42 | margin-bottom: 6px; 43 | } 44 | 45 | blockquote { 46 | border-left: 1px solid #c1c1c1; 47 | color: #747474; 48 | padding-left: 15px; 49 | margin-left: -15px; 50 | } 51 | 52 | h1 { 53 | font-size: 30px; 54 | line-height: 36px; /* Changing this will break the baseline grid. */ 55 | margin-bottom: 24px; /* Changing this will break the baseline grid. */ 56 | font-family: Georgia; 57 | font-weight: lighter; 58 | } 59 | 60 | h2 { 61 | font-size: 20px; 62 | margin-bottom: 24px; /* Changing this will break the baseline grid. */ 63 | font-family: Georgia, serif; 64 | font-weight: lighter; 65 | } 66 | 67 | h3 { 68 | font-size: 16px; 69 | margin-bottom: 24px; /* Changing this will break the baseline grid. */ 70 | font-family: Georgia, serif; 71 | font-weight: lighter; 72 | } -------------------------------------------------------------------------------- /AppHarbor.TransformTester/assets/css/xmlcolors.css: -------------------------------------------------------------------------------- 1 | html { 2 | cursor: text; 3 | } 4 | 5 | .editbox { 6 | margin: .4em; 7 | padding: 0; 8 | font-family: monospace; 9 | font-size: 10pt; 10 | color: black; 11 | } 12 | 13 | .editbox p { 14 | margin: 0; 15 | } 16 | 17 | span.xml-tagname { 18 | color: #A0B; 19 | } 20 | 21 | span.xml-attribute { 22 | color: #281; 23 | } 24 | 25 | span.xml-punctuation { 26 | color: black; 27 | } 28 | 29 | span.xml-attname { 30 | color: #00F; 31 | } 32 | 33 | span.xml-comment { 34 | color: #A70; 35 | } 36 | 37 | span.xml-cdata { 38 | color: #48A; 39 | } 40 | 41 | span.xml-processing { 42 | color: #999; 43 | } 44 | 45 | span.xml-entity { 46 | color: #A22; 47 | } 48 | 49 | span.xml-error { 50 | color: #F00 !important; 51 | } 52 | 53 | span.xml-text { 54 | color: black; 55 | } 56 | -------------------------------------------------------------------------------- /AppHarbor.TransformTester/assets/js/codemirror/codemirror.js: -------------------------------------------------------------------------------- 1 | /* CodeMirror main module (http://codemirror.net/) 2 | * 3 | * Implements the CodeMirror constructor and prototype, which take care 4 | * of initializing the editor frame, and providing the outside interface. 5 | */ 6 | 7 | // The CodeMirrorConfig object is used to specify a default 8 | // configuration. If you specify such an object before loading this 9 | // file, the values you put into it will override the defaults given 10 | // below. You can also assign to it after loading. 11 | var CodeMirrorConfig = window.CodeMirrorConfig || {}; 12 | 13 | var CodeMirror = (function(){ 14 | function setDefaults(object, defaults) { 15 | for (var option in defaults) { 16 | if (!object.hasOwnProperty(option)) 17 | object[option] = defaults[option]; 18 | } 19 | } 20 | function forEach(array, action) { 21 | for (var i = 0; i < array.length; i++) 22 | action(array[i]); 23 | } 24 | function createHTMLElement(el) { 25 | if (document.createElementNS && document.documentElement.namespaceURI !== null) 26 | return document.createElementNS("http://www.w3.org/1999/xhtml", el) 27 | else 28 | return document.createElement(el) 29 | } 30 | 31 | // These default options can be overridden by passing a set of 32 | // options to a specific CodeMirror constructor. See manual.html for 33 | // their meaning. 34 | setDefaults(CodeMirrorConfig, { 35 | stylesheet: [], 36 | path: "", 37 | parserfile: [], 38 | basefiles: ["util.js", "stringstream.js", "select.js", "undo.js", "editor.js", "tokenize.js"], 39 | iframeClass: null, 40 | passDelay: 200, 41 | passTime: 50, 42 | lineNumberDelay: 200, 43 | lineNumberTime: 50, 44 | continuousScanning: false, 45 | saveFunction: null, 46 | onLoad: null, 47 | onChange: null, 48 | undoDepth: 50, 49 | undoDelay: 800, 50 | disableSpellcheck: true, 51 | textWrapping: true, 52 | readOnly: false, 53 | width: "", 54 | height: "300px", 55 | minHeight: 100, 56 | autoMatchParens: false, 57 | markParen: null, 58 | unmarkParen: null, 59 | parserConfig: null, 60 | tabMode: "indent", // or "spaces", "default", "shift" 61 | enterMode: "indent", // or "keep", "flat" 62 | electricChars: true, 63 | reindentOnLoad: false, 64 | activeTokens: null, 65 | onCursorActivity: null, 66 | lineNumbers: false, 67 | firstLineNumber: 1, 68 | onLineNumberClick: null, 69 | indentUnit: 2, 70 | domain: null, 71 | noScriptCaching: false, 72 | incrementalLoading: false 73 | }); 74 | 75 | function addLineNumberDiv(container, firstNum) { 76 | var nums = createHTMLElement("div"), 77 | scroller = createHTMLElement("div"); 78 | nums.style.position = "absolute"; 79 | nums.style.height = "100%"; 80 | if (nums.style.setExpression) { 81 | try {nums.style.setExpression("height", "this.previousSibling.offsetHeight + 'px'");} 82 | catch(e) {} // Seems to throw 'Not Implemented' on some IE8 versions 83 | } 84 | nums.style.top = "0px"; 85 | nums.style.left = "0px"; 86 | nums.style.overflow = "hidden"; 87 | container.appendChild(nums); 88 | scroller.className = "CodeMirror-line-numbers"; 89 | nums.appendChild(scroller); 90 | scroller.innerHTML = "
" + firstNum + "
"; 91 | return nums; 92 | } 93 | 94 | function frameHTML(options) { 95 | if (typeof options.parserfile == "string") 96 | options.parserfile = [options.parserfile]; 97 | if (typeof options.basefiles == "string") 98 | options.basefiles = [options.basefiles]; 99 | if (typeof options.stylesheet == "string") 100 | options.stylesheet = [options.stylesheet]; 101 | 102 | var sp = " spellcheck=\"" + (options.disableSpellcheck ? "false" : "true") + "\""; 103 | var html = [""]; 104 | // Hack to work around a bunch of IE8-specific problems. 105 | html.push(""); 106 | var queryStr = options.noScriptCaching ? "?nocache=" + new Date().getTime().toString(16) : ""; 107 | forEach(options.stylesheet, function(file) { 108 | html.push(""); 109 | }); 110 | forEach(options.basefiles.concat(options.parserfile), function(file) { 111 | if (!/^https?:/.test(file)) file = options.path + file; 112 | html.push("