Exemplo n.º 1
0
        public string ValidateBook(string descriptionOfBookForErrorLog)
        {
            var ids     = new List <string>();
            var builder = new StringBuilder();

            Ensure(RawDom.SafeSelectNodes("//div[contains(@class,'bloom-page')]").Count > 0, "Must have at least one page",
                   builder);
            EnsureIdsAreUnique(this, "textarea", ids, builder);
            EnsureIdsAreUnique(this, "p", ids, builder);
            EnsureIdsAreUnique(this, "img", ids, builder);

            //TODO: validate other things, including html
            var x = builder.ToString().Trim();

            if (x.Length == 0)
            {
                Logger.WriteEvent("HtmlDom.ValidateBook({0}): No Errors", descriptionOfBookForErrorLog);
            }
            else
            {
                Logger.WriteEvent("HtmlDom.ValidateBook({0}): {1}", descriptionOfBookForErrorLog, x);
            }

            return(builder.ToString());
        }
Exemplo n.º 2
0
        public void RemoveModeStyleSheets()
        {
            foreach (XmlElement linkNode in RawDom.SafeSelectNodes("/html/head/link"))
            {
                var href = linkNode.GetAttribute("href");
                if (href == null)
                {
                    continue;
                }

                var fileName = Path.GetFileName(href);
                if (fileName.Contains("edit") || fileName.Contains("preview"))
                {
                    linkNode.ParentNode.RemoveChild(linkNode);
                }
            }
        }
Exemplo n.º 3
0
        public void RemoveModeStyleSheets()
        {
            foreach (XmlElement linkNode in RawDom.SafeSelectNodes("/html/head/link"))
            {
                var href = linkNode.GetAttribute("href");
                if (href == null)
                {
                    continue;
                }

                var fileName = Path.GetFileName(href);
                if (fileName.Contains("edit") || fileName.Contains("preview"))
                {
                    linkNode.ParentNode.RemoveChild(linkNode);
                }
            }
            // If present, remove the editMode attribute that tells use which mode we're editing in (original or translation)
            var body = RawDom.SafeSelectNodes("/html/body")[0] as XmlElement;

            if (body.HasAttribute("editMode"))
            {
                body.RemoveAttribute("editMode");
            }
        }
Exemplo n.º 4
0
 public XmlNodeList SafeSelectNodes(string xpath)
 {
     return(RawDom.SafeSelectNodes(xpath));
 }