public static XmlElement CrossDomainLink(this HtmlElementContext context, XmlElement element) { string domain = context.Parameters.GetValue <string>("link-domain", String.Empty); string redirect = context.Parameters.GetValue <string>("link-redirect"); string location = element.GetAttribute("href"); element.RemoveAttribute("target"); Uri uri; if (!Uri.TryCreate(location, UriKind.Absolute, out uri)) { if (!Uri.TryCreate("http://" + location, UriKind.Absolute, out uri)) { return(null); } } if ((uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps) && !uri.Host.EndsWith(domain, StringComparison.OrdinalIgnoreCase)) { if (!String.IsNullOrEmpty(redirect)) { element.SetAttribute("href", String.Format("{0}?url={1}", redirect, Uri.EscapeDataString(uri.AbsoluteUri))); } element.SetAttribute("target", "_blank"); element.SetAttribute("rel", "nofollow"); } return(element); }
public HtmlLinkStyleTagManager(HtmlElementContext htmlElement) { this.htmlElement = htmlElement; var buffer = htmlElement.GetRuleContext <BufferValueContext <File> >(0); if (buffer != null) { File = buffer.Value; } }
public static XmlElement FlashPlayer(this HtmlElementContext context, XmlElement element, string movie, int width, int height, string variables) { XmlElement video = element.OwnerDocument.CreateElement("object"); video.SetAttribute("classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"); video.SetAttribute("width", width.ToString()); video.SetAttribute("height", height.ToString()); video.AppendChild("param", new { name = "movie", value = movie }); video.AppendChild("param", new { name = "allowfullscreen", value = "true" }); video.AppendChild("param", new { name = "wmode", value = "transparent" }); video.AppendChild("param", new { name = "allowscriptaccess", value = "always" }); video.AppendChild("param", new { name = "flashvars", value = variables }); video.AppendChild("embed", new { type = "application/x-shockwave-flash", src = movie, width = width, height = height, wmode = "transparent", allowscriptaccess = "always", allowfullscreen = "true", flashVars = variables }); return(video); }
public override object VisitHtmlElement([NotNull] HtmlElementContext context) { var content = context.htmlContent(); var name = context.htmlTagName(0)?.GetText(); if (name == null || name.ToUpper() != "HEAD") { return(base.VisitHtmlElement(context)); } HtmlElemFactory factory = new HtmlElemFactory(); var space = new CommonToken(SEA_WS, " "); foreach (var item in files) { HtmlElementContext elem = new HtmlElementContext(content, 0); elem.AddChild(new CommonToken(TAG_OPEN, "<")); elem.AddChild(factory.CreateTagName(elem, "link")); elem.AddChild(space); var type = factory.CreateAttribute(elem, "type", "text/css"); elem.AddChild(type); elem.AddChild(space); var rel = factory.CreateAttribute(elem, "rel", "styleSheet"); elem.AddChild(rel); elem.AddChild(space); var href = factory.CreateAttribute(elem, "href", item.FileName); elem.AddChild(href); elem.AddChild(new CommonToken(TAG_SLASH_CLOSE, "/>")); content.AddChild(elem); } return(null); }
public override object VisitHtmlElement([NotNull] HtmlElementContext context) { var content = context.htmlContent(); var name = context.htmlTagName(0)?.GetText(); if (name == null || name.ToUpper() != "BODY") { return(base.VisitHtmlElement(context)); } HtmlElemFactory factory = new HtmlElemFactory(); foreach (var item in files) { HtmlElementContext elem = new HtmlElementContext(content, 0); ScriptContext script = new ScriptContext(elem, 0); script.AddChild(new CommonToken(RULE_script, "<script")); script.AddChild(new CommonToken(SEA_WS, " ")); var attribute = factory.CreateAttribute(script, "src", item.FileName); script.AddChild(attribute); script.AddChild(new CommonToken(TAG_CLOSE, ">")); script.AddChild(new HtmlContentContext(script, 0)); script.AddChild(new CommonToken(TAG_OPEN, "<")); script.AddChild(new CommonToken(TAG_SLASH, "/")); script.AddChild(factory.CreateTagName(script, "script")); script.AddChild(new CommonToken(TAG_CLOSE, ">")); elem.AddChild(script); content.AddChild(elem); } return(null); }
public override object VisitHtmlElement([NotNull] HtmlElementContext context) { ProcessingNode(context); return(base.VisitHtmlElement(context)); }