public string TransformContent(ResourceSet resourceSet, Resource resource, string content)
        {
            var extension = Path.GetExtension(resource.Path);
            if (extension != null && !extension.Equals(".coffee", StringComparison.InvariantCultureIgnoreCase))
                return content;

            var engine = new CoffeeSharp.CoffeeScriptEngine();
            return engine.Compile(content, filename: resource.Path);
        }
        public string TransformContent(ResourceSet resourceSet, Resource resource, string content)
        {
            var extension = Path.GetExtension(resource.Path);

            if (extension != null && !extension.Equals(".coffee", StringComparison.InvariantCultureIgnoreCase))
            {
                return(content);
            }

            var engine = new CoffeeSharp.CoffeeScriptEngine();

            return(engine.Compile(content, filename: resource.Path));
        }
Example #3
0
 public void Process(BundleContext context, BundleResponse response)
 {
     var coffeeEngine = new CoffeeSharp.CoffeeScriptEngine();
     string compiledCoffeeScript = string.Empty;
     foreach (var file in response.Files)
     {
         string physicalPath = System.Web.Hosting.HostingEnvironment.MapPath(HttpContext.Current.Request.ApplicationPath);
         using (var reader = new StreamReader(physicalPath + file.VirtualFile.VirtualPath))//////////////////////////////////////////////////
         {
             compiledCoffeeScript += coffeeEngine.Compile(reader.ReadToEnd());
             reader.Close();
         }
     }
     response.Content = compiledCoffeeScript;
     response.ContentType = "text/javascript";
     response.Cacheability = HttpCacheability.Public;
 }
Example #4
0
        public void Process(BundleContext context, BundleResponse response)
        {
            var    coffeeEngine         = new CoffeeSharp.CoffeeScriptEngine();
            string compiledCoffeeScript = string.Empty;

            foreach (var file in response.Files)
            {
                string physicalPath = System.Web.Hosting.HostingEnvironment.MapPath(HttpContext.Current.Request.ApplicationPath);
                using (var reader = new StreamReader(physicalPath + file.VirtualFile.VirtualPath))//////////////////////////////////////////////////
                {
                    compiledCoffeeScript += coffeeEngine.Compile(reader.ReadToEnd());
                    reader.Close();
                }
            }
            response.Content      = compiledCoffeeScript;
            response.ContentType  = "text/javascript";
            response.Cacheability = HttpCacheability.Public;
        }
Example #5
0
        private void compileCoffeeBtn_Click(object sender, EventArgs e)
        {
            fixButton();
            var coffeeScriptDir = Path.Combine(currAddon.contentPath, "panorama", "scripts", "coffeescript");

            if (!Directory.Exists(coffeeScriptDir))
            {
                MetroMessageBox.Show(this,
                                     coffeeScriptDir + " " + strings.DirectoryDoesntExistCaption,
                                     strings.DirectoryDoesntExistMsg,
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
                return;
            }

            if (cse == null)
            {
                cse = new CoffeeSharp.CoffeeScriptEngine();
            }

            var coffeePaths = Directory.GetFiles(coffeeScriptDir, "*.coffee", SearchOption.AllDirectories);

            foreach (var coffeePath in coffeePaths)
            {
                string coffeeCode = File.ReadAllText(coffeePath, Util.GetEncoding(coffeePath));
                string js         = cse.Compile(coffeeCode, true);

                string relativePath = coffeePath.Substring(coffeePath.IndexOf("coffeescript") + 13);

                var jsPath = Path.Combine(currAddon.contentPath, "panorama", "scripts", relativePath);
                jsPath = jsPath.Replace(".coffee", ".js");

                // ensure the dir housing the new js file exists.
                string foldPath = jsPath.Substring(0, jsPath.LastIndexOf('\\') + 1);
                if (!Directory.Exists(foldPath))
                {
                    Directory.CreateDirectory(foldPath);
                }

                File.WriteAllText(jsPath, js, Encoding.UTF8);
            }
            text_notification(strings.CoffeeScriptFilesCompiled, MetroColorStyle.Green, 1500);
        }
Example #6
0
        public void Process(BundleContext context, BundleResponse response)
        {
            var coffee = new CoffeeSharp.CoffeeScriptEngine();

            response.ContentType = "text/javascript";
            response.Content = string.Empty;

            foreach (var fileInfo in response.Files)
            {
                if (fileInfo.Extension.Equals(".coffee", StringComparison.Ordinal))
                {
                    var result = coffee.Compile(File.ReadAllText(fileInfo.FullName));

                    response.Content += result;
                }
                else if (fileInfo.Extension.Equals(".js", StringComparison.Ordinal))
                {
                    response.Content += File.ReadAllText(fileInfo.FullName);
                }
            }
        }
Example #7
0
        public void Process(BundleContext context, BundleResponse response)
        {
            var    coffeeEngine         = new CoffeeSharp.CoffeeScriptEngine();
            string compiledCoffeeScript = String.Empty;
            var    currentDirectory     = HttpContext.Current.Server.MapPath("~/");

            foreach (var file in response.Files)
            {
                var path = currentDirectory + file.VirtualFile.VirtualPath;

                using (var reader = new StreamReader(path))
                {
                    compiledCoffeeScript += coffeeEngine.Compile(reader.ReadToEnd());
                    reader.Close();
                }
            }

            response.Content      = compiledCoffeeScript;
            response.ContentType  = "text/javascript";
            response.Cacheability = HttpCacheability.Public;
        }
Example #8
0
        public void Process(BundleContext context, BundleResponse response)
        {
            var coffee = new CoffeeSharp.CoffeeScriptEngine();

            response.ContentType = "text/javascript";
            response.Content     = string.Empty;

            foreach (var fileInfo in response.Files)
            {
                if (fileInfo.Extension.Equals(".coffee", StringComparison.Ordinal))
                {
                    var result = coffee.Compile(File.ReadAllText(fileInfo.FullName));

                    response.Content += result;
                }
                else if (fileInfo.Extension.Equals(".js", StringComparison.Ordinal))
                {
                    response.Content += File.ReadAllText(fileInfo.FullName);
                }
            }
        }
Example #9
0
        public void Process(BundleContext context, BundleResponse response)
        {
            var coffeeEngine = new CoffeeSharp.CoffeeScriptEngine();
            string compiledCoffeeScript = String.Empty;
            var currentDirectory = HttpContext.Current.Server.MapPath("~/");
            foreach (var file in response.Files)
            {
                var path = currentDirectory + file.VirtualFile.VirtualPath;

                using (var reader = new StreamReader(path))
                {

                    compiledCoffeeScript += coffeeEngine.Compile(reader.ReadToEnd());
                    reader.Close();
                }
            }

            response.Content = compiledCoffeeScript;
            response.ContentType = "text/javascript";
            response.Cacheability = HttpCacheability.Public;
        }