예제 #1
0
        public static void PostProcessParserResults(ParserResult parserResult) {
            foreach(XDoc tail in parserResult.Tail["script"]) {
                var node = tail.AsXmlNode;

                // check if script is using $() to load when DOM is ready
                if(!node.InnerText.StartsWithInvariant("$(function")) {
                    node.InsertBefore(node.OwnerDocument.CreateTextNode("$(function(){"), node.FirstChild);
                    node.InsertAfter(node.OwnerDocument.CreateTextNode("});"), node.LastChild);
                }
            }
        }
예제 #2
0
        public static void PostProcessTemplateInsertBody(ParserResult result, PageBE page) {

            // add nested template links
            XDoc body = result.MainBody;
            XDoc tree = PageSiteMapBL.BuildHtmlSiteMap(page, null, int.MaxValue, false);
            tree = tree[".//ul"];
            if(!tree.IsEmpty) {
                foreach(XDoc a in tree[".//a"]) {
                    a["@href"].ReplaceValue("#");
                    a.Attr("template", a["@title"].AsText);
                    a.Attr("class", "site");
                    a.RemoveAttr("rel");
                    a.RemoveAttr("pageid");
                }
                body.Add(tree);
            }

            // add tag inclusion hints
            var tagBL = new TagBL();
            IList<TagBE> tags = tagBL.GetTagsForPage(page);
            if(tags.Count > 0) {
                body.Start("p")
                    .Attr("class", "template:tag-insert")
                    .Elem("em", DekiContext.Current.Resources.Localize("Page.Tags.tags-inserted-from-template") + " ");
                bool first = true;
                foreach(TagBE tag in tags) {
                    if(!first) {
                        body.Elem("span", ", ");
                    }
                    first = false;
                    body.Start("a").Attr("href", "#").Value(tag.PrefixedName).End();
                }
                body.End();
            }
        }