private void PageOnPreRender(Page aspnetPage, IPage page)
        {
            bool emitMenuTitleMetaTag = !page.MenuTitle.IsNullOrEmpty();
            bool emitUrlTitleMetaTag  = !page.UrlTitle.IsNullOrEmpty();

            if ((emitMenuTitleMetaTag || emitUrlTitleMetaTag) &&
                UserValidationFacade.IsLoggedIn())
            {
                var xhtmlDocument = new XhtmlDocument();

                PageRenderer.AppendC1MetaTags(page, xhtmlDocument);


                if (aspnetPage.Header != null)
                {
                    string xml = string.Join(string.Empty, xhtmlDocument.Head.Nodes().Select(node => node.ToString()));

                    aspnetPage.Header.Controls.Add(new Literal {
                        Text = xml
                    });
                }
            }
        }
Esempio n. 2
0
        public override void ExecuteResult(ControllerContext context)
        {
            string markup;

            using (TimerProfilerFacade.CreateTimerProfiler())
            {
                var page          = PageRenderer.CurrentPage;
                var markupBuilder = new StringBuilder();
                var sw            = new StringWriter(markupBuilder);
                var output        = new HtmlTextWriter(sw);

                IView view;
                using (Profiler.Measure("Resolving view for template"))
                {
                    view = FindView(context).View;
                }

                var viewContext = new ViewContext(context, view, ViewData, TempData, output);

                view.Render(viewContext, output);

                markup = markupBuilder.ToString();
                var xml = XDocument.Parse(markup);

                var functionContext = PageRenderer.GetPageRenderFunctionContextContainer();

                functionContext = new FunctionContextContainer(functionContext, new Dictionary <string, object>
                {
                    { "viewContext", viewContext }
                });

                using (Profiler.Measure("Executing embedded functions"))
                {
                    PageRenderer.ExecuteEmbeddedFunctions(xml.Root, functionContext);
                }

                using (Profiler.Measure("Resolving pagefields"))
                {
                    PageRenderer.ResolvePageFields(xml, page);
                }

                var document = new XhtmlDocument(xml);

                using (Profiler.Measure("Normalizing html"))
                {
                    PageRenderer.NormalizeXhtmlDocument(document);
                }

                PageRenderer.ResolveRelativePaths(document);
                PageRenderer.AppendC1MetaTags(page, document);

                using (Profiler.Measure("Resolving localized strings"))
                {
                    LocalizationParser.Parse(document);
                }

                markup = document.ToString();

                using (Profiler.Measure("Changing 'internal' page urls to 'public'"))
                {
                    markup = PageUrlHelper.ChangeRenderingPageUrlsToPublic(markup);
                }

                using (Profiler.Measure("Changing 'internal' media urls to 'public'"))
                {
                    markup = MediaUrlHelper.ChangeInternalMediaUrlsToPublic(markup);
                }

                markup = _mvcContext.FormatXhtml(markup);
            }

            if (_mvcContext.ProfilingEnabled)
            {
                markup = _mvcContext.BuildProfilerReport();

                context.HttpContext.Response.ContentType = "text/xml";
            }

            context.HttpContext.Response.Write(markup);
        }