Exemple #1
0
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            var fileName = requestContext.RouteData.Values.Select(x => x.Value as string).Where(x => x.IsNotEmpty()).Join("/");
            var fullPath = _folders.FileNameFor(_contentType, fileName);

            return(new FileHttpHandler(fullPath, _mimeTypeProvider));
        }
Exemple #2
0
        public IEnumerable <HtmlTag> Write(IEnumerable <string> scripts)
        {
            var rawFiles     = scripts.Select(script => _folderService.FileNameFor(ContentType.scripts, script)).Where(x => x != null).ToArray();
            var combinedName = _fileCombiner.GenerateCombinedFile(rawFiles, "; // src: {0}");

            if (combinedName == null)
            {
                return(Enumerable.Empty <HtmlTag>());
            }
            var scriptUrl = "~/content/{0}".ToFormat(combinedName).ToAbsoluteUrl();

            return(new[] { new HtmlTag("script").Attr("src", scriptUrl).Attr("type", "text/javascript") });
        }
Exemple #3
0
        public IEnumerable <HtmlTag> Write(IEnumerable <string> stylesheets)
        {
            // if only 1 file, use single file writer... or should it write the file (w/its real name) anyway, to get it out of _content?
            if (!stylesheets.Skip(1).Any())
            {
                return(_singleFileWriter.Write(stylesheets));
            }
            // TODO: keep track of files that are combined, for this request. if it is asked for again, do not render anything
            var rawFiles     = stylesheets.Select(file => _folderService.FileNameFor(ContentType.styles, file)).Where(x => x != null).ToArray();
            var combinedName = _fileCombiner.GenerateCombinedFile(rawFiles, "/* src: {0} */");

            if (combinedName == null)
            {
                return(Enumerable.Empty <HtmlTag>());
            }
            var url = "~/content/{0}".ToFormat(combinedName).ToAbsoluteUrl();

            return(new[] { new HtmlTag("link").Attr("href", url).Attr("rel", "stylesheet").Attr("type", "text/css") });
        }