private void CurrentFilter_OnAfterFiltering(ResponseOutputFilter filter, ref string finalHtml)
        {
            // if it is the live site, we are bailing. Quick Bail, I do not want to affect performance of the live site
            if (PortalContext.ViewMode == ViewModeEnum.LiveSite)
            {
                return;
            }


            bool injectJs = false;

            if (PortalContext.ViewMode == ViewModeEnum.EditLive)
            {
                // On Site Editing
                injectJs = SettingsUtility.GetIsEnabledOnOnSiteEditing();
            }
            else if (PortalContext.ViewMode == ViewModeEnum.Edit)
            {
                // Assume "Page" tab
                injectJs = SettingsUtility.GetIsEnabledOnPage();
            }
            else
            {
                return; // bail on all other ViewModes
            }
            if (!injectJs)
            {
                return;
            }

            // add script to bottom of body
            var jsCode = SiteimproveUtility.GetJavascriptBigBoxSmart(DocumentContext.CurrentDocument);

            finalHtml = CommonUtility.AddJavascriptToEndOfBody(finalHtml, jsCode, false);
        }
Esempio n. 2
0
        /// <summary>
        /// Handler for PostMapRequest
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="e">Event arguments</param>
        private void PostMapRequestHandler_Execute(object sender, EventArgs e)
        {
            // Creates an output filter instance
            ResponseOutputFilter.EnsureOutputFilter();

            // Assigns a handler to the OutputFilterContext.CurrentFilter.OnAfterFiltering event
            OutputFilterContext.CurrentFilter.OnAfterFiltering += ampFilter.OnFilterActivated;
        }
Esempio n. 3
0
        /// <summary>
        /// If the filter is enabled for current page, final HTML will be modified
        /// </summary>
        /// <param name="filter">Output filter</param>
        /// <param name="finalHtml">Final HTML string</param>
        public void OnFilterActivated(ResponseOutputFilter filter, ref string finalHtml)
        {
            int state = CheckStateHelper.GetFilterState();

            if (state == Constants.ENABLED_AND_ACTIVE)
            {
                finalHtml = TransformToAmpHtml(finalHtml);
            }
            else if (state == Constants.ENABLED_AND_INACTIVE)
            {
                finalHtml = AppendAmpHtmlLink(finalHtml);
            }
        }
Esempio n. 4
0
    /// <summary>
    /// After PreRender is complete, specified control may be directly rendered and send to response
    /// </summary>
    protected void Page_PreRenderComplete(object sender, EventArgs e)
    {
        Control startingControl = null;

        // Find parent or setup page as starting control
        if (!String.IsNullOrEmpty(this.StartingParentControlID))
        {
            startingControl = FindParentControl(this, this.StartingParentControlID);
        }
        else
        {
            startingControl = this.Page;
        }

        if (startingControl != null)
        {
            // Find control which should be rendered
            Control renderedControl = startingControl.FindControl(this.RenderedControlID);

            if (renderedControl != null)
            {
                StringBuilder    sb      = new StringBuilder();
                StringWriter     sw      = new StringWriter(sb);
                Html32TextWriter mwriter = new Html32TextWriter(sw);
                renderedControl.RenderControl(mwriter);

                string finalHtml = sb.ToString();

                if (this.UseFullPageCache)
                {
                    OutputData output = new OutputData(finalHtml, RequestContext.UseGZip, GetResponseEncoding());

                    // Save the data to cache
                    ResponseOutputFilter.SaveOutputToCache(output);
                }

                // Write rendered control directly to output
                Response.Clear();
                Response.Write(finalHtml);
                RequestHelper.EndResponse();
            }
        }
    }
 private void PostMapRequestHandler_Execute(object sender, EventArgs e)
 {
     ResponseOutputFilter.EnsureOutputFilter();
     OutputFilterContext.CurrentFilter.OnAfterFiltering += CurrentFilter_OnAfterFiltering;
 }