Example #1
0
        static ResourceManagementOptionsConfiguration()
        {
            _manifest = new ResourceManifest();

            // See https://github.com/marella/material-icons for usage
            _manifest
            .DefineStyle("material-icons")
            .SetCdn("https://fonts.googleapis.com/icon?family=Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp")
            .SetUrl("~/TheAdmin/fonts/material-icons/material-icons.min.css", "~/TheAdmin/fonts/material-icons/material-icons.css")
            .SetVersion("1.10.11");

            _manifest
            .DefineScript("admin")
            .SetDependencies("jQuery")
            .SetUrl("~/TheAdmin/js/TheAdmin.min.js", "~/TheAdmin/js/TheAdmin.js")
            .SetVersion("1.0.0");

            _manifest
            .DefineScript("admin-head")
            .SetUrl("~/TheAdmin/js/TheAdmin-header.min.js", "~/TheAdmin/js/TheAdmin-header.js")
            .SetVersion("1.0.0");

            _manifest
            .DefineStyle("admin")
            .SetUrl("~/TheAdmin/css/TheAdmin.min.css", "~/TheAdmin/css/TheAdmin.css")
            .SetVersion("1.0.0");
        }
        static ResourceManagementOptionsConfiguration()
        {
            manifest = new ResourceManifest();

            manifest
            .DefineScript("ZachsBlogTheme-vendor-jQuery")
            .SetUrl("~/ZachsBlogTheme/vendor/jquery/jquery.min.js", "~/ZachsBlogTheme/vendor/jquery/jquery.js")
            .SetCdn("https://code.jquery.com/jquery-3.4.1.min.js", "https://code.jquery.com/jquery-3.4.1.js")
            .SetCdnIntegrity("sha384-vk5WoKIaW/vJyUAd9n/wmopsmNhiy+L2Z+SBxGYnUkunIxVxAv/UtMOhba/xskxh", "sha384-mlceH9HlqLp7GMKHrj5Ara1+LvdTZVMx4S1U43/NxCvAkzIo8WJ0FE7duLel3wVo")
            .SetVersion("3.4.1");

            manifest
            .DefineScript("ZachsBlogTheme-vendor-jQuery.slim")
            .SetUrl("~/ZachsBlogTheme/vendor/jquery/jquery.slim.min.js", "~/ZachsBlogTheme/vendor/jquery/jquery.slim.js")
            .SetCdn("https://code.jquery.com/jquery-3.4.1.slim.min.js", "https://code.jquery.com/jquery-3.4.1.slim.js")
            .SetCdnIntegrity("sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n", "sha384-teRaFq/YbXOM/9FZ1qTavgUgTagWUPsk6xapwcjkrkBHoWvKdZZuAeV8hhaykl+G")
            .SetVersion("3.4.1");

            manifest
            .DefineScript("ZachsBlogTheme-vendor-bootstrap")
            .SetDependencies("ZachsBlogTheme-vendor-jQuery")
            .SetUrl("~/ZachsBlogTheme/vendor/bootstrap/js/bootstrap.min.js", "~/ZachsBlogTheme/vendor/bootstrap/js/bootstrap.js")
            .SetCdn("https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js", "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.js")
            .SetCdnIntegrity("sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM", "sha384-rkSGcquOAzh5YMplX4tcXMuXXwmdF/9eRLkw/gNZG+1zYutPej7fxyVLiOgfoDgi")
            .SetVersion("4.3.1");

            manifest
            .DefineScript("ZachsBlogTheme-vendor-bootstrap-bundle")
            .SetDependencies("ZachsBlogTheme-vendor-jQuery")
            .SetUrl("~/ZachsBlogTheme/vendor/bootstrap/js/bootstrap.bundle.min.js", "~/ZachsBlogTheme/vendor/bootstrap/js/bootstrap.bundle.js")
            .SetCdn("https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js", "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.js")
            .SetCdnIntegrity("sha384-xrRywqdh3PHs8keKZN+8zzc5TX0GRTLCcmivcbNJWm2rs5C8PRhcEn3czEjhAO9o", "sha384-szbKYgPl66wivXHlSpJF+CKDAVckMVnlGrP25Sndhe+PwOBcXV9LlFh4MUpRhjIB")
            .SetVersion("4.3.1");

            manifest
            .DefineStyle("ZachsBlogTheme-vendor-bootstrap")
            .SetUrl("~/ZachsBlogTheme/vendor/bootstrap/css/bootstrap.min.css", "~/ZachsBlogTheme/vendor/bootstrap/css/bootstrap.css")
            .SetCdn("https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css", "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.css")
            .SetCdnIntegrity("sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T", "sha384-t4IGnnWtvYimgcRMiXD2ZD04g28Is9vYsVaHo5LcWWJkoQGmMwGg+QS0mYlhbVv3")
            .SetVersion("4.3.1");

            manifest
            .DefineStyle("ZachsBlogTheme-bootstrap-oc")
            .SetUrl("~/ZachsBlogTheme/css/bootstrap-oc.min.css", "~/ZachsBlogTheme/css/bootstrap-oc.css")
            .SetVersion("1.0.0");

            manifest
            .DefineStyle("ZachsBlogTheme-vendor-font-awesome")
            .SetUrl("~/ZachsBlogTheme/vendor/fontawesome-free/css/all.min.css", "~/ZachsBlogTheme/vendor/fontawesome-free/css/all.css")
            .SetCdn("https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/all.min.css", "https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/all.css")
            .SetCdnIntegrity("sha384-rtJEYb85SiYWgfpCr0jn174XgJTn4rptSOQsMroFBPQSGLdOC5IbubP6lJ35qoM9", "sha384-Ex0vLvgbKZTFlqEetkjk2iUgM+H5udpQKFKjBoGFwPaHRGhiWyVI6jLz/3fBm5ht")
            .SetVersion("5.10.2");

            manifest
            .DefineScript("ZachsBlogTheme-vendor-font-awesome")
            .SetCdn("https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/js/all.min.js", "https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/js/all.js")
            .SetCdnIntegrity("sha384-QMu+Y+eu45Nfr9fmFOlw8EqjiUreChmoQ7k7C1pFNO8hEbGv9yzsszTmz+RzwyCh", "sha384-7/I8Wc+TVwiZpEjE4qTV6M27LYR5Dus6yPGzQZowRtgh+0gDW9BNR9GmII1/YwmG")
            .SetVersion("5.10.2");
        }
        public async Task RenderFootScript()
        {
            var options  = new ResourceManagementOptions();
            var manifest = new ResourceManifest();

            manifest.DefineScript("required").SetUrl("required.js")
            .SetDependencies("dependency");
            manifest.DefineScript("dependency").SetUrl("dependency.js");
            manifest.DefineScript("not-required").SetUrl("not-required.js");

            options.ResourceManifests.Add(manifest);

            var resourceManager = new ResourceManager(
                new OptionsWrapper <ResourceManagementOptions>(options),
                StubFileVersionProvider.Instance
                );

            // Require resource
            resourceManager.RegisterResource("script", "required").AtFoot();

            // Register custom script
            var customScript = "doSomeAction();";

            resourceManager.RegisterFootScript(new HtmlString($"<script>{customScript}</script>"));

            using var sw = new StringWriter();
            resourceManager.RenderFootScript(sw);
            var htmlBuilder = new HtmlContentBuilder();

            htmlBuilder.AppendHtml(sw.ToString());

            var document = await ParseHtmlAsync(htmlBuilder);

            var scripts = document
                          .QuerySelectorAll <IHtmlScriptElement>("script");

            Assert.Equal(3, scripts.Count());
            Assert.Contains(scripts, script => script.Source == "dependency.js");
            Assert.Contains(scripts, script => script.Source == "required.js");
            Assert.Contains(scripts, script => script.Text == customScript);
            // Required script after its dependency
            Assert.Equal(DocumentPositions.Following, scripts.First(script => script.Source == "dependency.js")
                         .CompareDocumentPosition(
                             scripts.First(script => script.Source == "required.js")
                             )
                         );
            // Custom script after resources
            Assert.Equal(DocumentPositions.Following, scripts.First(script => script.Source == "required.js")
                         .CompareDocumentPosition(
                             scripts.First(script => script.Text == customScript)
                             )
                         );
        }
        static ResourceManagementOptionsConfiguration()
        {
            _manifest = new ResourceManifest();

            _manifest
            .DefineScript("monaco-liquid-intellisense")
            .SetUrl("~/OrchardCore.Liquid/monaco/liquid-intellisense.js")
            .SetDependencies("monaco")
            .SetVersion("1.0.0");

            _manifest
            .DefineScript("liquid-intellisense")
            .SetDependencies("monaco-liquid-intellisense")
            .SetUrl("~/OrchardCore.Liquid/Scripts/liquid-intellisense.js");
        }
        public void BuildManifests(ResourceManifestBuilder builder)
        {
            ResourceManifest manifest = builder.Add();

            //easyui全部控件样式
            manifest.DefineStyle("Easyui").SetUrl("default/easyui.css");
            //自定义的主样式
            manifest.DefineStyle("MainSty").SetUrl("Styles.css").SetDependencies("Easyui");
            //凭证样式
            manifest.DefineStyle("voucher").SetUrl("voucher.css").SetDependencies("MainSty");

            //easyui库
            manifest.DefineScript("Easyui").SetUrl("jquery.easyui.min.js").SetDependencies("jQuery");
            //easyui中文化
            manifest.DefineScript("Easyui.cn").SetUrl("easyui-lang-zh_CN.js").SetDependencies("Easyui");
            //easyui验证方法扩展
            manifest.DefineScript("Easyui.Extend").SetUrl("easyui.extend.js").SetDependencies("Easyui");

            //企业信息相关脚本
            manifest.DefineScript("Company.App").SetUrl("App/Company.App.js").SetDependencies("Easyui.cn", "Easyui.Extend");

            //科目设置
            manifest.DefineScript("Subject.App").SetUrl("App/Subject.App.js").SetDependencies("Easyui.cn", "Easyui.Extend");

            //凭证录入、查询
            manifest.DefineScript("Voucher.App").SetUrl("App/Voucher.App.js").SetDependencies("Easyui.cn", "Easyui.Extend");
        }
        public async Task RenderLocalScript()
        {
            var options  = new ResourceManagementOptions();
            var manifest = new ResourceManifest();

            manifest.DefineScript("required").SetUrl("required.js")
            .SetDependencies("dependency");
            manifest.DefineScript("dependency").SetUrl("dependency.js");
            manifest.DefineScript("not-required").SetUrl("not-required.js");

            options.ResourceManifests.Add(manifest);

            var resourceManager = new ResourceManager(
                new OptionsWrapper <ResourceManagementOptions>(options),
                StubFileVersionProvider.Instance
                );

            var requireSetting = resourceManager.RegisterResource("script", "required");

            using var sw = new StringWriter();
            resourceManager.RenderLocalScript(requireSetting, sw);
            var htmlBuilder = new HtmlContentBuilder();

            htmlBuilder.AppendHtml(sw.ToString());


            var document = await ParseHtmlAsync(htmlBuilder);

            var scripts = document
                          .QuerySelectorAll <IHtmlScriptElement>("script");

            Assert.Equal(2, scripts.Count());
            Assert.Contains(scripts, script => script.Source == "dependency.js");
            Assert.Contains(scripts, script => script.Source == "required.js");
            Assert.Equal(DocumentPositions.Following, scripts.First(script => script.Source == "dependency.js")
                         .CompareDocumentPosition(
                             scripts.First(script => script.Source == "required.js")
                             )
                         );
        }
Example #7
0
        public void DefineCultureSet(ResourceManifest manifest, string version)
        {
            string cultureKey  = string.Format(KeyFormat, "kendo.culture", "site");
            string messagesKey = string.Format(KeyFormat, "kendo.messages", "site");

            string siteCultureFilePath  = string.Format("cultures/kendo.culture.{0}.min.js", this.kendoThemeService.SiteCulture());
            string siteMessagesFilePath = string.Format("messages/kendo.messages.{0}.min.js", this.kendoThemeService.SiteCulture());

            manifest.DefineScript(cultureKey)
            .SetUrl(VersionPath(version, siteCultureFilePath))
            .SetDependencies(keyPrefix)
            .SetVersion(version);

            manifest.DefineScript(messagesKey)
            .SetUrl(VersionPath(version, siteMessagesFilePath))
            .SetDependencies(keyPrefix)
            .SetVersion(version);

            foreach (var culture in cultureSets)
            {
                string key      = string.Format(KeyFormat, "kendo.culture", culture);
                string filePath = string.Format("cultures/{0}.min.js", key);

                manifest.DefineScript(key)
                .SetUrl(VersionPath(version, filePath))
                .SetDependencies(keyPrefix)
                .SetVersion(version);
            }

            foreach (var culture in cultureSets)
            {
                string key      = string.Format(KeyFormat, "kendo.messages", culture);
                string filePath = string.Format("messages/{0}.min.js", key);

                manifest.DefineScript(key)
                .SetUrl(VersionPath(version, filePath))
                .SetDependencies(keyPrefix)
                .SetVersion(version);
            }
        }
Example #8
0
        static ResourceManagementOptionsConfiguration()
        {
            _manifest = new ResourceManifest();

            _manifest
            .DefineScript("vuejs")
            .SetUrl("~/VuetifyTheme/Scripts/vue.min.js", "~/VuetifyTheme/Scripts/vue.js")
            .SetCdn("https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.min.js", "https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js")
            .SetCdnIntegrity("sha384-ULpZhk1pvhc/UK5ktA9kwb2guy9ovNSTyxPNHANnA35YjBQgdwI+AhLkixDvdlw4", "sha384-t1tHLsbM7bYMJCXlhr0//00jSs7ZhsAhxgm191xFsyzvieTMCbUWKMhFg9I6ci8q")
            .SetVersion("2.6.14");

            _manifest
            .DefineStyle("vuetify-theme")
            .SetDependencies("vuejs")
            .SetUrl("~/VuetifyTheme/dist/vuetify-theme.css", "~/VuetifyTheme/dist/vuetify-theme.css")
            .SetVersion("1.0.0");
            _manifest
            .DefineScript("vuetify-theme")
            .SetDependencies("vuejs")
            .SetUrl("~/VuetifyTheme/dist/vuetify-theme.umd.min.js", "~/VuetifyTheme/dist/vuetify-theme.umd.js")
            .SetVersion("1.0.0");
        }
Example #9
0
        public void DefineAspNetMvc(ResourceManifest manifest, string kety, string currentVersion, params string[] previousVersions)
        {
            var versions = new List <string>(previousVersions)
            {
                currentVersion
            };

            foreach (var version in versions)
            {
                manifest.DefineScript("kendo.aspnetmvc")
                .SetUrl(VersionPath(version, "kendo.aspnetmvc.min.js"))
                .SetDependencies(keyPrefix);
            }
        }
        static ResourceManagementOptionsConfiguration()
        {
            _manifest = new ResourceManifest();

            _manifest
            .DefineScript("leaflet")
            .SetUrl("/OrchardCore.Spatial/Scripts/leaflet/leaflet.js", "/OrchardCore.Spatial/Scripts/leaflet/leaflet-src.js")
            .SetCdn("https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.min.js", "https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet-src.js")
            .SetCdnIntegrity("sha384-vdvDM6Rl/coCrMsKwhal4uc9MUUFNrYa+cxp+nJQHy3TvozEpVKVexz/NTbE5VSO", "sha384-mc6rNK5V0bzWGJ1EUEAR2o+a/oH6qaVl+NCF63Et+mVpGnlSnyVSBhSP/wp4ir+O")
            .SetVersion("1.7.1");

            _manifest
            .DefineStyle("leaflet")
            .SetUrl("/OrchardCore.Spatial/Styles/leaflet.min.css", "/OrchardCore.Spatial/Styles/leaflet.css")
            .SetCdn("https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.min.css", "https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.css")
            .SetCdnIntegrity("sha384-d7pQbIswLsqVbYoAoHHlzPt+fmjkMwiXW/fvtIgK2r1u1bZXvGzL9HICUg4DKSgO", "sha384-VzLXTJGPSyTLX6d96AxgkKvE/LRb7ECGyTxuwtpjHnVWVZs2gp5RDjeM/tgBnVdM")
            .SetVersion("1.7.1");
        }
        static ResourceManagementOptionsConfiguration()
        {
            _manifest = new ResourceManifest();

            _manifest
            .DefineScript("jsplumb")
            .SetDependencies("jQuery")
            .SetUrl("~/OrchardCore.Workflows/Scripts/jsplumb.min.js", "~/OrchardCore.Workflows/Scripts/jsplumb.js")
            .SetCdn("https://cdnjs.cloudflare.com/ajax/libs/jsPlumb/2.15.5/js/jsplumb.min.js", "https://cdnjs.cloudflare.com/ajax/libs/jsPlumb/2.15.5/js/jsplumb.js")
            .SetCdnIntegrity("sha384-vJ4MOlEjImsRl4La5sTXZ1UBtJ8uOOqxl2+0gdjRB7oVF6AvTVZ3woqYbTJb7vaf", "sha384-6qcVETlKUuSEc/QpsceL6BNiyEMBFSPE/uyfdRUvEfao8/K9lynY+r8nd/mwLGGh")
            .SetVersion("2.15.5");

            _manifest
            .DefineStyle("jsplumbtoolkit-defaults")
            .SetUrl("~/OrchardCore.Workflows/Styles/jsplumbtoolkit-defaults.min.css", "~/OrchardCore.Workflows/Styles/jsplumbtoolkit-defaults.css")
            .SetCdn("https://cdnjs.cloudflare.com/ajax/libs/jsPlumb/2.15.5/css/jsplumbtoolkit-defaults.min.css", "https://cdnjs.cloudflare.com/ajax/libs/jsPlumb/2.15.5/css/jsplumbtoolkit-defaults.css")
            .SetCdnIntegrity("sha384-4TTNOHwtAFYbq+UTSu/7Fj0xnqOabg7FYr9DkNtEKnmIx/YaACNiwhd2XZfO0A/u", "sha384-Q0wOomiqdBpz2z6/yYA8b3gc8A9t7z7QjD14d1WABvXVHbRYBu/IGOv3SOR57anB")
            .SetVersion("2.15.5");
        }
        static ResourceManagementOptionsConfiguration()
        {
            var root = "~/FlyingRat.Braksn";

            _manifest = new ResourceManifest();
            _manifest.DefineScript("Braksn-bootstrap")
            .SetUrl($"{root}/js/bootstrap.min.js")
            .SetVersion("4.0.0");

            #region js
            _manifest.DefineScript("Braksn-animsition")
            .SetUrl($"{root}/js/animsition.min.js")
            .SetVersion("4.0.2");

            _manifest.DefineScript("Braksn-custom_jquery")
            .SetUrl($"{root}/js/custom_jquery.js")
            .SetVersion("1.0.0");

            _manifest.DefineScript("Braksn-jquery")
            .SetUrl($"{root}/js/jquery-3.2.1.min.js")
            .SetVersion("3.2.1");

            _manifest.DefineScript("Braksn-popper")
            .SetUrl($"{root}/js/popper.js")
            .SetVersion("1.12.5");

            #endregion

            #region css
            _manifest.DefineStyle("Braksn-stylesheet")
            .SetUrl($"{root}/css/stylesheet.css")
            .SetVersion("1.0.0");

            _manifest.DefineStyle("Braksn-util")
            .SetUrl($"{root}/css/util.min.css")
            .SetVersion("1.0.0");

            _manifest.DefineStyle("Braksn-animate")
            .SetUrl($"{root}/css/animate.css")
            .SetVersion("1.0.0");

            _manifest.DefineStyle("Braksn-animstion")
            .SetUrl($"{root}/css/animsition.min.css")
            .SetVersion("1.0.0");

            _manifest.DefineStyle("Braksn-bootstrap")
            .SetUrl($"{root}/css/bootstrap.min.css")
            .SetVersion("4.0.0");

            _manifest.DefineStyle("Braksn-hamburgers")
            .SetUrl($"{root}/css/hamburgers.min.css")
            .SetVersion("1.0.0");
            #endregion

            #region font
            _manifest.DefineStyle("Braksn-font-awesome")
            .SetUrl($"{root}/fonts/fontawesome-5.0.8/css/fontawesome-all.min.css")
            .SetVersion("5.0.8");

            _manifest.DefineStyle("Braksn-font-iconic")
            .SetUrl($"{root}/fonts/iconic/css/material-design-iconic-font.min.css")
            .SetVersion("1.0.0");

            #endregion

            #region bundle assts
            _manifest.DefineScript("website-bundle")
            .SetUrl($"{root}/bundle/website.min.js")
            .SetVersion("1.0");

            _manifest.DefineScript("braksn-validate")
            .SetUrl($"{root}/bundle/validate.min.js")
            .SetVersion("1.0");

            _manifest.DefineScript("braksn-bundle")
            .SetUrl($"{root}/bundle/bundle.min.js")
            .SetVersion("1.0");

            _manifest.DefineStyle("braksn-bundle")
            .SetUrl($"{root}/bundle/bundle.min.css")
            .SetVersion("1.0");

            #region page

            _manifest.DefineScript("braksn-atlas")
            .SetUrl($"{root}/bundle/atlas.min.js")
            .SetVersion("1.0");

            #endregion

            #endregion
        }
        static ResourceManagementOptionsConfiguration()
        {
            _manifest = new ResourceManifest();

            _manifest.DefineStyle("theprocardtheme-vendor-bootstrapcss")
            .SetUrl("~/ProCardTheme/css/bootstrap.min.css", "~/ProCardTheme/css/bootstrap.css")
            .SetCdn("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css", "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css")
            .SetCdnIntegrity("sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u", "sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u")
            .SetVersion("3.3.7");

            _manifest.DefineStyle("TheProCardTheme-vendor-normalize")
            .SetUrl("~/ProCardTheme/css/normalize.css")
            .SetCdn("https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css", "https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css")
            .SetCdnIntegrity("sha512-NhSC1YmyruXifcj/KFRWoC561YpHpc5Jtzgvbuzx5VozKpWvQ+4nXhPdFgmx8xqexRcpAglTj9sIBWINXa8x5w==", "sha512-oHDEc8Xed4hiW6CxD7qjbnI+B07vDdX7hEPTvn9pSZO1bcRqHp8mj9pyr+8RVC2GmtEfI2Bi9Ke9Ass0as+zpg==")
            .SetVersion("8.0.1");

            _manifest.DefineStyle("TheProCardTheme-vendor-animate")
            .SetUrl("~/ProCardTheme/css/animate.css")
            .SetCdn("https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.1/animate.min.css", "https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.1/animate.css")
            .SetCdnIntegrity("sha512-4e743y/yh7ffjixFn2DBKvAA0j02JNn0iQ/bIq6usesbp6TRPcZFW0XHnwfSnpTtsTmMGh0UmvbXY26aJfIb0Q==", "sha512-K2J6Yt6ElUYEMPcTr0wm555AAyiqkgYiUgPIW18FT88/aYSNDk0EvGjsln/TEu3ee/jaHf0xoXzFppSbBtUXbQ==")
            .SetVersion("3.5.1");

            _manifest.DefineStyle("TheProCardTheme-vendor-transitionanimations")
            .SetUrl("~/ProCardTheme/css/transition-animations.css")
            .SetVersion("1.0.0");


            _manifest.DefineStyle("TheProCardTheme-vendor-owlcarousel")
            .SetUrl("~/ProCardTheme/css/owl.carousel.css")
            .SetCdn("https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.2.0/assets/owl.carousel.min.css", "https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.2.0/assets/owl.carousel.css")
            .SetCdnIntegrity("sha512-wOFbhKjhJWoAjlnxMK+uNACGNi2xrcTarIBCLpktzzajCOfxCR4AnJcT9mBEiVTFWmthRvQHY23v4OhyY981Lg==", "sha512-nQBtu5ETxTSzk2JroACVYGz3hR7lz1wli8+RSeEhX0KERJOpLbl+j7OtGwvrqE6DGdm4xyVpt7tAfFZGBDq+ug==")
            .SetVersion("2.2.0");


            _manifest.DefineStyle("TheProCardTheme-vendor-magnificpopup")
            .SetUrl("~/ProCardTheme/css/magnific-popup.css")
            .SetCdn("https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css", "https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.css")
            .SetCdnIntegrity("sha512-+EoPw+Fiwh6eSeRK7zwIKG2MA8i3rV/DGa3tdttQGgWyatG/SkncT53KHQaS5Jh9MNOT3dmFL0FjTY08And/Cw==", "sha512-WEQNv9d3+sqyHjrqUZobDhFARZDko2wpWdfcpv44lsypsSuMO0kHGd3MQ8rrsBn/Qa39VojphdU6CMkpJUmDVw==")
            .SetVersion("2.2.0");

            _manifest.DefineStyle("TheProCardTheme-main")
            .SetUrl("~/ProCardTheme/css/main.css");


            _manifest.DefineScript("TheProCardTheme-vendor-jquery")
            .SetUrl("~/ProCardTheme/js/jquery-2.1.3.min.js", "~/ProCardTheme/js/jquery-2.1.3.min.js")
            .SetCdn("https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js", "https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js")
            .SetCdnIntegrity("sha512-egJ/Y+22P9NQ9aIyVCh0VCOsfydyn8eNmqBy+y2CnJG+fpRIxXMS6jbWP8tVKp0jp+NO5n8WtMUAnNnGoJKi4w==", "sha512-uOsadAxj/qq4rCTYfzn0z+JjaUyXL0l4ufDjCS+RKnIllv0JTdY30i8DgWYX4TIQvxH62aVF27BCPcghyCcIHg==")
            .SetVersion("2.1.3");

            _manifest.DefineScript("TheProCardTheme-vendor-modernizr")
            .SetUrl("~/ProCardTheme/js/modernizr.custom.js", "~/ProCardTheme/js/modernizr.custom.js");

            _manifest.DefineScript("TheProCardTheme-vendor-bootstrap")
            .SetUrl("~/ProCardTheme/js/bootstrap.min.js", "~/ProCardTheme/js/bootstrap.min.js");

            _manifest.DefineScript("TheProCardTheme-vendor-pages-switcher")
            .SetUrl("~/ProCardTheme/js/pages-switcher.js", "~/ProCardTheme/js/pages-switcher.js");

            _manifest.DefineScript("TheProCardTheme-vendor-imagesloaded")
            .SetUrl("~/ProCardTheme/js/imagesloaded.pkgd.min.js", "~/ProCardTheme/js/imagesloaded.pkgd.min.js");

            _manifest.DefineScript("TheProCardTheme-vendor-validator")
            .SetUrl("~/ProCardTheme/js/validator.js", "~/ProCardTheme/js/validator.js");

            _manifest.DefineScript("TheProCardTheme-vendor-jqueryshuffle")
            .SetUrl("~/ProCardTheme/js/jquery.shuffle.min.js", "~/ProCardTheme/js/jquery.shuffle.min.js");

            _manifest.DefineScript("TheProCardTheme-vendor-masonry")
            .SetUrl("~/ProCardTheme/js/masonry.pkgd.min.js", "~/ProCardTheme/js/masonry.pkgd.min.js");

            _manifest.DefineScript("TheProCardTheme-vendor-owlcarousel")
            .SetUrl("~/ProCardTheme/js/owl.carousel.min.js", "~/ProCardTheme/js/owl.carousel.min.js");

            _manifest.DefineScript("TheProCardTheme-vendor-magnificpopup")
            .SetUrl("~/ProCardTheme/js/jquery.magnific-popup.min.js", "~/ProCardTheme/js/jquery.magnific-popup.min.js");

            _manifest.DefineScript("TheProCardTheme-vendor-hoverdir")
            .SetUrl("~/ProCardTheme/js/jquery.hoverdir.js", "~/ProCardTheme/js/jquery.hoverdir.js");

            _manifest.DefineScript("TheProCardTheme-vendor-jquerygooglemaps")
            .SetUrl("~/ProCardTheme/js/jquery.googlemap.js");
            _manifest.DefineScript("TheProCardTheme-main")
            .SetUrl("~/ProCardTheme/js/main.js");
        }
        static ResourceManifestOptionsConfiguration()
        {
            _manifest = new ResourceManifest();
            _manifest.DefineScript("TheRonaldoTheme-vendor-jQuery")
            .SetUrl("~/TheRonaldoTheme.OrchardCore/js/jquery-3.2.1.min.js", "~/TheRonaldoTheme.OrchardCore/js/jquery.min.js")
            .SetCdn("https://code.jquery.com/jquery-3.2.1.min.js", "https://code.jquery.com/jquery-3.2.1.js")
            .SetCdnIntegrity("sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=", "sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=")
            .SetVersion("3.2.1");

            _manifest.DefineScript("TheRonaldoTheme-vendor-jQuery-migrate")
            .SetUrl("~/TheRonaldoTheme.OrchardCore/js/jquery-migrate-3.0.1.min.js")
            .SetCdn("https://code.jquery.com/jquery-migrate-3.0.1.min.js", "https://code.jquery.com/jquery-migrate-3.0.1.js")
            .SetCdnIntegrity("sha256-F0O1TmEa4I8N24nY0bya59eP6svWcshqX1uzwaWC4F4=", "sha256-VvnF+Zgpd00LL73P2XULYXEn6ROvoFaa/vbfoiFlZZ4=")
            .SetVersion("3.0.1");

            _manifest.DefineScript("TheRonaldoTheme-vendor-popper")
            .SetUrl("~/TheRonaldoTheme.OrchardCore/js/popper.min.js")
            .SetCdn("https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js")
            .SetCdnIntegrity("sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1");

            _manifest.DefineScript("TheRonaldoTheme-vendor-bootstrap")
            .SetUrl("~/TheRonaldoTheme.OrchardCore/js/bootstrap.min.js")
            .SetCdn("https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js")
            .SetCdnIntegrity("sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM")
            .SetVersion("4.3.1");

            _manifest.DefineScript("TheRonaldoTheme-vendor-jqueryeasing")
            .SetUrl("~/TheRonaldoTheme.OrchardCore/js/jquery.easing.1.3.js")
            .SetCdn("https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js", "https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.js")
            .SetCdnIntegrity("sha512-ahmSZKApTDNd3gVuqL5TQ3MBTj8tL5p2tYV05Xxzcfu6/ecvt1A0j6tfudSGBVuteSoTRMqMljbfdU0g2eDNUA==", "sha512-brrjTp9G6MkKX5QjXwwAQkscfFpKi3okjyZ/M3vGwwg9qI1msoz7z+EbQBLXsTnVK3POjYBGHcQvX34GFKr/7A==")
            .SetVersion("1.3");

            _manifest.DefineScript("TheRonaldoTheme-vendor-waypoints")
            .SetUrl("~/TheRonaldoTheme.OrchardCore/js/jquery.waypoints.min.js")
            .SetCdn("https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.0/jquery.waypoints.min.js", "https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.0/jquery.waypoints.js")
            .SetCdnIntegrity("sha512-oy0NXKQt2trzxMo6JXDYvDcqNJRQPnL56ABDoPdC+vsIOJnU+OLuc3QP3TJAnsNKXUXVpit5xRYKTiij3ov9Qg==", "sha512-BnrjiUrz5UU3mBQD4awG5ekDBgTPUzpcNJtMQbNj4kfqStjn48180rUTEQjU5+Gf2BBfAtZETnMP4Khv0vcPug==")
            .SetVersion("4.0");

            _manifest.DefineScript("TheRonaldoTheme-vendor-animateNumber")
            .SetUrl("~/TheRonaldoTheme.OrchardCore/js/jquery.animateNumber.min.js")
            .SetCdn("https://cdnjs.cloudflare.com/ajax/libs/jquery-animateNumber/0.0.14/jquery.animateNumber.min.js", "https://cdnjs.cloudflare.com/ajax/libs/jquery-animateNumber/0.0.14/jquery.animateNumber.js")
            .SetCdnIntegrity("sha512-WY7Piz2TwYjkLlgxw9DONwf5ixUOBnL3Go+FSdqRxhKlOqx9F+ee/JsablX84YBPLQzUPJsZvV88s8YOJ4S/UA==", "sha512-1QMfUOxKmBVh0AakHIAh5tQfEW2r0atqXu4lHbAxgKZZnMY06M5MuTUrB6F/nQ6vjImMrWirGcLM1W6yslREpg==");

            _manifest.DefineScript("TheRonaldoTheme-vendor-magnificpopup")
            .SetUrl("~/TheRonaldoTheme.OrchardCore/js/jquery.mangnific-popup.min.js")
            .SetCdn("https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js", "https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.js")
            .SetCdnIntegrity("sha512-IsNh5E3eYy3tr/JiX2Yx4vsCujtkhwl7SLqgnwLNgf04Hrt9BT9SXlLlZlWx+OK4ndzAoALhsMNcCmkggjZB1w==", "sha512-C1zvdb9R55RAkl6xCLTPt+Wmcz6s+ccOvcr6G57lbm8M2fbgn2SUjUJbQ13fEyjuLViwe97uJvwa1EUf4F1Akw==")
            .SetVersion("1.1");

            _manifest.DefineScript("TheRonaldoTheme-vendor-stellar")
            .SetUrl("~/TheRonaldoTheme.OrchardCore/js/jquery.stellar.min.js");

            _manifest.DefineScript("TheRonaldoTheme-vendor-carousel")
            .SetUrl("~/TheRonaldoTheme.OrchardCore/js/owl.carousel.min.js");

            _manifest.DefineScript("TheRonaldoTheme-vendor-scrollax")
            .SetUrl("~/TheRonaldoTheme.OrchardCore/js/scrollax.min.js");

            _manifest.DefineScript("TheRonaldoTheme-vendor-aos")
            .SetUrl("~/TheRonaldoTheme.OrchardCore/js/aos.js");

            _manifest.DefineScript("TheRonaldoTheme-vendor-main")
            .SetUrl("~/TheRonaldoTheme.OrchardCore/js/main.js")
            .SetDependencies("TheRonaldoTheme-vendor-jQuery", "TheRonaldoTheme-vendor-jQuery-migrate",
                             "theronaldotheme-vendor-popper", "theronaldotheme-vendor-bootstrap", "theronaldotheme-vendor-jqueryeasing",
                             "theronaldotheme-vendor-waypoints", "theronaldotheme-vendor-animatenumber", "theronaldotheme-vendor-carousel",
                             "theronaldotheme-vendor-magnificpopup", "theronaldotheme-vendor-aos", "theronaldotheme-vendor-animatenumber",
                             "theronaldotheme-vendor-scrollax", "theronaldotheme-vendor-stellar"
                             );

            _manifest.DefineStyle("TheRonaldoTheme-vendor-openiconic")
            .SetUrl("~/TheRonaldoTheme.OrchardCore/css/open-iconic-bootstrap.min.css")
            .SetCdn("https://cdnjs.cloudflare.com/ajax/libs/open-iconic/1.1.1/font/css/open-iconic.min.css")
            .SetCdnIntegrity("sha512-LeCmts7kEi09nKc+DwGJqDV+dNQi/W8/qb0oUSsBLzTYiBwxj0KBlAow2//jV7jwEHwSCPShRN2+IWwWcn1x7Q==");

            _manifest.DefineStyle("TheRonaldoTheme-vendor-magnificpopup")
            .SetUrl("~/TheRonaldoTheme.OrchardCore/css/magnific-popup.css")
            .SetCdn("https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css", "https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.css")
            .SetCdnIntegrity("sha512-+EoPw+Fiwh6eSeRK7zwIKG2MA8i3rV/DGa3tdttQGgWyatG/SkncT53KHQaS5Jh9MNOT3dmFL0FjTY08And/Cw==", "sha512-WEQNv9d3+sqyHjrqUZobDhFARZDko2wpWdfcpv44lsypsSuMO0kHGd3MQ8rrsBn/Qa39VojphdU6CMkpJUmDVw==")
            .SetVersion("1.1");
        }
        public async Task RenderHeadAndFootScriptWithSameDependency()
        {
            var options  = new ResourceManagementOptions();
            var manifest = new ResourceManifest();

            manifest.DefineScript("required")
            .SetUrl("required.js")
            .SetDependencies("dependency");

            manifest.DefineScript("dependency")
            .SetUrl("dependency.js");

            manifest.DefineScript("required-at-foot")
            .SetUrl("required-at-foot.js")
            .SetDependencies("dependency");

            manifest.DefineScript("not-required")
            .SetUrl("not-required.js");

            options.ResourceManifests.Add(manifest);

            var resourceManager = new ResourceManager
                                  (
                new OptionsWrapper <ResourceManagementOptions>(options),
                StubFileVersionProvider.Instance
                                  );

            // Require resource.
            resourceManager.RegisterResource("script", "required").AtHead();

            // Register custom script.
            var customScript = "doSomeAction();";

            resourceManager.RegisterHeadScript(new HtmlString($"<script>{customScript}</script>"));

            // Require resource at Foot with same dependency at Head
            resourceManager.RegisterResource("script", "required-at-foot").AtFoot();

            using var sw1 = new StringWriter();
            resourceManager.RenderHeadScript(sw1);
            var htmlBuilder = new HtmlContentBuilder();

            htmlBuilder.AppendHtml(sw1.ToString());

            var document = await ParseHtmlAsync(htmlBuilder);

            var headScripts = document
                              .QuerySelectorAll <IHtmlScriptElement>("script");

            using var sw2 = new StringWriter();
            resourceManager.RenderFootScript(sw2);
            htmlBuilder = new HtmlContentBuilder();
            htmlBuilder.AppendHtml(sw2.ToString());

            document = await ParseHtmlAsync(htmlBuilder);

            var footScripts = document
                              .QuerySelectorAll <IHtmlScriptElement>("script");

            // Should render 4 scripts in total, 3 at head and 1 at foot.
            Assert.Equal(4, headScripts.Count() + footScripts.Count());

            //Check head script positions.
            Assert.Contains("dependency.js", headScripts.ElementAt(0).Source);
            Assert.Contains("required.js", headScripts.ElementAt(1).Source);
            Assert.Contains(customScript, headScripts.ElementAt(2).Text);

            //Check foot script positions.
            Assert.Contains("required-at-foot.js", footScripts.ElementAt(0).Source);
        }
Example #16
0
 /// <summary>
 /// Adds a script to the resourceManifest.
 /// The scripts name will be converted to a minified and a normal resource url.
 /// </summary>
 public static ResourceDefinition DefineScriptWithAllUrls(this ResourceManifest manifest, string name)
 {
     return(manifest.DefineScript(name).SetUrl(string.Format("{0}.min.js", name), string.Format("{0}.js", name)));
 }
Example #17
0
        /// <summary>
        /// Defines the scripts.
        /// </summary>
        /// <param name="manifest">The manifest.</param>
        /// <param name="key">The key.</param>
        /// <param name="currentVersion">The current version.</param>
        /// <param name="previousVersions">The previous versions.</param>
        public void DefineScripts(ResourceManifest manifest, string key, string currentVersion, params string[] previousVersions)
        {
            var    versions   = previousVersions.Concat(new[] { currentVersion });
            string webKey     = string.Format("{0}.{1}", key, "web");
            string webOnlyKey = string.Format("{0}.{1}", key, "web.only");

            //string all = string.Format("{0}.{1}", key, "all");
            string webData      = string.Format("{0}.{1}", key, "webdata");
            string dataVizKey   = string.Format("{0}.{1}", key, "data");
            string mobileKey    = string.Format("{0}.{1}", key, "mobile");
            string timezonesKey = string.Format("{0}.{1}", key, "timezones");
            string aspnetmvcKey = string.Format("{0}.{1}", key, "aspnetmvc");

            string allKey = string.Format("{0}.{1}", key, "all");

            //string orchard = string.Format("{0}.{1}", key, "orchard");

            foreach (var ver in versions)
            {
                manifest.DefineScript("kendo.angular")
                .SetUrl(VersionPath(ver, "angular.min.js"))
                .SetVersion(ver);

                manifest.DefineScript("kendo.jquery")
                .SetUrl(VersionPath(ver, "jquery.min.js"))
                .SetVersion(ver);

                manifest.DefineScript("kendo.jszip")
                .SetUrl(VersionPath(ver, "jszip.min.js"))
                .SetVersion(ver);

                //manifest.DefineScript("kendo.all")
                //    .SetUrl(VersionPath(ver, "kendo.all.js"))
                //    .SetVersion(ver);

                manifest.DefineScript("kendo.web")
                .SetUrl(VersionPath(ver, "kendo.web.min.js"))
                .SetVersion(ver);

                manifest.DefineScript(webOnlyKey)
                .SetDependencies("jQuery")
                .SetUrl(VersionPath(ver, "kendo.web.min.js"))
                .SetAttribute("kendo-version", ver)
                //.SetCdn("http://cdn.kendostatic.com/2012.2.913/js/kendo.web.min.js")
                .SetVersion(ver);

                manifest.DefineScript(webKey)
                .SetDependencies("jQuery", webOnlyKey)
                .SetUrl("custom/OrchardMvc.min.js", "custom/OrchardMvc.js")
                .SetVersion(ver);


                manifest.DefineScript(dataVizKey)
                .SetUrl(VersionPath(ver, "kendo.dataviz.min.js"))
                .SetVersion(ver);

                manifest.DefineScript(mobileKey)
                .SetDependencies("jQuery")
                .SetUrl(VersionPath(ver, "kendo.mobile.min.js"))
                .SetVersion(ver);

                manifest.DefineScript(webData)
                .SetUrl(VersionPath(ver, "kendo.webdata.min.js")).SetAttribute("kendo-version", ver)
                .SetDependencies("jQuery")
                .SetVersion(ver);

                manifest.DefineScript(timezonesKey)
                .SetUrl(VersionPath(ver, "kendo.timezones.min.js"))
                .SetVersion(ver);

                manifest.DefineScript(aspnetmvcKey)
                .SetUrl(VersionPath(ver, "kendo.aspnetmvc.min.js"))
                .SetVersion(ver);

                manifest.DefineScript(allKey)
                .SetUrl(VersionPath(ver, "kendo.all.min.js"))
                .SetVersion(ver);


                this.DefineCultureSet(manifest, ver);
            }

            //manifest.DefineScript("kendo.datasource")
            //    .SetDependencies("kendo.web")
            //    .SetUrl("custom/datasource.js");
        }