コード例 #1
0
        public void Init(HttpApplication context)
        {
            var coffeeEngine = new CoffeeScriptCompiler();

            var compilers = new ISimpleFileCompiler[] {
                new ConcatenationFileHandler(this),
                new MinifyingFileCompiler(coffeeEngine),
                new CoffeeScriptFileCompiler(coffeeEngine),
                new SassFileCompiler(),
                new JavascriptPassthroughCompiler(),
            };

            _handlers = new Dictionary<ISimpleFileCompiler, IHttpHandler>();
            foreach (var compiler in compilers) {
                compiler.Init(context);
                _handlers[compiler] = new CompilableFileHandler(compiler);
            }

            context.PostResolveRequestCache += (o, e) => {
                var app = o as HttpApplication;
                var compiler = MapPathToCompiler(app.Request.PhysicalPath);

                if (compiler == null) {
                    return;
                }

                app.Context.RemapHandler(_handlers[compiler]);
            };
        }
コード例 #2
0
        public void Init(HttpApplication context)
        {
            var compilers = new ISimpleFileCompiler[] {
                new CoffeeScriptFileCompiler(),
                new SassFileCompiler(),
            };

            _handlers = new Dictionary<string, IHttpHandler>();
            foreach (var compiler in compilers) {
                compiler.Init(context);
                _handlers[compiler.OutputFileExtension] = new CompilableFileHandler(compiler);
            }

            context.PostResolveRequestCache += (o, e) => {
                var app = o as HttpApplication;
                string ext = Path.GetExtension(app.Request.PhysicalPath.ToLowerInvariant());
                if (!_handlers.ContainsKey(ext)) {
                    return;
                }

                app.Context.RemapHandler(_handlers[ext]);
            };
        }
コード例 #3
0
 public CompilableFileHandler(ISimpleFileCompiler compiler)
 {
     _compiler = compiler;
 }
コード例 #4
0
 private CompilationResult CompileContent(string physicalFileName, ISimpleFileCompiler compiler)
 {
     var fi = new FileInfo(physicalFileName);
     return new CompilationResult(true, compiler.ProcessFileContent(physicalFileName), compiler.OutputMimeType, fi.LastWriteTimeUtc);
 }
コード例 #5
0
        private string GetCacheKey(string physicalFileName, ISimpleFileCompiler compiler)
        {
            var fi = new FileInfo(physicalFileName);
            var token = compiler.GetFileChangeToken(physicalFileName) ?? String.Empty;

            return String.Format("{0:yyyyMMddHHmmss}-{1}-{2}{3}",
                fi.LastWriteTimeUtc, token,
                Path.GetFileNameWithoutExtension(physicalFileName),
                compiler.OutputFileExtension);
        }
コード例 #6
0
 protected SassAndCoffeeHandler(ISimpleFileCompiler simpleFileCompiler)
 {
     this.simpleFileCompiler = simpleFileCompiler;
 }
コード例 #7
0
 protected SassAndCoffeeHandler(ISimpleFileCompiler simpleFileCompiler)
 {
     this.simpleFileCompiler = simpleFileCompiler;
 }
コード例 #8
0
 private CompilationResult CompileContent(ICompilerFile physicalFileName, ISimpleFileCompiler compiler)
 {
     return new CompilationResult(true, compiler.ProcessFileContent(physicalFileName), compiler.OutputMimeType, physicalFileName.LastWriteTimeUtc);
 }