public ITemplateDefinition AddRegion(string regionName)
        {
            var placeholder = BodyActions.AddPlaceholder();

            _nameManager.AddResolutionHandler(NameResolutionPhase.ResolveElementReferences, nm =>
            {
                var e = nm.ResolveRegion(regionName, _package);
                placeholder(r => e.WritePageArea(r, PageArea.Body, null, (rc, pa) => WriteResult.Continue())); // TODO: Write region
                AddConsumerNeeds(e as IDataConsumer);
            });

            return(this);
        }
Exemplo n.º 2
0
        protected override IWriteResult WritePageAreaInternal(
            IRenderContext renderContext,
            PageArea pageArea)
        {
            var layout = Element as ILayout;

            if (ReferenceEquals(layout, null))
            {
                return(WriteResult.Continue());
            }

            return(layout.WritePageArea(renderContext, pageArea, WriteRegion));
        }
Exemplo n.º 3
0
 public override IWriteResult WritePageArea(IRenderContext context, PageArea pageArea)
 {
     if (pageArea == PageArea.Body)
     {
         var address = context.Data.Get <Address>();
         context.Html.WriteElementLine("p", address.Street);
         context.Html.WriteElementLine("p", address.City);
         context.Html.WriteElementLine("p", address.ZipCode);
         context.Html.WriteOpenTag("hr", true);
         context.Html.WriteLine();
     }
     return(WriteResult.Continue());
 }
Exemplo n.º 4
0
        protected override IWriteResult WritePageAreaInternal(
            IRenderContext renderContext,
            PageArea pageArea)
        {
            var component = Element as IComponent;

            if (ReferenceEquals(component, null))
            {
                return(WriteResult.Continue());
            }

            return(component.WritePageArea(renderContext, pageArea));
        }
Exemplo n.º 5
0
        IWriteResult ITemplate.WritePageArea(IRenderContext context, PageArea pageArea)
        {
            var result = WriteResult.Continue();

            if (pageArea == PageArea.Body && _visualElements != null)
            {
                for (var i = 0; i < _visualElements.Length; i++)
                {
                    result = result.Add(_visualElements[i](context));
                }
            }

            return(result);
        }
Exemplo n.º 6
0
        private IWriteResult WriteRegion(
            IRenderContext renderContext,
            PageArea pageArea,
            string regionName)
        {
            PageRegion pageRegion;

            if (_regions.TryGetValue(regionName, out pageRegion))
            {
                return(pageRegion.WritePageArea(renderContext, pageArea));
            }

            return(WriteResult.Continue());
        }
Exemplo n.º 7
0
 public override IWriteResult WritePageArea(
     IRenderContext context,
     PageArea pageArea)
 {
     if (pageArea == PageArea.Body)
     {
         var menuItem   = context.Data.Get <MenuItem>();
         var url        = string.IsNullOrEmpty(menuItem.Url) ? "javascript:void(0);" : menuItem.Url;
         var attributes = string.IsNullOrEmpty(menuItem.Target)
             ? new[] { "href", url }
             : new[] { "href", url, "target", menuItem.Target };
         context.Html.WriteElementLine("a", menuItem.Name, attributes);
     }
     return(WriteResult.Continue());
 }
 public override IWriteResult WritePageArea(IRenderContext context, PageArea pageArea)
 {
     if (pageArea == PageArea.Body)
     {
         var functionalArea = context.Data.Get <SiteMap.FunctionalArea>();
         if (functionalArea != null)
         {
             context.Html.WriteOpenTag("li", "class", Package.NamespaceName + "_list-item " + Package.NamespaceName + "_area-identifier");
             context.Html.WriteElement("a", functionalArea.Identifier, "href", functionalArea.Document.LandingPageTemplate);
             context.Html.WriteCloseTag("li");
             context.Html.WriteLine();
         }
     }
     return(WriteResult.Continue());
 }
 public override IWriteResult WritePageArea(IRenderContext context, PageArea pageArea)
 {
     if (pageArea == PageArea.Body)
     {
         var repository = context.Data.Get <SiteMap.Repository>();
         if (repository != null)
         {
             context.Html.WriteOpenTag("li", "class", Package.NamespaceName + "_list-item " + Package.NamespaceName + "_repository-name");
             context.Html.WriteElement("a", repository.GitHubRepositoryName, "href", "/content/repository/" + repository.GitHubRepositoryName + "/landing");
             context.Html.WriteCloseTag("li");
             context.Html.WriteLine();
         }
     }
     return(WriteResult.Continue());
 }
Exemplo n.º 10
0
        public virtual IWriteResult WritePageArea(
            IRenderContext renderContext,
            PageArea pageArea)
        {
            if (!_hasPageArea[(int)pageArea])
            {
                return(WriteResult.Continue());
            }

#if TRACE
            renderContext.Trace(() => ToString() + " writing " + pageArea);
#endif

            return(WritePageAreaInternal(renderContext, pageArea));
        }
 public override IWriteResult WritePageArea(IRenderContext context, PageArea pageArea)
 {
     if (pageArea == PageArea.Body)
     {
         var document = context.Data.Get <SiteMap.Document>();
         if (document != null)
         {
             context.Html.WriteOpenTag("li", "class", Package.NamespaceName + "_list-item " + Package.NamespaceName + "_document-title");
             context.Html.WriteElement("a", document.Title, "href", document.LandingPageTemplate);
             context.Html.WriteCloseTag("li");
             context.Html.WriteLine();
         }
     }
     return(WriteResult.Continue());
 }
Exemplo n.º 12
0
 public override IWriteResult WritePageArea(IRenderContext context, PageArea pageArea)
 {
     if (pageArea == PageArea.Body)
     {
         var menuItems = context.Data.Get <IList <MenuPackage.MenuItem> >("sitemap");
         WriteMenu(context, menuItems, 0);
     }
     else if (pageArea == PageArea.Initialization)
     {
         var className = Package.NamespaceName + "_this-page";
         context.Html.WriteScriptOpen();
         context.Html.WriteLine("[].forEach.call(document.getElementsByClassName('" + className + "'), function(e){ e.scrollIntoView({block: 'center'}); });");
         context.Html.WriteScriptClose();
     }
     return(WriteResult.Continue());
 }
Exemplo n.º 13
0
 public override IWriteResult WritePageArea(
     IRenderContext context,
     PageArea pageArea)
 {
     if (pageArea == PageArea.Body)
     {
         var ns = Package.NamespaceName;
         context.Html.WriteOpenTag("input", true, "type", "checkbox", "class", ns + "_mb_hamburger_button", "id", ns + "_mb_hamburger_button");
         context.Html.WriteLine();
         context.Html.WriteOpenTag("label", "for", ns + "_mb_hamburger_button", "class", ns + "_mb_hamburger_icon");
         context.Html.WriteElementLine("div", null, "class", ns + "_mb_hamburger_icon " + ns + "_mb_hamburger_icon_1");
         context.Html.WriteElementLine("div", null, "class", ns + "_mb_hamburger_icon " + ns + "_mb_hamburger_icon_2");
         context.Html.WriteElementLine("div", null, "class", ns + "_mb_hamburger_icon " + ns + "_mb_hamburger_icon_3");
         context.Html.WriteCloseTag("label");
     }
     return(WriteResult.Continue());
 }
Exemplo n.º 14
0
        public IWriteResult WriteStaticCss(ICssWriter writer)
        {
            if (CssRules != null && CssRules.Length > 0)
            {
                if (writer.IncludeComments)
                {
                    writer.WriteComment("css rules for " + _commentNameFunc());
                }

                for (var i = 0; i < CssRules.Length; i++)
                {
                    CssRules[i](writer);
                }
            }

            return(WriteResult.Continue());
        }
Exemplo n.º 15
0
        IWriteResult ITemplate.WritePageArea(IRenderContext context, PageArea pageArea)
        {
            if (pageArea == PageArea.Head && _headElements != null)
            {
                for (var i = 0; i < _headElements.Length; i++)
                {
                    _headElements[i](context);
                }
            }

            if (pageArea == PageArea.Styles && _styleElements != null)
            {
                for (var i = 0; i < _styleElements.Length; i++)
                {
                    _styleElements[i](context);
                }
            }

            if (pageArea == PageArea.Scripts && _scriptElements != null)
            {
                for (var i = 0; i < _scriptElements.Length; i++)
                {
                    _scriptElements[i](context);
                }
            }

            if (pageArea == PageArea.Body && _bodyElements != null)
            {
                for (var i = 0; i < _bodyElements.Length; i++)
                {
                    _bodyElements[i](context);
                }
            }

            if (pageArea == PageArea.Initialization && _initializationElements != null)
            {
                for (var i = 0; i < _initializationElements.Length; i++)
                {
                    _initializationElements[i](context);
                }
            }

            return(WriteResult.Continue());
        }
Exemplo n.º 16
0
        public override IWriteResult WritePageArea(IRenderContext context, PageArea pageArea)
        {
            if (pageArea == PageArea.Body)
            {
                var game = context.Data.Get <Game>();
                if (game != null)
                {
                    var ns = Package.NamespaceName;
                    context.Html.WriteUnclosedElement(
                        "img",
                        "class", ns + "_map",
                        "src", "/map/game?g=" + game.GameId,
                        "onload", "ns." + ns + ".reloadMap();");
                    context.Html.WriteLine();
                }
            }

            return(WriteResult.Continue());
        }
Exemplo n.º 17
0
        public IWriteResult WriteStaticJavascript(IJavascriptWriter writer)
        {
            if (JavascriptFunctions != null && JavascriptFunctions.Length > 0)
            {
                if (writer.IncludeComments)
                {
                    writer.WriteComment(
                        "javascript functions for " + _commentNameFunc(),
                        CommentStyle.SingleLineC,
                        _element.Package);
                }

                for (var i = 0; i < JavascriptFunctions.Length; i++)
                {
                    JavascriptFunctions[i](writer);
                }
            }

            return(WriteResult.Continue());
        }
Exemplo n.º 18
0
            public override IWriteResult WritePageArea(IRenderContext context, PageArea pageArea)
            {
                if (pageArea == PageArea.Head)
                {
                    if (_styleUrls != null)
                    {
                        foreach (var url in _styleUrls)
                        {
                            context.Html.WriteElementLine("link", string.Empty, "rel", "stylesheet", "href", url);
                        }
                    }
                    if (_scriptUrls != null)
                    {
                        foreach (var url in _scriptUrls)
                        {
                            context.Html.WriteElementLine("script", string.Empty, "src", url);
                        }
                    }
                }

                return(WriteResult.Continue());
            }
Exemplo n.º 19
0
        public virtual IWriteResult WritePageArea(
            IRenderContext context,
            PageArea pageArea,
            Func <IRenderContext, PageArea, string, IWriteResult> childWriter)
        {
            var result = WriteResult.Continue();

#if TRACE
            context.Trace(() => ToString() + " writing layout body");
            context.TraceIndent();
#endif

            if (context.IncludeComments)
            {
                context.Html.WriteComment("layout " + this.FullyQualifiedName());
            }

            for (var i = 0; i < _visualElements.Length; i++)
            {
                var visualElement = _visualElements[i];

                if (pageArea == PageArea.Body && !ReferenceEquals(visualElement.StaticHtml, null))
                {
                    visualElement.StaticHtml.WriteAction(context.Html);
                }

                if (!ReferenceEquals(visualElement.ZoneName, null))
                {
                    result.Add(childWriter(context, pageArea, visualElement.ZoneName));
                }
            }

#if TRACE
            context.TraceOutdent();
#endif
            return(result);
        }
Exemplo n.º 20
0
        public override IWriteResult WritePageArea(IRenderContext context, PageArea pageArea)
        {
            if (pageArea == PageArea.Head)
            {
                context.Html.WriteUnclosedElement(
                    "link", "rel", "canonical", "href",
                    "http://owinframework.net" + context.OwinContext.Request.Path.ToString().ToLower());
                context.Html.WriteLine();
            }
            if (pageArea == PageArea.Body)
            {
                var area = GetContentArea(context);
                if (area == null)
                {
                    return(WriteResult.Continue());
                }

                if (area == "area")
                {
                    ListFunctionalAreas(context);
                }
                else if (area == "project")
                {
                    ListProjects(context);
                }
                else if (area == "nuget")
                {
                    ListNuGet(context);
                }
                else if (area == "repository")
                {
                    ListRepositories(context);
                }
            }
            return(WriteResult.Continue());
        }
Exemplo n.º 21
0
 public virtual IWriteResult WriteInPageFunctions(
     IJavascriptWriter writer,
     Func <IJavascriptWriter, IWriteResult, IWriteResult> childrenWriter)
 {
     return(WriteResult.Continue());
 }
Exemplo n.º 22
0
 public virtual IWriteResult WriteStaticJavascript(IJavascriptWriter writer)
 {
     return(WriteResult.Continue());
 }
Exemplo n.º 23
0
 public virtual IWriteResult WriteInPageStyles(
     ICssWriter writer,
     Func <ICssWriter, IWriteResult, IWriteResult> childrenWriter)
 {
     return(WriteResult.Continue());
 }
Exemplo n.º 24
0
        public override IWriteResult WritePageArea(IRenderContext context, PageArea pageArea)
        {
            if (pageArea == PageArea.Body)
            {
                var html = context.Html;

                // Add form

                html.WriteOpenTag("form", "action", "/page3/add", "method", "POST");

                html.WriteElement("label", "A", "for", "a");
                html.WriteElement("span", "&nbsp;", "style", "width:20px;");
                html.WriteUnclosedElement("input", "type", "input", "name", "a", "value", "9");
                html.WriteUnclosedElement("br");

                html.WriteElement("label", "B", "for", "b");
                html.WriteElement("span", "&nbsp;", "style", "width:20px;");
                html.WriteUnclosedElement("input", "type", "input", "name", "b", "value", "5");
                html.WriteUnclosedElement("br");

                html.WriteUnclosedElement("input", "type", "hidden", "name", "r", "value", "/page3");
                html.WriteUnclosedElement("input", "type", "submit", "value", "Add");

                html.WriteCloseTag("form");
                html.WriteUnclosedElement("hr");

                // Subtract form

                html.WriteOpenTag("form", "action", "/page3/subtract", "method", "POST");

                html.WriteElement("label", "A", "for", "a");
                html.WriteElement("span", "&nbsp;", "style", "width:20px;");
                html.WriteUnclosedElement("input", "type", "input", "name", "a", "value", "15");
                html.WriteUnclosedElement("br");

                html.WriteElement("label", "B", "for", "b");
                html.WriteElement("span", "&nbsp;", "style", "width:20px;");
                html.WriteUnclosedElement("input", "type", "input", "name", "b", "value", "6");
                html.WriteUnclosedElement("br");

                html.WriteUnclosedElement("input", "type", "hidden", "name", "r", "value", "/page3");
                html.WriteUnclosedElement("input", "type", "submit", "value", "Subtract");

                html.WriteCloseTag("form");
                html.WriteUnclosedElement("hr");

                // Multiply form

                html.WriteOpenTag("form", "action", "/page3/multiply", "method", "POST");

                html.WriteElement("label", "A", "for", "a");
                html.WriteElement("span", "&nbsp;", "style", "width:20px;");
                html.WriteUnclosedElement("input", "type", "input", "name", "a", "value", "24");
                html.WriteUnclosedElement("br");

                html.WriteElement("label", "B", "for", "b");
                html.WriteElement("span", "&nbsp;", "style", "width:20px;");
                html.WriteUnclosedElement("input", "type", "input", "name", "b", "value", "18");
                html.WriteUnclosedElement("br");

                html.WriteUnclosedElement("input", "type", "hidden", "name", "r", "value", "/page3");
                html.WriteUnclosedElement("input", "type", "submit", "value", "Multiply");

                html.WriteCloseTag("form");
                html.WriteUnclosedElement("hr");

                // Divide form

                html.WriteOpenTag("form", "action", "/page3/divide", "method", "POST");

                html.WriteElement("label", "A", "for", "a");
                html.WriteElement("span", "&nbsp;", "style", "width:20px;");
                html.WriteUnclosedElement("input", "type", "input", "name", "a", "value", "23");
                html.WriteUnclosedElement("br");

                html.WriteElement("label", "B", "for", "b");
                html.WriteElement("span", "&nbsp;", "style", "width:20px;");
                html.WriteUnclosedElement("input", "type", "input", "name", "b", "value", "7");
                html.WriteUnclosedElement("br");

                html.WriteUnclosedElement("input", "type", "hidden", "name", "r", "value", "/page3");
                html.WriteUnclosedElement("input", "type", "submit", "value", "Divide");

                html.WriteCloseTag("form");
                html.WriteUnclosedElement("hr");

                var result = context.OwinContext.Get <ArithmeticResult>(typeof(ArithmeticResult).FullName);
                if (result != null)
                {
                    html.WriteUnclosedElement("br");
                    html.WriteElement("div", result.Result);
                }
            }
            return(WriteResult.Continue());
        }
Exemplo n.º 25
0
 public virtual IWriteResult WriteStaticCss(ICssWriter writer)
 {
     return(WriteResult.Continue());
 }
Exemplo n.º 26
0
 IWriteResult IDeployable.WriteStaticJavascript(IJavascriptWriter writer)
 {
     return(WriteResult.Continue());
 }
Exemplo n.º 27
0
        public virtual IWriteResult WritePageArea(
            IRenderContext context,
            PageArea pageArea,
            Action <IRenderContext, object> onListItem,
            Func <IRenderContext, PageArea, IWriteResult> contentWriter)
        {
#if TRACE
            context.Trace(() => ToString() + " writing page " + Enum.GetName(typeof(PageArea), pageArea).ToLower());
#endif
            IWriteResult result;

            if (context.IncludeComments)
            {
                context.Html.WriteComment("region " + this.FullyQualifiedName());
            }

            if (pageArea == PageArea.Body)
            {
                WriteOpen(context.Html);
            }

            if (pageArea == PageArea.Body && !ReferenceEquals(_repeatType, null))
            {
                result = WriteResult.Continue();

#if TRACE
                context.Trace(() => ToString() + " getting " + (string.IsNullOrEmpty(ListScope) ? "" : ListScope + " ") + _listType.DisplayName(TypeExtensions.NamespaceOption.None) + " from " + context.Data);
#endif
                var list = context.Data.Get(_listType, ListScope) as IEnumerable;
                if (!ReferenceEquals(list, null))
                {
                    foreach (var item in list)
                    {
#if TRACE
                        context.Trace(() => ToString() + " setting next " + (string.IsNullOrEmpty(RepeatScope) ? "" : RepeatScope + " ") + _repeatType.DisplayName(TypeExtensions.NamespaceOption.None) + " in " + context.Data + " " + item);
#endif

                        context.Data.Set(_repeatType, item, RepeatScope);

                        if (!ReferenceEquals(onListItem, null))
                        {
                            onListItem(context, item);
                        }

                        context.TraceIndent();

                        WriteChildOpen(context.Html);
                        result.Add(contentWriter(context, pageArea));
                        WriteChildClose(context.Html);

                        context.TraceOutdent();
                    }
                }
#if TRACE
                else
                {
                    context.Trace(() => ToString() + " will not repeat because there is no list in the data context of the required type");
                }
#endif
            }
            else
            {
                result = contentWriter(context, pageArea);
            }

            if (pageArea == PageArea.Body)
            {
                WriteClose(context.Html);
            }

            _assetDeploymentMixin.WritePageArea(context, pageArea);

            return(result);
        }
        public ITemplateDefinition AddLayout(ILayout layout)
        {
            BodyActions.Add(r => layout.WritePageArea(r, PageArea.Body, (rc, pa, rn) => WriteResult.Continue())); // TODO: Write layout regions
            AddConsumerNeeds(layout as IDataConsumer);

            return(this);
        }
        public ITemplateDefinition AddRegion(IRegion region)
        {
            BodyActions.Add(r => region.WritePageArea(r, PageArea.Body, null, (rc, pa) => WriteResult.Continue())); // TODO: Write region
            AddConsumerNeeds(region as IDataConsumer);

            return(this);
        }
Exemplo n.º 30
0
 IWriteResult IPageWriter.WriteInPageStyles(ICssWriter writer, Func <ICssWriter, IWriteResult, IWriteResult> childrenWriter)
 {
     return(WriteResult.Continue());
 }