コード例 #1
0
        public void GenerateSidebarSurface()
        {
            var surface = new WebTemplate()
            {
                Name = "SidebarTemplate",
                Html = "/Website/templates/SidebarTemplate.html"
            };

            var sidebarLeft = new WebSection()
            {
                Template = surface,
                Name     = "Left",
                Default  = false
            };

            new WebSection()
            {
                Template = surface,
                Name     = "Right",
                Default  = true
            };

            var templatesUrl = new WebUrl()
            {
                Template = surface,
                Url      = "/website/cms/surfaces"
            };

            new WebMap()
            {
                Url = templatesUrl, Section = sidebarLeft, ForeignUrl = "/website/help?topic=surfaces", SortNumber = 1
            };
        }
コード例 #2
0
        private static void CreateLoginLayout()
        {
            WebTemplate loginSurface = CreateSurface("LoginSurface", "LoginSurface");

            CreateCatchUri(loginSurface, "/signin/signinuser");
            WebSection logoBp   = CreateBlendingPoint(loginSurface, "Logo");
            WebSection footerBp = CreateBlendingPoint(loginSurface, "Footer");

            CreateBlendingPoint(loginSurface, "SignIn", isBlendingPointDefault: true);

            CreatePinningRule(logoBp, CreateWrappedHtmlUrl("Logo"), 0);
            CreatePinningRule(logoBp, CreateWrappedHtmlUrl("Slogan"), 1);
            CreatePinningRule(footerBp, CreateWrappedHtmlUrl("TermsAndConditionsLink"));

            var compositionKey = "/sc/htmlmerger?SignIn=/SignIn/viewmodels/SignInFormPage.html";
            var composition    = HTMLComposition.GetUsingKey(compositionKey) ?? new HTMLComposition()
            {
                Key = compositionKey
            };

            // ReSharper disable once AssignNullToNotNullAttribute this should always work, because it's compiled into the assembly
            using (var streamReader = new StreamReader(typeof(MainHandlers).Assembly.GetManifestResourceStream("SampleWebsiteTheme.wwwroot.SampleWebsiteTheme.html.SignInComposition.html")))
            {
                composition.Value = streamReader.ReadToEnd();
            }
        }
コード例 #3
0
        static MediaTypes()
        {
            mediaToExt = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
            extToMedia = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            WebSection         section      = WebSection.Get() ?? new WebSection();
            MediaMapCollection mediaTypeMap = section.MediaTypeMap;

            foreach (MediaMapElement map in mediaTypeMap)
            {
                AddMediaTypeMap(map.MediaType, map.CanonicalMediaType, map.Extension, map.CanonicalExtension);
            }
            defaultExtension = mediaTypeMap.GetDefaultExtension();
            defaultMediaType = mediaTypeMap.GetDefaultMediaType();
            if (defaultExtension != null)
            {
                defaultExtension = "." + NormalizeCase(defaultExtension);                  // add the period to match mediaToExt
            }
            if (defaultMediaType != null)
            {
                defaultMediaType = NormalizeCase(defaultMediaType);
            }
            CanonicalizeExtensions();

            CompressionMapCollection compressionMap = section.CompressionMap;

            compression = new CompressionEntry[compressionMap.Count];
            int index = 0;

            foreach (CompressionMapElement map in compressionMap)
            {
                compression[index++] = new CompressionEntry(map.MediaTypePattern, map.Compress);
            }
        }
コード例 #4
0
        public void GenerateDefaultSurface()
        {
            var surface = new WebTemplate()
            {
                Name = "DefaultTemplate",
                Html = "/Website/templates/DefaultTemplate.html"
            };

            var topbar = new WebSection()
            {
                Template = surface,
                Name     = "TopBar",
                Default  = false
            };

            var main = new WebSection()
            {
                Template = surface,
                Name     = "Main",
                Default  = true
            };

            var catchAllUrl = new WebUrl()
            {
                Template = surface,
                Url      = null,
                IsFinal  = true
            };

            new WebMap()
            {
                Section = topbar, ForeignUrl = "/signin/user", SortNumber = 1
            };
        }
コード例 #5
0
        public void GenerateLauncherSurface()
        {
            var surface = new WebTemplate()
            {
                Name = "LauncherTemplate",
                Html = "/Website/templates/LauncherTemplate.html"
            };

            var topbar = new WebSection()
            {
                Template = surface,
                Name     = "TopBar",
                Default  = false
            };

            var leftbar = new WebSection()
            {
                Template = surface,
                Name     = "LeftBar",
                Default  = false
            };

            var main = new WebSection()
            {
                Template = surface,
                Name     = "Main",
                Default  = true
            };

            new WebMap()
            {
                Section = topbar, ForeignUrl = "/signin/user", SortNumber = 1
            };
        }
コード例 #6
0
        private static WebMap CreatePinningRule(WebSection blendingPoint, string foreignUrl, int order = 0)
        {
            var pinningRule = blendingPoint.Maps.FirstOrDefault(map => map.Url == null && map.ForeignUrl == foreignUrl && map.Section.Key == blendingPoint.Key)
                              ?? new WebMap()
            {
                Section    = blendingPoint,
                Url        = null,
                ForeignUrl = foreignUrl
            };

            pinningRule.SortNumber = order;
            return(pinningRule);
        }
コード例 #7
0
        private static void CreateDesktopLayout()
        {
            WebTemplate desktopSurface = CreateSurface("DesktopSurface", "DesktopSurface");

            CreateCatchUri(desktopSurface, null);

            WebSection appTitleBlendingPoint = CreateBlendingPoint(desktopSurface, "AppTitle");
            WebSection mainMenuBlendingPoint = CreateBlendingPoint(desktopSurface, "MainMenu");
            WebSection logoBlendingPoint     = CreateBlendingPoint(desktopSurface, "Logo");
            WebSection topBarBlendingPoint   = CreateBlendingPoint(desktopSurface, "TopBar");

            CreateBlendingPoint(desktopSurface, "Main", isBlendingPointDefault: true);

            var content = Db.SQL <Content>($"SELECT c FROM {typeof(Content).FullName} c WHERE {nameof(Content.URL)} = ?", DefaultSystemLogoContentUrl).First;

            if (content == null)
            {
                content = new Content()
                {
                    Name     = DefaultSystemLogoContentName,
                    URL      = DefaultSystemLogoContentUrl,
                    MimeType = DefaultSystemLogoContentMimeType
                };
            }

            var concept = Db.SQL <Something>($"SELECT s FROM {typeof(Something).FullName} s WHERE {nameof(Something.Name)} = ?", DefaultSystemLogoName).First;

            if (concept == null)
            {
                concept = new Something()
                {
                    Name = DefaultSystemLogoName
                };
            }

            if (concept.Illustration == null)
            {
                new Illustration()
                {
                    WhatIs = content,
                    ToWhat = concept
                };
            }

            CreatePinningRule(logoBlendingPoint, $"/images/partials/somethings-single-static/{concept.GetObjectID()}");
            CreatePinningRule(appTitleBlendingPoint, "/DisplayAppTitle");
            CreatePinningRule(mainMenuBlendingPoint, "/Launchpad");
            CreatePinningRule(topBarBlendingPoint, "/signin/user");
        }
コード例 #8
0
        public void UnmapBlendingPoint(WebSection webSection)
        {
            if (webSection.Template == null)
            {
                // if the Surface (WebTemplate) was deleted earlier
                return;
            }
            string token  = webSection.GetMappingToken();
            string mapUri = webSection.GetMappingUrl();

            foreach (WebMap webMap in webSection.Maps)
            {
                UnmapPinningRule(webMap);
            }
            Blender.UnmapUri(mapUri, token);
            if (Handle.IsHandlerRegistered("GET " + mapUri, selfOnlyOptions))
            {
                Handle.UnregisterHttpHandler("GET", mapUri);
            }
        }
コード例 #9
0
        internal static IEnumerable <StyleSheetDefinition> GetStyleSheets(WebSection instance)
        {
            var styleSheets = instance?.StyleSheets;

            if (styleSheets != null)
            {
                //throw new Exception($"{styleSheets.Count} Stylesheets configured");
                foreach (Configuration.StyleSheet styleSheet in styleSheets)
                {
                    //throw new Exception($"StyleSheet {styleSheet.Name}");
                    var styleSheetDefinition = new StyleSheetDefinition()
                    {
                        Name         = styleSheet.Name,
                        Path         = styleSheet.Path,
                        DebugPath    = styleSheet.DebugPath,
                        CdnPath      = styleSheet.CdnPath,
                        CdnDebugPath = styleSheet.CdnDebugPath,
                        //CdnSupportsSecureConnection = true
                    };
                    yield return(styleSheetDefinition);
                }
            }
        }
コード例 #10
0
 public static string GetMappingUrl(this WebSection webSection, WebUrl webUrl = null)
 {
     return(string.IsNullOrWhiteSpace(webUrl?.Url)
         ? $"/website/blender/surface/{webSection.Template.Key}/point/{webSection.Key}"
         : $"/website/blender/surface/{webSection.Template.Key}/point/{webSection.Key}/uri/{webUrl.Key}");
 }
コード例 #11
0
 public static string GetMappingToken(this WebSection webSection, WebUrl webUrl = null)
 {
     return(webUrl == null
         ? $"website%{webSection.Template.Key}%{webSection.Key}"
         : $"website%{webSection.Template.Key}%{webSection.Key}%{webUrl.Key}");
 }
コード例 #12
0
        public void GenerateHolyGrailSurface()
        {
            var surface = new WebTemplate()
            {
                Name = "HolyGrailTemplate",
                Html = "/Website/templates/HolyGrailTemplate.html"
            };

            var content = new WebSection()
            {
                Template = surface,
                Name     = "Content",
                Default  = true
            };

            var header = new WebSection()
            {
                Template = surface,
                Name     = "Header",
                Default  = false
            };

            var left = new WebSection()
            {
                Template = surface,
                Name     = "Left",
                Default  = false
            };

            var right = new WebSection()
            {
                Template = surface,
                Name     = "Right",
                Default  = false
            };

            var footer = new WebSection()
            {
                Template = surface,
                Name     = "Footer",
                Default  = false
            };

            var homeUrl = new WebUrl()
            {
                Template = surface,
                Url      = "/content/dynamic/apps",
                IsFinal  = true
            };

            var appsUrl = new WebUrl()
            {
                Template = surface,
                Url      = "/content/dynamic/apps/wanted-apps",
                IsFinal  = true
            };

            var profileUrl = new WebUrl()
            {
                Template = surface,
                Url      = "/content/dynamic/userprofile",
                IsFinal  = true
            };

            new WebMap()
            {
                Section = header, ForeignUrl = "/signin/user", SortNumber = 1
            };
            new WebMap()
            {
                Section = header, ForeignUrl = "/content/dynamic/navigation", SortNumber = 2,
            };
            new WebMap()
            {
                Url = homeUrl, Section = header, ForeignUrl = "/content/dynamic/index/header", SortNumber = 3
            };
            new WebMap()
            {
                Url = homeUrl, Section = header, ForeignUrl = "/signin/signinuser", SortNumber = 4
            };
            new WebMap()
            {
                Url = homeUrl, Section = header, ForeignUrl = "/registration", SortNumber = 5
            };
            new WebMap()
            {
                Url = homeUrl, Section = header, ForeignUrl = "/content/dynamic/index/registration", SortNumber = 6
            };

            new WebMap()
            {
                Url = homeUrl, Section = left, ForeignUrl = "/content/dynamic/index/left", SortNumber = 1
            };

            new WebMap()
            {
                Url = homeUrl, Section = right, ForeignUrl = "/content/dynamic/index/right", SortNumber = 1
            };

            new WebMap()
            {
                Url = homeUrl, Section = footer, ForeignUrl = "/content/dynamic/index/footer", SortNumber = 1
            };

            new WebMap()
            {
                Url = appsUrl, Section = header, ForeignUrl = "/content/dynamic/apps/header", SortNumber = 1
            };
            new WebMap()
            {
                Url = appsUrl, Section = header, ForeignUrl = "/content/dynamic/apps/footer", SortNumber = 2
            };

            new WebMap()
            {
                Url = profileUrl, Section = header, ForeignUrl = "/content/dynamic/userprofile/header", SortNumber = 1
            };
            new WebMap()
            {
                Url = profileUrl, Section = content, ForeignUrl = "/userprofile", SortNumber = 2
            };
            new WebMap()
            {
                Url = profileUrl, Section = footer, ForeignUrl = "/content/dynamic/userprofile/footer", SortNumber = 3
            };
        }