private void writeScripts(HtmlTag foot)
        {
            // Do this regardless
            foot.Append(_assets.For("FubuDiagnostics.js").ToScriptTag(_request));

            var routeData = _routeWriter.WriteJavascriptRoutes("FubuDiagnostics.routes", _routes);

            foot.Append(routeData);

            var extensionFiles = _assets.JavascriptFiles().Where(x => x.AssemblyName != "FubuMVC.Core");

            if (FubuMode.Mode() == "diagnostics")
            {
                var names = _scripts.Union(extensionFiles.Select(x => x.Name));
                var links = _tags.BuildScriptTags(names.Select(x => "fubu-diagnostics/" + x));
                links.Each(x => foot.Append(x));
            }
            else
            {
                _scripts.Each(name =>
                {
                    var file = _assets.For(name);
                    foot.Append(file.ToScriptTag(_request));
                });

                extensionFiles.Each(file => foot.Append(file.ToScriptTag(_request)));
            }
        }
Пример #2
0
        private void writeScripts(HtmlTag foot)
        {
            // Do this regardless
            foot.Append(_assets.For("FubuDiagnostics.js").ToEmbeddedScriptTag());

            var routeData = _routeWriter.WriteJavascriptRoutes("FubuDiagnostics.routes", _routes);

            foot.Append(routeData);

            var extensionFiles = _assets.JavascriptFiles().Where(x => x.AssemblyName != "FubuMVC.Core");

            if (_runtime.Mode.InDiagnostics())
            {
                var names = _scripts.Union(extensionFiles.Select(x => x.Name.Split('.').Reverse().Take(2).Reverse().Join(".")));
                var links = _tags.BuildScriptTags(names.Select(x => "fubu-diagnostics/" + x));
                links.Each(x => foot.Append(x));
            }
            else
            {
                _scripts.Each(name =>
                {
                    var file = _assets.For(name);
                    foot.Append(file.ToEmbeddedScriptTag());
                });

                extensionFiles.Each(file => foot.Append(file.ToEmbeddedScriptTag()));
            }
        }
Пример #3
0
        public DashboardModel get__fubu()
        {
            var files    = _files.FindFiles(FileSet.Deep("fubu-diagnostics/*.html"));
            var htmlTags = files.Select(x => {
                var contents = x.ReadContents();
                var tag      = new HtmlTag("div").Id(Path.GetFileNameWithoutExtension(x.Path));
                tag.Encoded(false);
                tag.Text(contents);
                tag.Hide();
                tag.AddClass("left-content");

                return(tag);
            }).ToArray();

            var allJS      = findAssets(MimeType.Javascript).ToArray();
            var javascript = allJS.Where(x => !x.Filename.Contains(".jsx."));
            var react      = allJS.Where(x => x.Filename.Contains(".jsx."));


            return(new DashboardModel
            {
                StyleTags = findAssets(MimeType.Css).Select(x => new StylesheetLinkTag(_request.ToFullUrl(x.Url))).ToArray().ToTagList(),
                ScriptTags = javascript.Select(x => new ScriptTag(_ => _request.ToFullUrl(_), x)).ToArray().ToTagList(),
                Router = _routeWriter.WriteJavascriptRoutes("FubuDiagnostics.routes", _routes),
                ReactTags = react.Select(x => new ScriptTag(_ => _request.ToFullUrl(_), x).Attr("type", "text/jsx")).ToArray().ToTagList(),
                HtmlTags = htmlTags.ToTagList()
            });
        }