コード例 #1
0
 public static void Process(PageResources pageResources, Site site)
 {
     foreach (IPageResourcesPostProcessor postProcessor in All)
     {
         postProcessor.Process(pageResources, site);
     }
 }
コード例 #2
0
        /// <summary>
        /// Creates a  PdfTemplate .
        /// </summary>

        internal PdfTemplate(PdfWriter wr) : base(wr)
        {
            type          = TYPE_TEMPLATE;
            pageResources = new PageResources();
            pageResources.AddDefaultColor(wr.DefaultColorspace);
            ThisReference = Writer.PdfIndirectReference;
        }
コード例 #3
0
    /// <summary>
    /// Builds page to <see cref="HtmlText"/> to be embedded in other content or written to disk
    /// </summary>
    private void BuildMarkdown(Site site, PageResources allResources, MarkdownPipeline markdownPipeline)
    {
        if (MarkdownText == null)
        {
            ProcessMarkdown(File.ReadAllText(FullPath), site, allResources);
        }

        string text = Location switch
        {
            ResourceLocation.Embed =>
            // Embeds are not fully processed into HTML until they are built when embedded into site content.
            // This is done because something like Abbreviations requires the abbreviation target to be processed at the same time as the source.
            MarkdownText !,
            ResourceLocation.Site => ToHtml(MarkdownText !, markdownPipeline),
            _ => throw new ArgumentOutOfRangeException(nameof(Location), Location, "Location was not handled.")
        };

        if (HtmlText == null)
        {
            HtmlText = text;
        }
        else
        {
            HtmlText += text;
        }
    }
コード例 #4
0
        internal ShapeContext(ContentStream contentStream, PageResources resources)
        {
            _contentStream = contentStream;

            _contentStream.SaveState();

            State = new GraphicsState(resources);
        }
コード例 #5
0
 public static void GeneratePageSourceLookup(Arguments arguments, PageResources pageResources)
 {
     // Gather file paths.
     int trimIndex = arguments.TroubleshooterRoot !.Length;
     Dictionary <string, string> sourceLookup = pageResources
                                                .Where(pair =>
                                                       pair.Value.Location == ResourceLocation.Site &&
                                                       pair.Value.Type == ResourceType.Markdown
                                                       ).ToDictionary(pair => pair.Value.OutputLinkPath !, pair => pair.Key[trimIndex..].Replace('\\', '/'));
コード例 #6
0
        /// <summary>
        /// Inserts .css and .js resources at the start of the page's block of CSS and JavaScript files.
        /// There can be one or more css or js resource for each page template.
        /// This information is found in the PageTemplateInfo object of the
        /// PageAssembleyContext.Current
        ///
        /// This method inserts those resources marked as "Beginning" as well as resources
        /// which have no location specified.
        /// </summary>
        protected virtual void InsertHeaderStyleSheetsJavascriptsReferences()
        {
            if (CurrentPageHead != null)
            {
                PageTemplateInfo pgTemplateInfo = PageAssemblyContext.Current.PageTemplateInfo;
                if (pgTemplateInfo != null)
                {
                    StyleSheetInfo[] colCss = pgTemplateInfo.StyleSheets;
                    JavascriptInfo[] colJs  = pgTemplateInfo.Javascripts;

                    PageResources pgResources = PageAssemblyContext.Current.PageAssemblyInstruction.GetPageResources();
                    if (pgResources != null)
                    {
                        colCss = colCss.Concat(pgResources.StyleSheets).ToArray();
                        colJs  = colJs.Concat(pgResources.Javascripts).ToArray();
                    }

                    // Capture all items marked as going at the start of the block.
                    IEnumerable <StyleSheetInfo> firstStylesheet = System.Linq.Enumerable.Where(colCss, fcss => fcss.Beginning == "true");
                    IEnumerable <JavascriptInfo> firstJavaScript = System.Linq.Enumerable.Where(colJs, fjs => fjs.Beginning == "true");

                    // Capture all items which aren't marked for a particular location.
                    IEnumerable <StyleSheetInfo> unspecifiedStylesheets = System.Linq.Enumerable.Where(colCss, fcss => fcss.Beginning != "true" && fcss.End != "true");
                    IEnumerable <JavascriptInfo> unspecifiedJavaScripts = System.Linq.Enumerable.Where(colJs, fjs => fjs.Beginning != "true" && fjs.End != "true");

                    //Load first Javascript
                    foreach (JavascriptInfo jsBeginningInfo in firstJavaScript)
                    {
                        String url = appendFileFingerprint(jsBeginningInfo.JavascriptPath);
                        NCI.Web.UI.WebControls.JSManager.AddExternalScript(this, url, jsBeginningInfo.Async, jsBeginningInfo.Defer);
                    }

                    //Load first Stylesheet
                    foreach (StyleSheetInfo cssBeginningInfo in firstStylesheet)
                    {
                        String url = appendFileFingerprint(cssBeginningInfo.StyleSheetPath);
                        NCI.Web.UI.WebControls.CssManager.AddStyleSheet(this, url, cssBeginningInfo.Media);
                    }

                    // Load the js and css resources with no specified location
                    foreach (JavascriptInfo jsInfo in unspecifiedJavaScripts)
                    {
                        String url = appendFileFingerprint(jsInfo.JavascriptPath);
                        NCI.Web.UI.WebControls.JSManager.AddExternalScript(this, url, jsInfo.Async, jsInfo.Defer);
                    }

                    foreach (StyleSheetInfo ssInfo in unspecifiedStylesheets)
                    {
                        String url = appendFileFingerprint(ssInfo.StyleSheetPath);
                        NCI.Web.UI.WebControls.CssManager.AddStyleSheet(this, url, ssInfo.Media);
                    }
                }
            }
        }
コード例 #7
0
 internal Type3Glyph(PdfWriter writer, PageResources pageResources, float wx, float llx, float lly, float urx, float ury, bool colorized) : base(writer)
 {
     _pageResources = pageResources;
     _colorized     = colorized;
     if (colorized)
     {
         Content.Append(wx).Append(" 0 d0\n");
     }
     else
     {
         Content.Append(wx).Append(" 0 ").Append(llx).Append(' ').Append(lly).Append(' ').Append(urx).Append(' ').Append(ury).Append(" d1\n");
     }
 }
コード例 #8
0
    public void BuildText(Site site, PageResources allResources, MarkdownPipeline markdownPipeline)
    {
        switch (Type)
        {
        case ResourceType.None:
            SetHtmlTextAsEmpty();
            return;

        case ResourceType.Markdown:
            BuildMarkdown(site, allResources, markdownPipeline);
            break;

        case ResourceType.RichText:
            try
            {
                HtmlText = RtfUtility.RtfToHtml(File.ReadAllText(FullPath));
            }
            catch (Exception e)
            {
                throw new BuildException(e, $"Error when parsing \"{FullPath}\" into RTF");
            }

            break;

        case ResourceType.Html:
            try
            {
                HtmlText = HtmlUtility.Parse(File.ReadAllText(FullPath));
            }
            catch (Exception e)
            {
                throw new BuildException(e, $"Error when parsing HTML at \"{FullPath}\"");
            }

            break;

        case ResourceType.Generator:
            // Generators are processed during the gather stage.
            return;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
コード例 #9
0
        /// <summary>
        /// Inserts .css and .js resources at the end of the page's block of CSS and JavaScript files.
        /// There can be one or more css or js resource for each page template.
        /// This information is found in the PageTemplateInfo object of the
        /// PageAssembleyContext.Current
        ///
        /// This method inserts only those resources marked as "End".
        /// </summary>
        protected virtual void InsertFooterStyleSheetsJavascriptsReferences()
        {
            if (CurrentPageBody != null)
            {
                PageTemplateInfo pgTemplateInfo = PageAssemblyContext.Current.PageTemplateInfo;
                if (pgTemplateInfo != null)
                {
                    StyleSheetInfo[] colCss = pgTemplateInfo.StyleSheets;
                    JavascriptInfo[] colJs  = pgTemplateInfo.Javascripts;

                    PageResources pgResources = PageAssemblyContext.Current.PageAssemblyInstruction.GetPageResources();
                    if (pgResources != null)
                    {
                        colCss = colCss.Concat(pgResources.StyleSheets).ToArray();
                        colJs  = colJs.Concat(pgResources.Javascripts).ToArray();
                    }

                    // Capture all items which are marked exclusively as going at the end of the block.
                    // The present UI allows an item to be specified as both beginning and end, however
                    // this is a UI error. Items marked as "Beginning" are only loaded via
                    // InsertLeadingStyleSheetsJavascriptsReferences().
                    IEnumerable <StyleSheetInfo> lastStylesheet = System.Linq.Enumerable.Where(colCss, fcss => fcss.Beginning != "true" && fcss.End == "true");
                    IEnumerable <JavascriptInfo> lastJavaScript = System.Linq.Enumerable.Where(colJs, fjs => fjs.Beginning != "true" && fjs.End == "true");

                    //Load Javascript marked as "End"
                    foreach (JavascriptInfo jsLastInfo in lastJavaScript)
                    {
                        String url = appendFileFingerprint(jsLastInfo.JavascriptPath);
                        // Add script to end of body control, before WebAnalyticsControl
                        NCI.Web.UI.WebControls.JSManager.AddFooterScript(CurrentPageBody, null, url, jsLastInfo.Async, jsLastInfo.Defer);
                    }

                    //Load Stylesheets marked as "End"
                    foreach (StyleSheetInfo cssLastInfo in lastStylesheet)
                    {
                        String url = appendFileFingerprint(cssLastInfo.StyleSheetPath);
                        NCI.Web.UI.WebControls.CssManager.AddStyleSheet(this, url, cssLastInfo.Media);
                    }
                }
            }
        }
コード例 #10
0
 /// <summary>
 /// Creates a new instance of StampContent
 /// </summary>
 internal StampContent(PdfStamperImp stamper, PdfStamperImp.PageStamp ps) : base(stamper)
 {
     Ps            = ps;
     pageResources = ps.PageResources;
 }
コード例 #11
0
 /**
 * Creates new PdfTemplate
 *
 * @param wr the <CODE>PdfWriter</CODE>
 */
 
 internal PdfTemplate(PdfWriter wr) : base(wr) {
     type = TYPE_TEMPLATE;
     pageResources = new PageResources();
     pageResources.AddDefaultColor(wr.DefaultColorspace);
     thisReference = writer.PdfIndirectReference;
 }
コード例 #12
0
 internal GraphicsState(PageResources resources)
 {
     Resources = resources;
 }